Code: Select all
local masterSlave = {
['zza FB 11 Stehlampen Salon'] = 'FB 11 Stehlampen Salon',
['zza FB 12 Downlight Kamin'] = 'FB 12 Downlight Kamin',
['zza FB 13 Downlight Terrasse'] = 'FB 13 Downlight Terrasse',
['zza FB 14 Lampe Esstisch'] = 'FB 14 Lampe Esstisch',
['zza FB 21 Heizkreis Salon'] = 'FB 21 Heizkreis Salon',
['zza FB 23 Heizkreis Buero'] = 'FB 23 Heizkreis Buero',
['zza FB 31 Infrarot'] = 'FB 31 Infrarot',
['zza FB 32 Heizkreis Schlafzimmer'] = 'FB 32 Heizkreis Schlafzimmer',
['zza FB 33 Waermepumpe'] = 'FB 33 Waermepumpe',
['zza FB 41 Heizkreis Gaestebad'] = 'FB 41 Heizkreis Gaestebad',
['zza FB 42 Heizkreis Bad'] = 'FB 42 Heizkreis Bad',
['zza FB 43 Downlight Tresen'] = 'FB 43 Downlight Tresen',
['zza FB 44 Stehlampe Buero'] = 'FB 44 Stehlampe Buero'
}
return {
active = true,
on = {
'zza FB *' -- you use prefix method here so no need to list them all individually, use the wildcard.
},
execute = function(domoticz, masterSwitch)
-- get the slave device using the lookup table above
-- but do some checking first to catch misstakes
if (masterSlave[masterSwitch.name] == nil) then
-- oops
domoticz.log(masterSwitch.name .. ' cannot be found in the lookup table. Check the names.', domoticz.LOG_ERROR)
end
-- now get the slave device and check if it exists
local slaveSwitch = domoticz.devices[masterSlave[masterSwitch.name]]
if (slaveSwitch == nil) then
-- oops again
domoticz.log('There is no slave device by the name ' .. masterSlave[masterSwitch.name] .. '. Check the names', domoticz.LOG_ERROR)
else
-- we're good to go.. we have a slave device
if (masterSwitch.state == 'On') then
slaveSwitch.switchOn()
else
slaveSwitch.switchOff()
end
end
end
}The slave is not switching.