Page 2 of 2
Re: Somfy Alarm Script
Posted: Friday 07 February 2020 8:57
by MikeyMan
Well to be honest...
Nothing is really happening. The script ran something one time, for whathever reason.
Havent been able to get any response whatsoever after that.
The switches is a bug i guess in domoticz, where an empty switch keeps switching.
But i think i'll have to give up and stop bothering you. Wasting your time
Thanks for the support anyhow!
Re: Somfy Alarm Script not running
Posted: Friday 07 February 2020 12:10
by clumpton
Before we give up I have been taking a look at the code.
The "CarteAuthentification" variable is a lookup table for passcodes - is this something that is supplied with the alarm?
Just before your script fails it tries to contact the somfy server and gets an "Access Code" back (which looks like it can be A1 to A5 through to F1 to F5). The script then looks in the CarteAuthentification array and returns a 4 letter (or digit?) code which is then used to log in to the server.
The script is not getting back the access code prompt from the server so it is trying to read a member of the array indexed by blank - obviously this fails. (I told you that error checking was minimal).
The script is looking for a prompt of "authentification" on the login page - is this word there or is it some other text?
Re: Somfy Alarm Script not running
Posted: Friday 07 February 2020 14:54
by MikeyMan
@clumpton; the lookup table is provided and has been adapted by me. It consists of numbers.
It can ineed be from A1 to F5.
10.0.0.112/gb/login.htm looks like this:

- login page.png (374.63 KiB) Viewed 1945 times
Dont know if it helps, but this is the html:
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="content-style-type" content="text/css" />
<title>Central unit</title>
<link rel="shortcut icon" href="/domis.ico" type="image/x-icon"/>
<meta name="language" content="en" />
<meta http-equiv="expires" content="0">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache, must-revalidate">
<link href="/domis_welcome.css" rel="stylesheet" type="text/css" /><style type="text/css">img{border:none;};#menu a{border-bottom:none;}</style></head><body><div id="page"><div id="fond"><div id="menu"><div class="logohmb"> </div><div id="filler"></div></div><div id="titlebar"><div class="widetitlevoid">Welcome</div><div class="titlecorner"></div></div><div id="content"><div class="loginhouse">My Somfy alarm system</div><form id="form_id" method="post" action="login.htm"><table><col width="165px"><tr><td>Account</td><td><select name="login" class="skinnedselectinput"> <option value="u">User1 </option><option value="i">Installer </option><option value="t">Remote mon. </option></select></td></tr><tr><td>Access code</td><td><input type="password" name="password" value="" class="skinnedtextinput" maxlength="12" size="16"/></td></tr><tr><td>Authentication code <b>B1</b></td><td><input type="password" name="key" value="" class="skinnedtextinput" maxlength="6" size="16"/></td></tr></table><div id="content_footer"><input type="submit" name="btn_login" value="Login" class="arrowdark"/></div></form></div> <!--content -->
<div id="spacer">
<!-- -->
<!--[if IE]>
<![endif]-->
</div>
<div id="menu_footerflag">
Select language:<br><br>
<a href="/gb/login.htm"><img src="/img/gb.gif" alt="gb"/></a>
<a href="/fr/login.htm"><img src="/img/fr.gif" alt="fr"/></a>
<a href="/nl/login.htm"><img src="/img/nl.gif" alt="nl"/></a><br>
<a href="/it/login.htm"><img src="/img/it.gif" alt="it"/></a>
<a href="/de/login.htm"><img src="/img/de.gif" alt="de"/></a>
<a href="/sp/login.htm"><img src="/img/sp.gif" alt="sp"/></a><br>
Copyright ©2013 Somfy
</div>
</div>
<!-- fond -->
</div>
<!-- page -->
</body>
</html>
Re: Somfy Alarm Script not running
Posted: Friday 07 February 2020 17:46
by clumpton
OK, so it's not picking up the "B1", mainly because it's looking for "Code d'authentification" rather than "Authentication code".
So you can replace this bit of code:
Code: Select all
# Ophalen toegangscode
if [ "$Debug" = "True" ]; then
echo " Toegangscode ophalen"
CodeAcces="$(curl $SrvSomfyIp $UrlLogin | grep -Eoi 'authentification <b>.*</b>')"
CodeAcces="$(echo "${CodeAcces:20:2}")"
echo " Code d'accès = "$CodeAcces
else
CodeAcces="$(curl -s $SrvSomfyIp $UrlLogin | grep -Eoi 'authentification <b>.*</b>')"
CodeAcces="$(echo "${CodeAcces:20:2}")"
fi
by:
Code: Select all
# Get access code
if [ "$Debug" = "True" ]; then
echo " Retrieving access code""
CodeAcces="$(curl $SrvSomfyIp $UrlLogin | grep -Eoi 'code <b>.*</b>')"
CodeAcces="$(echo "${CodeAcces:9:2}")"
echo " Access code = "$CodeAcces
else
CodeAcces="$(curl -s $SrvSomfyIp $UrlLogin | grep -Eoi 'code <b>.*</b>')"
CodeAcces="$(echo "${CodeAcces:9:2}")"
fi
It should echo the access code reference (A1, B5 etc.).
Re: Somfy Alarm Script not running
Posted: Friday 07 February 2020 17:50
by MikeyMan
Haha, really? The code is actually searching the screen for a term?
So a translation issue... I'll crack on it tomorrow.
Again, much appreciated!
Re: Somfy Alarm Script not running
Posted: Saturday 08 February 2020 10:00
by MikeyMan
Well, at least there is some response now:
Code: Select all
pi@raspberrypi:~/domoticz/scripts $ sudo ./somfy.sh
Starting script in file: ./somfy.sh
./somfy.sh: line 856: syntax error: unexpected end of file
No code echo by the way
code looks like this now:
Code: Select all
#!/bin/bash
echo "Starting script in file: "$0
#----------------------------------------------------------------------------------------------------------------------
# Script alarme_Somfy.sh
# Date : 11/2016
# Version : 2.0
# Par : jcjames_13009 <jcjames_13009 at yahoo.fr>
# Description : Script de pilotage de l'alarme Somfy Protexiom 5000 via Domoticz sur Raspberry Pi
# - Adapatation du script de Seb13 du forum easydomoticz.com pour Alarme Somfy Protexion 600 au modèle Protexion 5000
# * Lecture des états du système et mise àjour dans Domoticz
# * Mise en marche de l'alarme Zone A
# * Mise en marche de l'alarme Zone B
# * Mise en marche de l'alarme Zone C
# * Mise en marche de l'alarme Zones A B C
# * Arret de l'alarme Zones A B C
# * Reset defauts piles, liaisons et alarmes
# * Gestion liste des Elements et mise àjour dans Domoticz
#----------------------------------------------------------------------------------------------------------------------
# Appel du script
# - Mise àjour des états de l'alarme toutes les 15min via le crontab :
# */15 * * * * sudo /home/pi/domoticz/scripts/somfy.sh --Status
# - Pilotage de l'alarme àpartir de DOMOTICZ :
# Ex pour la mise en marche Zone A ajouter dans l'onglet "Action On" du capteur virtuel:
# script:///home/pi/domoticz/scripts/somfy.sh --ZoneAOn
#----------------------------------------------------------------------------------------------------------------------
# Version : 2.1
# Date : 25/11/2016
# - Ajout d'un "sleep 1" pour éviter les pertes de retour d'état de l'alarme entre chaque cde dans la lecture de l'état
# du système et de la liste des Elements
#----------------------------------------------------------------------------------------------------------------------
# Version : 2.2
# Date : 27/11/2016
# - Ajout cde reset defauts piles, liaisons et alarmes
#----------------------------------------------------------------------------------------------------------------------
# Version : 2.3
# Date : 10/12/2016
# - Gestion liste des Elements et mise àjour dans Domoticz
#----------------------------------------------------------------------------------------------------------------------
# Version : 2.4
# Date : 04/01/2017
# - Envoie d'une seule commande pour éviter les pertes de retour d'état de l'alarme entre chaque cde dans la lecture de
# l'état du système et de la liste des Elements
#----------------------------------------------------------------------------------------------------------------------
# Version 2.5
# Date : 21/12/2017
# - Adaptation du script àDomoticz sur NAS Synology
# Remplacement de iconv qui n'existe pas sur Synology par uconv
#----------------------------------------------------------------------------------------------------------------------
Debug=True
#Debug=False
#----------------------------------------------------------------------------------------------------------------------
# PARAMETRES ALARME
#----------------------------------------------------------------------------------------------------------------------
# Carte d'authentification perso
declare -A CarteAuthentification
CarteAuthentification=( ["A1"]="7092" ["B1"]="2220" ["C1"]="4790" ["D1"]="5830" ["E1"]="0920" ["F1"]="0912"
["A2"]="7402" ["B2"]="5242" ["C2"]="2044" ["D2"]="5284" ["E2"]="4478" ["F2"]="8110"
["A3"]="2992" ["B3"]="9928" ["C3"]="9394" ["D3"]="9250" ["E3"]="7988" ["F3"]="4348"
["A4"]="3830" ["B4"]="5174" ["C4"]="9560" ["D4"]="8672" ["E4"]="0090" ["F4"]="0698"
["A5"]="3004" ["B5"]="1332" ["C5"]="5390" ["D5"]="7870" ["E5"]="0848" ["F5"]="3528" )
# Adresse IP alarme Somfy
SrvSomfyIp="http://10.0.0.112/"
# Code Utilisateur1
CodeUtilisateur1=9859
# URLs alarme SOMFY PROTEXION 5000 GSM
UrlLogin=$SrvSomfyIp"gb/login.htm" # Connect
UrlLogout=$SrvSomfyIp"logout.htm" # Log out
UrlEtat=$SrvSomfyIp"status.xml" # Status
UrlPilotage=$SrvSomfyIp"gb/u_pilotage.htm" # Control of alarm and automatic devices
UrlElements=$SrvSomfyIp"gb/u_listelmt.htm" # List of system devices
#----------------------------------------------------------------------------------------------------------------------
# PARAMETRES DOMOTICZ
#----------------------------------------------------------------------------------------------------------------------
# ID's Domoticz
AlarmeSomfyPilesIdx=18 #Batteries
AlarmeSomfyRadioIdx=19 #Radio link
AlarmeSomfyPorteIdx=20 #Door
AlarmeSomfyAlarmeIdx=21 #Alarm
AlarmeSomfyBoitierIdx=22 #Status
AlarmeSomfyGSMIdx=26 #GSM
AlarmeSomfySignalGSMIdx=24 #Signal
AlarmeSomfyOperateurGSMIdx=25 #Provider
#AlarmeSomfyCameraIdx=xxx #Camera
AlarmeSomfyZoneAIdx=15 #Zone A
AlarmeSomfyZoneBIdx=16 #Zone B
AlarmeSomfyZoneCIdx=17 #Zone C
#AlarmeSomfyDOEntreeIdx=xxx
#AlarmeSomfyDOAtelierIdx=xxx
# Domoticz IP Address
SrvDomoticzIp="10.0.0.30:8080"
#----------------------------------------------------------------------------------------------------------------------
# Functions
#----------------------------------------------------------------------------------------------------------------------
# Function Help Menu
Aide() {
echo -e "\tScript Domoticz Alarme Somfy Protexion 5000"
echo -e "\t--help or -h \t\tMenu d'aide"
echo -e "\t--Status \t\tLecture de l'état du système"
echo -e "\t--Elements \t\tListe des Elements"
echo -e "\t--ZoneAOn \t\tMise en marche de l'alarme Zone A"
echo -e "\t--ZoneBOn \t\tMise en marche de l'alarme Zone B"
echo -e "\t--ZoneCOn \t\tMise en marche de l'alarme Zone C"
echo -e "\t--ZonesABCOn \t\tMise en marche de l'alarme Zones A B C"
echo -e "\t--AlarmeOff \t\tArret de l'alarme Zones A B C"
echo -e "\t--RSTPiles \t\tReset defauts piles"
echo -e "\t--RSTAlarmes \t\tReset defauts alarmes"
echo -e "\t--RSTLiaisons \t\tReset defauts liaisons"
}
# Function Alarm Connection
login_alarme () {
# Affichage des URLs
if [ "$Debug" = "True" ]; then
echo " ********************************* "
echo " Liste des URLs"
echo " ********************************* "
echo " UrlLogin = "$UrlLogin
echo " UrlLogout = "$UrlLogout
echo " UrlEtat = "$UrlEtat
echo " UrlPilotage = "$UrlPilotage
echo " UrlElements = "$UrlElements
fi
# Get access code
if [ "$Debug" = "True" ]; then
echo " Retrieving access code""
CodeAcces="$(curl $SrvSomfyIp $UrlLogin | grep -Eoi 'code <b>.*</b>')"
CodeAcces="$(echo "${CodeAcces:9:2}")"
echo " Access code = "$CodeAcces
else
CodeAcces="$(curl -s $SrvSomfyIp $UrlLogin | grep -Eoi 'code <b>.*</b>')"
CodeAcces="$(echo "${CodeAcces:9:2}")"
fi
# Get access code from table
CodeAuthentification="${CarteAuthentification["$CodeAcces"]}"
if [ "$Debug" = "True" ]; then
echo " Ophalen Authentificatiecode"
echo " Authenticatiecode = "$CodeAuthentification
fi
# De user1-code en de authenticatiecode verzenden in de aanmeldings-URL voor Inloggen
if [ "$Debug" = "True" ]; then
echo " Gebruiker1-code en verificatiecode verzenden"
curl -L --cookie cjar --cookie-jar cjar --data "password="$CodeUtilisateur1"&key="$CodeAuthentification"&btn_login=Connexion" $UrlLogin | iconv -f iso8859-1 -t utf-8
#curl -L --cookie cjar --cookie-jar cjar --data "password="$CodeUtilisateur1"&key="$CodeAuthentification"&btn_login=Connexion" $UrlLogin | uconv -f iso8859-1 -t utf-8
else
curl -s -L --cookie cjar --cookie-jar cjar --data "password="$CodeUtilisateur1"&key="$CodeAuthentification"&btn_login=Connexion" $UrlLogin | iconv -f iso8859-1 -t utf-8 > /dev/null
#curl -s -L --cookie cjar --cookie-jar cjar --data "password="$CodeUtilisateur1"&key="$CodeAuthentification"&btn_login=Connexion" $UrlLogin | uconv -f iso8859-1 -t utf-8 > /dev/null
fi
}
# Functie verbinden met Alarm
logout_alarme () {
if [ "$Debug" = "True" ]; then
echo " Verbinden met alarm"
curl -L --cookie cjar --cookie-jar cjar $UrlLogout | iconv -f iso8859-1 -t utf-8
#curl -L --cookie cjar --cookie-jar cjar $UrlLogout | uconv -f iso8859-1 -t utf-8
else
curl -s -L --cookie cjar --cookie-jar cjar $UrlLogout | iconv -f iso8859-1 -t utf-8 > /dev/null
#curl -s -L --cookie cjar --cookie-jar cjar $UrlLogout | uconv -f iso8859-1 -t utf-8 > /dev/null
fi
}
# Functie update Domoticz sensoren
# Parameters: $1 Sensornaam / $2 On / Off / $3 Idx sensor
maj_capteur () {
if [ "$Debug" = "True" ]; then
echo " Staat "$1
if [ "$2" = "On" ]; then
curl "http://$SrvDomoticzIp/json.htm?type=command¶m=switchlight&idx=$3&switchcmd=On"
else
curl "http://$SrvDomoticzIp/json.htm?type=command¶m=switchlight&idx=$3&switchcmd=Off"
fi
else
if [ "$2" = "On" ]; then
curl -s "http://$SrvDomoticzIp/json.htm?type=command¶m=switchlight&idx=$3&switchcmd=On" > /dev/null
else
curl -s "http://$SrvDomoticzIp/json.htm?type=command¶m=switchlight&idx=$3&switchcmd=Off" > /dev/null
fi
fi
}
#----------------------------------------------------------------------------------------------------------------------
# Menu des options de lancement du script
#----------------------------------------------------------------------------------------------------------------------
while [[ $1 == -* ]]; do
case "$1" in
--help|-h) Aide; exit 0;;
--Status) Status="1"; break;;
--Elements) Elements="1"; break;;
--ZoneAOn) ZoneAOn="1"; break;;
--ZoneBOn) ZoneBOn="1"; break;;
--ZoneCOn) ZoneCOn="1"; break;;
--ZonesABCOn) ZonesABCOn="1"; break;;
--AlarmeOff) AlarmeOff="1"; break;;
--RSTPiles) RSTPiles="1"; break;;
--RSTAlarmes) RSTAlarmes="1"; break;;
--RSTLiaisons) RSTLiaisons="1"; break;;
--*|-*) shift; break;;
esac
done
#----------------------------------------------------------------------------------------------------------------------
# Lecture de l'état du système
#----------------------------------------------------------------------------------------------------------------------
if [ "$Status" = "1" ]; then
# Connexion àl'alarme
login_alarme
# Lecture de l'état du système et récupération dans les variables
# Envoie URL http://IPAlarme/status.xml
# Retour:
# <zone0>off</zone0> -> Zone A
# <zone1>off</zone1> -> Zone B
# <zone2>off</zone2> -> Zone C
#
# <defaut0>ok</defaut0> -> Piles
# <defaut1>ok</defaut1> -> Radio
# <defaut2>ok</defaut2> -> Porte/Fenêtre
# <defaut3>ok</defaut3> -> Alarme
# <defaut4>ok</defaut4> -> Boitier
#
# <gsm>GSM connecté au réseau</gsm> -> GSM
# <recgsm>4</recgsm> -> Signal GSM
# <opegsm>"Orange</opegsm> -> Opérateur GSM
# <camera>disabled</camera> -> Caméra
# Lecture de l'état du système et stockage dans fichier temporaire
if [ "$Debug" = "True" ]; then
echo " Lecture de l'état du système"
curl -L --cookie cjar --cookie-jar cjar $UrlEtat | iconv -f iso8859-1 -t utf-8 > status
#curl -L --cookie cjar --cookie-jar cjar $UrlEtat | uconv -f iso8859-1 -t utf-8 > status
else
curl -s -L --cookie cjar --cookie-jar cjar $UrlEtat | iconv -f iso8859-1 -t utf-8 > status
#curl -s -L --cookie cjar --cookie-jar cjar $UrlEtat | uconv -f iso8859-1 -t utf-8 > status
fi
# Deconnexion de l'alarme
logout_alarme
# Récupération dans les variables
EtatZoneA="$(grep -Eoi '<zone0>.*' status)"
EtatZoneA="$(echo "${EtatZoneA:7:-9}")"
EtatZoneB="$(grep -Eoi '<zone1>.*' status)"
EtatZoneB="$(echo "${EtatZoneB:7:-9}")"
EtatZoneC="$(grep -Eoi '<zone2>.*' status)"
EtatZoneC="$(echo "${EtatZoneC:7:-9}")"
EtatPiles="$(grep -Eoi '<defaut0>.*' status)"
EtatPiles="$(echo "${EtatPiles:9:-11}")"
EtatRadio="$(grep -Eoi '<defaut1>.*' status)"
EtatRadio="$(echo "${EtatRadio:9:-11}")"
EtatPorte="$(grep -Eoi '<defaut2>.*' status)"
EtatPorte="$(echo "${EtatPorte:9:-11}")"
EtatAlarme="$(grep -Eoi '<defaut3>.*' status)"
EtatAlarme="$(echo "${EtatAlarme:9:-11}")"
EtatBoitier="$(grep -Eoi '<defaut4>.*' status)"
EtatBoitier="$(echo "${EtatBoitier:9:-11}")"
EtatGSM="$(grep -Eoi '<gsm>.*' status)"
EtatGSM="$(echo "${EtatGSM:5:-7}")"
SignalGSM="$(grep -Eoi '<recgsm>.*' status)"
SignalGSM="$(echo "${SignalGSM:8:-10}")"
OperateurGSM="$(grep -Eoi '<opegsm>.*' status)"
OperateurGSM="$(echo "${OperateurGSM:9:-10}")"
EtatCamera="$(grep -Eoi '<camera>.*' status)"
EtatCamera="$(echo "${EtatCamera:8:-10}")"
if [ "$Debug" = "True" ]; then
# Statusoverzicht
echo " ******************************************* "
echo " Status van het systeem"
echo " ******************************************* "
echo " Zone A = "$EtatZoneA
echo " Zone B = "$EtatZoneB
echo " Zone C = "$EtatZoneC
echo ""
echo " Status Batterijen = "$EtatPiles
echo " Status communicatie = "$EtatRadio
echo " Status Ramen/Deuren = "$EtatPorte
echo " Status Alarm = "$EtatAlarme
echo " Status Behuizing = "$EtatBoitier
echo ""
echo " Status GSM = "$EtatGSM
echo " Signal GSM = "$SignalGSM
echo " GSM Provider = "$OperateurGSM
echo ""
echo " Status Camera = "$EtatCamera
fi
# Mise àjour capteurs Domoticz
if [ "$Debug" = "True" ]; then
echo " Mise àjour capteurs Domoticz"
fi
# Zone A
if [ "$EtatZoneA" = "off" ]; then
maj_capteur ZoneA Off $AlarmeSomfyZoneAIdx
else
maj_capteur ZoneA On $AlarmeSomfyZoneAIdx
fi
# Zone B
if [ "$EtatZoneB" = "off" ]; then
maj_capteur ZoneB Off $AlarmeSomfyZoneBIdx
else
maj_capteur ZoneB On $AlarmeSomfyZoneBIdx
fi
# Zone C
if [ "$EtatZoneC" = "off" ]; then
maj_capteur ZoneC Off $AlarmeSomfyZoneCIdx
else
maj_capteur ZoneC On $AlarmeSomfyZoneCIdx
fi
# Status Batterijen
if [ "$EtatPiles" = "ok" ]; then
maj_capteur Piles On $AlarmeSomfyPilesIdx
else
maj_capteur Piles Off $AlarmeSomfyPilesIdx
fi
# Status Communicatie
if [ "$EtatRadio" = "ok" ]; then
maj_capteur Radio On $AlarmeSomfyRadioIdx
else
maj_capteur Radio Off $AlarmeSomfyRadioIdx
fi
# Status Ramen/Deuren
if [ "$EtatPorte" = "ok" ]; then
maj_capteur Porte/Fenetre Off $AlarmeSomfyPorteIdx
else
maj_capteur Porte/Fenetre On $AlarmeSomfyPorteIdx
fi
# Status Alarm
if [ "$EtatAlarme" = "ok" ]; then
maj_capteur Alarme Off $AlarmeSomfyAlarmeIdx
else
maj_capteur Alarme On $AlarmeSomfyAlarmeIdx
fi
# Status Behuizing
if [ "$EtatBoitier" = "ok" ]; then
maj_capteur Boitier Off $AlarmeSomfyBoitierIdx
else
maj_capteur Boitier On $AlarmeSomfyBoitierIdx
fi
# Status GSM
if [ "$EtatGSM" = "GSM connecté au réseau" ]; then
maj_capteur GSM On $AlarmeSomfyGSMIdx
else
maj_capteur GSM Off $AlarmeSomfyGSMIdx
fi
# GSM Signaal
if [ "$Debug" = "True" ]; then
echo " Niveau Signal GSM"
curl "http://$SrvDomoticzIp/json.htm?type=command¶m=udevice&idx=$AlarmeSomfySignalGSMIdx&nvalue=0&svalue=$SignalGSM"
else
curl -s "http://$SrvDomoticzIp/json.htm?type=command¶m=udevice&idx=$AlarmeSomfySignalGSMIdx&nvalue=0&svalue=$SignalGSM" > /dev/null
fi
# GSM Provider
if [ "$Debug" = "True" ]; then
echo " Opérateur GSM"
curl "http://$SrvDomoticzIp/json.htm?type=command¶m=udevice&idx=$AlarmeSomfyOperateurGSMIdx&nvalue=0&svalue=$OperateurGSM"
else
curl -s "http://$SrvDomoticzIp/json.htm?type=command¶m=udevice&idx=$AlarmeSomfyOperateurGSMIdx&nvalue=0&svalue=$OperateurGSM" > /dev/null
fi
# Camera
#if [ "$EtatCamera" = "disabled" ]; then
# maj_capteur Camera Off $AlarmeSomfyCameraIdx
#else
# maj_capteur Camera On $AlarmeSomfyCameraIdx
#fi
fi
#----------------------------------------------------------------------------------------------------------------------
# Mise en marche de l'alarme Zones A B C
#----------------------------------------------------------------------------------------------------------------------
if [ "$ZonesABCOn" = "1" ]; then
# Connexion àl'alarme
login_alarme
# Mise en marche de l'alarme Zones A B C
if [ "$Debug" = "True" ]; then
echo "Mise en marche de l'alarme Zones A B C"
curl -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&hidden=hidden&btn_zone_on_ABC=Marche A B C" $UrlPilotage | iconv -f iso8859-1 -t utf-8
#curl -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&hidden=hidden&btn_zone_on_ABC=Marche A B C" $UrlPilotage | uconv -f iso8859-1 -t utf-8
else
curl -s -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&hidden=hidden&btn_zone_on_ABC=Marche A B C" $UrlPilotage | iconv -f iso8859-1 -t utf-8 > /dev/null
#curl -s -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&hidden=hidden&btn_zone_on_ABC=Marche A B C" $UrlPilotage | uconv -f iso8859-1 -t utf-8 > /dev/null
fi
# Deconnexion de l'alarme
logout_alarme
# Mise àjour capteurs Domoticz
if [ "$Debug" = "True" ]; then
echo " Mise àjour capteurs Domoticz"
fi
maj_capteur ZoneA On $AlarmeSomfyZoneAIdx
maj_capteur ZoneB On $AlarmeSomfyZoneBIdx
maj_capteur ZoneC On $AlarmeSomfyZoneCIdx
fi
#----------------------------------------------------------------------------------------------------------------------
# Mise en marche de l'alarme Zone A
#----------------------------------------------------------------------------------------------------------------------
if [ "$ZoneAOn" = "1" ]; then
# Connexion àl'alarme
login_alarme
# Mise en marche de l'alarme Zone A
if [ "$Debug" = "True" ]; then
echo "Mise en marche de l'alarme Zone A"
curl -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&hidden=hidden&btn_zone_on_A=Marche A" $UrlPilotage | iconv -f iso8859-1 -t utf-8
#curl -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&hidden=hidden&btn_zone_on_A=Marche A" $UrlPilotage | uconv -f iso8859-1 -t utf-8
else
curl -s -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&hidden=hidden&btn_zone_on_A=Marche A" $UrlPilotage | iconv -f iso8859-1 -t utf-8 > /dev/null
#curl -s -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&hidden=hidden&btn_zone_on_A=Marche A" $UrlPilotage | uconv -f iso8859-1 -t utf-8 > /dev/null
fi
# Deconnexion de l'alarme
logout_alarme
# Mise àjour capteurs Domoticz
if [ "$Debug" = "True" ]; then
echo " Mise àjour capteurs Domoticz"
fi
maj_capteur ZoneA On $AlarmeSomfyZoneAIdx
fi
#----------------------------------------------------------------------------------------------------------------------
# Mise en marche de l'alarme Zone B
#----------------------------------------------------------------------------------------------------------------------
if [ "$ZoneBOn" = "1" ]; then
# Connexion àl'alarme
login_alarme
# Mise en marche de l'alarme Zone B
if [ "$Debug" = "True" ]; then
echo "Mise en marche de l'alarme Zone B"
curl -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&hidden=hidden&btn_zone_on_B=Marche B" $UrlPilotage | iconv -f iso8859-1 -t utf-8
#curl -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&hidden=hidden&btn_zone_on_B=Marche B" $UrlPilotage | uconv -f iso8859-1 -t utf-8
else
curl -s -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&hidden=hidden&btn_zone_on_B=Marche B" $UrlPilotage | iconv -f iso8859-1 -t utf-8 > /dev/null
#curl -s -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&hidden=hidden&btn_zone_on_B=Marche B" $UrlPilotage | uconv -f iso8859-1 -t utf-8 > /dev/null
fi
# Deconnexion de l'alarme
logout_alarme
# Mise àjour capteurs Domoticz
if [ "$Debug" = "True" ]; then
echo " Mise àjour capteurs Domoticz"
fi
maj_capteur ZoneB On $AlarmeSomfyZoneBIdx
fi
#----------------------------------------------------------------------------------------------------------------------
# Mise en marche de l'alarme Zone C
#----------------------------------------------------------------------------------------------------------------------
if [ "$ZoneCOn" = "1" ]; then
# Connexion àl'alarme
login_alarme
# Mise en marche de l'alarme Zone C
if [ "$Debug" = "True" ]; then
echo "Mise en marche de l'alarme Zone C"
curl -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&hidden=hidden&btn_zone_on_C=Marche C" $UrlPilotage | iconv -f iso8859-1 -t utf-8
#curl -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&hidden=hidden&btn_zone_on_C=Marche C" $UrlPilotage | uconv -f iso8859-1 -t utf-8
else
curl -s -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&hidden=hidden&btn_zone_on_C=Marche C" $UrlPilotage | iconv -f iso8859-1 -t utf-8 > /dev/null
#curl -s -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&hidden=hidden&btn_zone_on_C=Marche C" $UrlPilotage | uconv -f iso8859-1 -t utf-8 > /dev/null
fi
# Deconnexion de l'alarme
logout_alarme
# Mise àjour capteurs Domoticz
if [ "$Debug" = "True" ]; then
echo " Mise àjour capteurs Domoticz"
fi
maj_capteur ZoneC On $AlarmeSomfyZoneCIdx
fi
#----------------------------------------------------------------------------------------------------------------------
# Arret de l'alarme Zones A B C
#----------------------------------------------------------------------------------------------------------------------
if [ "$AlarmeOff" = "1" ]; then
# Connexion àl'alarme
login_alarme
# Arret de l'alarme Zones A B C
if [ "$Debug" = "True" ]; then
echo "Arret de l'alarme Zones A B C"
curl -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&btn_zone_off_ABC=Arret A B C" $UrlPilotage | iconv -f iso8859-1 -t utf-8
#curl -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&btn_zone_off_ABC=Arret A B C" $UrlPilotage | uconv -f iso8859-1 -t utf-8
else
curl -s -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&btn_zone_off_ABC=Arret A B C" $UrlPilotage | iconv -f iso8859-1 -t utf-8 > /dev/null
#curl -s -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&btn_zone_off_ABC=Arret A B C" $UrlPilotage | uconv -f iso8859-1 -t utf-8 > /dev/null
fi
# Deconnexion de l'alarme
logout_alarme
# Mise àjour capteurs Domoticz
if [ "$Debug" = "True" ]; then
echo " Mise àjour capteurs Domoticz"
fi
maj_capteur ZoneA Off $AlarmeSomfyZoneAIdx
maj_capteur ZoneB Off $AlarmeSomfyZoneBIdx
maj_capteur ZoneC Off $AlarmeSomfyZoneCIdx
fi
#----------------------------------------------------------------------------------------------------------------------
# Reset defauts piles
#----------------------------------------------------------------------------------------------------------------------
if [ "$RSTPiles" = "1" ]; then
# Connexion àl'alarme
login_alarme
# Reset defauts piles
if [ "$Debug" = "True" ]; then
echo "Reset defauts piles"
curl -L --cookie cjar --cookie-jar cjar --data "btn_del_pil=Piles" $UrlElements | iconv -f iso8859-1 -t utf-8
#curl -L --cookie cjar --cookie-jar cjar --data "btn_del_pil=Piles" $UrlElements | uconv -f iso8859-1 -t utf-8
else
curl -s -L --cookie cjar --cookie-jar cjar --data "btn_del_pil=Piles" $UrlElements | iconv -f iso8859-1 -t utf-8 > /dev/null
#curl -s -L --cookie cjar --cookie-jar cjar --data "btn_del_pil=Piles" $UrlElements | uconv -f iso8859-1 -t utf-8 > /dev/null
fi
# Deconnexion de l'alarme
logout_alarme
fi
#----------------------------------------------------------------------------------------------------------------------
# Reset defauts alarmes
#----------------------------------------------------------------------------------------------------------------------
if [ "$RSTAlarmes" = "1" ]; then
# Connexion àl'alarme
login_alarme
# Reset defauts alarmes
if [ "$Debug" = "True" ]; then
echo "Reset defauts alarmes"
curl -L --cookie cjar --cookie-jar cjar --data "btn_del_alm=Alarmes" $UrlElements | iconv -f iso8859-1 -t utf-8
#curl -L --cookie cjar --cookie-jar cjar --data "btn_del_alm=Alarmes" $UrlElements | uconv -f iso8859-1 -t utf-8
else
curl -s -L --cookie cjar --cookie-jar cjar --data "btn_del_alm=Alarmes" $UrlElements | iconv -f iso8859-1 -t utf-8 > /dev/null
#curl -s -L --cookie cjar --cookie-jar cjar --data "btn_del_alm=Alarmes" $UrlElements | uconv -f iso8859-1 -t utf-8 > /dev/null
fi
# Deconnexion de l'alarme
logout_alarme
fi
#----------------------------------------------------------------------------------------------------------------------
# Reset defauts liaisons
#----------------------------------------------------------------------------------------------------------------------
if [ "$RSTLiaisons" = "1" ]; then
# Connexion àl'alarme
login_alarme
# Reset defauts liaisons
if [ "$Debug" = "True" ]; then
echo "Reset defauts liaisons"
curl -L --cookie cjar --cookie-jar cjar --data "btn_del_lia=Liaisons" $UrlElements | iconv -f iso8859-1 -t utf-8
#curl -L --cookie cjar --cookie-jar cjar --data "btn_del_lia=Liaisons" $UrlElements | uconv -f iso8859-1 -t utf-8
else
curl -s -L --cookie cjar --cookie-jar cjar --data "btn_del_lia=Liaisons" $UrlElements | iconv -f iso8859-1 -t utf-8 > /dev/null
#curl -s -L --cookie cjar --cookie-jar cjar --data "btn_del_lia=Liaisons" $UrlElements | uconv -f iso8859-1 -t utf-8 > /dev/null
fi
# Deconnexion de l'alarme
logout_alarme
fi
#----------------------------------------------------------------------------------------------------------------------
# Gestion de la liste des Elements
#----------------------------------------------------------------------------------------------------------------------
if [ "$Elements" = "1" ]; then
# Connexion àl'alarme
login_alarme
# Lecture de la liste des Elements et stockage dans fichier temporaire
if [ "$Debug" = "True" ]; then
echo "Gestion liste des Elements"
curl -L --cookie cjar --cookie-jar cjar $UrlElements | iconv -f iso8859-1 -t utf-8 > elements
#curl -L --cookie cjar --cookie-jar cjar $UrlElements | uconv -f iso8859-1 -t utf-8 > elements
else
curl -s -L --cookie cjar --cookie-jar cjar $UrlElements | iconv -f iso8859-1 -t utf-8 > elements
#curl -s -L --cookie cjar --cookie-jar cjar $UrlElements | uconv -f iso8859-1 -t utf-8 > elements
fi
# Deconnexion de l'alarme
logout_alarme
# Récupération dans les variables
TypeElements="$(grep -Eoi 'var item_label.*' elements)"
NomElements="$(grep -Eoi 'var elt_name.*' elements)"
EtatElements="$(grep -Eoi 'var item_pause.*' elements)"
EtatPiles="$(grep -Eoi 'var elt_pile.*' elements)"
EtatLiaison="$(grep -Eoi 'var elt_onde.*' elements)"
EtatPortes="$(grep -Eoi 'var elt_porte.*' elements)"
EtatBoitiers="$(grep -Eoi 'var elt_as.*' elements)"
EtatAlarme="$(grep -Eoi 'var elt_maison.*' elements)"
# Affichage des Elements
if [ "$Debug" = "True" ]; then
echo " Type des Elements"
echo $TypeElements
echo " Nom des Elements"
echo $NomElements
echo " Etat des Elements"
echo $EtatElements
echo " Etat des piles"
echo $EtatPiles
echo " Etat liaison radio"
echo $EtatLiaison
echo " Etat détecteurs ouverture"
echo $EtatPortes
echo " Etat ouverture boitiers"
echo $EtatBoitiers
echo " Etat alarme"
echo $EtatAlarme
fi
# Formatage du type des Elements
# Suppression des 21 1er caractères et 2 derniers
TypeElements="$(echo "${TypeElements:21:-2}")"
# Suppression des "
TypeElements="$(echo "$TypeElements" | sed s/\"//g)"
# Suppression des espaces entre les ,
TypeElements="$(echo "$TypeElements" | sed s/\,\ /\,/g)"
# Déclaration , comme séparateur
IFS=","
# Stockage dans le tableau
TabTypeElements=($TypeElements)
# Formatage des noms des Elements
# Suppression des 21 1er caractères et 2 derniers
NomElements="$(echo "${NomElements:21:-2}")"
# Suppression des "
NomElements="$(echo "$NomElements" | sed s/\"//g)"
# Suppression des espaces entre les ,
NomElements="$(echo "$NomElements" | sed s/\,\ /\,/g)"
# Déclaration , comme séparateur
IFS=","
# Stockage dans le tableau
TabNomElements=($NomElements)
# Formatage état des Elements
# Suppression des 21 1er caractères et 2 derniers
EtatElements="$(echo "${EtatElements:21:-2}")"
# Suppression des "
EtatElements="$(echo "$EtatElements" | sed s/\"//g)"
# Suppression des espaces entre les ,
EtatElements="$(echo "$EtatElements" | sed s/\,\ /\,/g)"
# Déclaration , comme séparateur
IFS=","
# Stockage dans le tableau
TabEtatElements=($EtatElements)
# Modification valeurs tableau
TailleTab=${#TabEtatElements[@]}
for (( i=0; i<$TailleTab; i++ ))
do
if [ ${TabEtatElements["$i"]} = "running" ]; then TabEtatElements["$i"]="Activé"
else
TabEtatElements["$i"]="Désactivé"
fi
done
# Formatage état des piles
# Suppression des 21 1er caractères et 2 derniers
EtatPiles="$(echo "${EtatPiles:21:-2}")"
# Suppression des "
EtatPiles="$(echo "$EtatPiles" | sed s/\"//g)"
# Suppression des espaces entre les ,
EtatPiles="$(echo "$EtatPiles" | sed s/\,\ /\,/g)"
# Déclaration , comme séparateur
IFS=","
# Stockage dans le tableau
TabEtatPiles=($EtatPiles)
# Modification des valeurs du tableau
TailleTab=${#TabEtatPiles[@]}
for (( i=0; i<$TailleTab; i++ ))
do
if [ ${TabEtatPiles["$i"]} = "itemhidden" ]; then TabEtatPiles["$i"]="NA"
else
if [ ${TabEtatPiles["$i"]} = "itembattok" ]; then TabEtatPiles["$i"]="OK"
else
TabEtatPiles["$i"]="NOK"
fi
fi
done
# Formatage état liaison radio
# Suppression des 21 1er caractères et 2 derniers
EtatLiaison="$(echo "${EtatLiaison:21:-2}")"
# Suppression des "
EtatLiaison="$(echo "$EtatLiaison" | sed s/\"//g)"
# Suppression des espaces entre les ,
EtatLiaison="$(echo "$EtatLiaison" | sed s/\,\ /\,/g)"
# Déclaration , comme séparateur
IFS=","
# Stockage dans le tableau
TabEtatLiaison=($EtatLiaison)
# Modification des valeurs du tableau
TailleTab=${#TabEtatLiaison[@]}
for (( i=0; i<$TailleTab; i++ ))
do
if [ ${TabEtatLiaison["$i"]} = "itemhidden" ]; then TabEtatLiaison["$i"]="NA"
else
if [ ${TabEtatLiaison["$i"]} = "itemcomok" ]; then TabEtatLiaison["$i"]="OK"
else
TabEtatLiaison["$i"]="NOK"
fi
fi
done
# Récup état détecteurs ouverture
# Suppression des 21 1er caractères et 2 derniers
EtatPortes="$(echo "${EtatPortes:21:-2}")"
# Suppression des "
EtatPortes="$(echo "$EtatPortes" | sed s/\"//g)"
# Suppression des espaces entre les ,
EtatPortes="$(echo "$EtatPortes" | sed s/\,\ /\,/g)"
# Déclaration , comme séparateur
IFS=","
# Stockage dans le tableau
TabEtatPortes=($EtatPortes)
# Modification des valeurs du tableau
TailleTab=${#TabEtatPortes[@]}
for (( i=0; i<$TailleTab; i++ ))
do
if [ ${TabEtatPortes["$i"]} = "itemhidden" ]; then TabEtatPortes["$i"]="NA"
else
if [ ${TabEtatPortes["$i"]} = "itemdoorok" ]; then TabEtatPortes["$i"]="Fermée"
else
TabEtatPortes["$i"]="Ouverte"
fi
fi
done
# Récup état ouverture boitiers
# Suppression des 21 1er caractères et 2 derniers
EtatBoitiers="$(echo "${EtatBoitiers:21:-2}")"
# Suppression des "
EtatBoitiers="$(echo "$EtatBoitiers" | sed s/\"//g)"
# Suppression des espaces entre les ,
EtatBoitiers="$(echo "$EtatBoitiers" | sed s/\,\ /\,/g)"
# Déclaration , comme séparateur
IFS=","
# Stockage dans le tableau
TabEtatBoitiers=($EtatBoitiers)
# Modification des valeurs du tableau
TailleTab=${#TabEtatBoitiers[@]}
for (( i=0; i<$TailleTab; i++ ))
do
if [ ${TabEtatBoitiers["$i"]} = "itemhidden" ]; then TabEtatBoitiers["$i"]="NA"
else
if [ ${TabEtatBoitiers["$i"]} = "itemboxok" ]; then TabEtatBoitiers["$i"]="Fermé"
else
TabEtatBoitiers["$i"]="Ouvert"
fi
fi
done
# Récup état alarme
# Suppression des 21 1er caractères et 2 derniers
EtatAlarme="$(echo "${EtatAlarme:21:-2}")"
# Suppression des "
EtatAlarme="$(echo "$EtatAlarme" | sed s/\"//g)"
# Suppression des espaces entre les ,
EtatAlarme="$(echo "$EtatAlarme" | sed s/\,\ /\,/g)"
# Déclaration , comme séparateur
IFS=","
# Stockage dans le tableau
TabEtatAlarme=($EtatAlarme)
# Modification des valeurs du tableau
TailleTab=${#TabEtatAlarme[@]}
for (( i=0; i<$TailleTab; i++ ))
do
if [ ${TabEtatAlarme["$i"]} = "itemhouseok" ]; then TabEtatAlarme["$i"]="Pas d'alarme"
else
TabEtatAlarme["$i"]="Alarme"
fi
done
# Affichage de la liste des Elements
if [ "$Debug" = "True" ]; then
echo " Liste des Elements"
TailleTab=${#TabNomElements[@]}
for (( i=0; i<$TailleTab; i++ ))
do
echo " Type : "${TabTypeElements["$i"]} "/ Nom : "${TabNomElements["$i"]} "/ Etat : "${TabEtatElements["$i"]} "/ Etat piles : "${TabEtatPiles["$i"]} "/ Etat liaison : "${TabEtatLiaison["$i"]} "/ Etat portes : "${TabEtatPortes["$i"]} "/ Etat boitiers : "${TabEtatBoitiers["$i"]} "/ Etat alarme : "${TabEtatAlarme["$i"]}
done
fi
# Mise àjour capteurs Domoticz
if [ "$Debug" = "True" ]; then
echo " Mise àjour capteurs Domoticz"
fi
# DO Entré
TailleTab=${#TabNomElements[@]}
for (( i=0; i<$TailleTab; i++ ))
do
if [ ${TabNomElements["$i"]} = "DO Entree" ]; then PosElement=$i
fi
done
if [ ${TabEtatPortes["$PosElement"]} = "Fermée" ]; then
maj_capteur DOEntrée Off $AlarmeSomfyDOEntreeIdx
else
maj_capteur DOEntrée On $AlarmeSomfyDOEntreeIdx
fi
# DO Couloir
for (( i=0; i<$TailleTab; i++ ))
do
if [ ${TabNomElements["$i"]} = "DO Couloir" ]; then PosElement=$i
fi
done
if [ ${TabEtatPortes["$PosElement"]} = "Fermée" ]; then
maj_capteur DOAtelier Off $AlarmeSomfyDOAtelierIdx
else
maj_capteur DOAtelier On $AlarmeSomfyDOAtelierIdx
fi
fi
exit 0
Re: Somfy Alarm Script not running
Posted: Saturday 08 February 2020 10:55
by clumpton
My bad!!
Remove the extra " at the end of this line
Re: Somfy Alarm Script not running
Posted: Saturday 08 February 2020 11:04
by MikeyMan
That fixes the error indeed...
However; nothing happens. I see a lot of echo lines, which should at least be displayed.
What happens if you run it?
Been adding some test echos, it does seem to go through the whole script in a way.
edit: wait a minute... is it even supposed to do something without command line options?
Probably isn't, i get some continuous response now:
Code: Select all
Starting script in file: ./somfy.sh
Debug is set to True
Server address: 10.0.0.30:8080
Test 1
*********************************
Liste des URLs
*********************************
UrlLogin = http://10.0.0.112/gb/login.htm
UrlLogout = http://10.0.0.112/logout.htm
UrlEtat = http://10.0.0.112/status.xml
UrlPilotage = http://10.0.0.112/gb/u_pilotage.htm
UrlElements = http://10.0.0.112/gb/u_listelmt.htm
Retrieving access code
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 34 0 34 0 0 4250 0 --:--:-- --:--:-- --:--:-- 4250
100 2539 0 2539 0 0 49784 0 --:--:-- --:--:-- --:--:-- 49784
Access code = 4<
Ophalen Authentificatiecode
Authenticatiecode =
Gebruiker1-code en verificatiecode verzenden
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 38 0 0 100 38 0 1520 --:--:-- --:--:-- --:--:-- 1520
100 1642 0 1642 0 0 5419 0 --:--:-- --:--:-- --:--:-- 15941
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="content-style-type" content="text/css" />
<title>Central unit</title>
<link rel="shortcut icon" href="/domis.ico" type="image/x-icon"/>
<meta name="language" content="en" />
<meta http-equiv="expires" content="0">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache, must-revalidate">
<link href="/domis_welcome.css" rel="stylesheet" type="text/css" /> </head>
<body>
<div id="page">
<div id="fond">
<div id="menu">
<div class="logohmb"> </div>
</div>
<div id="navbar"><div id="mode"></div></div><div id="titlebar"><div class="widetitlevoid">Error</div><div class="titlecorner"></div></div><div id="content" class="contentall"><br /><br /><div id="infobox">Maximum number of attempts reached.
<b>(0x0904)</b><br/><br/>Try again in
9:59<br /><br /><form method="post" action="error.htm"><input type="submit" name="btn_ok" value="OK" class="arrowdark_short" /></form></div><div id="content_footer"> </div></div> <!--content -->
<div id="spacer">
<!-- -->
<!--[if IE]>
<![endif]-->
</div>
<div id="menu_footer">
<br />
Copyright ©2013 Somfy
</div>
</div>
<!-- fond -->
</div>
<!-- page -->
</body>
</html>
Gestion liste des Elements
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 1604 0 1604 0 0 5455 0 --:--:-- --:--:-- --:--:-- 5455
Verbinden met alarm
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 2539 0 2539 0 0 9334 0 --:--:-- --:--:-- --:--:-- 9334
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="content-style-type" content="text/css" />
<title>Central unit</title>
<link rel="shortcut icon" href="/domis.ico" type="image/x-icon"/>
<meta name="language" content="en" />
<meta http-equiv="expires" content="0">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache, must-revalidate">
<link href="/domis_welcome.css" rel="stylesheet" type="text/css" /><style type="text/css">img{border:none;};#menu a{border-bottom:none;}</style></head><body><div id="page"><div id="fond"><div id="menu"><div class="logohmb"> </div><div id="filler"></div></div><div id="titlebar"><div class="widetitlevoid">Welcome</div><div class="titlecorner"></div></div><div id="content"><div class="loginhouse">My Somfy alarm system</div><form id="form_id" method="post" action="login.htm"><table><col width="165px"><tr><td>Account</td><td><select name="login" class="skinnedselectinput"> <option value="u">User1 </option><option value="i">Installer </option><option value="t">Remote mon. </option></select></td></tr><tr><td>Access code</td><td><input type="password" name="password" value="" class="skinnedtextinput" maxlength="12" size="16"/></td></tr><tr><td>Authentication code <b>B4</b></td><td><input type="password" name="key" value="" class="skinnedtextinput" maxlength="6" size="16"/></td></tr></table><div id="content_footer"><input type="submit" name="btn_login" value="Login" class="arrowdark"/></div></form></div> <!--content -->
<div id="spacer">
<!-- -->
<!--[if IE]>
<![endif]-->
</div>
<div id="menu_footerflag">
Select language:<br><br>
<a href="/gb/login.htm"><img src="/img/gb.gif" alt="gb"/></a>
<a href="/fr/login.htm"><img src="/img/fr.gif" alt="fr"/></a>
<a href="/nl/login.htm"><img src="/img/nl.gif" alt="nl"/></a><br>
<a href="/it/login.htm"><img src="/img/it.gif" alt="it"/></a>
<a href="/de/login.htm"><img src="/img/de.gif" alt="de"/></a>
<a href="/sp/login.htm"><img src="/img/sp.gif" alt="sp"/></a><br>
Copyright ©2013 Somfy
</div>
</div>
<!-- fond -->
</div>
<!-- page -->
</body>
</html>
Type des Elements
Nom des Elements
Etat des Elements
Etat des piles
Etat liaison radio
Etat détecteurs ouverture
Etat ouverture boitiers
Etat alarme
Liste des Elements
Mise à jour capteurs Domoticz
./somfy.sh: line 855: [: =: unary operator expected
Staat DOEntrée
{
"status" : "ERR"
}
./somfy.sh: line 867: [: =: unary operator expected
Staat DOAtelier
{
"status" : "ERR"
}
Now it's a matter of debugging i guess...
Re: Somfy Alarm Script not running
Posted: Saturday 08 February 2020 11:29
by MikeyMan
added a couple of " " to lines that errored out...
One step further…
Code: Select all
Starting script in file: ./somfy.sh
Debug is set to True
Server address: 10.0.0.30:8080
Test 1
*********************************
List of URLs
*********************************
UrlLogin = http://10.0.0.112/gb/login.htm
UrlLogout = http://10.0.0.112/logout.htm
UrlEtat = http://10.0.0.112/status.xml
UrlPilotage = http://10.0.0.112/gb/u_pilotage.htm
UrlElements = http://10.0.0.112/gb/u_listelmt.htm
Retrieving access code
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 34 0 34 0 0 115 0 --:--:-- --:--:-- --:--:-- 115
100 34 0 34 0 0 39 0 --:--:-- --:--:-- --:--:-- 0
Access code =
./somfy.sh: line 161: CarteAuthentification: bad array subscript
Get authentication code
Authentication code =
Gebruiker1-code en verificatiecode verzenden
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 38 0 0 100 38 0 2235 --:--:-- --:--:-- --:--:-- 2235
100 2605 0 2605 0 0 4128 0 --:--:-- --:--:-- --:--:-- 4128
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="content-style-type" content="text/css" />
<title>Central unit : User</title>
<link rel="shortcut icon" href="/domis.ico" type="image/x-icon"/>
<meta name="language" content="en" />
<meta http-equiv="expires" content="0">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache, must-revalidate">
<link href="/domis_welcome.css" rel="stylesheet" type="text/css" /> </head>
<body onLoad="allowAJAX=true;" onUnload="allowAJAX=false;">
<div id="page">
<div id="fond">
<div id="menu">
<div class="logohmb"> </div>
<div id="filler"> </div>
<a class="menuvoid" href="u_pilotage.htm">CONTROL OF ALARM/AUTOMATISMS</a>
<a class="menuvoid" href="u_regqck.htm">QUICK SETTINGS</a>
<a class="menuvoid" href="u_listelmt.htm">DEVICE LIST</a>
<a class="menuvoid" href="journal.htm">EVENT LOG</a>
<a class="menuvoid" href="regalm.htm">ARMING SETTINGS</a>
<a class="menuvoid" href="u_regvol.htm">ROLLER SHUTTER SETTINGS</a>
<a class="menuvoid" href="u_reglum.htm">LIGHT SETTINGS</a>
<a class="menuvoid" href="u_regcam.htm" >MY CAMERAS</a>
<a class="menuvoid" href="u_challenge.htm">AUTHENTICATION CARD</a>
</div>
<div id="navbar">
<div id="mode">User</div>
<div id="disconnect"><a href="/logout.htm">Logout</a></div>
<div id="refresh"><a href="javascript:location.reload(true)">Update</a></div>
</div>
<div id="navbar"><div id="mode"></div></div><div id="titlebar"><div class="widetitlevoid">Error</div><div class="titlecorner"></div></div><div id="content" class="contentall"><br /><br /><div id="infobox">Session already open. Please try again later.
<b>(0x0902)</b><br /><br /><form method="post" action="error.htm"><input type="submit" name="btn_ok" value="OK" class="arrowdark_short" /></form></div><div id="content_footer"> </div></div> <!--content -->
<div id="spacer">
<!-- -->
<!--[if IE]>
<![endif]-->
</div>
<div id="menu_footer">
<br />
Copyright ©2013 Somfy
</div>
</div>
<!-- fond -->
</div>
<!-- page -->
</body>
</html>
Lecture de l'état du système
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 353 0 353 0 0 292 0 --:--:-- 0:00:01 --:--:-- 292
Verbinden met alarm
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 2605 0 2605 0 0 5853 0 --:--:-- --:--:-- --:--:-- 5853
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="content-style-type" content="text/css" />
<title>Central unit : User</title>
<link rel="shortcut icon" href="/domis.ico" type="image/x-icon"/>
<meta name="language" content="en" />
<meta http-equiv="expires" content="0">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache, must-revalidate">
<link href="/domis_welcome.css" rel="stylesheet" type="text/css" /> </head>
<body onLoad="allowAJAX=true;" onUnload="allowAJAX=false;">
<div id="page">
<div id="fond">
<div id="menu">
<div class="logohmb"> </div>
<div id="filler"> </div>
<a class="menuvoid" href="u_pilotage.htm">CONTROL OF ALARM/AUTOMATISMS</a>
<a class="menuvoid" href="u_regqck.htm">QUICK SETTINGS</a>
<a class="menuvoid" href="u_listelmt.htm">DEVICE LIST</a>
<a class="menuvoid" href="journal.htm">EVENT LOG</a>
<a class="menuvoid" href="regalm.htm">ARMING SETTINGS</a>
<a class="menuvoid" href="u_regvol.htm">ROLLER SHUTTER SETTINGS</a>
<a class="menuvoid" href="u_reglum.htm">LIGHT SETTINGS</a>
<a class="menuvoid" href="u_regcam.htm" >MY CAMERAS</a>
<a class="menuvoid" href="u_challenge.htm">AUTHENTICATION CARD</a>
</div>
<div id="navbar">
<div id="mode">User</div>
<div id="disconnect"><a href="/logout.htm">Logout</a></div>
<div id="refresh"><a href="javascript:location.reload(true)">Update</a></div>
</div>
<div id="navbar"><div id="mode"></div></div><div id="titlebar"><div class="widetitlevoid">Error</div><div class="titlecorner"></div></div><div id="content" class="contentall"><br /><br /><div id="infobox">Session already open. Please try again later.
<b>(0x0902)</b><br /><br /><form method="post" action="error.htm"><input type="submit" name="btn_ok" value="OK" class="arrowdark_short" /></form></div><div id="content_footer"> </div></div> <!--content -->
<div id="spacer">
<!-- -->
<!--[if IE]>
<![endif]-->
</div>
<div id="menu_footer">
<br />
Copyright ©2013 Somfy
</div>
</div>
<!-- fond -->
</div>
<!-- page -->
</body>
</html>
*******************************************
Status van het systeem
*******************************************
Zone A = on
Zone B = on
Zone C = on
Status Batterijen = ok
Status communicatie = ok
Status Ramen/Deuren = ok
Status Alarm = ok
Status Behuizing = ok
Status GSM = GSM connected to network
Signal GSM = 4
GSM Provider = vodafo
Status Camera = disabled
Mise à jour capteurs Domoticz
Staat ZoneA
{
"status" : "OK",
"title" : "SwitchLight"
}
Staat ZoneB
{
"status" : "OK",
"title" : "SwitchLight"
}
Staat ZoneC
{
"status" : "OK",
"title" : "SwitchLight"
}
Staat Piles
{
"status" : "OK",
"title" : "SwitchLight"
}
Staat Radio
{
"status" : "OK",
"title" : "SwitchLight"
}
Staat Porte/Fenetre
{
"status" : "OK",
"title" : "SwitchLight"
}
Staat Alarme
{
"status" : "OK",
"title" : "SwitchLight"
}
Staat Boitier
{
"status" : "OK",
"title" : "SwitchLight"
}
Staat GSM
{
"status" : "OK",
"title" : "SwitchLight"
}
Test 2
Niveau Signal GSM
{
"status" : "OK",
"title" : "Update Device"
}
Opérateur GSM
{
"status" : "OK",
"title" : "Update Device"
}
./somfy.sh: line 161: CarteAuthentification: bad array subscript
Pulled that specific part through a script checker:
Code: Select all
$ shellcheck myscript
Line 6:
declare -A CarteAuthentification
^-- SC2039: In POSIX sh, 'declare' is undefined.
Line 8:
CarteAuthentification=( ["A1"]="7092" ["B1"]="2220" ["C1"]="4790" ["D1"]="5830" ["E1"]="0920" ["F1"]="0912"
^-- SC2039: In POSIX sh, arrays are undefined.
Line 16:
CodeAuthentification="${CarteAuthentification["$CodeAcces"]}"
^-- SC2039: In POSIX sh, array references are undefined.
Line 19:
echo " Authentication code = "$CodeAuthentification
^-- SC2086: Double quote to prevent globbing and word splitting.
Did you mean: (apply this, apply all SC2086)
echo " Authentication code = ""$CodeAuthentification"
Re: Somfy Alarm Script not running
Posted: Saturday 08 February 2020 15:38
by clumpton
Oops missed a character
Change
Code: Select all
CodeAcces="$(echo "${CodeAcces:9:2}")"
to
Code: Select all
CodeAcces="$(echo "${CodeAcces:8:2}")"
(twice!)
And, yes the script needs an argument, e.g. --Status which should read the alarm state
PS These urls might need changing to their english version. You will need to check the address bar in your browser to see what they are called.
Code: Select all
UrlPilotage = http://10.0.0.112/gb/u_pilotage.htm
UrlElements = http://10.0.0.112/gb/u_listelmt.htm
Re: Somfy Alarm Script not running
Posted: Saturday 08 February 2020 15:50
by MikeyMan
clumpton wrote: ↑Saturday 08 February 2020 15:38
Oops missed a character
Change
Code: Select all
CodeAcces="$(echo "${CodeAcces:9:2}")"
to
Code: Select all
CodeAcces="$(echo "${CodeAcces:8:2}")"
(twice!)
And, yes the script needs an argument, e.g. --Status which should read the alarm state
PS These urls might need changing to their english version. You will need to check the address bar in your browser to see what they are called.
Code: Select all
UrlPilotage = http://10.0.0.112/gb/u_pilotage.htm
UrlElements = http://10.0.0.112/gb/u_listelmt.htm
I was wondering the same about the URLS, but they seem to be the same. It's mostly working now, only still get the
./somfy.sh: line 161: CarteAuthentification: bad array subscript error
No clue whats going on there… Got any idea? I think we're set there!
I can start fiddling around with the buttons in domoticz

Somehow if i trigger the script to turn on the alarm once, it gets into some kind of loop, which triggers all switches every 6 seconds.
Re: Somfy Alarm Script not running
Posted: Saturday 08 February 2020 17:21
by clumpton
MikeyMan wrote: ↑Saturday 08 February 2020 15:50
I was wondering the same about the URLS, but they seem to be the same. It's mostly working now, only still get the
./somfy.sh: line 161: CarteAuthentification: bad array subscript error
Somehow if i trigger the script to turn on the alarm once, it gets into some kind of loop, which triggers all switches every 6 seconds.
Is it printing out the correct Access Code now?
It won't work properly until it can authenticate correctly.
Re: Somfy Alarm Script not running
Posted: Saturday 08 February 2020 17:26
by MikeyMan
clumpton wrote: ↑Saturday 08 February 2020 17:21
MikeyMan wrote: ↑Saturday 08 February 2020 15:50
I was wondering the same about the URLS, but they seem to be the same. It's mostly working now, only still get the
./somfy.sh: line 161: CarteAuthentification: bad array subscript error
Somehow if i trigger the script to turn on the alarm once, it gets into some kind of loop, which triggers all switches every 6 seconds.
Is it printing out the correct Access Code now?
It won't work properly until it can authenticate correctly.
Oops... Made a typo myself... Yes now the right code is displayed. I can control the alarm through the command line. Very cool!
Now for some fiddling with the switches in domoticz.
Thanks a million, where can I send the beers?

Re: Somfy Alarm Script not running
Posted: Saturday 08 February 2020 17:27
by clumpton
MikeyMan wrote: ↑Saturday 08 February 2020 17:26
I can control the alarm through the command line. Very cool!
Now for some fiddling with the switches in domoticz.
YAY!

Re: Somfy Alarm Script not running
Posted: Saturday 08 February 2020 17:28
by MikeyMan
Any idea if the script could cause the switches to be triggered automatically ? And all three at a time when I press one?
Re: Somfy Alarm Script not running
Posted: Saturday 08 February 2020 17:42
by clumpton
MikeyMan wrote: ↑Saturday 08 February 2020 17:28
Any idea if the script could cause the switches to be triggered automatically ? And all three at a time when I press one?
I am not sure exactly what you want to do...
As far as I can see you can use the script to query the alarm status and switch zones on and off. Any changes made by the script are reflected by the corresponding switches in Domoticz, it also looks as if you query the status it will update Domoticz.
So you can set the alarm on or off from other events in Domoticz by simply calling the script with the relevant command option.
If you want to set all 3 zones by just one switch you can make a group in Domoticz.
Re: Somfy Alarm Script not running
Posted: Saturday 08 February 2020 17:57
by MikeyMan
Made a dummy hardware for somfy in domoticz
Created several sensors, for the hardware id's in the script.
then made a switch for the three zones.
For Zone A:
On action : script://somfy.sh --ZoneAOn
Off action: script://somfy.sh --AlarmeOff
same for zone B and C.
Seems to work, but it gets triggered every six seconds,
And when i press zone A, also B and C are triggered.