Page 1 of 1

dzVents if and elseif not working.

Posted: Friday 09 February 2018 9:50
by straatm
Who can help me I am just a beginner in programming in dzVents
I try to switch on two groups if they are not switched in yet with an extra switch.
Added some log rules to show if the script passes these phrases but there is nothing in the logging and the lamps are not switched on.

See code and logging below.

Thanks in advance for any help.
Marc

return {
on = {
devices = { 'Laat-Thuis' }
},
execute = function(domoticz, switch)
if (switch.state == 'On' and (domoticz.groups('Binnen-Lampen') == 'Off' or domoticz.groups('Buiten-Lampen') == 'Off' )) then
domoticz.log('Welkom Thuis')
domoticz.groups('Binnen-Lampen').switchOn().forSec('60')
domoticz.groups('Buiten-Lampen').switchOn().forSec('60')
domoticz.devices('Laat-Thuis').switchOff().afterSec('10')
elseif (switch.state == 'On' and (domoticz.groups('Binnen-Lampen') == 'On' or domoticz.groups('Buiten-Lampen') == 'On' )) then
domoticz.log('Lampen zijn aan')
domoticz.devices('Laat-Thuis').switchOff().afterSec('10')
end
end
}

2018-02-09 09:44:57.082 (RFXCOM) Lighting 2 (Laat-Thuis)
2018-02-09 09:44:57.208 dzVents: Info: Handling events for: "Laat-Thuis", value: "Off"
2018-02-09 09:44:57.208 dzVents: Info: ------ Start internal script: LaatThuis: Device: "Laat-Thuis (RFXCOM)", Index: 28
2018-02-09 09:44:57.208 dzVents: Info: ------ Finished LaatThuis
2018-02-09 09:45:01.583 User: Admin initiated a switch command (28/Laat-Thuis/On)
2018-02-09 09:45:01.973 (RFXCOM) Lighting 2 (Laat-Thuis)
2018-02-09 09:45:02.161 dzVents: Info: Handling events for: "Laat-Thuis", value: "On"
2018-02-09 09:45:02.161 dzVents: Info: ------ Start internal script: LaatThuis: Device: "Laat-Thuis (RFXCOM)", Index: 28
2018-02-09 09:45:02.161 dzVents: Info: ------ Finished LaatThuis

Re: dVents if and elseif not working.

Posted: Friday 09 February 2018 10:12
by waaren
Try to change (domoticz.groups('Binnen-Lampen') == 'On' to (domoticz.groups('Binnen-Lampen').state == 'On'

and

domoticz.groups('Buiten-Lampen') == 'On' to domoticz.groups('Buiten-Lampen').state == 'On'

and see what happens..

Re: dVents if and elseif not working.

Posted: Friday 09 February 2018 10:33
by straatm
waaren wrote: Friday 09 February 2018 10:12 Try to change (domoticz.groups('Binnen-Lampen') == 'On' to (domoticz.groups('Binnen-Lampen').state == 'On'

and

domoticz.groups('Buiten-Lampen') == 'On' to domoticz.groups('Buiten-Lampen').state == 'On'

and see what happens..

Thanks that solved the problem!