Script onduleur
Publié : 04 avr. 2018, 16:39
Bonjour,
Afin de sécuriser mon PI3, je viens de le basculer sur un onduleur que j'avais en stock.
L'installation s'est bien passée et j'accède aux caractéristiques de l'onduleur avec la commande "apcaccess" qui me retourne :
pi@raspberrypi:~/domoticz/scripts $ apcaccess
APC : 001,035,0905
DATE : 2018-04-04 16:26:48 +0200
HOSTNAME : raspberrypi
VERSION : 3.14.14 (31 May 2016) debian
UPSNAME : myups
CABLE : USB Cable
DRIVER : USB UPS Driver
UPSMODE : Stand Alone
STARTTIME: 2018-04-03 17:21:59 +0200
MODEL : Back-UPS ES 700G
STATUS : ONLINE
LINEV : 232.0 Volts
LOADPCT : 0.0 Percent
BCHARGE : 100.0 Percent
TIMELEFT : 42.8 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME : 0 Seconds
SENSE : Medium
LOTRANS : 180.0 Volts
HITRANS : 266.0 Volts
ALARMDEL : 30 Seconds
BATTV : 13.6 Volts
LASTXFER : Unacceptable line voltage changes
NUMXFERS : 7
XONBATT : 2018-04-04 13:50:01 +0200
TONBATT : 0 Seconds
CUMONBATT: 332 Seconds
XOFFBATT : 2018-04-04 13:50:01 +0200
STATFLAG : 0x05000008
SERIALNO : 5B1109T26626
BATTDATE : 2011-02-25
NOMINV : 230 Volts
NOMBATTV : 12.0 Volts
FIRMWARE : 871.O2 .I USB FW:O2
END APC : 2018-04-04 16:26:49 +0200
La valeur STATUS prend les valeurs ONLINE (en ligne) et ONBAT (sur batterie).
J'ai réalisé le script ci-dessous pour mettre à jour mon interface Domoticz (dans un dispositif de type Alert Idx 529)
#!/bin/bash
STATUS="$(sudo apcaccess|grep STATUS|awk -F ":" '{print $2}')"
echo $STATUS;
#couleurs : 0 – gris; 1 – vert; 2 – jaune caca d’oie; 3 – orange; 4 – rouge
if [ $STATUS = "ONLINE" ]
then
wget "http://192.168.2.12:8080/json.htm?type= ... ue=$STATUS"
else
wget "http://192.168.2.12:8080/json.htm?type= ... ue=$STATUS"
fi
Ce script fonctionne très bien.
J'aimerai à présent l'intégrer dans un script LUA de type time (exécuté toutes les minutes).
Si je passe par la commande :
os.execute('/home/pi/domoticz/scripts/onduleur.sh')
le script LUA me retourne "Warning!, lua script /home/pi/domoticz/scripts/lua/script_time_onduleur.lua has been running for more than 10 seconds".
Question : Comment écrire mon script LUA pour mettre à jour mon dispositif de type alert toutes les minutes ?
Merci pour votre aide.
Afin de sécuriser mon PI3, je viens de le basculer sur un onduleur que j'avais en stock.
L'installation s'est bien passée et j'accède aux caractéristiques de l'onduleur avec la commande "apcaccess" qui me retourne :
pi@raspberrypi:~/domoticz/scripts $ apcaccess
APC : 001,035,0905
DATE : 2018-04-04 16:26:48 +0200
HOSTNAME : raspberrypi
VERSION : 3.14.14 (31 May 2016) debian
UPSNAME : myups
CABLE : USB Cable
DRIVER : USB UPS Driver
UPSMODE : Stand Alone
STARTTIME: 2018-04-03 17:21:59 +0200
MODEL : Back-UPS ES 700G
STATUS : ONLINE
LINEV : 232.0 Volts
LOADPCT : 0.0 Percent
BCHARGE : 100.0 Percent
TIMELEFT : 42.8 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME : 0 Seconds
SENSE : Medium
LOTRANS : 180.0 Volts
HITRANS : 266.0 Volts
ALARMDEL : 30 Seconds
BATTV : 13.6 Volts
LASTXFER : Unacceptable line voltage changes
NUMXFERS : 7
XONBATT : 2018-04-04 13:50:01 +0200
TONBATT : 0 Seconds
CUMONBATT: 332 Seconds
XOFFBATT : 2018-04-04 13:50:01 +0200
STATFLAG : 0x05000008
SERIALNO : 5B1109T26626
BATTDATE : 2011-02-25
NOMINV : 230 Volts
NOMBATTV : 12.0 Volts
FIRMWARE : 871.O2 .I USB FW:O2
END APC : 2018-04-04 16:26:49 +0200
La valeur STATUS prend les valeurs ONLINE (en ligne) et ONBAT (sur batterie).
J'ai réalisé le script ci-dessous pour mettre à jour mon interface Domoticz (dans un dispositif de type Alert Idx 529)
#!/bin/bash
STATUS="$(sudo apcaccess|grep STATUS|awk -F ":" '{print $2}')"
echo $STATUS;
#couleurs : 0 – gris; 1 – vert; 2 – jaune caca d’oie; 3 – orange; 4 – rouge
if [ $STATUS = "ONLINE" ]
then
wget "http://192.168.2.12:8080/json.htm?type= ... ue=$STATUS"
else
wget "http://192.168.2.12:8080/json.htm?type= ... ue=$STATUS"
fi
Ce script fonctionne très bien.
J'aimerai à présent l'intégrer dans un script LUA de type time (exécuté toutes les minutes).
Si je passe par la commande :
os.execute('/home/pi/domoticz/scripts/onduleur.sh')
le script LUA me retourne "Warning!, lua script /home/pi/domoticz/scripts/lua/script_time_onduleur.lua has been running for more than 10 seconds".
Question : Comment écrire mon script LUA pour mettre à jour mon dispositif de type alert toutes les minutes ?
Merci pour votre aide.