Here's a script that I use to do this. Just replace the device names with your device names and the 2 switches should follow each other's lead. It doesn't really matter which switch is called master and which is called slave, I just needed the variable names to be clearly distinguishable:
Code: Select all
local MASTER = 'Keuken: Aanrecht'
local SLAVE = 'Keuken: S3'
return {
on = {
devices = {
MASTER,
SLAVE
}
},
execute = function(domoticz, device, triggerInfo)
if (domoticz.EVENT_TYPE_TIMER == triggerInfo.type) then
domoticz.log( 'timer event: '..tostring(triggerInfo.trigger)..'.', domoticz.LOG_INFO)
elseif (domoticz.EVENT_TYPE_DEVICE == triggerInfo.type) then
if (device.name == MASTER) then
if (device.state ~= domoticz.devices(SLAVE).state) then
domoticz.devices(SLAVE).setState(device.state).silent()
end
elseif (device.name == SLAVE) then
if (device.state ~= domoticz.devices(MASTER).state) then
domoticz.devices(MASTER).setState(device.state).silent()
end
end
end
end
}