Page 8 sur 14

Re: Script alarme Somfy Protexiom 600

Publié : 19 nov. 2016, 10:14
par Seb13
Comme personne n'utilise les Zones, je vais remonter les Zones ABC mais pour l'activation et désactivation de l'alarme, je vais le faire que sur ABC et non A ou B ou C.

Re: Script alarme Somfy Protexiom 600

Publié : 19 nov. 2016, 10:20
par n1c0l45
je viens de voir avec httpfox que le POST data de connexion est:

Code : Tout sélectionner

login=u&password=XXXX&key=XXXX&btn_login=Connexion
Seb13,par contre, je suis desole, je connais pas encore tous les outils que tu utilises, aurais tu un peu de temps a me consacrer pour m'expliquer?
Merci

Re: Script alarme Somfy Protexiom 600

Publié : 19 nov. 2016, 10:36
par Seb13
S1eepy a écrit :Salut seb, merci pour le partage. Ca a l'air très bien, cependant ne marche pas sur mon syno car la commande iconv n'est pas présente.
Oui il est possible de la rajouter en bidouillant (ipkg ou autres...) mais je pense que je vais rester sur PHP pour cette raison.
Désolé, impossible de passer sans iconv car il me permet d'afficher le code html de la page avec les "é" de la porte fermée par exemple.
Si je supprime j'ai un carré à la place :?

Sinon je peux essayer de faire une recherche sans é ou î etc...

J'ai testé c'est possible... en fait, je ne fais pas une recherche sur "Boîtier" mais sur "Bo%tier" ou "tier" cela fonctionne...

Je ferai la modif plus tard.

Re: Script alarme Somfy Protexiom 600

Publié : 19 nov. 2016, 10:37
par Seb13
n1c0l45 a écrit :je viens de voir avec httpfox que le POST data de connexion est:

Code : Tout sélectionner

login=u&password=XXXX&key=XXXX&btn_login=Connexion
Seb13,par contre, je suis desole, je connais pas encore tous les outils que tu utilises, aurais tu un peu de temps a me consacrer pour m'expliquer?
Merci
Balance tes questions, je vais essayer d'y répondre.

Re: Script alarme Somfy Protexiom 600

Publié : 19 nov. 2016, 10:50
par Seb13
Bon, voici la version 3 de mon script.
J'ai ajouté un retour sur la connexion et déconnexion puis l'état des Zones ABC, cela donne ceci à la fin si cela fonctionne.

Code : Tout sélectionner

Connexion au site Somfy Mobile OK

Etat Porte = Porte ou fenêtre fermée
Etat Piles = Piles OK
Etat Communication Radio = Communication radio OK
Etat Alarme = Pas d'alarme
Etat Boitier = Boîtier OK
Etat Zone A = OFF
Etat Zone B = OFF
Etat Zone C = OFF
Etat Zone ABC = OFF

Deconnexion au site Somfy Mobile OK

Re: Script alarme Somfy Protexiom 600

Publié : 19 nov. 2016, 11:00
par Seb13
Voici le script complet.

Il faut remplacer :

- dans la ZONE DE MODIFICATION vos codes
- Serveur Somfy @IP
- Serveur Domoticz @IP
- Code utilisateur1

Il faut créer les IDX pour Domoticz, chez moi c'est des interrupteurs, si vous créez un autre type, il faut modifier le script quand je balance les infos sur le serveur Domoticz.

Pour executer c'est toujours :

Pour voir seulement

Code : Tout sélectionner

./EtatSomfyV3.sh -v
Pour l'aide

Code : Tout sélectionner

./EtatSomfyV3.sh -h
Pour activer l'alarme

Code : Tout sélectionner

./EtatSomfyV3.sh --AlarmeON
Pour désactiver l'alarme

Code : Tout sélectionner

./EtatSomfyV3.sh --AlarmeOFF
Pour mettre dans la CronTab c'est toujours
Pour éditer

Code : Tout sélectionner

crontab -e
Ajouter ceci et faire CTRL-x pour sortir avec un Oui

Code : Tout sélectionner

*/10 * * * * sudo /home/pi/domoticz/scripts/shell/EtatSomfyV3.sh -v
Dans Domoticz dans l'interrupteur Alarme Somfy ON/OFF il faut faire edition et mettre dans le script.
Cela va lancer le script pour activer/desactiver l'alarme

Pour ON

Code : Tout sélectionner

script:///home/pi/domoticz/scripts/shell/EtatSomfyV2.sh --AlarmeON
Pour OFF

Code : Tout sélectionner

script:///home/pi/domoticz/scripts/shell/EtatSomfyV2.sh --AlarmeOFF
Voilà Voilà... prochaine étape la liste des équipements, cela va nous permettre d'avoir le détail sur les ouvertures de porte par exemple.
Quelle fenêtre est ouverte ou quel équipement à un problème de pile etc...

Je vous laisse... j'ai du taf :D

Code : Tout sélectionner

#!/bin/bash
#----------------------------------------------------------------------------------------------------------------------------------
# Date : 19/11/2016
# Version : 3
# Description : Script Domoticz pour recuperer les etats des alarmes SOMFY PROTEXIUM 600 et Alarme ON/OFF
# Auteur : Seb13
# Merci au forum easydomoticz
#----------------------------------------------------------------------------------------------------------------------------------

declare -A CarteAuthentification
Debug=False

#----------------------------------------------------------------------------------------------------------------------------------
# ZONE DE MODIFICATION
#----------------------------------------------------------------------------------------------------------------------------------
# Carte d'authentification perso
CarteAuthentification=( ["A1"]="xxxx" ["B1"]="xxx" ["C1"]="xxxx" ["D1"]="xxxx" ["E1"]="xxxx" ["F1"]="xxxx" ["A2"]="xxxx" ["B2"]="xxxx" ["C2"]="xxxx" ["D2"]="xxxx" ["E2"]="xxxx" ["F2"]="xxxx" ["A3"]="xxxx" ["B3"]="xxxx" ["C3"]="xxxx" ["D3"]="xxxx" ["E3"]="xxxx" ["F3"]="xxxx" ["A4"]="xxxx" ["B4"]="xxxx" ["C4"]="xxxx" ["D4"]="xxxx" ["E4"]="xxxx" ["F4"]="xxxx" ["A5"]="xxxx" ["B5"]="xxxx" ["C5"]="xxxx" ["D5"]="xxxx" ["E5"]="xxxx" ["F5"]="xxxx" )

# Adresse IP du serveur Somfy
SrvSomfyIp="http://xxx.xxx.xxx.xxx/"
SrvDomoticzIp="xxx.xxx.xxx.xxx:8080"
# Code Utilisateur1
CodeUtilisateur1=xxxx

# IDX pour Domoticz
AlarmeSomfyPilesIDX=xxx
AlarmeSomfyBoitierIDX=xxx
AlarmeSomfyRadioIDX=xxx
AlarmeSomfyEtatIDX=xxx
AlarmeSomfyPorteIDX=xxx
AlarmeSomfyZoneABCIDX=xxx
#---------------------------------------------------------------------------------------------------------------------------------

# Menu Aide
Aide() {
echo -e "\tScript Domoticz Somfy Protexion 600"
echo -e "\t--help or -h\t\tMenu Aide"
echo -e "\t--view or -v\t\tVerification des etats"
echo -e "\t--AlarmeON \t\tMise en route de l'alarme sur Zone A B C"
echo -e "\t--AlarmeOFF \t\tArret de l'alarme sur Zone A B C"
}

# Script de connexion au site Somfy version Mobile
Connexion_Somfy() {
        # Declaration des URLs du site Somfy Mobile
        UrlMLogin=$SrvSomfyIp"m_login.htm"
        UrlMuEtat=$SrvSomfyIp"mu_etat.htm"
        UrlMLogout=$SrvSomfyIp"m_logout.htm"
        UrlMuPilotage=$SrvSomfyIp"mu_pilotage.htm"

        # Affichage des URLs
        if [ "$Debug" = "True" ]; then
                echo ""
                echo " ********************************* "
                echo " Liste des URLs"
                echo " ********************************* "
                echo " UrlMLogin = "$UrlMLogin
                echo " UrlMuEtat = "$UrlMuEtat
                echo " UrlMLogout = "$UrlMLogout
                echo " UrlMuPilotage = "$UrlMuPilotage
                echo ""
        fi


        # Recuperation du code d'acces apres lecture sur la page MLogin
        if [ "$Debug" = "True" ]; then
                echo ""
                CodeAcces="$(curl $SrvSomfyIp $UrlMLogin | grep -Eoi 'authentification <b>.*</b>')"
                CodeAcces="$(echo "${CodeAcces:20:2}")"
                echo "Code Acces = "$CodeAcces
                echo ""
        else
                        CodeAcces="$(curl -s $SrvSomfyIp $UrlMLogin | grep -Eoi 'authentification <b>.*</b>')"
                        CodeAcces="$(echo "${CodeAcces:20:2}")"
        fi


        # Recuperation du code d'authentification avec le code d'acces
        CodeAuthentification="${CarteAuthentification["$CodeAcces"]}"

        if [ "$Debug" = "True" ]; then
                        echo ""
                echo "Code Authentification = "$CodeAuthentification
                echo ""
        fi

        # Envoi du code utilisateur1 et du code d'authentification dans l'url MLogin pour connexion
        if [ "$Debug" = "True" ]; then
                echo ""
                #curl -L --cookie cjar --cookie-jar cjar --data "password="$CodeUtilisateur1"&key="$CodeAuthentification"&action=Connexion" $UrlMLogin | iconv -f iso8859-1 -t utf-8
                curl -L --cookie cjar --cookie-jar cjar --data "password="$CodeUtilisateur1"&key="$CodeAuthentification"&action=Connexion" $UrlMLogin
                echo ""
        else
                #curl -s -L --cookie cjar --cookie-jar cjar --data "password="$CodeUtilisateur1"&key="$CodeAuthentification"&action=Connexion" $UrlMLogin | iconv -f iso8859-1 -t utf-8 > /dev/null
                curl -s -L --cookie cjar --cookie-jar cjar --data "password="$CodeUtilisateur1"&key="$CodeAuthentification"&action=Connexion" $UrlMLogin > /dev/null
        fi
echo ""
echo "Connexion au site Somfy Mobile OK"
echo ""
}

# Script de deconnexion au site Somfy version Mobile

Deconnexion_Somfy() {
        # Logout du site Somfy
        if [ "$Debug" = "True" ]; then
                echo ""
                #curl -L --cookie cjar --cookie-jar cjar $UrlMLogout | iconv -f iso8859-1 -t utf-8
                curl -L --cookie cjar --cookie-jar cjar $UrlMLogout
                echo ""
        else
                echo ""
                #curl -s -L --cookie cjar --cookie-jar cjar $UrlMLogout | iconv -f iso8859-1 -t utf-8 > /dev/null
                curl -s -L --cookie cjar --cookie-jar cjar $UrlMLogout > /dev/null
                echo ""
        fi
echo ""
echo "Deconnexion au site Somfy Mobile OK"
echo ""
}


# Menu des options du script
while [[ $1 == -* ]]; do
case "$1" in
--help|-h) Aide; exit 0;;
--view|-v) VerifEtat="1"; break;;
--AlarmeON) AlarmeON="1"; break;;
--AlarmeOFF) AlarmeOFF="1"; break;;
--*|-*) shift; break;;
esac
done

# Exection si option -v activee
if [ "$VerifEtat" = "1" ]; then

        # Script de connexion au site Somfy version Mobile
        Connexion_Somfy

        # Lecture de la page MuEtat pour recuperer les etats de l alarme
        if [ "$Debug" = "True" ]; then
                echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
                curl -L --cookie cjar --cookie-jar cjar $UrlMuEtat | iconv -f iso8859-1 -t utf-8
                curl -L --cookie cjar --cookie-jar cjar $UrlMuEtat | iconv -f iso8859-1 -t utf-8 | grep -Eoi 'Porte.*fermée'
                curl -L --cookie cjar --cookie-jar cjar $UrlMuEtat | iconv -f iso8859-1 -t utf-8 | grep -Eoi 'Porte.*ouverte'
                curl -L --cookie cjar --cookie-jar cjar $UrlMuEtat | iconv -f iso8859-1 -t utf-8 | grep -Eoi 'Pile.*OK'
                curl -L --cookie cjar --cookie-jar cjar $UrlMuEtat | iconv -f iso8859-1 -t utf-8 | grep -Eoi 'Pile.*</td>'
                curl -L --cookie cjar --cookie-jar cjar $UrlMuEtat | iconv -f iso8859-1 -t utf-8 | grep -Eoi 'Communication.*</td>'
                curl -L --cookie cjar --cookie-jar cjar $UrlMuEtat | iconv -f iso8859-1 -t utf-8 | grep -Eoi 'Pas.*</td>'
                curl -L --cookie cjar --cookie-jar cjar $UrlMuEtat | iconv -f iso8859-1 -t utf-8 | grep -Eoi 'Boîtier.*</td>'
                curl -L --cookie cjar --cookie-jar cjar $UrlMuEtat | iconv -f iso8859-1 -t utf-8 | grep -Eoi 'zonea.*</td>'
                curl -L --cookie cjar --cookie-jar cjar $UrlMuEtat | iconv -f iso8859-1 -t utf-8 | grep -Eoi 'zoneb.*</td>'
                curl -L --cookie cjar --cookie-jar cjar $UrlMuEtat | iconv -f iso8859-1 -t utf-8 | grep -Eoi 'zonec.*</td>'
                echo ""
        fi

        # Recuperation des etats dans les variables
        EtatPorte="$(curl -s -L --cookie cjar --cookie-jar cjar $UrlMuEtat | iconv -f iso8859-1 -t utf-8 | grep -Eoi 'Porte.*</td>')"
        EtatPorte="$(echo "${EtatPorte:0:24}" | sed s/\<//g)"
        EtatPiles="$(curl -s -L --cookie cjar --cookie-jar cjar $UrlMuEtat | iconv -f iso8859-1 -t utf-8 | grep -Eoi 'Pile.*</td>')"
        EtatPiles="$(echo "${EtatPiles:0:8}")"
        EtatRadio="$(curl -s -L --cookie cjar --cookie-jar cjar $UrlMuEtat | iconv -f iso8859-1 -t utf-8 | grep -Eoi 'Communication.*</td>')"
        EtatRadio="$(echo "${EtatRadio:0:22}")"
        EtatAlarme="$(curl -s -L --cookie cjar --cookie-jar cjar $UrlMuEtat | iconv -f iso8859-1 -t utf-8 | grep -Eoi 'Pas.*</td>')"
        EtatAlarme="$(echo "${EtatAlarme:0:12}")"
        EtatBoitier="$(curl -s -L --cookie cjar --cookie-jar cjar $UrlMuEtat | iconv -f iso8859-1 -t utf-8 | grep -Eoi 'Boîtier.*</td>')"
        EtatBoitier="$(echo "${EtatBoitier:0:10}")"
        EtatZoneA="$(curl -s -L --cookie cjar --cookie-jar cjar $UrlMuEtat | iconv -f iso8859-1 -t utf-8 | grep -Eoi 'zonea.*</td>')"
        EtatZoneA="$(echo "${EtatZoneA:28:3}" | sed s/\<//g)"
        EtatZoneB="$(curl -s -L --cookie cjar --cookie-jar cjar $UrlMuEtat | iconv -f iso8859-1 -t utf-8 | grep -Eoi 'zoneb.*</td>')"
        EtatZoneB="$(echo "${EtatZoneB:28:3}" | sed s/\<//g)"
        EtatZoneC="$(curl -s -L --cookie cjar --cookie-jar cjar $UrlMuEtat | iconv -f iso8859-1 -t utf-8 | grep -Eoi 'zonec.*</td>')"
        EtatZoneC="$(echo "${EtatZoneC:28:3}" | sed s/\<//g)"


        # Affichage des etats
        echo "Etat Porte = "$EtatPorte
        echo "Etat Piles = "$EtatPiles
        echo "Etat Communication Radio = "$EtatRadio
        echo "Etat Alarme = "$EtatAlarme
        echo "Etat Boitier = "$EtatBoitier
        echo "Etat Zone A = "$EtatZoneA
        echo "Etat Zone B = "$EtatZoneB
        echo "Etat Zone C = "$EtatZoneC

        if [ "$EtatZoneA" = "OFF" ] && [ "$EtatZoneB" = "OFF" ] && [ "$EtatZoneC" = "OFF" ]; then
                EtatZoneABC="OFF"
                echo "Etat Zone ABC = "$EtatZoneABC
        fi

        if [ "$EtatZoneA" = "ON" ] && [ "$EtatZoneB" = "ON" ] && [ "$EtatZoneC" = "ON" ]; then
                EtatZoneABC="ON"
                echo "Etat Zone ABC = "$EtatZoneABC
        fi

        # Envoi des etats a Domoticz
        # Etat des piles
        if [ "$Debug" = "True" ]; then
                if [ "$EtatPiles" = "Piles OK" ]; then
                        curl "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyPilesIDX&switchcmd=On"
                else
                        curl "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyPilesIDX&switchcmd=Off"
                fi
        else
                if [ "$EtatPiles" = "Piles OK" ]; then
                        curl -s "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyPilesIDX&switchcmd=On" > /dev/null
                else
                        curl -s "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyPilesIDX&switchcmd=Off" > /dev/null
                fi
        fi

        # Etat Boitier
        if [ "$Debug" = "True" ]; then
                if [ "$EtatBoitier" = "Boîtier OK" ]; then
                        curl "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyBoitierIDX&switchcmd=On"
                else
                        curl "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyBoitierIDX&switchcmd=Off"
                fi
        else
                if [ "$EtatBoitier" = "Boîtier OK" ]; then
                        curl -s "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyBoitierIDX&switchcmd=On" > /dev/null
                else
                        curl -s "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyBoitierIDX&switchcmd=Off" > /dev/null
                fi
        fi

        # Etat Communication Radio
        if [ "$Debug" = "True" ]; then
                if [ "$EtatRadio" = "Communication radio OK" ]; then
                        curl "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyRadioIDX&switchcmd=On"
                else
                        curl "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyRadioIDX&switchcmd=Off"
                fi
        else
                if [ "$EtatRadio" = "Communication radio OK" ]; then
                        curl -s "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyRadioIDX&switchcmd=On" > /dev/null
                else
                        curl -s "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyRadioIDX&switchcmd=Off" > /dev/null
                fi
        fi

        # Etat Alarme Somfy
        if [ "$Debug" = "True" ]; then
                if [ "$EtatAlarme" = "Pas d'alarme" ]; then
                        curl "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyEtatIDX&switchcmd=Off"
                else
                        curl "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyEtatIDX&switchcmd=On"
                fi
        else
                if [ "$EtatAlarme" = "Pas d'alarme" ]; then
                        curl -s "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyEtatIDX&switchcmd=Off" > /dev/null
                else
                        curl -s "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyEtatIDX&switchcmd=On" > /dev/null
                fi
        fi

        # Etat Porte
        if [ "$Debug" = "True" ]; then
                if [ "$EtatPorte" = "Porte ou fenêtre fermée" ]; then
                        curl "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyPorteIDX&switchcmd=Off"
                else
                        curl "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyPorteIDX&switchcmd=On"
                fi
        else
                if [ "$EtatPorte" = "Porte ou fenêtre fermée" ]; then
                        curl -s "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyPorteIDX&switchcmd=Off" > /dev/null
                else
                        curl -s "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyPorteIDX&switchcmd=On" > /dev/null
                fi
        fi
        # Etat Zone ABC
        if [ "$Debug" = "True" ]; then
                if [ "$EtatZoneABC" = "OFF" ]; then
                        curl "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyZoneABCIDX&switchcmd=Off"
                else
                        curl "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyZoneABCIDX&switchcmd=On"
                fi
        else
                if [ "$EtatZoneABC" = "OFF" ]; then
                        curl -s "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyZoneABCIDX&switchcmd=Off" > /dev/null
                else
                        curl -s "http://$SrvDomoticzIp/json.htm?type=command&param=switchlight&idx=$AlarmeSomfyZoneABCIDX&switchcmd=On" > /dev/null
                fi
        fi



        # Logout du site Somfy
        Deconnexion_Somfy
fi

if [ "$AlarmeON" = "1" ]; then
        echo "Alarme en fonction - script à faire"

        # Script de connexion au site Somfy version Mobile
        Connexion_Somfy

        # curl -L --cookie cjar --cookie-jar cjar $UrlMuPilotage | iconv -f iso8859-1 -t utf-8

        curl -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&zone=Marche%20A%20B%20C" $UrlMuPilotage | iconv -f iso8859-1 -t utf-8

        Deconnexion_Somfy



fi
if [ "$AlarmeOFF" = "1" ]; then
        echo "Alarme en arrêt - script à faire"

        # Script de connexion au site Somfy version Mobile
        Connexion_Somfy

        # curl -L --cookie cjar --cookie-jar cjar $UrlMuPilotage | iconv -f iso8859-1 -t utf-8

        curl -L --cookie cjar --cookie-jar cjar --data "hidden=hidden&zone=Arr%EAt%20A%20B%20C" $UrlMuPilotage | iconv -f iso8859-1 -t utf-8

        Deconnexion_Somfy
fi

Re: Script alarme Somfy Protexiom 600

Publié : 19 nov. 2016, 12:53
par n1c0l45
voila ce que j'ai trouvé pour la 5000

Code : Tout sélectionner

UrlMLogin=$SrvSomfyIp"fr/login.htm"
UrlMuEtat=$SrvSomfyIp"fr/u_listelmt.htm"
UrlMLogout=$SrvSomfyIp"logout.htm"
UrlMuPilotage=$SrvSomfyIp"fr/u_pilotage.htm"
Le POST data de connexion est le suivant

Code : Tout sélectionner

login=u&password=XXXX&key=XXXX&btn_login=Connexion

mise en marche de toutes les zones

Code : Tout sélectionner

 on se connecte à la page 
http://IP_ALARME/fr/u_pilotage.htm
et on a ce "POST data"
hidden=hidden&btn_zone_on_ABC=Marche+A+B+C
Arret de toutes les zones

Code : Tout sélectionner

 on se connecte à la page 
 http://IP_ALARME/fr/u_pilotage.htm
et on a ce "POST data"
hidden=hidden&btn_zone_off_ABC=Arr%C3%AAt+A+B+C

Re: Script alarme Somfy Protexiom 600

Publié : 19 nov. 2016, 17:01
par jcjames_13009
n1c0l45 a écrit :voila ce que j'ai trouvé pour la 5000

Code : Tout sélectionner

UrlMLogin=$SrvSomfyIp"fr/login.htm"
UrlMuEtat=$SrvSomfyIp"fr/u_listelmt.htm"
UrlMLogout=$SrvSomfyIp"logout.htm"
UrlMuPilotage=$SrvSomfyIp"fr/u_pilotage.htm"
Le POST data de connexion est le suivant

Code : Tout sélectionner

login=u&password=XXXX&key=XXXX&btn_login=Connexion

mise en marche de toutes les zones

Code : Tout sélectionner

 on se connecte à la page 
http://IP_ALARME/fr/u_pilotage.htm
et on a ce "POST data"
hidden=hidden&btn_zone_on_ABC=Marche+A+B+C
Arret de toutes les zones

Code : Tout sélectionner

 on se connecte à la page 
 http://IP_ALARME/fr/u_pilotage.htm
et on a ce "POST data"
hidden=hidden&btn_zone_off_ABC=Arr%C3%AAt+A+B+C
Salut

pour completer ce qu'a trouvé n1c0l45

Mise en marche par Zone

Code : Tout sélectionner

hidden=hidden&hidden=hidden&btn_zone_on_A=Marche A
hidden=hidden&hidden=hidden&btn_zone_on_B=Marche B
hidden=hidden&hidden=hidden&btn_zone_on_C=Marche C
Rappel l'arrêt par zone n'est pas possible

Pour connaitre l'état du système il faut utiliser l'url suivant

Code : Tout sélectionner

http://IP_ALARME/status.xml
Les info sont revoyées au format xml

Code : Tout sélectionner

<?xml version="1.0" encoding="iso-8859-15"?>
<response>

<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/Fenetre
<defaut3>ok</defaut3>				-> Alarme
<defaut4>ok</defaut4>				-> Boitier

<gsm>GSM connecté au réseau</gsm> 	-> GSM
<recgsm>4</recgsm>					-> Signal
<opegsm>"Orange</opegsm>			-> Operateur

<camera>disabled</camera>			-> Camera
</response>
Mais je n'ai pas encore trouvé comment les récupérer...

@+

JC

Re: Script alarme Somfy Protexiom 600

Publié : 19 nov. 2016, 18:44
par n1c0l45
Cool ça avance !
Maintenant faut trouver comment utiliser tout cela !

Re: Script alarme Somfy Protexiom 600

Publié : 20 nov. 2016, 22:18
par Seb13
Hello à tous,

J'ai commencé le script pour récupérer la liste des éléments et l'état.

Cela fonctionne chez moi, cela me donne la liste des éléments.
A ajouter dans mon code v3.

Code : Tout sélectionner

# Declaration des URLs du site Somfy
UrluListeElement=$SrvSomfyIp"u_listelmt.htm"


Connexion_Somfy

# On recup la liste des elements par la recherche elt_name
ListeElement="$(curl -L --cookie cjar --cookie-jar cjar $UrluListeElement | iconv -f iso8859-1 -t utf-8 | grep 'var elt_name')"
# On supprime les 21 premiers caracteres et les 2 derniers
ListeElement="$(echo "${ListeElement:21:-2}")"
# On remplace les " par rien on les supprime
ListeElement="$(echo "$ListeElement" | sed s/\"//g)"
# On remplace ", " par "," on supprime les espaces entre les virgules
ListeElement="$(echo "$ListeElement" | sed s/\,\ /\,/g)"
# On doit avoir la liste des elements sans , et avec des ' a la place des "
echo "Liste des elements = "$ListeElement
# On declare la virgule comme element separateur
IFS=","
# On alimente la variable tableau avec les elements separes par une virgule
TabListeElement=($ListeElement)
# On affiche les elements du tableau
for TabLecture in ${TabListeElement[*]}
do
echo $TabLecture;
done

Deconnexion_Somfy
Quand on a compris mon fonctionnement, il suffit de rechercher les états pour chaque elements et le mettre dans un tableau aussi.
J'ai passé le code mais j'avance chez moi aussi.