Store Lights state when Hue bridge goes down


#1

I’m not sure if this is already done but here’s the scenario.

(Assuming you have an UPS on your HA)
There is a power outage, all lights and hue hub goes down, power is restored, now all lights are on, but you’re not home! So when you get home you find all your lights lit up.

If you can store the state of lights, you can monitor the hue hub going down, and based on that, assume there was a power outage, and as soon as it’s back online restore the lights state to the whole house (including turning off everything that was not before)

Let me know if you have address this scenario in a different way


#2

You can monitor the devices like your router or hubs and then if you see them go offline for a certain amount of time, you can have actions take place.

for your example, you can have HA watch for the Hub to come back ONLINE and then maybe wait 10 minutes or so and start shutting lights IF you are not home.

Check out this for ideas.
https://github.com/CCOSTAN/Home-AssistantConfig/blob/master/automation/device_status.yaml


#3

Thanks but what I’m proposing addresses different scenarios.

For example, if I have automation for my lights on sunset (regardless if I’m home), what you mentioned would turn them all off. Of course I could add a condition based on if the sun already set, but what if the power outage is at 3 in the morning? Then my light would stay on.

Easier way to cover all scenarios is to store the state, and then restore it as soon as the hub is back.

Storing the state of lights not only helps with this scenario, but also if you want to trigger a scene for a few seconds and then go back to where you were


#4

But then you run into the scenario where the power is out for 6 or 12 hours and when it comes back on, you don’t want the old state, you want it to come on at the state it should be at the time power comes back on.
There really isn’t a win win on this one. I’ve seen people going round and round with phillips on this one because by default the phillips Hue lights come on bright white. They consider it a safety thing. I consider it a pain, but I don’t work for Phillips.


#5

That’s another problem to address - any automation that should have run on hue while it was out should stay on queue waiting for hue to come back online


#6

Ok, lets go through some of the requirements here.

  • do you want to suspend operation so everything runs when the power comes back on or just start back up at the current time.
  • How should we handle devices where multiple automations may have passed since the power went out?
  • How do you want to run automations that run at a specific time and that time has passed?

#7

Power back on = Hue hub is back online

  • If no automations have run, restore the last known state as soon as the power is back on.
  • If there was an automation based on time, keep the state change in queue, to apply as soon as the power is back on.
  • If there was an automation based on sensor, disregard it (If an alarm went off, you probably don’t care to turn on the lights long after the thief is gone). Still restore the last known state as soon as the power is back on.
  • If there were multiple automations based on time while the power was out, queue the last automation and apply as soon as the power is back on.

Bear with me, I know I probably haven’t make myself very clear, but this might solve the hue scenario everybody hates!


#8

@kellerza is working on a PR (https://github.com/home-assistant/home-assistant/pull/4614) to restore states from the database. May be that will help.


#9

I imagine that’s assuming HA goes down too, my request here is if HA stays online while the power is out.

Still, I guess a lot of the code might be useful, thanks for sharing!


#10

The scenario I hate about the Hue lights is that they come on full bright white when they get power. So even if HA remembers the state, Hue is going to come on bright white while HA adjusts the automations. If that’s in my bedroom, it’s going to wake me up. There isn’t anything HA can do about that.


#11

I agree, there is nothing to do about that, but it’s better to have them at full bright for a couple minutes than for hours, or make you have to wake up in the middle of the night to turn them all off.


#12

Sorry to hijack this topic, but - i am about to buy a Hue bridge and a couple of E27 light bulbs (white only). Those bulbs will be mounted in lamps that still have a physical switch. So it’s likely to happen, that the power is switched off (just the bulb, not the bridge, not HA).

I understand that once power returns, the bulbs will revert to cool white will full intensity. Something which is not good for their intended purpose as “ambient” light.

Question: Can HA discover that a bulb becomes “live” again and use this informationen to trigger an automation setting light color and temperature?


#13

yes but it will take a few seconds for it to do so. I think you just keep monitoring for a trigger state of on.


#14

This code does that all day long.


#15

I have built an app to help you just with this

Hue Restore let you save and restore all Philips Hue lights in your home with single tap. You can do this right from home screen of your phone with convenient home screen widget.
You no more have to worry about those pesky power cycle resets because you can get back your favourite settings in a single tap.