I'm really bad with figuring out automations, so sorry if I miss something obvious :D I'd like to make the lights in this room flash red for a second when triggered, and then return to their original state. As in, if they were pink before they should be pink afterwards, if they were bright white they should be bright white again. Is this possible with an automation or can this not be done?
#Flash lights in color and return to original state
1 messages · Page 1 of 1 (latest)
Just make a scene with scene.create and add them to the 'Entities snapshot'. Afterwards you can restore that scene.
If you also want to cover the off state you will have to make 2 snapshots. Do
- Make Snapshot A
- Turn light on, don't set other attributes
- Make Snapshot B
- Make the lights flash red
- When done
- Restore Snapshot B
- Restore Snapshot A
Can you explain a bit why you need an extra scene? I’m doing something similar to store the state of lights in a scene to store the state when the room is vacated, and then the state is restored when the room is entered. I’m not doing anything clever and AFAIK it will keep a light off if it was off when the room is entered again. Edit: messed up a load of words there!
The reason for the two scenes is a bit complicated, but basically the problem is that home assistant doesn't provide any way to tell what color and brightness a light is set to, or change the color/brightness, while the light is off.
so you have to turn the light on in order to check what its original color/brightness is
then when turning it back off, you have to first set it back to the original color/brightness before you turn the light off.
if you want to leave the light off when it's already off, then you only need one scene, but you need to make sure that the code only runs when the light is already on, for example by using an automation condition, or an if conditional action.
Thank you! That helps a lot.
I created a helper-entity group of the 3 lights up here. Do I need to add each entity to the scene.create individually, or would adding the group work as well?
how would I do that when I want to have that work for 3 different lights (that are in a group?) Would I need to create 3 seperate automations here or what?
I'd like it to only work on lights that are currently on, and just ignore the lights that are off
Or wait, nevermind, I think I'll just run it like described above and have it only work during the day
Not sure if I'm doing something wrong. I'm trying to create a scene snapshot-before-co2alert-a and -b and then restore them, but scene activate keeps saying unknown entity.
it's expecting an entity id, so it should start with scene.
Right. So in my setup with one scene if someone turned the light on while the room was empty and changed the light to pink then turned it off then someone came in the room the light would stay off, but the next time it was turned on it would be pink and not whatever colour it was in the on state when the scene was made? Or have I totally miss understood. PS. Thanks for interpreting my original nonsense correctly.
mh, still says unknown entity
maybe because i never create those scenes yet and the automation just doesn't know them?
With one scene, if someone changed the light to blue then turned off, then your automation ran and turned the light on to red then turned it off, then the next time someone turns on the lights they will be red instead of blue like they expected
And yeah, the scene entities do not exist until you call the create action
Mh, but without that I can't save the automation :D thats annoying
Ah, found the issue, apparently the ID can't contain a -
replaced with _ and it seems to work
Oh, huh. That seems like an issue that should be reported on the automation editor.
Ah. Yep, that would do it.
Entity IDs have to have value that work as python variable names to be valid in HA
Scenes are a bit strange. I’m guessing they don’t get a lot of love. They are in the “advanced” bucket with templates. Very powerful but difficult to figure out. But that’s how it is; if everything was foolproof most of the power would be gone.
yeah, i use scripts rather than preset scenes for a lot of things, i find them more flexible. but scenes are useful specifically for the case of saving and restoring state, as long as you are aware of the hidden state that they don't restore properly
To make it easy to do from the UI, you can just run the two actions manually that create the scene. After which they are defined and selectable via the UI.
As for three lights in a group, it depends on if you expect them to have the same state/color/brightness/etc. If you make a scene with a group it will not take the state of the individual entities but just the group state. So if they can be different you have to add the individual devices.
And yeah, the scenes could use some love and some updates to also support area's, labels etc.
HA won't allow two consecutive underscores in an entity ID. I'm not saying you did that, I'm just griping that for some reason it's not allowed in HA even though I believe Python has zero issue with it. Not a leading double underscore, that is special, but something like device_id__entity_id isn't allowed. I wonder why...
I haven’t found this to be an issue. I have…
- 4 lights within a room
- 3 different light settings across the 4 lights
- 2 grouped and effect applied (Nanoleaf)
- 1 WiZ light, no effect just 100% on
- 1 x dimmer set to 30%
- Create scene with script to capture settings
- change settings manually, turn off lights etc.
- Apply scene created by the script earlier and lights all have correct settings applied.
I’ve also created a scene directly via Live Edit and unique settings hold
@uneven ether As long as you know the lights are always on you can do it in a single scene. If they can be off and you want them to turn on like when you turned them off, you need two scenes. otherwise only the off state is captured, not brightness and color
This is a common issue with dynamically created (script created scenes). The scenes don't technically exist until they are created (the script is ran). As a result of that, the entity ID of the scene is unknown (known at run time).
EDIT: I do wish that (at least with scenes), that the script/automation editor had a way of determining earlier in the script/automation to determine if the scene name is valid from within the scope of the automation/script. As of right now, that isn't a thing. Just do note, even with that error, things function properly at run time.