I'm not sure if this is possible but here goes.
I'm looking to make a rule that when power goes out and the hub shuts down the shutdown time is retained. When power comes back on and the hub powers on again it will run the rules missed form shutdown to power up. So if the hub shut down at 10am and powered up again at 2pm it will run all the rules between the two times that have not been run.
If you have required expressions in your rules you could use the 'evaluate expression at startup' option. I'm not sure how you could do it otherwise.
The only way I could see this working is if the hub was on a UPS and a device detected a power outage (Ring Range Extenders,and some other devices can to this) and recorded the time in a hub variable and issued the shutdown. Then have a rule triggered at startup to read the variable and run the list of rules missed. (List would most likely have to be manually created.)
I didn't think it was possible. I'm not sure you could make a list of the rules because the list would change depending on time of day. Well, I guess you could make a list for each hour of the day.
Maybe you could make a virtual button to run the rule list. But that's a lot of work. A button for each hour list.
Can you provide some examples of rules where you would want to do this?
Would be easier to do in a small app. For setup tell it the variable to use, and have it load a list of Rules and then do a select for each hour. Then have it trigger on start up, determine the starting time and iterate through the rules list using a loop that adds 1 hour to the starting variable each time until the current time is reached.
Might also be able to have the app query the pending jobs list (/logs/json->jobs[...]) to build a starting list. Or alternatively capture the pending jobs list right before shutdown and then execute from it.
Blockquote
Just standard rules like turn on or off lighting missed. Thermostat set temperature at the time Hub was down. Any rule missed on down time. But only rules missed when hub was down.
It would of coarse depend on the rule, but it would seem to me the easiest way, as in the quoted example, would be to set a trigger on system restart for any rule that you want to do this with. Then have conditions set in the rule on a system restart trigger.
Now would that trigger the rules if you reboot the hub?
Are you certain you want the hub to do this when power is restored?
Depending on which rules were skipped while the hub was dead, you could end up with a bunch of lights turning on/off, thermostat settings changing, locks locking or unlocking, etc.
Just because you wanted something to happen at 7pm, that doesn’t necessarily mean you want it to happen at 2am if that’s when the power comes back on.
Looking at this post
Yes I saw that thread, but the OP there appears to have a different goal than you do.
If that’s your goal, i.e. re-run all rules with a time-based trigger once the hub boots after a power outage, you may find that you don’t actually want every one of those rules to run. But you know which automations you’ve setup better than anyone else.
If you put a trigger on system restart as a rule trigger anytime you reboot the hub it will trigger the rule.
Say you have a rule that turns on lights at 7:00 pm.
So IF the rule was triggered because of a restart and it is between 7:00 and whenever the light might have been turned off AND the light is off THEN turn it on and exit the rule.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.