I have several apps in Rule Machine that are time of day triggered. I have found that if the hub is rebooted after the start trigger then the app does not pick up where it left off unless I open the app and hit run. One case involves the cycling of an electric heater overnight that is turned on/off between two times depending on the reading from a temperature sensor. If the heater is on when the reboot happens then the heater never turns off overheating the room. Any tips?
Check out this hidden gem:
Basically you'd add another Trigger of type Location Event, and select System Start so the rule evaluates on every hub restart. I'll leave it to you to set up the rule logic to avoid unintended consequences.
I would also add a second "failsafe" rule to turn off the heater (and any other problematic devices) independently of the existing rule. I set these up (usually tied to sunset+ or -sunrise) for fans, certain outlets, anything that produces heat, even reset speaker volumes, etc.
What is the setup of the rule and actions? Wait for Events are supposed to make it through a Hub reboot and be unaffected. At least that is the theory.
A lot of this also depends on setup of the overall rule. Required Expressions have an option to be evaluated on system startup. That can help depending on the rule structure.
Finally, for your Heater example, it might be better to split on and off into two different rules. This way the off rule will trigger with any temperature reading above the determined level. It might take a few minutes after a system reboot, but would still prevent the heater from running all night.
Having seen this rule, I strongly recommend breaking this into two different ones for On and Off. You are basically asking the rule to wait 11 hours which can sometimes cause problems. If you really wanted one rule, have it triggered at both 12 and 23. It would look something like:
Triggers
12:00pm
or
23:00pm
Actions
IF 12pm….rest of the actions that happen with outlet turning on
else-if 23pm…rest of the actions that happen with outlet turning off
End-If
The other option you could do is breakout the ON/OFF and the Notifications into separate rules. ON happens at 12:00pm, the ON notification rule runs at 12:01pm, the OFF rule happens at 23:00pm, and the OFF notification rule happens at 23:01pm.
Lastly, you could look to move ON/OFF into Room Lighting. When a hub reboots or power ups, Room Lighting will check time periods and adjust the lights at that time. Then, you could keep the notification rule(s) in Rule Machine.
What is the rule that sets the variable? It might make more sense to just trigger based on the temperature sensor. You could set something similar to:
Required Expression
Between the two times
Triggers
Temperature sensor is greater than XX degrees (only if plug is off)
Temperature sensor is less than or equal to XX degrees (only if plug is on)
Time is 1 minute before the end of the required expression (only if plug is on)
Actions
If plug is off, turn on plug
else
turn off plug
End-IF
The above rule would work for most of your cases. The only time it would fail is if you had hub reboot 2 minutes before the end of Required Expression and it lasted long enough for the temperature sensor to not trigger again inside the time frame. If you are concerned about that, move the Required Expression into the IF, so that it looks like:
IF between X and Y time AND Plug is Off, turn on Plug
Else Turn OFF Plug
End-IF
I would do the heater one a different way (depending on how you trigger for the boolean). I would think there is a rule that triggers on temperature change, and if it is below a threshold, it changes to true, and then above a threshold, it changes back to false.
Assuming the above, if it were my rule, I would simply turn it on, and then wait for expression, Front Bedroom Cold = false with a duration of 15 minutes
This would just turn it on and wait for the variable to turn false, and stay that way for 15 minutes.
The other option might be to have triggers on when the boolean changes. Then, if it is true, wait for time elapsed 15 minutes, then if Boolean = true switch on, else switch off. So, you have a 15 minute buffer before it turns on or off once it changes, keeping it from short cycling. The wait gets automatically canceled on retrigger and restarts the 15 minute counter. (effectively an "and stays").
For the light one, I would absolutely either split it into two rules, or run with two triggers and logic for if it is one time or the other.
This is what I ended up doing with the fish tank light. On the other fish tank suggestion I did not see that you could have an IF statement for a specific time, only between two times. For the heater suggestions, I will have to wait for the heating season to try those sugestions.


