I don't know if it is a coincidence that I updated my Domoticz to the most recent version around the same time.
My script was running (kind of) flawless until then and now it isn't.
That being said, I don't know whether this is a dzVents issue or rathers something to do with the behavior my PIR(s).
It seems that my script is only triggered when a PIR changes its status to "Off" and not on the status change to "On". Which is unfortunate, because I use it to do stuff immediately following the detection of motion.
This is the script that I use to flip a virtual switch named 'BewegingWoonkamerTimeout'. It used to flip the switch immediately when motion was detected, but since a week or so I noticed quite an annoying delay in this process. Tonight I got the time to look further into it and I discovered that it seems that this code does not flip the switch when the PIR status changes to "On", but it does flip the switch when the PIR status changes to "Off".
Code: Select all
--[[ livingroomMotionHelper.lua
This script flips the Dummy switch named 'BewegingWoonkamerTimeout' when one of the PIR WK sensors
(the PIR's in the WoonKamer) detects motion.
When none of the PIR's has been active for 10 minutes, the Dummy switches is flipped to off status.
The status of the Dummy switch is used in the conditionalMotion script that relies on this
for determining whether the lights can be switched off.
original source: https://www.domoticz.com/forum/viewtopic.php?t=30136
]]--
return
{
on =
{
devices = {'PIR WK*'}, -- triggered by PIRs in the livingroom
timer = {'every minute'},
},
logging =
{
level = domoticz.LOG_ERROR, -- Select one of LOG_INFO, LOG_DEBUG, LOG_ERROR, LOG_FORCE to override system log level
marker = "### livingroomMotionHelper ###"
},
execute = function(dz,trigger,triggerInfo)
local active = 0
local motionActive = dz.devices('BewegingWoonkamerTimeout')
-- filter devices on name
dz.devices().filter(function(dv)
return (dv.name):match('PIR WK')
-- filter result on lastUpdate
end).filter(function(dv)
return dv.lastUpdate.minutesAgo <= 10
-- act on result
end).forEach(function(dv)
active = active + 1
--dz.log(dv.name .. '; status ==>> ' .. dv.state .. '; last Updated: ' .. dv.lastUpdate.rawDate ..', ' ..dv.lastUpdate.rawTime ,dz.LOG_FORCE)
end)
if active == 0 then
motionActive.switchOff().checkFirst()
else
motionActive.switchOn().checkFirst()
dz.log('BewegingWoonkamerTimeout aangezet',dz.LOG_FORCE)
end
--dz.log('Aantal actieve devices = ' .. active,dz.LOG_FORCE)
end
}
These are the relevant lines of the logfile:
Code: Select all
2021-05-03 22:23:14.430 Aeon Z-Stick: Light/Switch (PIR WK FIB3)
2021-05-03 22:23:14.594 Status: dzVents: Info: Handling events for: "PIR WK FIB3", value: "On"
[... nothing happens here ...]
2021-05-03 22:23:48.876 Aeon Z-Stick: Light/Switch (PIR WK FIB3)
2021-05-03 22:23:49.126 Dummy: Lighting 1 (BewegingWoonkamerTimeout)
2021-05-03 22:23:49.037 Status: dzVents: Info: Handling events for: "PIR WK FIB3", value: "Off"
2021-05-03 22:23:49.115 Status: dzVents: !Info: ### livingroomMotionHelper ###: BewegingWoonkamerTimeout aan
2021-05-03 22:23:49.118 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
The PIR is a Fibaro motion sensor (not the most recent version).