[SOLVED] restricting lights from a certain hour
-
Is the day vs night coming from modes on Hubitat? It's quite likely that the time is not in perfect sync between the Hubitat hub and your MSR host. If the Hubitat goes to day even 1 second before the MSR host thinks it's 05:30:00.000, your restrictions won't work. You might try buffering your time a little bit (that is, opening the restriction window a few minutes earlier).
-
@toggledbits Makes me wanna write a "Time Sync Warning" rule that compares MSR's time with that of each controller, and sends out a message if they drift apart too far.
-
@toggledbits Yes, coming from Hubitat. So you're saying back up to 05:25?
-
Try that. How are you setting mode? Where is that coming from?
-
@toggledbits Had to go verify as I'd done that originally in Hubitat but then shifted to MSR because I didn't want "some stuff here, some stuff there" model.
-
@librasun Combined your notes with those from @toggledbits
-
toggledbitswrote on Jun 8, 2021, 2:26 PM last edited by toggledbits Jun 8, 2021, 10:30 AM
OK. Keep in mind that there's no guarantee to the order of rule evaluation. If two rules A and B both have conditions for 05:30, there's no guarantee which will be evaluated first. If it happens that B also depends on A directly, or on something A does, it's possible that if B is evaluated first, it will be looking at the "old" state of A because it hasn't updated yet. This may cause B to do some unexpected reaction. And worse, a moment later, A will be evaluated to its new state, and then B will see A changed and re-evaluate to the correct, expected state. This will happen so fast that the only way you'll see it is by examining the logs (or, you can add Notify/Alert actions to your reactions as a poor-man's debug stream). Leaving a wider window on time conditions can help with this as well. Other mitigation strategies may include moving time conditions that are often repeated into a rule, and then using the rule instead of the date/time condition(s).
In this particular case, you also don't really care if it's 5:30 in the constraints. You're thinking that way because that's when your day mode changes, but in fact, your time tests should probably just be before 6:30 and before 7:30. This would not be true if your "night" mode starts after midnight, but if it starts before, you're being too specific here.
If you don't change it to before, then put your ending times back to 6:30 and 7:30. You don't need to change those.
-
@toggledbits Wouldn't be the first time I've over-complicated the thinking...
This is where I am now given 99% of the time NIGHT is invoked before midnight. My m-i-l always says "nothing good happens after 9pm"
-
Let us know how things go tomorrow morning and thereafter.
-
@librasun There was no joy in Muddville... and then I got to staring at the rule and realized, in setting it to
before 6:30
andbefore 7:30
we'd lost thenot between
aspect. -
The future is looking bright!
-
@gwp1 Welp, awoke this morning to... light. Really scratching my head here. Unless I'm misunderstanding how the
not between
works I'm stumped.I'll send @toggledbits a log snip for the ten minute window around this event.
-
I think I'd "widen" those time slots by another 30 minutes (i.e. 5-7am / 5-8am), and give it another day of testing. Something tells me it's too precise for now, still. Nothing else jumps out at me, but as you've already pinpointed, Logs are your friend as is watching the Rule's live status in RuleSets.
-
I disagree. Unless the controller is down at the moment, one minute would be sufficient widening to prevent a race condition. There's something more here than meets the eye.
@gwp1 if you're going to send logs, don't snip, send me the whole thing, and also send all rules involved (if you click on the rule name in the Rule Sets list, it shows you the rule ID under the conditions -- there's a JSON file in your reactor/storage/rules with that ID as its base name).
-
toggledbitswrote on Jun 10, 2021, 3:50 PM last edited by toggledbits Jun 10, 2021, 11:53 AM
Actually, before we go any further, look at this more carefully:
Let's say for the sake of argument that it's 4am. Your "not between" conditions are going to be true (4am is not between 5:30 and 7:30), so the condition is true, and that means your "exclusion" isn't.
For me, based on what I understand your intent to be, and working within the existing structure, you really want these to be after operators with the earliest time you're willing to accept the lights coming on.
-
gwp1replied to toggledbits on Jun 10, 2021, 5:02 PM last edited by gwp1 Jun 10, 2021, 1:05 PM
@toggledbits Hmmm... that's an interesting approach. Mode + After alarm time = lights allowed. Let me try that.
-
@gwp1 Sadness abounds. Lights this morning. I've emailed @toggledbits the logs he requested in full.
Of note: when I was originally creating this rule I noticed something with the
Weekday
andWeekend
"button/links"... when saved, the days chosen by using those were blank again. Only way I could save them visibly was by manually checking them. I should have filed a bug - work intervened and then it slipped my mind. Perhaps unrelated - perhaps not, if the choices aren't really saved. -
toggledbitswrote on Jun 11, 2021, 1:52 PM last edited by toggledbits Jun 11, 2021, 9:53 AM
The log shows that this rule set at 20:28 and ran the "Rainstorm Lights ON" reaction from its set reaction. It remained set until 22:55, when it reset and ran the "Rainstorm lights OFF" reaction from its reset reaction.
The rule remained reset for the remainder of the log. It did not set at 05:30 or any other time, it did not start its set reaction or the "Rainstorm Lights ON" reaction it references.
However, the "Rainstorm Lights ON" reaction was run by another reaction at 05:30. So you've got a mention of this somewhere. I can't easily tell which (I'd need a higher level of debug), but it is probably one of active objects (or something they start):
- Rule Notify: Mode Day ON<SET>
- Rule Notify: Mode Night ON<RESET>
- Rule Notify: Screened room door<RESET>
- Cooling All Modes but Night: ON<SET>
- Reaction Sunset light group on
-
gwp1replied to toggledbits on Jun 11, 2021, 3:09 PM last edited by gwp1 Jun 11, 2021, 11:09 AM
@toggledbits
"this rule set at 20:28 and ran the "Rainstorm Lights ON" reaction from its set reaction. It remained set until 22:55, when it reset and ran the "Rainstorm lights OFF" reaction from its reset reaction."Yes, makes sense as this rule gets included in the @sunset rule for those two lights it controls. That would be sunset (20:28 until sleep time 22:55).
Reaction Sunset light group on
contains the rest of the lights that come on at sunset, of which this is a subset.I'll look at what's happening at 05:30 (IIFC it's just a mode change ruleset).
Rule Notify: Mode Day ON<SET>
This is the 05:30 mode change
Rule Notify: Mode Night ON<RESET>
I would gather this is Night Mode ON deactivating
Rule Notify: Screened room door<RESET>
This is the screened room door sensor alert being turned off after Night mode is deactivated
Cooling All Modes but Night: ON<SET>
This is HVAC switching from Night Mode to everything else with the mode change.
12/42