It isn’t very confortable to have all lights on in the middle of the night after a power outage. After the power comes back, I want the lights and switches/relays to remain the same state before the power outage. Something like the Power loss recovery from Philips Hue (“hue_power_on_behavior”: “recover”) but done from HA.
It would be great to add this option to lever on HA to manage the state restoration.
It could be “as easy” to configure as adding a flag, and when a device is unavailable, after it becomes available again, force to set the last state. I say force because some devices don’t report their state/values.
Hi there! I’d say this can be achieved by already existing functionality.
Add an input boolean helper for a light bulb
Create an automation using a template. Inside that template put a condition helper state does not equal to bulb’s state.
Inside action just toggle the bulb.
This way you are forcing HA to synchronize bulb’s state with the helper. I.e. helper is the master now, not the bulb.
But this isn’t a perfect solution. If there’s a power outage, then after the power turns back on it will take some time for the bulb and HA to recover the connection. Meaning all that time the bulb will keep being turned on.
For me, after reboot it is better to have state turning_on, and automatically try to turn on devices. turning_on state will be useful for all switches, because sometimes it takes 30 seconds to turn on (especially, for devices with WIFI), when I turn on wall switch, lamps receive wifi connection after 30 and ready to change colors.