Page 1 of 1

Clock/timer device

Posted: Wednesday 08 November 2017 11:38
by Andrex
I'm adding to DomoticZ the garden irrigation.
I've added a switch for every valve and a general "start timing" push button where I've added a timer for when the irrigation should start.
Now I need a couple of device where I can put the duration of the irrigation. I need 2 because 3 zones needs the same time and the other 7 need to stay open longer. Putting a "start" and "end" timer for each valve is not applicable since if I need to change the duration, I would have to modify all the 10 timers.
I will manage in Node Red the switch between valves, I just need to receive the start command (from the push button timer) and the duration.
I need the duration to be a device because I need to change it sometimes and I don't want my family to go over the code.
Any idea?
Thanks,
Andrea

Re: Clock/timer device

Posted: Wednesday 08 November 2017 13:54
by elmortero
Maybe you could use to virtual thermostat devices.
There you can use the up/down arrows to set the value and read them from your script.

Re: Clock/timer device

Posted: Wednesday 08 November 2017 15:03
by Andrex
elmortero wrote: Wednesday 08 November 2017 13:54 Maybe you could use to virtual thermostat devices.
There you can use the up/down arrows to set the value and read them from your script.
Good one!
I'll try that.
Thanks for the idea!
Andrea

Re: Clock/timer device

Posted: Wednesday 08 November 2017 15:17
by emme
you can use dzVents with some variables or text devices in which put the timers (so you won't modify the scripts) and us the .switchOff().afterMin() functions...

so.. le'ts imagine you have your zone like this:

Zone Valve Names:
Garden_Zone_1 ON/OFF
Garden_Zone_2 ON/OFF
etc etc
in each switch you have a timer event that witch it on

you also have a integer variable with the same name as the valve switch name containing the amount in mins of the timer

so.. the script would be:

Code: Select all

local gardenValveNames = {
      'Garden_Zone_1',
      'Garden_Zone_2'
    }

return {
	on = {
		devices = { gardenValveNames }
	},
	execute = function(dz, gardenValve)
	   if gardenValve.state() == 'On'	then
	       gardenValve.switchOff().afterMin(dz.variables(gardenValve.name))
	   end
	end
}