leos1971

heateron.sh

May 5th, 2013
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.97 KB | None | 0 0
  1. #!/bin/bash
  2.      
  3. # LIMITS
  4. SENSORIDX="5"
  5. HEATERIDX="19"
  6. # DEVICES
  7. DOMIP="192.168.0.14"
  8. MINTEMP="19.0"
  9. MAXTEMP="19.0"
  10.      
  11. # END OF USER CONFIGURABLE PARAMS
  12.  
  13. while true
  14. do
  15.  
  16. echo Reading temperature
  17.  
  18. TEMP=`curl -s "http://192.168.0.14:9010/json.htm?type=devices&rid=$SENSORIDX"|grep Temp|grep -v Type|awk '{print $3}' `
  19.  
  20.  
  21. echo Temperature: $TEMP
  22.  
  23.  result=`expr $MINTEMP \> $TEMP`
  24.   if [ "$result" -eq "1" ] ; then
  25.     echo "Temperature is $TEMP and is lower than MIN ($MINTEMP) so I'm turning on heater"
  26.     curl -s "http://192.168.0.14:9010/json.htm?type=command&param=switchlight&idx=$HEATERIDX&switchcmd=On&level=0"
  27.   else
  28.   result=`expr $TEMP \> $MAXTEMP`
  29.     if [ "$result" -eq "1" ] ; then
  30.       echo "Temperature is $TEMP and is higher than MAX ($MAXTEMP) so I'm turning off heater"
  31.       curl -s "http://192.168.0.14:9010/json.htm?type=command&param=switchlight&idx=$HEATERIDX&switchcmd=Off&level=0"
  32.     fi
  33.   fi
  34.   sleep 100     # 100 seconds
  35.  
  36. done
Advertisement
Add Comment
Please, Sign In to add comment