I thought Iād change my nighttime routine rule and have it poll my bedroom thermo 30 seconds after arming, to see if forcing that information change would fire the rule but it didnāt work, right now in RM the conditions are showing as both true but the fan isnāt turning on and in the logs the rule hasnāt run for 20 minutes. Iām not sure how to set the frequency for it to run?
The terminology for this trigger is misleading. Although it says "becomes" it actually means "is". That's because it will trigger everytime it receives a temperature reading in that condition, not just the first time it "becomes" true to that condition. So it will trigger for every reading from the sensor where the current temperature satisfies your condition. And that will depend upon how that specific sensor works (eg. when it decides to report the value to the hub).
The normal way to deal with this is to use a Private Boolean. This is a binary variable, local to each rule, that you can set true or false and use to only trigger the rule once in such a condition. You will find examples if you search for it. So the first time this condition fires you would set it, say, to false, and then use a conditional to first check for false and not again run the action if so. Then you would have a further conditional statement or use a different rule to set the PB back to true again when sensible to do so, ready for the next time you want to check the temp is crossing that boundary again.
To add to the above, as-written, your rule won't do anything unless a temperature reading comes in (and it's greater than your threshold--any reading, not just the first such reading, as explained above). The IF in your actions that checks the HSM and fan status does not cause anything to be evaluated just by being there except when a trigger matches (or your rule actions are otherwise run, e.g., by invoking them from another rule).
Hi again. In case it helps, here is one of my rules (actually I don't use it any more, but maybe it will help you) which uses a PB and triggers on a temperature reading similar to yours....
However iām still confused as to why, even when both conditions are showing as true in RM as my original screenshot the rule didnāt take any action until 20 minutes later? Looking in the logs the rule runs sporadically and when it eventually ran it found the conditions met and activated the fan. Iām confused as to why it didnāt run as soon as the trigger conditions were met and then action conditions were met?
However in the mean time the temperature poll had run three times and confirmed a temptation over 19.9c and was showing that the temperature was 20 in hubitat but the trigger still didnāt fire until 20 minutes after? Iām trying to work out in my head what the logic is behind when a rule runs and why it didnāt run.
Are you saying that my trigger only fires specifically if the temperature moves from 19.9c to 20c and wonāt fire if the temperature is already over 20c?
Ok, so after some reading on private boolean and local variables as I didnāt understand them at all Iāve rewritten the rule, and I think this will cover fan on and off rather than having two separate rules as I did?
You should probably add a trigger for HSM Status is Armed Night. That way the rule will run and check for the correct temperature directly on arming and not just next time the temperature is updated.
Do you think that the āif fan offā Or āif fan onā part may cause problems? I.e if the wife turned the fan on via alexa then the rule wonāt trigger because the fan status is already on?
If I remove that requirement the rule should still run fine shouldnāt it?
Yes, this should work, since I don't use RM I don't know if this is a rule that is to complex and it should be broken down into more rules for the sake of performance, but yes, this should work.
@bertabcd1234 posted an excellent explanation of what a Private Boolean is and how to use Boolean status in a rule a couple months ago. Here is his post:
I'd suggest an END IF at the end of your rule as well.
I think switching to 'changed' for your temperature is going to work better than 'becomes' as well.
I suspect part of the reason your first rule logic failed was due to no change in the temp. So the current temp == existing temp, either at your trigger or at the device measuring temp. Can't become if it already is. But I could be wrong!
I didnāt understand the need for PB either but basically itās a virtual switch to signify if the action is already active. So for my rule it shows if the Conditions are already met then the āswitchā will be active and therefore doesnāt need to be turned on again.
So this almost worked but for some readon it wasnāt changing the boolean when triggered but I think iād maybe not set that up right?
So i used something @BorrisTheCat taught me on another post and mapped the boolean variable into a virtual switch and have that flipped on and off with the actions.