Using Home Assistant Groups To Turn Lights On/Off

Cyan Automation
2 min readJul 27, 2020

--

Photo by Cinn on Unsplash

In Home Assistant, Groups are powerful and convenient. It’s helpful to group multiple lights in a single room or across a single floor. But Groups aren’t limited to just lights, and you can include other items – including switches that toggle lights. Before we go further, it’s helpful to read the entry on Groups (link here).

Note that there is a difference between Groups and Light Groups

Getting Started

Let’s set up a group for all lights in the house. Before we start, it’s handy to know all the entity names, so make use of the Entity List or the States Module under Developer Tools.

Here are the steps:

  1. Define the group in the group area (unless you’ve split out your Groups configuration)
  2. Give you Group a system name and friendly name; here being lights_all and All Lights
  3. List all the entities that you want to group; this can be light entities but also other entities (I’ve included switches that control lights)

Here is this looks like in YAML:

Now you have a group called group.lights_all, that you can use in your scripts or automations. To change the state of this group (i.e. from off to on, or vice versa), we should use the service: homeassistant.turn_on (for turning on), homeassistant.turn_off (for turning off) or homeassistant.toggle (for inverting the state).

Note: By default when any member of a group is on then the group will also be on. If you set the all option to true though, this behavior is inverted and all members of the group have to be on for the group to turn on as well.

Making It Work

Here is a simple script to turn off all lights in the household that you can start via a trigger. This can be a switch, or the time (as below) or a Boolean State provided by a device tracker. Here is the YAML code:

--

--

Cyan Automation
Cyan Automation

Written by Cyan Automation

Marc’s tips on building your Smart Home with Home Assistant, Shelly and ESPHome.

No responses yet