Page 1 of 1

Should this work ?

Posted: Friday 01 November 2024 12:29
by Dave21w
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

Re: Should this work ?

Posted: Friday 01 November 2024 15:13
by waltervl
No, this will not work. There is no command .switch(). Do not trust AI for dzvents as there are not enough good samples to scan. Better check the wiki https://www.domoticz.com/wiki/DzVents:_ ... _scripting

Re: Should this work ?

Posted: Monday 11 November 2024 8:48
by Dave21w
Well, I did read the wiki but still couldn't get anything to work my self so I went back to the AI and told it what happened when it didn't work and it's second attempt works just fine. I'm not trying to be lazy but now I have something that works I can learn from it myself as well. Just in case anyone wants to take a look this is what it wrote.

Re: Should this work ?

Posted: Monday 11 November 2024 9:17
by waltervl
You might want to play with quietOn/Off() or silent() to get rid of the debounce stuff.

quietOn(), quietOff() ==>> status in domoticz will change but command is not send to physically attached device. Subsequent events are triggered.
silent() ==>> status in domoticz will change and command is send to physically attached device. Subsequent events are not triggered