Damealas wrote: ↑Wednesday 08 April 2020 9:09
Hi, I'm trying to make a toggle switch, I have a switch with a light and another switch, I want the two switches to turn on the light, but I can't, I've tried a lot of things and it drives me crazy
First please explain what device 48 and device 98 are. Which one is the switch and which is the light ?
Then add some logging to the script so you can see in the logfile what happens (see below)
if L1 and L2 are Xiaomi selector switches the toggle won't work. Domoticz would not know where to toggle to from 'click'
Code: Select all
return
{
on =
{
devices =
{
98, 48,
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'Toggle',
},
execute = function (domoticz, device)
local L1 = domoticz.devices(98)
local L2 = domoticz.devices(48)
domoticz.log('state of L1 ' .. L1.state, domoticz.LOG_DEBUG )
domoticz.log('state of L2 ' .. L2.state, domoticz.LOG_DEBUG )
if L1.state == 'Click' or L2.state == 'Click' then
L1.toggleSwitch ().silent()
L2.toggleSwitch ().silent()
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>>
dzVents wiki