In this guide, we are going to create a group of lights in Home assistant which we can then control under a button or within an automation. The advantage of this is we can control multiple lights Instead of individually control the lights within an automation or script
Finding all entities to add to the group
First, we need to write down the entities of the lights we want to have in a group. You can find that under the development tools. Go to development tools then states and type in light. In the image below I have highlighted where you can find the entity name.
In my case that are six lights I have in my Gym room
create a group of lights in home assistant
We need to edit the file in Home Assistant called configuration.yaml . You can do this through an FTP or smb connection but it is easier to just install a plugin called file editor and edit the file in the GUI. To install this plugin got to Supervisor -> Add-on Store and click on File editor and install the add-on
Once the addon is installed you will see it in the menu. Now click on the file editor button
Then click on the folder in the upper right corner
Now click on configuration.yaml
Scroll all the way down and add the following with the entities you wrote down earlier and change the name to the name you want. Also, notice the spaces. It is Yaml code
light:
- platform: group
name: Sport Lights
entities:
- light.gym_spot_1
- light.gym_spot_2
- light.gym_spot_3
- light.gym_spot_4
- light.gym_spot_5
- light.gym_spot_6
Once done click on the Save button
How to check if configuration is correct in Home Assistant
We need to reboot Home assistant before the light group will appear in Home assistant. But first, we need to check if the code we entered is valid.
- Click on Configuration
- Click on Server Controls
- Click the butoon Check configuration
If the configuration is valid you can reboot Home assistant by clicking on restart in this same screen.
If it is not valid you need to go back and edit the file again. It is usually spaces that are wrong. Like more spaces than you need or fewer spaces between the functions.
I have highlighted where the spaces are. In this example, the highlighted area has 2 spaces
Where can I find the light group in Home Assistant
You can find it under the development tools. Just type in the light again and find the name you have given it. Also, notice the icon it has. You can now use this entity in automation or script or just put it under a button on your dashboard
I’m using this one on my picture elements card for my fitness room. If you want to know how to create this kind of image then follow Create a Floorplan in Home Assistant series