I tried to make a script when sensor 'Buitensensor' has updated x minutes ago, and the group 'Tuinverlichting' is on, then turn off 'Tuinverlichting'.
I tried to debug my script with the print() so i know what outcome i get. And it seems that if i combine the to conditions with and it will return false. But if i use them separately they work.
I tried
Code: Select all
if (domoticz.devices('Buitensensor').lastUpdate.minutesAgo >= 1 and domoticz.groups('Tuinverlichting') == 'On') thenCode: Select all
if ((domoticz.devices('Buitensensor').lastUpdate.minutesAgo >= 1) and (domoticz.groups('Tuinverlichting') == 'On')) thenCode: Select all
return {
on = {
timer = {
'every 1 minutes'
}
},
execute = function(domoticz, timer)
if ((domoticz.devices('Buitensensor').lastUpdate.minutesAgo >= 1) and (domoticz.groups('Tuinverlichting') == 'On')) then
domoticz.groups('Tuinverlichting').switchOff()
print('Tuinverlichting is ' .. (domoticz.groups('Tuinverlichting').lastUpdate.minutesAgo) .. ' minuten geleden ge-update')
print('Tuinverlichting staat op ' .. (domoticz.groups('Tuinverlichting').state))
else
print('Tuinverlichting is ' .. (domoticz.groups('Tuinverlichting').lastUpdate.minutesAgo) .. ' minuten geleden ge-update')
print('Buitensensor is ' .. (domoticz.devices('Buitensensor').lastUpdate.minutesAgo) .. ' minuten geleden ge-update')
end
end
}Code: Select all
2021-02-01 16:42:00.641 Status: dzVents: Info: ------ Start internal script: Buiten verlichting uit bij geen beweging:, trigger: "every 1 minutes"
2021-02-01 16:42:00.660 Status: dzVents: Tuinverlichting is 68 minuten geleden ge-update
2021-02-01 16:42:00.660 Status: dzVents: Buitensensor is 4 minuten geleden ge-update
2021-02-01 16:42:00.661 Status: dzVents: Info: ------ Finished Buiten verlichting uit bij geen beweging