Using Home Assistant Groups To Turn Lights On/Off

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:




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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Run Oracle 11g XE in Docker for Local Development

Building a Web Service to Manage Scientific Simulation Data Using GraphQL

gRPC support in kuma

Hive ACID Transactions -Part 2

Shipping React Native apps with Fastlane and Travis

Seven important elements to be considered in App Development

How to Guide the Compiler to Speed-up Your Code

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cyan Automation

Cyan Automation

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

More from Medium

OnePlus Nord — Review & Full Phone Specifications

How to restore iPhone after forgetting your password

New Goal: Reading 25 pages a day.

Tips to place office furniture to make your space look functional