Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # LIMITS
- SENSORIDX="5"
- HEATERIDX="19"
- # DEVICES
- DOMIP="192.168.0.14"
- MINTEMP="19.0"
- MAXTEMP="19.0"
- # END OF USER CONFIGURABLE PARAMS
- while true
- do
- echo Reading temperature
- TEMP=`curl -s "http://192.168.0.14:9010/json.htm?type=devices&rid=$SENSORIDX"|grep Temp|grep -v Type|awk '{print $3}' `
- echo Temperature: $TEMP
- result=`expr $MINTEMP \> $TEMP`
- if [ "$result" -eq "1" ] ; then
- echo "Temperature is $TEMP and is lower than MIN ($MINTEMP) so I'm turning on heater"
- curl -s "http://192.168.0.14:9010/json.htm?type=command¶m=switchlight&idx=$HEATERIDX&switchcmd=On&level=0"
- else
- result=`expr $TEMP \> $MAXTEMP`
- if [ "$result" -eq "1" ] ; then
- echo "Temperature is $TEMP and is higher than MAX ($MAXTEMP) so I'm turning off heater"
- curl -s "http://192.168.0.14:9010/json.htm?type=command¶m=switchlight&idx=$HEATERIDX&switchcmd=Off&level=0"
- fi
- fi
- sleep 100 # 100 seconds
- done
Advertisement
Add Comment
Please, Sign In to add comment