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?
Presence detection script with guest mode error
Moderator: leecollings
- StanHD
- Posts: 347
- Joined: Friday 12 July 2013 16:09
- Target OS: Windows
- Domoticz version:
- Location: East Sussex, UK
- Contact:
Re: Presence detection script with guest mode error
The nested "If" structure doesn't work in Domoticz. Also your nested if block wouldn't work because it does not have an "else-if". Only the "if" block without the blue "gear" symbol would work.
Can you re-write with a single "if" and multiple "else-if" conditions? (No nesting)
Can you re-write with a single "if" and multiple "else-if" conditions? (No nesting)

Domoticz Main - Intel nuc, Windows, RFXTRX433E. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
Who is online
Users browsing this forum: No registered users and 1 guest