dzVents if and elseif not working.

Easy to use, 100% Lua-based event scripting framework.
Post Reply
straatm
Posts: 16
Joined: Monday 15 January 2018 11:06
Target OS: Windows
Domoticz version:
Contact:

dzVents if and elseif not working.

Post by straatm » Friday 09 February 2018 10:50

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

User avatar
waaren
Posts: 1081
Joined: Tuesday 03 January 2017 15:18
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: dVents if and elseif not working.

Post by waaren » Friday 09 February 2018 11: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..
Raspberry (debian stretch via berryboot on Synology DS916+) , Domoticz (almost) latest Beta, , dzVents 2.6, RFLink, RFXtrx433e, P1, Youless, Harmony, Hue, Yeelight, Xiaomi, HomeWizard, Zwave, Amazon echo

straatm
Posts: 16
Joined: Monday 15 January 2018 11:06
Target OS: Windows
Domoticz version:
Contact:

Re: dVents if and elseif not working.

Post by straatm » Friday 09 February 2018 11:33

waaren wrote:
Friday 09 February 2018 11: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!

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests