I'm asking for help, as this is my first DzVents script. Any tips are welcome, because I'm not a great coder either.
The idea is simple: sync a pair of outdoor lights when Home/Away is set at home. I'm not getting errors, but it's not working. The script is set ON.
Sorry about the names being in finnish gibberish ("Pihavalot" is main yard lights, "PuuCee Polkuvalo" is the one that's separate, KotonaPoissa = HomeAway). The spelling matches Domoticz names. Domoticz is v4.10717
Code: Select all
return {
on = {
devices = {
'Pihavalot'
}
},
execute = function(domoticz, piha)
local polkuvalo = domoticz.devices('PuuCee Polkuvalo')
if (
(device.name == 'KotonaPoissa' and device.state == 'On') and
(device.name == 'Pihavalot' and device.state == 'On')) then
polkuvalo.switchOn().checkFirst()
end
if (
(device.name == 'KotonaPoissa' and device.state == 'On') and
(device.name == 'Pihavalot' and device.state == 'Off')) then
polkuvalo.switchOff().checkFirst()
end
end
}