Modération
Publié : 24 mai 2021, 21:22
Fefeld, nous sommes sur un forum francophone. Ce serait mieux si tu pouvais rédiger tes messages en français comme pour tes posts précédents. Merci
Reprenez le contrôle de votre domotique
https://easydomoticz.com/forum/
Error: WebServer PO exception occurred : 'stoull'
Code : Tout sélectionner
$login_url = "https://id.eu.worx.com/oauth/token";
Code : Tout sélectionner
$postinfo["client_id"] = "150da4d2-bb44-433b-9429-3773adc70a2a";
$postinfo["grant_type"] = "password";
$postinfo["scope"] = "*";
$postinfo["username"] =
$postinfo["password"] =
Code : Tout sélectionner
$state = $json["last_status"]["payload"]['dat']['ls'] * 10;
$temperature = $json["last_status"]["payload"]['dat']['bt']['t'];
$current_distance = $json["last_status"]["payload"]['dat']['st']['d'];
$working_time = $json["last_status"]["payload"]['dat']['st']['wt'];
$blade_time = $json["last_status"]["payload"]['dat']['st']['b'];
$nb_charge = $json["last_status"]["payload"]['dat']['bt']['nr'];
$tension = $json["last_status"]["payload"]['dat']['bt']['v'];
$batteryP = $json["last_status"]["payload"]['dat']['bt']['p'];
Bonjour,Hober Mallow a écrit : 25 mai 2020, 22:22 Bonsoir
Je vous propose quelques évolutions sur le script :
- Variable au début du script (login/mdp/idx/serial...)
- Ajout pourcentage charge de la batterie
- Utilisation de Devices type Alerte pour le statut et les erreures, j'ai arbitrarement classifié les alertes
- j'ai détaillé les dummy que je propose
- mise à jour du statut ou des erreures uniquement si ils change (facilita la lecutre des log)
Bonne soiréeCode : Tout sélectionner
#!/bin/sh ########################################################################## ### Script de mise a jour des statuts Tondeuse Landroide dans Domoticz ### ### 2020 05 25 ### ########################################################################## ### ### Mettre les bonnes informations ci-dessous ### ########################################################################## ### Compte WORX - Format Mail LOGIN_WORX=xxxxxxx@xxxxxxx ########################################################################## ### MdP WORX MDP_WORX=xxxxxxxx ########################################################################## ### Numero de serie de la tondeuse SERIAL_LANDROID=xxxxxxxxxxxxxxxxxxxxxxxxxx ########################################################################## ### Adresse ip Domoticz ADRESSE_IP=xxx.xxx.xxx.xxx ########################################################################## ### Adresse port Domoticz ADRESSE_PORT=xxxx ########################################################################## ### ID Device Domoticz - Distance parcouru - Type Dummy, Custom Sensor, Echelle Km ID_DISTANCE=xxxx ########################################################################## ### ID Device Domoticz - Temps de Fonctionnement - Type Dummy, Custom Sensor, Echelle Heures ID_TEMPS_TRAVAIL=xxxx ########################################################################## ### ID Device Domoticz - Temps de Lame - Type Dummy, Custom Sensor, Echelle Heures ID_TEMPS_LAME=xxxx ########################################################################## ### ID Device Domoticz - Nombre Cycle Batterie - Type Dummy, Compteur ID_N_BATTERIE=xxxx ########################################################################## ### ID Device Domoticz - Tension de la Batterie - Type Dummy, Tension ID_V_BATTERIE=xxxx ########################################################################## ### ID Device Domoticz - Temperature de la Batterie - Dummy Custom sensor, Temperature ID_TEMP_BATTERIE=xxxx ########################################################################## ### ID Device Domoticz - Pourcentage charge de la Batterie - Dummy Custom sensor, pourcentage ID_POURCENTAGE_BATTERIE=xxxx ########################################################################## ### ID Device Domoticz - Statut Tondeuse - Dummy Custom sensor, Alert ID_STATUT=xxxx ########################################################################## ### ID Device Domoticz - Erreur Tondeuse - Dummy Custom sensor, Alert ID_ERREUR=xxxx ########################################################################## PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games TOKEN=$(curl -v -X POST -d "{\"client_id\": 1, \"grant_type\": \"password\", \"scope\": \"*\", \"client_secret\": \"nCH3A0WvMYn66vGorjSrnGZ2YtjQWDiCvjg7jNxK\", \"username\": \"$LOGIN_WORX\", \"password\":\"$MDP_WORX\"}" -H 'Content-Type: application/json' https://api.worxlandroid.com/api/v2/oauth/token | jq -r '.access_token') curl -X GET -H 'Accept: application/json' -H 'Content-Type: application/json' -H "Authorization: Bearer $TOKEN" "https://api.worxlandroid.com/api/v2/product-items/${SERIAL_LANDROID}/status" > /home/pi/domoticz/scripts/shell/worx_curl2.json curl -X GET -H 'Accept: application/json' -H 'Content-Type: application/json' -H "Authorization: Bearer $TOKEN" https://api.worxlandroid.com/api/v2/product-items > /home/pi/domoticz/scripts/shell/worx_curl1.json ## Distance parcouru - Type Dummy, Custom Sensor, Echelle Km DISTANCE_COVERED=`cat /home/pi/domoticz/scripts/shell/worx_curl1.json | jq '.[]|.distance_covered'/1000` echo "EXEC" exec="http://${ADRESSE_IP}:${ADRESSE_PORT}/json.htm?type=command¶m=udevice&idx=${ID_DISTANCE}&svalue=${DISTANCE_COVERED}" echo $exec curl $exec ## Temps de Fonctionnement - Type Dummy, Custom Sensor, Echelle Heures MOWER_WORKED=`cat /home/pi/domoticz/scripts/shell/worx_curl1.json | jq '.[]|.mower_work_time'/60` echo "EXEC" exec="http://${ADRESSE_IP}:${ADRESSE_PORT}/json.htm?type=command¶m=udevice&idx=${ID_TEMPS_TRAVAIL}&svalue=${MOWER_WORKED}" echo $exec curl $exec ## Temps de Lame - Type Dummy, Custom Sensor, Echelle Heures BLADE_WORKED=`cat /home/pi/domoticz/scripts/shell/worx_curl1.json | jq '.[]|.blade_work_time'/60` echo "EXEC" exec="http://${ADRESSE_IP}:${ADRESSE_PORT}/json.htm?type=command¶m=udevice&idx=${ID_TEMPS_LAME}&svalue=${BLADE_WORKED}" echo $exec curl $exec ## Temperature de la Batterie - Dummy Custom sensor, Temperature TEMP_BAT=`cat /home/pi/domoticz/scripts/shell/worx_curl2.json | jq .dat.bt."t"` echo "EXEC" exec="http://${ADRESSE_IP}:${ADRESSE_PORT}/json.htm?type=command¶m=udevice&idx=${ID_TEMP_BATTERIE}&svalue=${TEMP_BAT}" echo $exec curl $exec ## Nombre Cycle Batterie - Type Dummy, Compteur NB_CHARGE=`cat /home/pi/domoticz/scripts/shell/worx_curl2.json | jq .dat.bt."nr"` echo "EXEC" exec="http://${ADRESSE_IP}:${ADRESSE_PORT}/json.htm?type=command¶m=udevice&idx=${ID_N_BATTERIE}&svalue=${NB_CHARGE}" echo $exec curl $exec ## Tension batterie, Dummy Custom sensor, Tension TENSION_BAT=`cat /home/pi/domoticz/scripts/shell/worx_curl2.json | jq .dat.bt."v"` echo "EXEC" exec="http://${ADRESSE_IP}:${ADRESSE_PORT}/json.htm?type=command¶m=udevice&idx=${ID_V_BATTERIE}&svalue=${TENSION_BAT}" echo $exec curl $exec ## Pourcentage batterie, Dummy Custom sensor, pourcentage POURCENTAGE_BAT=`cat /home/pi/domoticz/scripts/shell/worx_curl2.json | jq .dat.bt."p"` echo "EXEC" exec="http://${ADRESSE_IP}:${ADRESSE_PORT}/json.htm?type=command¶m=udevice&idx=${ID_POURCENTAGE_BATTERIE}&svalue=${POURCENTAGE_BAT}" echo $exec curl $exec ## Statuts Tondeuse - Dummy Custom sensor, Alert STATE_STATE=`cat /home/pi/domoticz/scripts/shell/worx_curl2.json | jq '.dat.ls'` case $STATE_STATE in 0) ALERT=0;TEXT_STATE=Inactif;; 1) ALERT=1;TEXT_STATE=Maison;; 2) ALERT=1;TEXT_STATE=Démarrage;; 3) ALERT=1;TEXT_STATE=Départ%20maison;; 4) ALERT=1;TEXT_STATE=Suit%20le%20câble;; 5) ALERT=2;TEXT_STATE=Recherche%20la%20base;; 6) ALERT=2;TEXT_STATE=Recherche%20le%20câble;; 7) ALERT=1;TEXT_STATE=Tonte;; 8) ALERT=4;TEXT_STATE=Soulevée;; 9) ALERT=4;TEXT_STATE=Bloquée;; 10) ALERT=4;TEXT_STATE=Lames%20bloquées;; 11) ALERT=3;TEXT_STATE=Debug;; 12) ALERT=3;TEXT_STATE=Remote%20control;; 30) ALERT=1;TEXT_STATE=Retour%20maison;; 31) ALERT=1;TEXT_STATE=Création%20zones%20tonte;; 32) ALERT=1;TEXT_STATE=Coupe%20la%20bordure;; * ) ALERT=0;TEXT_STATE=Inconnu;; esac ACTUAL_TEXT_STATE=$(curl -s "http://$ADRESSE_IP:$ADRESSE_PORT/json.htm?type=devices&rid=$ID_STATUT" | grep 'Data'| cut -d'"' -f 4 | sed 's/ /%20/g' | sed 's/\\u00e9/é/' | sed 's/\\u00e2/â/') if [ "$ACTUAL_TEXT_STATE" != "$TEXT_STATE" ] then exec="http://${ADRESSE_IP}:${ADRESSE_PORT}/json.htm?type=command¶m=udevice&idx=${ID_STATUT}&nvalue=${ALERT}&svalue=${TEXT_STATE}" echo $exec curl $exec fi ## Erreur Tondeuse - Dummy Custom sensor, Alert LANDROID_ERROR=`cat /home/pi/domoticz/scripts/shell/worx_curl2.json | jq '.dat.le'` case $LANDROID_ERROR in 0) ALERT=1;TEXT_ERROR=RAS;; 1) ALERT=4;TEXT_ERROR=Bloquée;; 2) ALERT=4;TEXT_ERROR=Soulevée;; 3) ALERT=4;TEXT_ERROR=Câble%20non%20trouvé;; 4) ALERT=4;TEXT_ERROR=En%20dehors%20des%20limites;; 5) ALERT=2;TEXT_ERROR=Délai%20pluie;; 6) ALERT=3;TEXT_ERROR=Fermer%20capot%20pour%20tondre;; 7) ALERT=3;TEXT_ERROR=Fermer%20capot%20pour%20retour%20maison;; 8) ALERT=4;TEXT_ERROR=Moteur%20lames%20bloqué;; 9) ALERT=4;TEXT_ERROR=Moteur%20roues%20bloqué;; 10) ALERT=4;TEXT_ERROR=Timeout%20après%20blocage;; 11) ALERT=4;TEXT_ERROR=Renversée;; 12) ALERT=3;TEXT_ERROR=Batterie%20faible;; 13) ALERT=4;TEXT_ERROR=Câble%20inversé;; 14) ALERT=4;TEXT_ERROR=Erreur%20charge%20batterie;; 15) ALERT=4;TEXT_ERROR=Delai%20recherche%20station%20dépassé;; * ) ALERT=0;TEXT_ERROR=Inconnu;; esac ACTUAL_TEXT_ERROR=$(curl -s "http://$ADRESSE_IP:$ADRESSE_PORT/json.htm?type=devices&rid=$ID_ERREUR" | grep 'Data'| cut -d'"' -f 4 | sed 's/ /%20/g'| sed 's/\\u00e9/é/' | sed 's/\\u00e2/â/') if [ "$ACTUAL_TEXT_ERROR" != "$TEXT_ERROR" ] then exec="http://${ADRESSE_IP}:${ADRESSE_PORT}/json.htm?type=command¶m=udevice&idx=${ID_ERREUR}&nvalue=${ALERT}&svalue=${TEXT_ERROR}" echo $exec curl $exec fi
Code : Tout sélectionner
#!/bin/sh
##########################################################################
### Script de mise a jour des statuts Tondeuse Landroide dans Domoticz ###
### 2023 04 23 ###
##########################################################################
###
### Mettre les bonnes informations ci-dessous
###
##########################################################################
### Compte WORX - Format Mail
LOGIN_WORX=xxxxxxxxxx
##########################################################################
### MdP WORX
MDP_WORX=xxxxxxxxxx
##########################################################################
### Numero de serie de la tondeuse
SERIAL_LANDROID=xxxxxxxxxxx
##########################################################################
### MAC Adresse de la tondeuse
MAC_LANDROID=xxxxxxxxxxxx
##########################################################################
### Adresse ip Domoticz
ADRESSE_IP=0.0.0.0
##########################################################################
### Adresse port Domoticz
ADRESSE_PORT=8080
##########################################################################
### Chemin du scripts, ne pas oublier de créer le répertoire shell
PATH_SCRIPT=
##########################################################################
### ID Device Domoticz - Distance parcouru - Type Dummy, Custom Sensor, Echelle Km
ID_DISTANCE=xxxx
##########################################################################
### ID Device Domoticz - Temps de Fonctionnement - Type Dummy, Custom Sensor, Echelle Heures
ID_TEMPS_TRAVAIL=xxxxx
##########################################################################
### ID Device Domoticz - Temps de Lame - Type Dummy, Custom Sensor, Echelle Heures
ID_TEMPS_LAME=xxxx
##########################################################################
### ID Device Domoticz - Nombre Cycle Batterie - Type Dummy, Compteur
ID_N_BATTERIE=xxxx
##########################################################################
### ID Device Domoticz - Tension de la Batterie - Type Dummy, Tension
ID_V_BATTERIE=xxxx
##########################################################################
### ID Device Domoticz - Temperature de la Batterie - Dummy Custom sensor, Temperature
ID_TEMP_BATTERIE=xxxx
##########################################################################
### ID Device Domoticz - Pourcentage charge de la Batterie - Dummy Custom sensor, pourcentage
ID_POURCENTAGE_BATTERIE=xxxx
##########################################################################
### ID Device Domoticz - Statut Tondeuse - Dummy Custom sensor, Alert
ID_STATUT=xxxx
##########################################################################
### ID Device Domoticz - Erreur Tondeuse - Dummy Custom sensor, Alert
ID_ERREUR=xxxx
##########################################################################
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
TOKEN=$(curl -v -X POST -d "{\"client_id\": \"150da4d2-bb44-433b-9429-3773adc70a2a\", \"grant_type\": \"password\", \"scope\": \"*\", \"client_secret\": \"nCH3A0WvMYn66vGorjSrnGZ2YtjQWDiCvjg7jNxK\", \"username\": \"$LOGIN_WORX\", \"password\":\"$MDP_WORX\"}" -H 'Content-Type: application/json' https://id.eu.worx.com/oauth/token | jq -r '.access_token')
"landroid.sh" 178 lines, 8643 bytes
TOKEN=$(curl -v -X POST -d "{\"client_id\": \"150da4d2-bb44-433b-9429-3773adc70a2a\", \"grant_type\": \"password\", \"scope\": \"*\", \"client_secret\": \"nCH3A0WvMYn66vGorjSrnGZ2YtjQWDiCvjg7jNxK\", \"username\": \"$LOGIN_WORX\", \"password\":\"$MDP_WORX\"}" -H 'Content-Type: application/json' https://id.eu.worx.com/oauth/token | jq -r '.access_token')
curl -X GET -H 'Accept: application/json' -H 'Content-Type: application/json' -H "Authorization: Bearer $TOKEN" "https://api.worxlandroid.com/api/v2/product-items/$SERIAL_LANDROID?status=1&mac_address=$MAC_LANDROID" > $PATH_SCRIPT/shell/worx_curl2.json
curl -X GET -H 'Accept: application/json' -H 'Content-Type: application/json' -H "Authorization: Bearer $TOKEN" https://api.worxlandroid.com/api/v2/product-items > $PATH_SCRIPT/shell/worx_curl1.json
## Distance parcouru - Type Dummy, Custom Sensor, Echelle Km
DISTANCE_COVERED=`cat $PATH_SCRIPT/shell/worx_curl1.json | jq '.[]|.distance_covered'/1000`
echo "EXEC"
exec="http://${ADRESSE_IP}:${ADRESSE_PORT}/json.htm?type=command¶m=udevice&idx=${ID_DISTANCE}&svalue=${DISTANCE_COVERED}"
echo $exec
curl $exec
## Temps de Fonctionnement - Type Dummy, Custom Sensor, Echelle Heures
MOWER_WORKED=`cat $PATH_SCRIPT/shell/worx_curl1.json | jq '.[]|.mower_work_time'/60`
echo "EXEC"
exec="http://${ADRESSE_IP}:${ADRESSE_PORT}/json.htm?type=command¶m=udevice&idx=${ID_TEMPS_TRAVAIL}&svalue=${MOWER_WORKED}"
echo $exec
curl $exec
## Temps de Lame - Type Dummy, Custom Sensor, Echelle Heures
BLADE_WORKED=`cat $PATH_SCRIPT/shell/worx_curl1.json | jq '.[]|.blade_work_time'/60`
echo "EXEC"
exec="http://${ADRESSE_IP}:${ADRESSE_PORT}/json.htm?type=command¶m=udevice&idx=${ID_TEMPS_LAME}&svalue=${BLADE_WORKED}"
echo $exec
curl $exec
## Temperature de la Batterie - Dummy Custom sensor, Temperature
TEMP_BAT=`cat $PATH_SCRIPT/shell/worx_curl2.json | jq .last_status.payload.dat.bt."t"`
echo "EXEC"
exec="http://${ADRESSE_IP}:${ADRESSE_PORT}/json.htm?type=command¶m=udevice&idx=${ID_TEMP_BATTERIE}&svalue=${TEMP_BAT}"
echo $exec
curl $exec
## Nombre Cycle Batterie - Type Dummy, Compteur
NB_CHARGE=`cat $PATH_SCRIPT/shell/worx_curl2.json | jq .last_status.payload.dat.bt.nr`
echo "EXEC"
exec="http://${ADRESSE_IP}:${ADRESSE_PORT}/json.htm?type=command¶m=udevice&idx=${ID_N_BATTERIE}&svalue=${NB_CHARGE}"
echo $exec
curl $exec
## Tension batterie, Dummy Custom sensor, Tension
TENSION_BAT=`cat $PATH_SCRIPT/shell/worx_curl2.json | jq .last_status.payload.dat.bt."v"`
echo "EXEC"
exec="http://${ADRESSE_IP}:${ADRESSE_PORT}/json.htm?type=command¶m=udevice&idx=${ID_V_BATTERIE}&svalue=${TENSION_BAT}"
echo $exec
curl $exec
## Pourcentage batterie, Dummy Custom sensor, pourcentage
POURCENTAGE_BAT=`cat $PATH_SCRIPT/shell/worx_curl2.json | jq .last_status.payload.dat.bt."p"`
echo "EXEC"
exec="http://${ADRESSE_IP}:${ADRESSE_PORT}/json.htm?type=command¶m=udevice&idx=${ID_POURCENTAGE_BATTERIE}&svalue=${POURCENTAGE_BAT}"
echo $exec
curl $exec
## Statuts Tondeuse - Dummy Custom sensor, Alert
STATE_STATE=`cat $PATH_SCRIPT/shell/worx_curl2.json | jq '.last_status.payload.dat.ls'`
case $STATE_STATE in
0) ALERT=0;TEXT_STATE=Inactif;;
1) ALERT=1;TEXT_STATE=Maison;;
2) ALERT=1;TEXT_STATE=Démarrage;;
3) ALERT=1;TEXT_STATE=Départ%20maison;;
4) ALERT=1;TEXT_STATE=Suit%20le%20câble;;
3) ALERT=1;TEXT_STATE=Départ%20maison;;
4) ALERT=1;TEXT_STATE=Suit%20le%20câble;;
5) ALERT=2;TEXT_STATE=Recherche%20la%20base;;
6) ALERT=2;TEXT_STATE=Recherche%20le%20câble;;
7) ALERT=1;TEXT_STATE=Tonte;;
8) ALERT=4;TEXT_STATE=Soulevée;;
9) ALERT=4;TEXT_STATE=Bloquée;;
10) ALERT=4;TEXT_STATE=Lames%20bloquées;;
11) ALERT=3;TEXT_STATE=Debug;;
12) ALERT=3;TEXT_STATE=Remote%20control;;
30) ALERT=1;TEXT_STATE=Retour%20maison;;
31) ALERT=1;TEXT_STATE=Création%20zones%20tonte;;
32) ALERT=1;TEXT_STATE=Coupe%20la%20bordure;;
* ) ALERT=0;TEXT_STATE=Inconnu;;
esac
ACTUAL_TEXT_STATE=$(curl -s "http://$ADRESSE_IP:$ADRESSE_PORT/json.htm?type=devices&rid=$ID_STATUT" | grep 'Data'| cut -d'"' -f 4 | sed 's/ /%20/g' | sed 's/\\u00e9/é/' | sed 's/\\u00e2/â/')
if [ "$ACTUAL_TEXT_STATE" != "$TEXT_STATE" ]
then
exec="http://${ADRESSE_IP}:${ADRESSE_PORT}/json.htm?type=command¶m=udevice&idx=${ID_STATUT}&nvalue=${ALERT}&svalue=${TEXT_STATE}"
echo $exec
curl $exec
fi
## Erreur Tondeuse - Dummy Custom sensor, Alert
LANDROID_ERROR=`cat $PATH_SCRIPT/shell/worx_curl2.json | jq '.last_status.payload.dat.le'`
case $LANDROID_ERROR in
0) ALERT=1;TEXT_ERROR=RAS;;
1) ALERT=4;TEXT_ERROR=Bloquée;;
2) ALERT=4;TEXT_ERROR=Soulevée;;
3) ALERT=4;TEXT_ERROR=Câble%20non%20trouvé;;
4) ALERT=4;TEXT_ERROR=En%20dehors%20des%20limites;;
5) ALERT=2;TEXT_ERROR=Délai%20pluie;;
6) ALERT=3;TEXT_ERROR=Fermer%20capot%20pour%20tondre;;
7) ALERT=3;TEXT_ERROR=Fermer%20capot%20pour%20retour%20maison;;
8) ALERT=4;TEXT_ERROR=Moteur%20lames%20bloqué;;
9) ALERT=4;TEXT_ERROR=Moteur%20roues%20bloqué;;
10) ALERT=4;TEXT_ERROR=Timeout%20après%20blocage;;
11) ALERT=4;TEXT_ERROR=Renversée;;
12) ALERT=3;TEXT_ERROR=Batterie%20faible;;
13) ALERT=4;TEXT_ERROR=Câble%20inversé;;
14) ALERT=4;TEXT_ERROR=Erreur%20charge%20batterie;;
15) ALERT=4;TEXT_ERROR=Delai%20recherche%20station%20dépassé;;
* ) ALERT=0;TEXT_ERROR=Inconnu;;
esac
ACTUAL_TEXT_ERROR=$(curl -s "http://$ADRESSE_IP:$ADRESSE_PORT/json.htm?type=devices&rid=$ID_ERREUR" | grep 'Data'| cut -d'"' -f 4 | sed 's/ /%20/g'| sed 's/\\u00e9/é/' | sed 's/\\u00e2/â/')
if [ "$ACTUAL_TEXT_ERROR" != "$TEXT_ERROR" ]
then
exec="http://${ADRESSE_IP}:${ADRESSE_PORT}/json.htm?type=command¶m=udevice&idx=${ID_ERREUR}&nvalue=${ALERT}&svalue=${TEXT_ERROR}"
echo $exec
curl $exec
fiCode : Tout sélectionner
https://id.eu.worx.com/oauth/tokenCode : Tout sélectionner
https://id.worx.com/oauth/token