afterSec() cancels previous afterSec()

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
jgaalen
Posts: 15
Joined: Monday 11 February 2019 9:05
Target OS: Linux
Domoticz version:
Contact:

afterSec() cancels previous afterSec()

Post 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.
User avatar
waltervl
Posts: 5732
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: afterSec() cancels previous afterSec()

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
jgaalen
Posts: 15
Joined: Monday 11 February 2019 9:05
Target OS: Linux
Domoticz version:
Contact:

Re: afterSec() cancels previous afterSec()

Post 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
User avatar
waltervl
Posts: 5732
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: afterSec() cancels previous afterSec()

Post by waltervl »

I do not think there is another way. See also https://www.domoticz.com/wiki/DzVents:_ ... ggering.29
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
jgaalen
Posts: 15
Joined: Monday 11 February 2019 9:05
Target OS: Linux
Domoticz version:
Contact:

Re: afterSec() cancels previous afterSec()

Post by jgaalen »

Ok I'll implemented it with using a helper variable
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest