What do i want?
i have a on/off switch in the toilet and i want that the switch when i turn it on automatically turn off in 10 minutes.
who can help me with a dzVets script for wat i want.
Who can help me with dzvents scripts?
Moderator: leecollings
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
Re: Who can help me with dzvents scripts?
Code: Select all
local mySwitch = '<put here your switch Device Name>'
local minDelay = 10
return {
on = {
devices = { mySwitch }
},
execute = function(dz, mySw)
if mySw.state == 'On' then
dz.devices(mySwitch).switchOff().afterMin(minDelay)
elseif mySw.state == 'Off' then
dz.devices(mySwitch).cancelQueuedCommands()
end if
end
}
The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
-
- Posts: 11
- Joined: Tuesday 19 March 2019 16:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Who can help me with dzvents scripts?
Thanks emme for the script,emme wrote: ↑Tuesday 19 March 2019 16:45this way you ask Dz to switch of the light after 10 minutes, but if you switch it of manually it cancel the queued message so, the next time you switch it back on the 10 minutes countdown will restartCode: Select all
local mySwitch = '<put here your switch Device Name>' local minDelay = 10 return { on = { devices = { mySwitch } }, execute = function(dz, mySw) if mySw.state == 'On' then dz.devices(mySwitch).switchOff().afterMin(minDelay) elseif mySw.state == 'Off' then dz.devices(mySwitch).cancelQueuedCommands() end if end }
I test the script i put it like this see below end its working now.
local mySwitch = 'Hue Eetkamer tafel Lamp'
local minDelay = 1
return {
on = {
devices = { mySwitch }
},
execute = function(dz, mySw)
if mySw.state == 'On' then
dz.devices(mySwitch).switchOff().afterMin(minDelay)
elseif mySw.state == 'Off' then
dz.devices(mySwitch).cancelQueuedCommands()
end
end
}
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
Re: Who can help me with dzvents scripts?
oops!... forgot an "end" 
this is usually my signature in the scripts


this is usually my signature in the scripts



The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
Who is online
Users browsing this forum: Google [Bot] and 1 guest