Hi all,
I'm pretty new to dzVents scripting. I watched the video, searched the wiki and this forum, but I'm getting more and more frustrated, not getting a simple script with a PIR motion sensor to work. I'm not even so far to actually swith a light. I cannot detect in the script if the sensor is on or off..
This is the first start of my script:
Code: Select all
return {
on = {
devices = {
'PIR WC beneden'
},
},
execute = function(domoticz, pir)
print('**** DEBUG: Script execution started. ****')
print('**** DEBUG: Device ' .. pir.name .. ' was changed.' .. ' ****', domoticz.LOG_INFO)
if (pir.state == 'on') then
print('**** DEBUG: PIR switch is on. ****')
else
print('**** DEBUG: Nothing is on. ****')
end
end
}
The log results in this when the sensor detects motion:
Code: Select all
2020-07-11 19:18:04.547 Status: OpenZWave: Alarm received (Home Security: Motion Detected at Unknown Location), NodeID: 8 (0x08)
2020-07-11 19:18:04.652 Status: dzVents: Info: Handling events for: "PIR WC beneden", value: "Off"
2020-07-11 19:18:04.652 Status: dzVents: Info: ------ Start internal script: PIR_motion_detection: Device: "PIR WC beneden (Zwave)", Index: 173
2020-07-11 19:18:04.652 Status: dzVents: **** DEBUG: Script execution started. ****
2020-07-11 19:18:04.652 Status: dzVents: **** DEBUG: Device PIR WC beneden was changed. ****
2020-07-11 19:18:04.652 Status: dzVents: 3
2020-07-11 19:18:04.652 Status: dzVents: **** DEBUG: Nothing is on. ****
2020-07-11 19:18:04.652 Status: dzVents: Info: ------ Finished PIR_motion_detection
2020-07-11 19:18:04.750 Status: dzVents: Info: Handling events for: "PIR WC beneden", value: "On"
2020-07-11 19:18:04.750 Status: dzVents: Info: ------ Start internal script: PIR_motion_detection: Device: "PIR WC beneden (Zwave)", Index: 173
2020-07-11 19:18:04.750 Status: dzVents: **** DEBUG: Script execution started. ****
2020-07-11 19:18:04.750 Status: dzVents: **** DEBUG: Device PIR WC beneden was changed. ****
2020-07-11 19:18:04.750 Status: dzVents: 3
2020-07-11 19:18:04.750 Status: dzVents: **** DEBUG: Nothing is on. ****
2020-07-11 19:18:04.750 Status: dzVents: Info: ------ Finished PIR_motion_detection
I'm using a Neo CoolCam motion sensor. I noticed that the device settings seem not to be editable in Domotics, so I'm using the default settings. When motion is detected, the switch remains on for about 30 seconds. That would be ok for detecting in the script if the motion switch is on or not, I suppose.
Besides the pir.state == 'on' test I tried practically everything except for a working test in the if statement. Maybe I'm forgetting someting?
What am I missing here? Can someone help me out?
Thanks a lot in advance.