If one smartphone is at home, the virtual switch SomeoneHome needs to be turned on. But, if all Smartphones are away, the SomeoneHome switch needs to be turned off.
I have an extra virtual switch that can be manually set, for if we have a guest and none of the smartphones is at home (babysitter for example)
The first part works, the second not.
Code: Select all
return {
on = {
devices = {
'Geofence A',
'Geofence B',
'Guest at Home'
}
},
execute = function(domoticz, device)
if ((device.name == 'Geofence A' and device.state == 'On') or
(device.name == 'Geofence B' and device.state == 'On') or
(device.name == 'Guest at Home' and device.state == 'On')) then
domoticz.devices('SomeoneHome').switchOn()
domoticz.log('Device ' .. device.name .. ' was turned On', domoticz.LOG_INFO)
end
if ((device.name == 'Geofence A' and device.state == 'Off') and
(device.name == 'Geofence B' and device.state == 'Off') and
(device.name == 'Guest at Home' and device.state == 'Off')) then
domoticz.devices('SomeoneHome').switchOff()
domoticz.log('Device ' .. device.name .. ' was turned Off', domoticz.LOG_INFO)
end
end