What's the right way to get a timer back on routine after power loss?

My aquarium lights are controlled by Zigbee outlets and Simple Automation rules that turn the lights on and off at set times.

The Zigbee plugs should restore the last power state in the event of power loss. However, that's obviously only helpful if the power loss is brief. The longer the outage, the greater the chance that the last state is no longer correct.

What's a good way to make sure that a timer returns to its routine and sets the correct switch state after a power loss?

As an additional complication, the hub itself is on a battery backup and it may remain up during the entire power loss. Therefore, a routine that only checks timer status on system start isn't the best idea.

I have one of those Ring extenders with a battery that reports AC power status, so I can know when I lose power... But it's possible the hub may lose UPS power before the AC comes back, meaning there's no guarantee that it will see the Ring's message when power is restored.

The best idea I have right now is a rule that just keeps checking the switch states and issuing corrections if needed, but this seems crude.

Any ideas?

I use a normal rule.
When a hub reboots, or power is cycled, all hubs sequentially set themselves to "normal".
Mode, lighting levels, temp related, who is on, who is off.
Returns system to baseline.

Downside, overrides current local and specific settings.
(I think it is hot, the system sets it to, fan off on the one that blows on me, i just yell "alexa mozzies" and all the fans come on!)
Many ways to acomplish this.

My normal rules mostly just run existing rules.

1 Like

I would create a rule that has 2 triggers:

  1. Hub Reboots
  2. Power changes to “Mains”

Then have that rule either run the other rule if it will automatically set the light based on time of day, or otherwise have the rule itself do this.

Is there a way to set up a watchdog rule like that without duplicating the schedule? If I understand things right, running a check on reboot or return to mains power means that you need to repeat the schedule in that rule.

Might there be a way to do this without double data entry?

I've had some z-wave dimmers come on after a power outage. I have a rule that turns EVERYTHING off, twice, lol.

Practically speaking, how about just setting the zigbee plug to be off on a power return, and let the sequence begin next time?

I’m not sure I understand the question… If a rule is triggered on reboot or mains, it can be set to run the rule that sets the right state for the light.

That's certainly the easiest thing to do, it would just be nice to find an easy way to restore the ideal state. I'm honestly surprised that there isn't a provision for this already.

I think I see what you mean now. I thought you meant a second rule.

I am not sure how to set up a RM rule that both sets a schedule and can be retriggered to check that schedule, if someone has an example handy I would like to see it.

The other thing is, that I just thought of, is that all bets are off as far as normal performance after a return from a power outage. Communication with that zigbee/z-wave smart plug may be lost, with even a programmatic shutdown/power cycle not having a restorative effect. At least if it was off, maybe the fish wouldn't get too discombobulated. But I'm not a fish guy. :slight_smile:

@Horseflesh, can you share the rule that you currently use?

Right now I am only using Simple Automation to turn outlets on/off. I haven't yet built anything to restore an outlet to the correct state after a power interruption.

What I would do in this case is a RM rule:

Required Condition:
Time is greater than a few minutes before the time the light should turn on, less 5 minutes (This is to account for a power loss between midnight and the time the light should turn on. Without this, the light will turn on after midnight and stay on until it turns off at the « turn off » time, if there is a power loss between midnight and the turn on time.)

Triggers:
Time that the light should turn on less 5 minutes
Hub Reboot
Power: Mains

Actions:
Wait for condition: Power: Mains (So it doesn’t send the command if there is no power)
Turn on - Delay 5 minutes (Delay to give the Zigbee time to reconnect)
Wait for condition: Time it should turn off
Turn off

Guess I'm just lucky. I reboot my C7 at 4am every day and all my timed events work as expected.

Losing timers at a reboot is not the issue, it's getting timers back on track when the hub has been down for hours and the outlets' last state isn't correct any more--if the outlets even remember their last state, which many do not.

That makes sense, thanks. It seems ridiculous to write that rule for every timed switch of interest but I guess that is how it is.

This is maybe what I was looking for.
After a power outage and the hub restarts, this will restart rules from certain times missed by the hub being down, correct?

Can you please post an example of the steps to make this rule.

This, along with the data I included above, should give you the information needed:

Report back if you get stuck and there will be someone (me or another in the community) that can help you get unstuck.