One script for 2 identical switches
Posted: Saturday 26 September 2020 13:47
I can't figure this out and I hope someone can help me. I'm sure it is very simple, but I don't see it...
This one works, with one switch
I tried the following for 2 switches:
But it doesn't work.. I don't see why...
This one works, with one switch
Code: Select all
return {
on = {
devices = {
'A'
}
},
execute = function(domoticz, switch)
if (switch.state == 'B1') then
domoticz.devices('Light A').switchOn().checkFirst()
elseif (switch.state == 'B4') then
domoticz.devices('Light A').switchOff().checkFirst()
end
end
}
Code: Select all
return
{
on = { devices = { 'A', 'B' }},
execute = function(dz, triggerObject)
if dz.devices('A').state == 'B1' then
dz.devices('Light A').switchOn().checkFirst()
elseif dz.devices('B').state == 'B1' then
dz.devices('Light B').switchOn().checkFirst()
elseif dz.devices('A').state == 'B4' then
dz.devices('Light A').switchOff().checkFirst()
elseif dz.devices('B').state == 'B4' then
dz.devices('Light B').switchOff().checkFirst()
end
dz.log('Device ' .. triggerObject.name .. ' state: ' .. triggerObject.state, dz.LOG_INFO)
end
}