Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.47 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Domoticz server
  4. SERVER="192.168.0.103:8080"
  5.  
  6. # IDX DHT
  7. # The number of the IDX in the list of peripherals
  8. DHTIDX="3"
  9.  
  10. #DHTPIN
  11. # THE GPIO or connects DHT11
  12. DHTPIN="17"
  13.  
  14. # If you have a DHT22 change further down the line Adafruit_DHT 11 by 22 Adafruit_DHT
  15.  
  16. # TMPFILE: path for temporary file in place to avoid the RAMDRIVE
  17. # Scriptures on the SD card
  18. # Otherwise be written way or the file containing the temperature
  19. # /tmp/temper.txt Is a good choice if not installed RAMDRIVE
  20. # Www.easydomoticz.com visit to learn all
  21.  
  22. TMPFILE="/var/tmp/temper.txt"
  23.  
  24. # Modified patrick from 03/08/15 to question 5 times max
  25. cpt=0
  26. while [ $cpt -lt 6 ]
  27. do
  28. TEMP=""
  29. sleep 5
  30. sudo nice -20 /home/pi/domoticz/scripts/AdafruitDHT.py 2302 $DHTPIN > $TMPFILE
  31. TEMP=$(cat $TMPFILE|grep Temp |awk '{print $1}')
  32. if [ $TEMP ]
  33. then
  34. TEMP=$(cat $TMPFILE|grep Temp |awk '{print $1}' |sed -r 's/^.*=//' |  sed -r 's/\*//')
  35. HUM=$(cat  $TMPFILE |grep Temp |awk '{print $2}' | sed -r 's/^.*=//' | sed -r 's/\%//')
  36.  
  37. if [ $(echo "$HUM < 30" ) ]
  38. then
  39. COMFORT=2
  40. elif [ $(echo "$HUM < 40" ) ]
  41. then
  42. COMFORT=0
  43. elif [ $(echo "$HUM < 60" ) ]
  44. then
  45. COMFORT=1
  46. else
  47. COMFORT=3
  48. fi
  49.  
  50. echo "TEMP: $TEMP"
  51. echo "HUM: $HUM"
  52. echo "COMFORT: $COMFORT"
  53. # send data
  54. curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command&param=udevice&idx=$DHTIDX&nvalue=0&svalue=$TEMP;$HUM;$COMFORT"
  55. TEMP=""
  56. HUM=""
  57. #rm $TMPFILE
  58. exit 0
  59. fi
  60. echo "CPT: $cpt"
  61. cpt=$(($cpt+1))
  62. done
  63. exit 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement