Code: Select all
return {
on = {
timer = {'Every minute'},
},
execute = function(domoticz)
local fD = domoticz.devices('Front Door')
if (fD.state == 'Alarm') then -- state == 'On'
local x = FrontDoorOpenMins + 1
domoticz.variables('FrontDoorOpenMins').set(x)
domoticz.notify('Front Door open ' .. FrontDoorOpenMins .. ' ### ')
domoticz.log('Front Door open ' .. FrontDoorOpenMins .. ' ### ')
else
domoticz.log('Front Door not open ')
domoticz.variables('FrontDoorOpenMins').set(0)
end
end
Code: Select all
2019-05-13 16:38:00.541 Status: dzVents: Info: ------ Start internal script: FrontDoor:, trigger: every minute
2019-05-13 16:38:00.559 Status: dzVents: Error (2.4.18): An error occured when calling event handler FrontDoor
2019-05-13 16:38:00.559 Status: dzVents: Error (2.4.18): ...Domoticz\scripts\dzVents\generated_scripts/FrontDoor.lua:12: attempt to perform arithmetic on global 'FrontDoorOpenMins' (a nil value)
2019-05-13 16:38:00.559 Status: dzVents: Info: ------ Finished FrontDoor