Home Assistant Light Scene Selector, Scene Manager, Scene Cycle
by headseth in Circuits > Raspberry Pi
36 Views, 0 Favorites, 0 Comments
Home Assistant Light Scene Selector, Scene Manager, Scene Cycle
When having lots of lighting entities in Home Assistant, you can create scenes to control them. These scenes are useful and can be triggered by anything that is attached to your smart home (hass).
What I have done is connecting every scene with a certain number. This number represents the scene I want to display. No names attached, only numbers.
Why I did this? I have lots of scenes and I want to cycle trough them with use of a button. When I push the button, the number will increase or decrease. The corresponding scene will activate. Number 0 is every light off so when I long press the button to the left, the number will go to 0.
I made an automation to do this. Every number is attached to a scene, as I said. The scenes are called from a script made in home assistant (not the scenes itself). Why not scenes? Scripts have more room to play with variables and such. You have more freedom (for so far as I know) with scripts instead of scenes.
In this automation I also attached a text entity to show the scenes name on my dashboard. This entity is shown in the screenshot.
If you are still interested you can follow the steps to make this! I think it could be made more efficient or "pretty" but this works for me!
(sorry for gif quality, cannot get it to work with higher quality...)
Supplies
The only things needed are the following:
- Raspberry Pi (or other device) running home assistant (OS or docker, does not matter)
- Some light entities (I use home-made ESPHome devices and Philips Hue)
- Maybe a button or something (example: Aqara, IKEA)
Create Helpers
The first you have to make a counter helper in the helpers section of hass. This is going to be the number counter for the scenes.
You can also make the text entity if you like to do so. This is an input_text helper.
Create the Automation
Create the automation for all the numbers. You can add the scenes/scrips however you like. The screenshot shows how to implement it in yaml and in the visual editor.
This automation triggers when the counter entity changes from state. After that, it goes into a huge "switch case" system to trigger the correct scenes. Also, you can add the text entity here to show what scene is activated.
(optional) Attaching a Button
I attached an IKEA button with for buttons to hass. This button can control all the scene. When I press the right button, the scene counter will increment by one. This will trigger the automation we made. I also added a little timer for time consistency, you could experiment with this.
Scene Buttons on Dashboard
To control the scenes, you can add buttons to the dashboard. I made these buttons with the mushroom cards mod, downloaded from the HACS store. However, every kind of button will work. You just have to make use of the action command to control the behaviour of the button.
Now you can add the counter and set it to the correct number of the scene you like. You could add a text or icon according to your scene, like I did. I remember what the scenes are when I see the icons.
(optional) Adding Text Sensor on Dashboard
You can finally add a text sensor to the dashboard to see what scene is used. This is done by creating an entity card with the text entity attached to it. In my example, I used the mushroom cards mod again. Change the icon however you like.
Enjoy
Enjoy the scene selections!