I use some lights to flash blue in case my alarm fires. When the alarm is disarmed, these lights return to previous state by means of a scene which is created on the fly in the subsequent automation:
Before flashing the lights is initiated I create the scene on the fly:
- service: scene.create
data:
scene_id: before
snapshot_entities:
- light.schoorsteen_rechts
- light.schoorsteen_links
- light.wijnrek
And when the alarm is disarmed I return that state towards the subsequent lights:
- service: scene.turn_on
data: {}
entity_id: scene.before
This works fine, the lights return to their original color and intensity etc. The point however is, that this only works when these lights are actually in on state at the point where the entity snapshot is taken with scene.create (so when alarm fires). When the lights however are in off state (which usually is the case when an alarm fires), the color and intensity of the alarm state is being remembered (blue and max intensity) instead of the previous state.
I found a workaround by creating two scenes on he fly (one to remember the original on/off state of the light, then turn the subsequent lights on and create another scene to store intensity and color. When the alarm now turns back to disarmed state, I run those script in reverse order to make everything work fine.
So, there is a way to make the “return to previous state” also work fine in off state, but I cannot imagine that it is intended this way. Does anybody have a suggestion how to make the previous state work fully, even in case that the lights are turned off, without this funny workaround?