How to make a timer in Domoticz? Topic is solved

Post Reply
tjabas
Posts: 169
Joined: Sunday 11 December 2016 14:51
Target OS: Raspberry Pi
Domoticz version:
Contact:

How to make a timer in Domoticz?

Post by tjabas » Sunday 11 February 2018 15:13

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?

tjabas
Posts: 169
Joined: Sunday 11 December 2016 14:51
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: How to make a timer in Domoticz?

Post by tjabas » Wednesday 14 February 2018 23:35

Anyone?

User avatar
heggink
Posts: 455
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi
Domoticz version: V3.9530
Location: NL
Contact:

Re: How to make a timer in Domoticz?

Post by heggink » Thursday 15 February 2018 18:57

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.
Pi3, latest beta
RFXCOM, z-wave (AEOTEC, switches, temhum, pir, contacts),
Plugwise2py, P1 'smart'meter & solar panel
Alexa, Wifi Cams motion detection
ESP: relays, PIR & Temp/TempHum
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest

User avatar
emme
Posts: 798
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: How to make a timer in Domoticz?

Post by emme » Thursday 15 February 2018 19: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
}
That's one small step for a programmer, one giant leap for me!
- - - - -
Raspberry Pi3 + AeonStick G5 + RFXCOMM433 + iRTrans Server + NodeJS
There's no stress in the mess!!

tjabas
Posts: 169
Joined: Sunday 11 December 2016 14:51
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: How to make a timer in Domoticz?

Post by tjabas » Thursday 15 February 2018 19:30

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?

User avatar
emme
Posts: 798
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: How to make a timer in Domoticz?

Post by emme » Thursday 15 February 2018 19:36

probably it will :P

just replace the water flow device name

uh... what verstion of domoticz are you running?
That's one small step for a programmer, one giant leap for me!
- - - - -
Raspberry Pi3 + AeonStick G5 + RFXCOMM433 + iRTrans Server + NodeJS
There's no stress in the mess!!

tjabas
Posts: 169
Joined: Sunday 11 December 2016 14:51
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: How to make a timer in Domoticz?

Post by tjabas » Thursday 15 February 2018 20:02

thanks :)The latest beta.

User avatar
gielie
Posts: 216
Joined: Tuesday 12 January 2016 12:40
Target OS: Raspberry Pi
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: How to make a timer in Domoticz?

Post by gielie » Friday 16 February 2018 12:04

emme wrote:
Thursday 15 February 2018 19: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?
- Vision ZU1401 USB Stick
- Aeotec MultiSensor 6
- FIBARO FGS222
- FIBARO FGWPE Wall Plug
- Everspring AN157
- Neo CoolCam Power plug
- Neo CoolCam PIR Sensor
- Popp Smoke Detector
- Toon
- Kodi Media Server

User avatar
emme
Posts: 798
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: How to make a timer in Domoticz?

Post by emme » Friday 16 February 2018 12:21

gielie wrote:
Friday 16 February 2018 12: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 ;)
That's one small step for a programmer, one giant leap for me!
- - - - -
Raspberry Pi3 + AeonStick G5 + RFXCOMM433 + iRTrans Server + NodeJS
There's no stress in the mess!!

User avatar
gielie
Posts: 216
Joined: Tuesday 12 January 2016 12:40
Target OS: Raspberry Pi
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: How to make a timer in Domoticz?

Post by gielie » Monday 19 February 2018 12:48

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
- Vision ZU1401 USB Stick
- Aeotec MultiSensor 6
- FIBARO FGS222
- FIBARO FGWPE Wall Plug
- Everspring AN157
- Neo CoolCam Power plug
- Neo CoolCam PIR Sensor
- Popp Smoke Detector
- Toon
- Kodi Media Server

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests