Yesterday I wrote a small script to turn on electric heater in my room when temperature is less than 18C.
Below is the bash script :
temp=`node -pe ‘JSON.parse(process.argv).main.temp’ “$(curl -s http://api.openweathermap.org/data/2.5/weather?id=2158177\&APPID=XXXXXXXXXXXXXXXXXXXX\&units=metric)”`
echo “Current temperature “$temp
if [ $(echo “$temp < 18” | bc -l ) -gt 0 ];then
echo “Switching on Heater”
codesend is the binary which uses GPIO pins on raspberry pi to send RF signal through connected RF transmitter. I copied source code from RFutils project and tweaked a bit as per my requirements.