Skip to content

Instantly share code, notes, and snippets.

@nixpulvis
Created November 24, 2021 16:10
Show Gist options
  • Save nixpulvis/42ad6166aa87eec248418ff2b28d6f71 to your computer and use it in GitHub Desktop.
Save nixpulvis/42ad6166aa87eec248418ff2b28d6f71 to your computer and use it in GitHub Desktop.
Watching the weather is serious stuff, better use bash.
#!/bin/sh
alarm() {
while :;
do
play ~/Loud_Alarm_Clock_Buzzer-Muk1984-493547174.wav
done
}
while :;
do
temp=$(ssh raspberrypi.local 'echo "scale=2; ($(cat /sys/bus/w1/devices/28-05167183beff/temperature) / 1000) * (9/5) + 32" | bc -l')
echo $temp
if [ $(printf %.0f $temp) -lt 55 ]; then
alarm
fi
sleep 5
done
#!/bin/sh
# TODO: -b, --beep when outside range.
# TODO: -c, --color for fun?
# TODO: add flag for logging `| tee -a temperature_log`
watch -n1 -d 'echo "scale=2; $(cat /sys/bus/w1/devices/28-05167183beff/temperature)/1000 * 9/5 + 32" | bc -l | sed "s/$/°F/"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment