I'm not able to make this script work on my PI. I have changed all the settings and tested the URL's to my WoonveiligKeptenkurk wrote:This example switches my Woonveilig alarmpanel (which is actually a rebranded CTC-1716 by Climax Tech) according to the state of a Domoticz switch.
The LUA script is triggered by the device MASTERSWITCH. When switched on, the Woonveilig panel will be armed. When switched off, the panel will be disarmed.
An additional light (Lampje bij Thermostaat) confirms the alarmpanel state visually.
Application: automatic arm/disarm based on being at home (mobile phone's WiFi or Bluetooth - see other examples in this forum) or scheduled.
file: ~/domoticz/scripts/lua/script_device_alarmpanel.luaCode: Select all
commandArray = {} if (devicechanged['MASTERSWITCH'] == 'On') then os.execute('/home/pi/domoticz/scripts/alarmpanel.sh arm') print('Alarmpanel armed') commandArray['Lampje bij thermostaat']='On' end if (devicechanged['MASTERSWITCH'] == 'Off') then os.execute('/home/pi/domoticz/scripts/alarmpanel.sh disarm') print('Alarmpanel disarmed') commandArray['Lampje bij thermostaat']='Off' end return commandArray
Switching of the Alarmpanel is performed by the shell script "alarmpanel.sh" which can take the argument 'arm', 'armhome', 'disarm', 'sirenon' or 'sirenoff'.
First a login is made to a general page. Then the requested POST is made to the web page where the alarmpanel arming state can be set.
When the login expires, every first POST command will fail with an autentication request page, therefore we first login before every POST command.
tip: To find out the URL and POST values of the page use Firefox with the Firebug plugin enabled to browse to the page. The debug output will show
exactly which GET and POST messages and parameters were called. This will enable you to control or read from virtually any device which offers a web interface.
EDIT: Additionally an extra argument is available: checkstate
This reads the current state of the panel (Arm, Home or Disarm) and sets/resets a dummy switch in Domoticz.
I run this feature every minute by cron. This now reflects my "at home" state and consequently switch my close-in boiler off when not at home.
(need to build a businesscase for this hobby)
file: ~/domoticz/scripts/alarmpanel.shCode: Select all
#!/bin/bash ######################################################################################## ### Woonveilig script v1.2 beta added checkstate option to request current armed state ### ### Domoticz <--> Woonveilig interface script ### ### Usage: ### alarmpanel arm ### puts the Woonveilig alarmpane is the Armed state ### ### alarmpanel armhome ### puts the Woonveilig alarmpanel in the Armed & at Home state ### ### alarmpanel disarm ### puts the Woonveilig alarmpanel in the Disarmed state ### ### alarmpanel sirenon ### sounds the siren (and maybe the remote siren too) of the Woonveilig alarmpanel ### ### alarmpanel sirenoff ### silences the siren (and maybe the remote siren too) of the Woonveilig alarmpanel ### ### alarmpanel checkstate ### reads the current armed state of the Woonveilig alarmpanel and changes a Domoticz switch ### to On when disarmed or armed & home and to Off when armed. ### ######################################################################################## if [ $# -lt 1 ] then echo "Usage: alarmpanel {arm | armhome | disarm | sirenon | sirenoff | checkstate}" exit fi ### USER CONFIGURABLE PARAMETERS PANEL="192.168.1.133:80" # Alarm panel IP:PORT (find this in your router DHCP scope) PANEL_USR="admin" # Alarm panel username (default admin) PANEL_PASS="admin1234" # Alarm panel password (default admin1234) DZSERVER="192.168.1.95:8080" # Domoticz server IP:PORT AT_HOME="28" # Idx of dummy switch which reflects at home state # (find this in Domoticz|Devices|Idx column) ### END OF USER CONFIGURABLE PARAMETERS ### First login to alarmpanel /usr/bin/curl -u $PANEL_USR:$PANEL_PASS -s http://$PANEL/setting/index.htm >/dev/null ### Then issue appropriate command case "$1" in arm) echo "Arm Alarmpanel" /usr/bin/curl -d "mode=0" -u $PANEL_USR:$PANEL_PASS -s http://$PANEL/action/panelCondPost >/dev/null ;; armhome) echo "Armhome Alarmpanel" /usr/bin/curl -d "mode=1" -u $PANEL_USR:$PANEL_PASS -s http://$PANEL/action/panelCondPost >/dev/null ;; disarm) echo "Disarm Alarmpanel" /usr/bin/curl -d "mode=2" -u $PANEL_USR:$PANEL_PASS -s http://$PANEL/action/panelCondPost >/dev/null ;; sirenon) echo "Siren On" /usr/bin/curl -d "sndsiren_onoff=0" -u $PANEL_USR:$PANEL_PASS -s http://$PANEL/action/sndSirenPost >/dev/null ;; sirenoff) echo "Siren Off" /usr/bin/curl -d "sndsiren_onoff=1" -u $PANEL_USR:$PANEL_PASS -s http://$PANEL/action/sndSirenPost >/dev/null ;; ### Read current state webpage ### And watch for Arm, Home or Disarm in the answer ### Set (dummy) switch to On or Off as required checkstate) strPanelState=`/usr/bin/curl -u $PANEL_USR:$PANEL_PASS -s http://$PANEL/action/panelCondGet` if [[ $strPanelState == *\"Arm\"* ]] then echo "State is Armed" /usr/bin/curl "http://$DZSERVER/json.htm?type=command¶m=switchlight&idx=$AT_HOME&switchcmd=Off&level=0" else if [[ $strPanelState == *\"Disarm\"* ]] then echo "State is Disarmed" /usr/bin/curl "http://$DZSERVER/json.htm?type=command¶m=switchlight&idx=$AT_HOME&switchcmd=On&level=0" else if [[ $strPanelState == *\"Home\"* ]] then echo "State is Armed Home" /usr/bin/curl "http://$DZSERVER/json.htm?type=command¶m=switchlight&idx=$AT_HOME&switchcmd=On&level=0" else echo "No matched state found" fi fi fi ;; *) echo "Invalid argument. Usage: alarmpanel {arm | armhome | disarm | sirenon | sirenoff | checkstate}" ;; esac ### Done
system. Is there any possibility to check where it's going wrong?
EDIT: This is the first time i'm using script on Domoticz so maybe I forgot to do some 'first time' practical changes. I really hope anyone can help me.