StookAlert

From Domoticz
Jump to: navigation, search

StookAlert (only for the Netherlands)

Gives advice when it's suitable to use your wood-burning stove. More info: https://sfeerverwarmingsgilde.nl/stookalert

Create a virtual device, type alert/waarschuwing, name it Stookalert, and get the index-number from the device-list.

Create a script (eg. /home/pi/domoticz/script/stookalert.sh), fill in your settings and call this this script from the crontab every 5 minutes:

*/5 * * * * /home/pi/domoticz/scripts/stookalert.sh >/dev/null 2>&1


Script

#!/bin/sh

# Settings

USER=USER
PASSWD=PASSWORD
DOMO_IP="127.0.0.1"           # Domoticz IP Address
DOMO_PORT="8080"              # Domoticz Port

SA_IDX="265"                  # StookAlert IDX

PRIMPROV=gelderland	      # De provincie waarin je woont
SECUPROV=overijssel	      # De provincie waar je vlakbij woont, of anders de provincie waarin je woont

# Execution

CURLEVEL=`curl -s  "http://$USER:[email protected]$DOMO_IP:$DOMO_PORT/json.htm?type=devices&rid=$SA_IDX" | grep \"Level\" | awk '{print $NF}' | awk -F, '{print $1}'`

curl https://sfeerverwarmingsgilde.nl/code/stookalert/$PRIMPROV/index.php > /tmp/$PRIMPROV.txt
curl https://sfeerverwarmingsgilde.nl/code/stookalert/$SECUPROV/index.php > /tmp/$SECUPROV.txt

PCOUNT=`fgrep groen /tmp/$PRIMPROV.txt | wc -l`
SCOUNT=`fgrep groen /tmp/$SECUPROV.txt | wc -l`

if [ $PCOUNT -eq 1 ] && [ $SCOUNT -eq 1 ];then
	NVALUE=1
fi

if [ $PCOUNT -eq 1 ] && [ $SCOUNT -eq 0 ];then
	NVALUE=2
fi

if [ $PCOUNT -eq 0 ] && [ $SCOUNT -eq 1 ];then
	NVALUE=3
fi

if [ $PCOUNT -eq 0 ] && [ $SCOUNT -eq 0 ];then
	NVALUE=4
fi

[email protected]:/home/pi/domoticz/scripts# vi stookalert.sh 

        NVALUE=2
fi

if [ $PCOUNT -eq 0 ] && [ $SCOUNT -eq 1 ];then
        NVALUE=3
fi

if [ $PCOUNT -eq 0 ] && [ $SCOUNT -eq 0 ];then
        NVALUE=4
fi

case $NVALUE in
        1)
        SVALUE="Uitstekend_stookweer"
        ;;
        2)
        SVALUE="Prima_stookweer"
        ;;
        3)
        SVALUE="Matig_stookweer"
        ;;
        4)
        SVALUE="Slecht_stookweer"
        ;;
        *)
        NVALUE=4
        SVALUE="Onbekende waarde"
        ;;
esac

if [ $NVALUE -eq $CURLEVEL ];then
        echo Geen wijziging
else
        curl -s -i -H "Accept: application/json" "http://$USER:[email protected]$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$SA_IDX&nvalue=$NVALUE&svalue=$SVALUE"
fi

rm /tmp/$PRIMPROV.txt
rm /tmp/$SECUPROV.txt