I want to create an automation which listens for off->on state changes of any lights, and sets the brightness and color of that light to the corresponding state of the light in a specific scene, depending on the time of day. This way, whenever someone turns on a light, it can turn on to the appropriate scene setting for that time of the day.
I already know how I can create the trigger, where I am stuck is getting the state of a specific light in a scene. I know I can call state_attr to get all entities of a scene, but it doesn’t seem I can read the entities state that way.
This gets me a list of entities: {{state_attr("scene.morning", "entity_id")}}
But the list only contains the entity ids, not the state which they’re in the scene.
Is it possible to get the state of all entities within a scene? The data has to be stored somewhere so I would assume it’s possible somehow.
Correct. It reports a list of entities controlled by the scene and you can then check the current state of each entity but that’s not what you want (you want the entity’s state set by the scene).
Unfortunately, I’m unaware of any existing template function that can reveal this information.
Thanks for the reply! That’s a bummer. I guess I can’t use scenes in this scenario. I will have to define all the brightness and color data within the automations for the lights. It’s a shame because it would be so nice to have it all stored in scenes. Do you have any other ideas how I might accomplish my goal of recalling a specific brightness and color for any light when it is turned on?
Yeah that seems the best. I imagine storing the light states for the different times of day in a dictionary variable of some kind in the script? It would have been cool if a scene could be used just for that storing of different light states, since it’s a much nicer experience editing a scene than editing YAML.