I am using a DS18b20 probe connected to a konnected interface board to monitor freezer temp. I have a notification created to send a notification when temp is >32. My issue is when freezer goes into defrost I get a notification. Since the defrost cycle only lasts a few minutes, I am trying to create a rule that requires the temp to be >32 for a period of time before sending a notification to ignore the defrost period. Nothing I have tried works. Any suggestions?
May be a bit of a leap but you can use WebCore. It has functions like Stays Below or Rises Above and you can put time limits on these functions. Here is my freezer watchdog piston that I put on a Tile Master tile.
There is a flaw in my logic... every time the temperature reports greater than 32 it retriggers the rule, so if it triggers again within 10 min... it never gets to 10 min. That's what I get for not testing it! Try it with a delay instead of a wait... that might do the trick. I did a quick test with a virtual sensor and it seemed to work. The downside might be that it will send an alert repeatedly depending on how many times the temperature sensor reports in after the first 10 minute mark.
You're correct that the issue is a re-trigger, which cancels the wait. What I would do so that you only capture the first transition from below to above this threshold is use the "Use required expression" option (formerly called a predicate rule or predicate condition). This prevents the trigger event from actually triggering the rule unless the required expression is true, so in this case, you could use temperature <= 32. Then I'd make the first action a "Wait for expression: temperature > 32 --> duration 00:10:00" or similar.
I haven't tested this either and am writing about it from the passenger's seat of a car on a long trip, so maybe there is something I'm missing too...but I think it will work.
Actually, it's exactly what I meant. The trigger and required expression (predicate) work together in this case to capture only the first transition from below 32 (when the requiered expresion is still true) to the first reading at or above 32 (which will trigger the rule, then the predicate will become false--and prevent additional triggers, making the waits work as expected--until the temperature again goes below 32).
No, the trigger only counts if the required expression (predicate) is true. But we're only interested in triggering when the temperature is less than 32 and then becomes greater than 32, and the sequence of events is as described above because what matters is the evaluation of the expression at the moment right before the trigger event. There is perhaps a better description in the 2.2.8 release notes when this feature was new:
I have a bit of trouble getting my head around it too. The way I think about it is the precate rule must currently be true as the new event is processed. So if the hub thinks the current sensor report is 29 as it processes a new value of 33, the predicate is satisfied . But if the freezer temp reports 33 and then 35, the predicate is not satisfied and the rule never fires.
I'd recommend reading the thread I linked to above, which perhaps explains it better than I did previously. The "state transition" usage for predicate conditions (now "required expression") that they mention there is exactly the same use case as the above, except we're dealing with temperature and they're dealing with mode. The key in either case is that the value of the predicate matters at the time just before triggering, not after.