Page 1 of 1
dzVents timer with switch
Posted: Wednesday 17 January 2018 14:06
by parrotface
Hi
I have dzVents script running every minute OK but I am trying to run it only when a switch is on.
I still need it to run every minute but only when switch is on
Thanks
Re: dzVents timer with switch
Posted: Wednesday 17 January 2018 14:59
by emme
Code: Select all
return {
on = {
device = { 'myDevice'},
timer = {'every 1 minutes'}
},
execute = function(domoticz, device, triggerInfo)
if triggerInfo.type == domoticz.EVENT_TYPE_TIMER then
-- do timer event stuff
elseif triggerInfo.type == domoticz.EVENT_TYPE_DEVICE then
-- do device event stuff
end
end
}
Re: dzVents timer with switch
Posted: Thursday 18 January 2018 10:41
by parrotface
Thanks for your reply - very helpful but I am still having problem with the switch section. Every minute appears in log but when I switch On nothing happens. Do I have to check that it is either On or Off?
return {
on = {
device = { 'Switch1'},
timer = {'every 1 minutes'}
},
execute = function(domoticz, device, triggerInfo)
if triggerInfo.type == domoticz.EVENT_TYPE_TIMER then
-- do timer event stuff
domoticz.log(' timer ')
elseif triggerInfo.type == domoticz.EVENT_TYPE_DEVICE then
-- do device event stuff
domoticz.log(' switch ')
end
end
}
Thanks for your help
Re: dzVents timer with switch
Posted: Thursday 18 January 2018 10:46
by emme
that's quite wired....
is Switch1 wrote correctly and reflect the correct UPPER and lower case? (Swith1 is no switch1

)
try also to add this line after the extecute = (and before the if statement)
domoticz.log('Trigger ==> '..triggerInfo.type)
just to understand who's doing what

ciao
M
Re: dzVents timer with switch
Posted: Thursday 18 January 2018 11:49
by parrotface
Thanks for you help will try that next.
in the mean time I have got it doing what I want but I don't think it is the correct way of going about things
execute = function(domoticz, device, triggerInfo)
if triggerInfo.type == domoticz.EVENT_TYPE_TIMER and domoticz.devices('Switch1').state == 'On'then
-- do timer event stuff
domoticz.log(' === Switch On ===== ')
Re: dzVents timer with switch
Posted: Thursday 18 January 2018 11:54
by parrotface
triger info
2018-01-18 10:53:00.162 dzVents: Info: Trigger ==> timer
Re: dzVents timer with switch
Posted: Thursday 18 January 2018 12:04
by emme
and the switch never triggers?!
Re: dzVents timer with switch
Posted: Thursday 18 January 2018 12:05
by emme
uuuuuh... F***!!!
return {
on = {
device
S = { 'Switch1'},
timer = {'every 1 minutes'}
},
sorry... my fault

Re: dzVents timer with switch
Posted: Thursday 18 January 2018 12:24
by parrotface
Hi
Have tried devices before
still No Go
I will try again later as I have to go out for a few hours
Thanks for your help will let you know later
Re: dzVents timer with switch
Posted: Thursday 18 January 2018 21:00
by dannybloe
Read the troubleshooting section in the docs.
Re: dzVents timer with switch
Posted: Tuesday 01 January 2019 13:32
by TheWoodenGamer
Hi,
Perhaps this works? It does for me.
Code: Select all
return {
-- triggers
on = {
-- device triggers
devices = {
-- scripts is executed if the device that was updated matches with one of these triggers
42, -- Philips Hue Wall Switch
},
},
-- custom logging level for this script
logging = {
level = domoticz.LOG_DEBUG,
marker = "Hue wall switch initiated"
},
-- do something with the event
execute = function(domoticz, device, info)
if (device.active) then -- state == 'On'
device.switchOff().afterMin(1) -- if it is a switch, turn off after 1 minute
}