Presence detection script with guest mode error
Posted: Friday 23 December 2016 9:47
I've used the script Event based on https://www.domoticz.com/wiki/Presence_ ... ple_phones to interact with a Foscam IP camera, and activate the alarm motion sensor.
But sometimes, when a familiar comes at home, I want to use a "guest mode" (ModoInvitado), that don't enable the motion sensor.
I've created a user variable called ModoInvitado, we could change it with CGI script + API Json ( $URLDOMOTICZ/json.htm?type=command¶m=updateuservariable&vname=ModoInvitado&vtype=0&vvalue=1 )
I've modified the blocky script, to read if ModoInvitado == 0 (guest mode disabled) before set SomeoneHome (dummy switch device) to OFF, and activate alarm.
The Event SHI: But when the script runs, and GuestMode is enabled (ModoInvitado=1), the IF (Var "ModoInvitado" = 0) does not correctly read the user variable, and always set SomeoneHome to OFF ...
The log (printing messages):
2016-12-22 15:44:00.118 User: Admin initiated a switch command (5/Jordi Smartphone/Off)
2016-12-22 15:44:00.126 EventSystem: Event triggered: SHI_2
2016-12-22 15:44:00.126 ModoInvitado es
2016-12-22 15:44:00.126 1
2016-12-22 15:44:00.127 EventSystem: Fetching url...
2016-12-22 15:44:00.127 SOMEONEHOME A OFF
2016-12-22 15:44:00.118 (DUMMY) Lighting 1 (Jordi Smartphone)
2016-12-22 15:44:00.153 (DUMMY) Lighting 1 (SomeoneHome)
2016-12-22 15:44:00.162 (DUMMY) Lighting 1 (Alarma Foscam)
2016-12-22 15:44:06.486 Executing script: /opt/domoticz/scripts/script_device_foscamMotionAlarm_on.sh
Any reason?
Should I change to a LUA script?
But sometimes, when a familiar comes at home, I want to use a "guest mode" (ModoInvitado), that don't enable the motion sensor.
I've created a user variable called ModoInvitado, we could change it with CGI script + API Json ( $URLDOMOTICZ/json.htm?type=command¶m=updateuservariable&vname=ModoInvitado&vtype=0&vvalue=1 )
I've modified the blocky script, to read if ModoInvitado == 0 (guest mode disabled) before set SomeoneHome (dummy switch device) to OFF, and activate alarm.
The Event SHI: But when the script runs, and GuestMode is enabled (ModoInvitado=1), the IF (Var "ModoInvitado" = 0) does not correctly read the user variable, and always set SomeoneHome to OFF ...
The log (printing messages):
2016-12-22 15:44:00.118 User: Admin initiated a switch command (5/Jordi Smartphone/Off)
2016-12-22 15:44:00.126 EventSystem: Event triggered: SHI_2
2016-12-22 15:44:00.126 ModoInvitado es
2016-12-22 15:44:00.126 1
2016-12-22 15:44:00.127 EventSystem: Fetching url...
2016-12-22 15:44:00.127 SOMEONEHOME A OFF
2016-12-22 15:44:00.118 (DUMMY) Lighting 1 (Jordi Smartphone)
2016-12-22 15:44:00.153 (DUMMY) Lighting 1 (SomeoneHome)
2016-12-22 15:44:00.162 (DUMMY) Lighting 1 (Alarma Foscam)
2016-12-22 15:44:06.486 Executing script: /opt/domoticz/scripts/script_device_foscamMotionAlarm_on.sh
Any reason?
Should I change to a LUA script?