I created automation. If its trigged, light is setting yellow and blue for some seconds. This is working well but i want to set light’s color and its state what it is before automation. Thats why i use scenes on the fly.
If light is on first, everything is working and color is setting its default, but light is closed in beginnig, its closed after automation but its color stayed in blue.
What will I do to make color back to first color before automation started when first state of light is closed.
Yes, this is how it works. Your scene before hand is capturing the light as off. If you want to only capture the on state, first turn the light on, then capture the scene, then run your repeat, then recall the before scene.
You can use choose to conditionally turn the light on if the light is off.
I want it to work when it’s off too and it works fine, but when light off and automation works then it doesn’t return to its original color. Although the light is not navyblue in the initial state, it remains navyblue if i turn light back on.
On the fly scenes are not destroyed at the end of the automation.
But it will be if you restart HA or if you call the service scene.reload
And it will not be what you expect if in the meantime the automation (or another) has started (again) and recreated a scene with the same name.
You can also create 2 scenes
before_on
<light.turn_on>
after_on
then scene.turn on in the opposite order.
after_on
before_on
What is the interrest? Well, if it was off, it will get its color back and off. If it was on before the light.turn_on, it will not off.
Therefore you’ll get the exact situation prior to your automation, same color, same on/off status.
Very interesting. I think that this explains some of my (haunted) problems.
I have a porch light which is automated to come on a sunset and turn off at 22:30. It’s brightness is set by a light-sensor so that the brightness increases over time, as needed.
I also have a porch door sensor which when triggered will turn the porch light at max brightness for a duration of 2 mins and then afterwards restore the “scene: before” but was acting oddly as the light was getting stuck in a max brightness state.
I now understand that if somebody opens the porch door twice during that two minute period, scene.create will be run twice, with the second run gathering the state of the light at max brightness preventing the light from returning back to the original state which was set by the light-sensor.
I think that the solution proposed to you by CentralCommandMike will also fix my problem, but I worry that I’ll end up with a scene snapshot for each door-open command unless I somehow perform a scene: reload to clear out the history… but I’ll give it a try!
It is what I need now. Can you please explain it again? What is the order of doing it? Currently, I just create a snapshot named scene.before_on and load it at the end and have the problem like the OP that the colors have changed. So I can let this be like it is as I understand you. Then I turn the lights on shortly and create another snapshot.
Then I would do what I want like flashing all the lights in different colors. Then activate the after_on scene to get the colors back and activate the before_on scene to get them off again.
One thing I don’t understand… Why does it capture the brightness then?
Light is ON at 80% brightness blue
I turn OFF the light
I capture the scene (scene.create)
I turn on the light, set color to red, set brightness to 50%
I restore the scene (light turns OFF)
I turn ON the light: brightness is 80% (correct), color is… red (supposed to be blue) => brightness is captured, color is not.
I’d assume that if “it doesn’t have a color to restore to” it should also not have brightness “to restore to”. BTW, both values are null in the States panel, when the lightbulb is OFF.