Page 1 of 1

afterSec() cancels previous afterSec()

Posted: Thursday 01 September 2022 21:11
by jgaalen
I have an event that when a certain temp sensor is >= X then it sends an switchOff().afterSec(900) command. So when the value reaches X, I want to send the OFF command to the device 900 seconds later.
But the temp sensor gets updates every approx 60 seconds. Eventually the OFF command is never sent as I expect that the next minute the afterSec() command will overwrite the previous queue command. Eventually the OFF command is always scheduled, net never met.

Is there a function to solve this? I can create a dummy device and set the 'new' value and only send the switchOff().afterSec(900) command when the dummy value is not off, but this is not a nice solution.
Is there a way to read the queue and if there is already a switchOff() command in the queue, then ignore, if there's nothing in the queue, then schedule the command.

Re: afterSec() cancels previous afterSec()

Posted: Thursday 01 September 2022 23:33
by waltervl
In the script, the first time the sensor >=X set a variable to true after you have set the switchOff().afterSec(900) . Also do the switchOff().afterSec(900) only when >=X and variable is false (set it to false on setup).

Set the variable to false when <X

Re: afterSec() cancels previous afterSec()

Posted: Friday 02 September 2022 7:41
by jgaalen
Yes that is what I've meant with my first option as a workaround, use a helper variable. But it doesn't feel nice and I was wondering if there is a way to not overwrite the queue, but either read the queue (and then don't overwrite it in the script) or simply add a command to the queue

Re: afterSec() cancels previous afterSec()

Posted: Friday 02 September 2022 14:56
by waltervl
I do not think there is another way. See also https://www.domoticz.com/wiki/DzVents:_ ... ggering.29

Re: afterSec() cancels previous afterSec()

Posted: Friday 02 September 2022 16:55
by jgaalen
Ok I'll implemented it with using a helper variable