Create scene and then activate scene to change the colour of the light back to the last used colour and state.
It works unless the lamp is off and in which case it doesnt reset the colour back to the original colour. It switches it back off (i.e the light was off in the first place) but keeps the light red.
It is possible there are some special cases for some integrations / products.
However generally speaking in HA whenever a bulb is turned off the only attribute that can be set is that it is OFF. Other attributes such as color or brightness can only be set when the bulb is either on or turned on.
The way I work around the issue is that I never use the light toggle function and whenever I turn on a bulb I always send its full state (brightness + color).
If you don’t like my solution and you want to exclusively use scenes for this (not recommended) you would need to capture two scenes i.e. your flow would need to be.
Capture “before” scene.
Turn On (but don’t change color or brightness) of the bulbs.
Capture “partial” scene.
Change color of bulbs.
…
Wait until time to turn off.
…
Restore the “partial” scene.
Restore the “before” scene.
Restoring the “partial” scene will reset the colors so that when the bulbs are turned on again they have the correct colors.
Restoring the “before” scene will turn off any bulbs that need to be off.
Note: I actually do the exact opposite of your solution, I use (defined) scenes to turns lights on, but turn bulbs off using scripts - the scenes always send the full state of the bulb when they turn them on.
Ok so if the bulb is on it works fine. It captures the state and reinstates it.
If the bulb is off then the buld will return to its power state but it wont reinstate the colour.
Ive tried seperating these out into distinct items and scenes and it doesnt seem to make any difference.
It would be good to report the power and colour options separately so i can trouble shoot?
I was worried about timings - which is why I said “not recommended”.
If you put a large wait in there say 2 seconds between each step, there should be enough time for everything to capture and restore.
By doing that, you should be able to get it to “work”.
You could then try reducing the timeouts to see what the minimum you can get away with is.
However I gave up on the approach, because I want my lights to be “snappy” and I just couldn’t make them snappy with captured scenes.
TIP: Its when lights first come on (i.e. when someone passes a sensor) that is the real pain point, if you can make that fast, its not really that obnoxious, if lights take a while to turn off.
Due to the nature of the symptom (that some lights are turned off, but still have the incorrect color).
I think we can say that the problem is with the “partial” scene.
In that any light that was on during the “before” scene capture, likely was captured “correctly” - at least it’s state was captured as off.
Despite the fact that you captured the scenes during an/the automation, there is nothing stopping you debugging using the Developer Tools → Actions function to manually activate the captured scenes - that will allow you to see exactly what was captured.
I also have a different “solution” to the problem.
If you manually create a “standard” scene - where all the lights for a given room are on and set to a color/brightness that you would consider normal/standard. Then you can change your solution to:
Capture “before” scene.
Set the lights how you want them for the alert (on/off, brightness, color).
…
Wait until time to turn off.
…
Restore the “standard” scene.
Sleep 2
Restore the “before” scene.
Pros:
The lights will immediately change to how you want them.
You only need to capture 1 scene during the alert.
Any light that is on when the alert activates will be restored to how it was after the alert ends.
Cons:
Lights that are off will be restored to their “standard” color/brightness not their actual value before the alert.
All lights will be turned on briefly when the alert ends.
There is still a need for a small (2 second in this case) delay when restoring the lights.
Succinctly stated: As a general rule ** Home Assistant is unable to change the color of light without turning the bulb on.
I agree with you that, that is a functional issue (irrespective of who/what is the root cause).
However given you have to work around that issue, anything else is within your control it is simply a case of deciding which problem/workaround is the best way to avoid the issue.
My Solution
For each room in my house I have a set of scenes, - this includes scenes for alerts (for example turning all lights red to tell me to open a window).
That way I can simply activate the relevant scene to display an alert.
I do have to track which scene is currently active (HA doesn’t provide a mechanism to do that).
I have an input select containing all the scenes for a given room (actually that is built dynamically - using a naming convention).
You can also use a naming convention, so that your scenes are either “normal” or “alerts”.
Hence every time you switch the current scene if its a “normal” scene you store it.
That way it doesn’t matter how many alerts you have or what order they fire in - once they are all clear you just go back to the last “normal” scene.
** - You will find some posts from people claiming that for specific integrations/manufactures/bulbs they have a workaround / way of doing it.
Yep, Hue & some other manufacturer (not sure if it’s Ikea) support this. There’s multiple posts about it and the general consensus is that it’s hardware-dependent.