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
Should this work ?
Moderator: leecollings
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Should this work ?
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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 361
- Joined: Sunday 29 November 2015 21:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: UK
- Contact:
Re: Should this work ?
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.
- Attachments
-
- Switch Sync.jpg (77.35 KiB) Viewed 490 times
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Should this work ?
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
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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Who is online
Users browsing this forum: Bing [Bot] and 1 guest