Background: My smart home uses both HA and ALEXA to execute automations and commands. ALEXA is used for the voice commands and HA is basically used for everything else.
Scenario I am trying to fix: During the course of the day, we may have HA or ALEXA (via voice) change the warmth or color of the lighting in the house. Problem with this is that the next morning, the lights are in the last state that we left them the night before. For instance, I will ask ALEXA to turn on kitchen lights, and they may come on as RED. What I really want is to have the lights reset themselves to a default state each day.
What I have done so far: What I am doing currently is when I go to bed, I have an HA routine that puts the house in sleep mode (i.e., turns on alarm, shuts off lights, turns on cameras, etc…). During this routine, as HA turns out the lights, it runs a scene where it sets the lights that are on to the morning default setting – waits 50 milliseconds for that to happen — and then runs a scene to turn the lights off. It works, but is there a better way of doing it? I just feel there is a better way than flashing on and off a Scene (50 millisecond flash) to accomplish this. Also if any lights were off during the above action, those are not reset to default because they have to be ON. I cannot turn them ON to reset them because it would wake others in the household.
Look up scene.
You should be able to set your lights in the condition you want and store it as a scene, then recall it whenever you want.
I don’t use this, but it is a thing.
I didn’t think those things worked. I have tried them and read somewhere they were broken.
I instead for one light have an automation that looks for it to turn on from off and sets the color.
As far as I know you only really have two choices **:
Change the light color before you turn it off.
Change the light color as you turn them on.
** - There has been some discussion about changing light colors whilst bulbs are off - I have not had a lot of luck with that - your milage may vary.
Whether you use, scenes, scripts or default light profiles you still have two problems:
Depending upon your hardware you may get a brief flash either just before you switch off or as the light is switched on - though better (read more expensive) bulbs typically have less issue with switching color on power on (without flashing the old color).
Determining if the default color should be applied ***.
*** - It’s easy enough to have it reset every time the light is cycled (turned off and on again) however sometimes you may want to set it a particular way and turn it off, then have it come back on as you left it.
I use scenes, so that I get predictable color/brightness every time, but it means that I can’t easily turn the lights back on as I left them (my scripting always/only activates scenes) - note thats a restriction of my scripting - I could put more effort in and resolve the issue.
That is hardware dependent. Some hardware supports it, some does not. e.g. there is a set state action for Lifx lights that allows the state to be set while off. Works perfectly.
I used them for years, but there are unresolved bugs and you have to specify colours in xy which isn’t supported natively by many brands, plus where conversions are involved it cannot always be done as a 1:1 mapping. The Scenery HACS integration solved things neatly for me — still using profiles, but just not defined in that CSV format.
@Sir_Goodenough I do use scenes to set the default settings. However I am trying to get away from having to flash the lights in that state before I turn them off.
@tom_l Light profile is fine if I ALWAYS want them coming up in the Default state. However I only want them returning to a default state at the beginning of each day.
In other words, if we turn the lights RED using ALEXA command, I want them to stay RED the rest of the day unless I physically change them with ALEXA or HA. However when I go to bed and get up the next day, I want the lights back to a DEFAULT state (i.e., not RED).
@dtrott Kind of the conclusion I am finding and already have. Since HA executes my “Bedtime Routine”, I have been changing the color right before I turn them off with this routine. I cannot change the color when I turn them on because some are only turned on with ALEXA voice commands.
@tom_l Hmm… changing the bulbs that are mostly under ALEXA control to be set by HA to a color while off to Lifx lights might be an option I did not realize. During my bedtime routine, I could send an HA command to the Lifx bulbs to return to a default state after I have turned out all lights. INTERESTING…
I don’t use voice commands (so take this with a pinch of salt), however one of these workarounds/kludges might work:
Fake Devices
You can create fake devices in HA, for example:
MQTT Switch
Template Switch
Template Light
They show up as light or a switch in the HA UI, however they are not backed by any real device.
If ALEXA sees those devices, you may be able to use voice commands to switch them, hence you can use them to run an automation when their state changes (templates have explicit hooks to do that).
Trigger when turned on
You can create an automation that triggers whenever the light is turned on.
You can then add a set of conditions that check:
The time of day.
What color the light is at the moment.
If it’s in the morning and the color looks like an “evening” color you can send an additional command to change the color.
I.e. You still turn on the light using Alexa, however in the morning HA fixes the color for you.
It’s possible you might need a small (0.1 second) delay to make sure everything is synced, hence you may see a brief flash of the old color (per my previous comment).
With a bit more work you can probably create a single automation to handle multiple lights (all the lights are added to the trigger condition) - Just set it to parallel execution so that it triggers multiple times if you are turning on a lot of lights simultaneously.
@dtrott This is actually rather ingenious. Now you are going to make me have to learn how to do this via HELPERS since I am not a YAML coder. Problem with most of the GUI Template instructions is that there are never any examples using the GUI. Only examples are always using YAML.
My existing setup already had an input dropdown for each room (select.<room>_lighting) that contains (built dynamically) the list of scenes for that room.
Additionally every room has a “Bright” scene which contains all bulbs in that room.
After claude did it’s thing, I now have two “Fake/Generated” scenes for each room (Off & On).
They are fake because there isn’t a real matching scene, when I select either of those options a script runs (based on the “Bright” scene) that simply turns all of the lights in that room Off or On.
Hence using the select I can now choose to turn lights Off, Pick a specific scene or pick the On “scene” which just restores the previous values. Hence the remainder of my automations now have a choice whether they should restore previous values or pick a specific scene.
The only problem I have found with this setup is that selecting On turns all lights on so if I manually configure some lights on and some off I still can’t restore that exact configuration.
I could take another go at this and capture the scene before turning the lights off, but its really becoming a diminishing return / not worth it.