As title - I could really do with "has become and stayed above" for illuminance and temperature. I am using such a sensor to warn if the refrigerator door has been left open. Unfortunately I am so far having to just test again after 10 mins to see if it's still too bright inside. Which means anyone opening the door 10 minutes apart gets warned the fridge door has been left open which isn't true.
What I would suggest is a trigger on illuminance or temperature then a "wait for" to fall below the threshold with a timeout. If the timeout occurs and the thresholds are not currently being exceeded you can ignore the event. And if the triggers fire the rule a second time within the same period the wait will be canceled and the whole thing will reset, which is what you want,
I do something similar with presence sensors... if the person is gone and stays gone for at least X minutes... Here's my presence rule. Basically if any of the four sensors register give, a countdown starts. If any of them return the countdown is canceled. If the timeout is reached and the sensors all still show not present then the person really is not present.
So this is what I had been using currently - in Rule Machine Legacy. I'd have expected the delay to cancel if someone opens the door again just as the 10 minutes is coming up. Doesn't Delay cancel on a retrigger?
I know WAIT does... not sure about DELAY
Correct - If you use Wait for 10 minutes, it will cancel. To cancel a delay, you need to add a “Cancel Delayed Actions” command at the start of the rule.
So now I have the following
But this looks like the notification happens as soon as the door closes or when the timer ends, whichever is sooner. Do I have to run the test again as a condition to the notification?
yes, otherwise the notification will always happen...
Well then that will have the same problem as my original rule. Someone unlucky enough to open the fridge just as the timeout was happening will case an alert. In that case my request for a Basic Rule enhancement still stands
Hmm maybe a while loop with a counter...
But if someone opens the door within that 5 min countdown it should retrigger the rule and restart the wait, no? That's what happens in the example I sent you. At least I am pretty sure that's what happens Or maybe I just haven't had enough coffee this morning... that's a distinct possibility too.
I have to admit the Rule Machine options are really giving my brain a run for its money! I thought it would cancel the wait but not the entire rule so the last action would run anyway. Never mind the coffee I think I need a stiff drink!
Boolean logic is not our friend Sunday morning... or in your case Sunday afternoon.
Whenever I read your screen name I mis-read it as Inigo Jones and think of Greenwich.
So what happens if the wait gets cancelled by the rule retriggering? Does it go on to do any subsequent lines or does the entire script stop executing at that point?
It stops and starts over. The following lines will not be executed.
I still don't really see how to adapt that for my use case as I'd also want to abandon execution if the temperature or illumination came down to acceptable level during the wait for.
If it comes down to an acceptable level, the wait for will just wait until it is stopped by the app being re-triggered when the light turns on again.
Give it a try - see if it works for you.
So where do I insert the notification? I can't work it out with that method. I also get the feeling that it might be better to have a more complex looking rule that finishes altogether between triggers than a simpler looking one that's running in the background all day... or?
The notification can just be added in the line following the wait.
The rule will be running in the background either way - either waiting for the illuminance to trigger the whole rule, or waiting for it to trigger the wait. And as I understand it, the running in the background is just having it subscribed to illuminance change events from the device.
So I set the wait when the light in the fridge comes on, then the door closes and the light goes off before the 5 mins is up. What happens then? I've still got to run a test condition or the notification will run wrongly