Using Rule Machine to trigger an action after a power outage?

I’m trying to help out a fellow user here.
@gzisimatos postet this in the lounge, and thought maybe more people would help solve his challenge here in the support category:

The last state is not remembered on the Xiaomi two channel relay after an outage, default is off. He needs a solution to remember last state and set it back where it was before a power outage or a tripped circuit breaker occured (Basically same thing)

So my thought was to make a rule with a trigger/action to read the state/mode of the switch when changed, and store the state in a local variable. Then somehow, for action condition, detect that the hub is rebooted and use that to run an action to set the switch back to last variable (state), after the HE is up and running again.
I think that is what he is needing.

Any good advice on how to use a reboot or something else that only happens during a cold start as a condition in RM?

Yea. He could store the states in RM variables... But not sure how he would detect the power restored..

1 Like

Maybe a Canary Bulb? I use a smart bulb in a coat closet , which defaults to on after power is restored and is never used for any other purpose. My hub is on a UPS. so when there is an outage and power is restored, I can use that bulb's state change as a trigger. If your hub is not on a UPS (Shame on you!), you could set up a periodic rule that checks the state of that bulb and do your necessary actions.

1 Like

One way is to use hub boot as trigger


Greate! That must be tested, but it seems the systemStart can be used, greate tip, thanks a mill. :slight_smile:

I use systemStart event to turn on my Homeseer fan controllers. They do not remember their state after a power failure. It works like a champ! One thing though, any time the hub reboots, either from a power failure or it reboots manually or automatically after a platform update, this will fire.



I have my hub.. And all my networking gear on UPSs.. If you have battery backup on your hub this won’t be a solution..

1 Like

The above coupled with hubduino will help users with battery backup.


I tried this and it is not working. I unplugged the hubitat to simulate power outage, but when it comes online again, the bulb (Sengled) is still ON. In Rule Machine shows not installed after the reboot.

What Im doing wrong?


I added a 10 second delay and it started to work ... I don't know if it was because it was without delay.


Sorry if my answer isn't very sophisticate, but it's working to me. I have several devices - mainly bulbs, but some plugs too - that return on after a power outage; just in my hall there are 12 bulbs with this behavior. It's very inconvenient when it happens by night, but the most worrisome is the fact that it may happen when we're out.

So I took one of these plugs that I wasn't using and made a rule based in its behavior. I keep it always off; so, if it turns on, the rule turns off all other lamps after 5 minutes. I put this delay to prevent any device that takes longer to connect from staying on.

It's simple, but is working to me.