Page 1 of 1
How to make a timer in Domoticz?
Posted: Sunday 11 February 2018 14:13
by tjabas
Hi!
i have a water flow (water system in our house)sensor connected to a fibaro universal sensor, the water sensor is connected to the 1in on the fibaro sensor, everything so far is working great, when i turn on the water the sensor show in domoticz that the water is flowing.
But now i want to set a timer like this, if the water is flowing more than 30 minutes another switch is going to turn off the water, but if the sensor sensing that the water is flowing just for 29 minutes nothing will happen, and the timer will restart next time the water starts to flow.
how can i do this in Domoticz?
Re: How to make a timer in Domoticz?
Posted: Wednesday 14 February 2018 22:35
by tjabas
Anyone?
Re: How to make a timer in Domoticz?
Posted: Thursday 15 February 2018 17:57
by heggink
Use dzvents. On timer 1 minute
Define a persistent local variable initialised 0
Check if valve open and add 1 to local variable if open else reset local variable to 0.
Check if local variable equals 30 and close valve if so.
Re: How to make a timer in Domoticz?
Posted: Thursday 15 February 2018 18:04
by emme
a basic dzvents script:
Code: Select all
return {
on = {
timers = {
'every 1 minute'
},
},
execute = function(domoticz, device)
if domoticz.devices('waterFlow').state == 'On' and domoticz.devices('waterFlow').lastUpdate.minutesAgo >= 30 then
domoticz.devices('waterFlow').switchOff()
end
end
}
Re: How to make a timer in Domoticz?
Posted: Thursday 15 February 2018 18:30
by tjabas
Thanks for your answer.
I have never used dzevents at all, can i just copy the example you gave me and paste in dzevents, and it would work?
Re: How to make a timer in Domoticz?
Posted: Thursday 15 February 2018 18:36
by emme
probably it will
just replace the water flow device name
uh... what verstion of domoticz are you running?
Re: How to make a timer in Domoticz?
Posted: Thursday 15 February 2018 19:02
by tjabas
thanks :)The latest beta.
Re: How to make a timer in Domoticz?
Posted: Friday 16 February 2018 11:04
by gielie
emme wrote: Thursday 15 February 2018 18:04
a basic dzvents script:
Code: Select all
return {
on = {
timers = {
'every 1 minute'
},
},
execute = function(domoticz, device)
if domoticz.devices('waterFlow').state == 'On' and domoticz.devices('waterFlow').lastUpdate.minutesAgo >= 30 then
domoticz.devices('waterFlow').switchOff()
end
end
}
Very nice example, but now i want to do the same with a selector switch.
I have a thermostat selector switch called "Toon auto program" with no, yes and temporary. When the thermostat is set manually to a temp outside the program the switch will go to temporary and i want this to go back to yes after 30 minutes.
How can i achieve this?
Re: How to make a timer in Domoticz?
Posted: Friday 16 February 2018 11:21
by emme
gielie wrote: Friday 16 February 2018 11:04
Very nice example, but now i want to do the same with a selector switch.
I have a thermostat selector switch called "Toon auto program" with no, yes and temporary. When the thermostat is set manually to a temp outside the program the switch will go to temporary and i want this to go back to yes after 30 minutes.
How can i achieve this?
mmmh
let me sum:
Actors:
1 setPoint for manual operations
1 selector Switch (Toon auto program) with 3 values: No (lvl. 10), Yes (lvl. 20), Temp. (lvl.30)
Scene:
if setPoint changes the Toon auto program should go to Temp. for 30 mins and then go back to Yes
Note:
i the logic behind No and Yes there is no change to the manual setPoint, correct?
If so, once back to No or Yes, the manual setPoint has no impact in the heating system...
Correct?
then this should be achieved with:
Code: Select all
local manSetPoint = 'Manual SetPoint Name'
local toonDev = 'Toon auto program'
local delay = 30 -- delay in minutes to turn back to yes
return {
on = {
devices = { manSetPoint },
},
execute = function(domoticz, device)
domoticz.devices(toonDev).cancelQueuedCommands()
domoticz.devices(toonDev).switchSelector(30)
domoticz.devices(toonDev).switchSelector(20).afterMin(delay)
end
}
note the presence of .cancelQueuedCommands() available ONLY in dzVents ver. > 2.4.1
this will remove all old changes to the thermostat, and basically reset the timer by whitch the selector moves back
let me know if it works

Re: How to make a timer in Domoticz?
Posted: Monday 19 February 2018 11:48
by gielie
First thanks for the help, this is what i made of it
Code: Select all
local manSetPoint = 'Temporary'
local toonDev = 'Toon Auto Program'
local delay = 2 -- delay in minutes to turn back to yes
return {
on = {devices = { manSetPoint },
},
execute = function(domoticz, device)
domoticz.devices(toonDev).cancelQueuedCommands()
domoticz.devices(toonDev).switchSelector(30)
domoticz.devices(toonDev).switchSelector(20).afterMin(delay)
end
}
I put 2 min in there to test it but the script does nothing, i dont find anything in the log either