Rule wait step and power outage

I have a number of rules set up along the lines of at a certain time, turn this light on, then another rule to turn it off at a certain time. I never gave much thought to combining them to one rule with a wait step, until I saw it in a YouTube video.

I know that would clean things up, but I live in an area that has storms pretty much every day in the summer, and it's not unusual to have the power flash off, or the power to just go out. So my question is, if a rule starts (turns the light on), and the Hubitat looses power, would it pick back up on that rule when the power is restored?

No.. That said, having separate rule in my opinion is better. (Don't put all your eggs in one basket).

A small ups power brick will also help you... In my own case when one of my extenders detects power failure (Ring v2 extender) it switches to it's built in battery and that status is reflected in the attributes. When hubitat sees that it waits a certain amount of time (usually a few hours) and when it doesn't see that attribute change from battery to mains it will do a clean shutdown. Though i have never had a power outage that long. I do get the notification the power went out. (Fios and servers are all on UPS so I usually have internet)

1 Like

If what you're asking is, will a 'Wait for event: When time is' survive a power outage? Yes, it will. A Wait for event is subscribed to an event just like a trigger. If the power goes out and is restored (or hub rebooted) before the time is reached then the Wait for event will happen and the rule will proceed to the next action. If the power is out at the time the Wait is supposed to happen then it'll be missed and the rule won't proceed. The rule will start again the next day. A rule with a separate trigger will also be missed so the lack of action is similar. There are strategies to handle this but a ups should be your first line of defense.

1 Like

Yes, unless the wait would happen while the hub is not powered. A wait for a certain time creates a scheduled job, and those schedules are not changed by a reboot, power off/on, etc.

This is completely wrong, on both counts.

1 Like

Let me rephrase this.

I have a light that I want to turn on at 10:00PM, then off at 11:00PM. At 10:00, it turns on. At 10:15 the power goes out until 10:30. When 11:00 rolls around, would the light turn off?

Yes, this is what Bruce meant above, and you can verify this if you want. Assuming that to do what you ask, you might have a rule written like this:

Trigger event: Time is 10:00 PM

Actions to run:

On: Light
Wait for event: time is 11:00 PM
Off: Light

Then, upon creation, you'll have a scheduled job that will cause the rule to be triggered every day at 10 PM. You can check "Scheduled Jobs" on the App Status page to see this.

Then, once you get to that "Wait" action (so almost right after it's triggered and the lights turn on), you'll get another scheduled job for the next time it becomes 11 PM. You can also check the App Status page to see this. If you shut down or reboot the hub between this time and 11 PM, you'll see that this job remains after the hub comes back up — and, if you wait, that the scheduler will execute it as expected. (Of course, if the hub is still down at 11 PM, all bets are off, but it should resume working fine the next day.)

Yes. When the hub restarts, the scheduled job is still there, still in the future, so at 11:00 it will turn off.

1 Like

My assumption has always been since HE is event driven, that lets say that a light is scheduled to come on at 5:30pm. The hub has no power from 5:27-5:38 and then comes back up. Since that time was past the rule time, the rule shouldn't fire till the next time it's 5:30. Is that incorrect? (I'm not talking about triggers like motion or what not, just time)

I always thought that too, but it does work.

I tested it out last night after posting here. I set up a rule to turn a light on at a certain time, then off 10 minutes later. After it turned on, I cut power to the Hubitat for a minute, and the light still turned off at the designated time.

Well if it booted up prior to the time it was set to go off, sure... but I'm surprised if you booted up PAST the time it was supposed to go off it still went off. Try this

Set up rule to go off.
5 Minutes prior to rule shut down hub.
Wait 15 minutes and power hub back up. (This would be 10 mins past the rules proposed execution time)

Does the rule still execute?

1 Like

Just to save some time, that answer would be no. :slight_smile: A scheduled job will not "catch up" and execute at a future time if the hub was off at the time when it was supposed to run. However, as mentioned above, it will run if the hub is back up by that time (an assumption I made above, and the situation the OP appears to have tested just now, though I see not clearly stated originally).

But this is true no matter how the rule is written — as one rule with a "Wait" or as two with separate triggers. The only difference is that the single rule does actually need the trigger event to happen (i.e., the hub to be online at that time) so that the "Wait" itself is reached and that "temporary" scheduled job created. So, in my example above, if the hub is off at 10 PM, nothing would happen at 11 PM because that scheduled job never had a chance to be created.

2 Likes

Here's a rule that'll handle the hub being power off during intended events.

Trigger Events:
Time is 10:00 PM
OR
Location event: systemStart

Actions to Run:
IF (Time between 10:00 PM and 11:00 PM) On: Light
Wait for expression: Time between 11:00 PM and 6:00 AM
Off: Light

Note that the IF is a simple condition and I'm using Wait for expression now.

I'm sorry - I misread the times you put in the last post. I thought you said power back on at 5:28, not 5:38. So that would mean it wouldn't go back and run something that was supposed to run when the power was off.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.