It seems that DZvents sometimes already trigger a script on device change BEFORE domoticz has already updated the value of the device.
In my case i run a script to see the gasflow, so in case when it misses the updated value i get a zero, and the next update a double value.
So i look for a way that i can let a script run 10 sec AFTER it is trigger on a device change e.g.:
return {
on = {
devices = { 'Gas', after 10 sec }
},
Without having Domoticz stalled for 10 sec because it wait for the script....
Run script 10 sec after device changed
Moderator: leecollings
-
- Posts: 82
- Joined: Thursday 02 March 2017 20:28
- Target OS: Linux
- Domoticz version: V4.1174
- Location: Netherlands
- Contact:
Run script 10 sec after device changed
Raspberry PI 3 - Opentherm Gateway + ESP8826 - EvoHome - ESPEasy CO2 + Fancontrol - RF-Link - zigbee2mqqt -
-
- Posts: 247
- Joined: Sunday 29 November 2015 20:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.9639
- Location: Spain
- Contact:
Re: Run script 10 sec after device changed
Have a look at the dzVents wiki.
Look for afterSec
Look for afterSec
-
- Posts: 23
- Joined: Wednesday 28 March 2018 20:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.11307
- Location: Nederland
- Contact:
Re: Run script 10 sec after device changed
This will only work on a switch.Look for afterSec
So, maybe use it a inbetween helper switch?
So use switchOn().AfterSec(10) to turn on a switch when the value you monitor changes
then use a 2nd event triggered by the helper switch?
[EDIT] see below, indeed a delay route via Uservariable is a cleaner solution vs adding another device
Last edited by BOverdevest on Wednesday 23 October 2019 23:26, edited 1 time in total.
HUE, Tradfri, Zwave, RFXCOM, rooted TOON, PS4
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Run script 10 sec after device changed
I never saw this. Can you show me the script and the domoticz log of an example and the version where you see this ? Maybe there is something else causing this.
You cannot code a delayed reaction to a device update in the on section. With a delayedURL function you can do this
[EDIT] or indeed using a helper uservariable of device like @BOverdevest suggests
Code: Select all
-- Delayed Gas
local scriptVar = "delayedGas"
return {
on = {
devices = { 'Gas' },
httpResponses = { scriptVar },
},
logging = {
level = domoticz.LOG_DEBUG,
marker = scriptVar
},
execute = function(dz, item)
local function delayedURL(delay, callback, logMessage)
callback = callback or scriptVar
logMessage = dz.utils.urlEncode(logMessage or scriptVar)
delay = delay or 60
local url= dz.settings['Domoticz url'] .. "/json.htm?type=command¶m=addlogmessage&message=" .. logMessage
dz.openURL({
url = url,
method = "GET",
callback = callback
}).afterSec(delay)
end
if item.isDevice then
delayedURL(10)
else
dz.log('The value of Gas: ' .. dz.devices('Gas').sValue )
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 82
- Joined: Thursday 02 March 2017 20:28
- Target OS: Linux
- Domoticz version: V4.1174
- Location: Netherlands
- Contact:
Re: Run script 10 sec after device changed
Yes.. this is the way to go.. I will try and check if it solves my flow issues (0 or double valvue)
Raspberry PI 3 - Opentherm Gateway + ESP8826 - EvoHome - ESPEasy CO2 + Fancontrol - RF-Link - zigbee2mqqt -
Who is online
Users browsing this forum: No registered users and 1 guest