Should this work ?
Posted: Friday 01 November 2024 12:29
I'm cheating here and have used MS Copilot to write this in the hope I can learn from the code it shows me. I want to sync two physical zigbee light switches, only one has actual wiring to the lamp the other just gets power. Both switches have an LED in them so they can be found in the dark so they need to be in sync. Presently I have created 2 dummy toggle switches in Domoticz for testing purposes, I see no errors in the log but they do not interact with each other in anyway.
return {
active = true,
on = {
devices = { 'Switch1', 'Switch2' }
},
execute = function(domoticz, device)
local switch1 = domoticz.devices('Switch1')
local switch2 = domoticz.devices('Switch2')
if (device.id == switch1.id) then
switch2.switch(device.state)
else
switch1.switch(device.state)
end
end
}
Thanks
return {
active = true,
on = {
devices = { 'Switch1', 'Switch2' }
},
execute = function(domoticz, device)
local switch1 = domoticz.devices('Switch1')
local switch2 = domoticz.devices('Switch2')
if (device.id == switch1.id) then
switch2.switch(device.state)
else
switch1.switch(device.state)
end
end
}
Thanks