Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Domoticz server
- SERVER="192.168.0.103:8080"
- # IDX DHT
- # The number of the IDX in the list of peripherals
- DHTIDX="3"
- #DHTPIN
- # THE GPIO or connects DHT11
- DHTPIN="17"
- # If you have a DHT22 change further down the line Adafruit_DHT 11 by 22 Adafruit_DHT
- # TMPFILE: path for temporary file in place to avoid the RAMDRIVE
- # Scriptures on the SD card
- # Otherwise be written way or the file containing the temperature
- # /tmp/temper.txt Is a good choice if not installed RAMDRIVE
- # Www.easydomoticz.com visit to learn all
- TMPFILE="/var/tmp/temper.txt"
- # Modified patrick from 03/08/15 to question 5 times max
- cpt=0
- while [ $cpt -lt 6 ]
- do
- TEMP=""
- sleep 5
- sudo nice -20 /home/pi/domoticz/scripts/AdafruitDHT.py 2302 $DHTPIN > $TMPFILE
- TEMP=$(cat $TMPFILE|grep Temp |awk '{print $1}')
- if [ $TEMP ]
- then
- TEMP=$(cat $TMPFILE|grep Temp |awk '{print $1}' |sed -r 's/^.*=//' | sed -r 's/\*//')
- HUM=$(cat $TMPFILE |grep Temp |awk '{print $2}' | sed -r 's/^.*=//' | sed -r 's/\%//')
- if [ $(echo "$HUM < 30" ) ]
- then
- COMFORT=2
- elif [ $(echo "$HUM < 40" ) ]
- then
- COMFORT=0
- elif [ $(echo "$HUM < 60" ) ]
- then
- COMFORT=1
- else
- COMFORT=3
- fi
- echo "TEMP: $TEMP"
- echo "HUM: $HUM"
- echo "COMFORT: $COMFORT"
- # send data
- curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command¶m=udevice&idx=$DHTIDX&nvalue=0&svalue=$TEMP;$HUM;$COMFORT"
- TEMP=""
- HUM=""
- #rm $TMPFILE
- exit 0
- fi
- echo "CPT: $cpt"
- cpt=$(($cpt+1))
- done
- exit 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement