I have a funny problem.
I have a PIR sensor, that turns on the light.
Some time it works and sometime it dosen't
Code: Select all
local lux_device = 265
return {
active = true,
on = {
devices = {
263
}
},
execute = function(domoticz, mySensor)
domoticz.log('Start af script' , domoticz.PRIORITY_INFO)
domoticz.log('Last update:' , domoticz.PRIORITY_INFO)
domoticz.log(domoticz.devices(263).lastUpdate.minutesAgo , domoticz.PRIORITY_INFO)
domoticz.log('263 State:' , domoticz.PRIORITY_INFO)
domoticz.log(domoticz.devices(263).state , domoticz.PRIORITY_INFO)
domoticz.log('175 State:' , domoticz.PRIORITY_INFO)
domoticz.log(domoticz.devices(175).state , domoticz.PRIORITY_INFO)
if (domoticz.devices(263).lastUpdate.minutesAgo<1 and domoticz.devices(263).state == 'On' and domoticz.devices(175).state == 'Off') then
domoticz.devices(175).switchOn()
domoticz.devices(175).dimTo(30)
domoticz.devices(175).dimTo(50).afterSec(2)
domoticz.devices(175).dimTo(100).afterSec(4)
domoticz.log('light on' , domoticz.PRIORITY_INFO)
end
if (domoticz.devices(175).lastUpdate.minutesAgo>15 and domoticz.devices(263).state == 'Off' and domoticz.devices(175).state == 'On') then
domoticz.devices(175).switchOff()
domoticz.log('light off' , domoticz.PRIORITY_INFO)
end
domoticz.log('Slut af script' , domoticz.PRIORITY_INFO)
end
}
The 263 is the pir sensor and trigger of the script.
When its not working the lastupdate.minutesAgo is not updating even that the 263 device is the trigger and goes from Off to On.
Code: Select all
2017-10-23 20:41:47.674 dzVents: Info: Handling events for: "BadStort | Sensor", value: "On"
2017-10-23 20:41:47.674 dzVents: Info: ------ Start external script: badstort_pir_light.lua: Device: "BadStort | Sensor (PiTeknikskab)", Index: 263
2017-10-23 20:41:47.674 dzVents: Info: Start af script
2017-10-23 20:41:47.674 dzVents: Info: Last update:
2017-10-23 20:41:47.674 dzVents: Info: 3
2017-10-23 20:41:47.674 dzVents: Info: 263 State:
2017-10-23 20:41:47.674 dzVents: Info: On
2017-10-23 20:41:47.674 dzVents: Info: 175 State:
2017-10-23 20:41:47.674 dzVents: Info: Off
2017-10-23 20:41:47.674 dzVents: Info: Slut af script
2017-10-23 20:41:47.674 dzVents: Info: ------ Finished badstort_pir_light.lua
2017-10-23 20:41:47.674 dzVents: Info: Last update:
2017-10-23 20:41:47.674 dzVents: Info: 3
And of cause when its working the minutes ago are updating correctly.
Code: Select all
2017-10-23 20:34:26.125 dzVents: Info: Handling events for: "BadStort | Sensor", value: "On"
2017-10-23 20:34:26.125 dzVents: Info: ------ Start external script: badstort_pir_light.lua: Device: "BadStort | Sensor (PiTeknikskab)", Index: 263
2017-10-23 20:34:26.125 dzVents: Info: Start af script
2017-10-23 20:34:26.125 dzVents: Info: Last update:
2017-10-23 20:34:26.125 dzVents: Info: 0
2017-10-23 20:34:26.125 dzVents: Info: 263 State:
2017-10-23 20:34:26.125 dzVents: Info: On
2017-10-23 20:34:26.125 dzVents: Info: 175 State:
2017-10-23 20:34:26.125 dzVents: Info: Off
2017-10-23 20:34:26.125 dzVents: Info: light on
2017-10-23 20:34:26.125 dzVents: Info: Slut af script
2017-10-23 20:34:26.125 dzVents: Info: ------ Finished badstort_pir_light.lua
The device is correctly changing the status Any ideas?