Page 1 sur 1

[Bash] Récupération du tarif EDF

Publié : 16 nov. 2014, 21:41
par patrice
But : Récupération de la couleur du tarif EDF du jour pour déclenchement d'actions en fonction du tarif (bleu,blanc,rouge)
Langage : script bash
Prérequis : Aucun sinon un chmod 777 sur ce fichier pour autoriser son exécution
Déclenchement : à volonté via crontab.

Code : Tout sélectionner

#!/bin/bash
tempo=$(curl -s "http://api.domogeek.fr/tempoedf/now")
echo $tempo

case "$tempo" in
        # tarif bleu : actions à faire
        bleu)
                curl "http://192.168.1.81:8080/json.htm?type=command&param=udevice&idx=90&svalue=$tempo"
                curl "http://192.168.1.81:8080/json.htm?type=command&param=switchlight&idx=101&switchcmd="On"&level=0"
                ;;
        # tarif blanc
        blanc)
                curl "http://192.168.1.81:8080/json.htm?type=command&param=udevice&idx=90&svalue=$tempo"
                curl "http://192.168.1.81:8080/json.htm?type=command&param=switchlight&idx=101&switchcmd="Off"&level=0"
                ;;
        # actions pendant tarif rouge
        rouge)
                curl "http://192.168.1.81:8080/json.htm?type=command&param=udevice&idx=90&svalue=$tempo"
                curl "http://192.168.1.81:8080/json.htm?type=command&param=switchlight&idx=101&switchcmd="Off"&level=0"
                ;;
esac
[/quote]