added script for www.weatherapi.com

works great so far. You will need an API key for this.
This commit is contained in:
Martin Preuss
2026-08-16 23:44:30 +02:00
parent c9f4339fb2
commit 1934a40ae6

View File

@@ -0,0 +1,47 @@
#!/bin/bash
# see https://www.weatherapi.com
JSONFILE="/tmp/weather1.json"
#AQHOME_TOOL="./aqhome-tool.sh"
AQHOME_TOOL="/usr/local/bin/aqhome-tool"
POS_CITY="$1"
POS_LAT="$2"
POS_LONG="$3"
API_KEY="$4"
if test -z "$POS_CITY"; then
echo "Usage: $0 CITY LATITUDE LONGITUDE APIKEY"
exit 1;
fi
if test -z "$POS_LAT"; then
echo "Usage: $0 CITY LATITUDE LONGITUDE APIKEY"
exit 1;
fi
if test -z "$POS_LONG"; then
echo "Usage: $0 CITY LATITUDE LONGITUDE APIKEY"
exit 1;
fi
if test -z "$API_KEY"; then
echo "Usage: $0 CITY LATITUDE LONGITUDE APIKEY"
exit 1;
fi
#
# get current weather
#
if ( curl -s -S "https://api.weatherapi.com/v1/current.json?key=$API_KEY&q=$POS_LAT,$POS_LONG&aqi=yes" -o $JSONFILE ); then
$AQHOME_TOOL adddata -J $JSONFILE -c weather -d "$POS_CITY" -N "Temperature" -v "@current/temp_c" -U "C"
$AQHOME_TOOL adddata -J $JSONFILE -c weather -d "$POS_CITY" -N "Humidity" -v "@current/humidity" -U "%"
$AQHOME_TOOL adddata -J $JSONFILE -c weather -d "$POS_CITY" -N "Wetbulb" -v "@current/wetbulb_c" -U "C"
$AQHOME_TOOL adddata -J $JSONFILE -c weather -d "$POS_CITY" -N "pm2_5" -v "@current/air_quality/pm2_5" -U "ug/m3"
$AQHOME_TOOL adddata -J $JSONFILE -c weather -d "$POS_CITY" -N "pm10" -v "@current/air_quality/pm10" -U "ug/m3"
fi