Hi:
Which code could I use to replicate the status of two switches or dimmers? I.e if switch 1 is on, then switch two should be off and viceversa.
Same thing for dimmers.
Thanks!!
Hi:
Which code could I use to replicate the status of two switches or dimmers? I.e if switch 1 is on, then switch two should be off and viceversa.
Same thing for dimmers.
Thanks!!
Easy to implement via GUI (setup two scenes and use the events ‘A device is turned on/off’), but IIUC you are asking for Luup code.
Untested (might require some additional typecasting …):
SwitchPower_SID = "urn:upnp-org:serviceId:SwitchPower1"
Switch_IDs = { 36, 42 } -- adjust accordingly
for i=1,#Switch_IDs
do
luup.variable_watch( "synchronize_SW", SwitchPower_SID, "Status", Switch_IDs[ i ] )
end
function synchronize_SW( lul_device, lul_service, lul_variable, lul_value_old, lul_value_new )
for i=1,#Switch_IDs
do
if tonumber( lul_device ) ~= Switch_IDs[ i ]
then
luup.call_action( SwitchPower_SID, "SetTarget", { newTargetValue = tostring( 1 - tonumber( lul_value_new ) ) }, Switch_IDs[ i ] )
end
end
end
Best Home Automation shopping experience. Shop at Ezlo!
© 2024 Ezlo Innovation, All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules