-
Notifications
You must be signed in to change notification settings - Fork 0
/
d1mini-temp-check.sh
executable file
·47 lines (37 loc) · 1.08 KB
/
d1mini-temp-check.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env zsh
APP_NAME=$(basename $0)
APP_VERSION="0.20231127"
D1MINI_HOST="d1mini"
TEMPERATURE_URL="http://${D1MINI_HOST}/temp"
TEMPERATURE_WARN=27
#TEMPERATURE_WARN=20
#export PUSHOVER_APP_ID="gallifrey"
export PUSHOVER_APP_ID="raspberrypi"
export PUSHOVER_PRIORITY=1
source $(dirname $0)/_base.inc.sh
usage() {
echo "Usage:"
echo " $SCRIPT_NAME [--help|--version]"
echo
}
while [[ $# -gt 0 ]]; do
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
# Run usage() to display a help text and immediately exit
usage
exit 0
elif [[ "$1" == "--version" || "$1" == "-V" ]]; then
# Like "--help", immediately display information and exit
version
exit 0
else
message_error "Unknown option: $1"
fi
shift
done
_temp=$(curl -s -o- ${TEMPERATURE_URL})
if [[ $_temp -ge ${TEMPERATURE_WARN} ]]; then
echo "The temperature is currently $_temp°C, which is over the threshold of ${TEMPERATURE_WARN}°C" \
| pushover-notify "Temperature $_temp°C (Threshold: ${TEMPERATURE_WARN}°C)"
echo "ESP8266 + RPi
Temperature: $_temp!" | ssh mcp /Users/malte70/code/mapid/notification.sh
fi