added some more weather api scripts.

This commit is contained in:
Martin Preuss
2026-08-24 23:36:25 +02:00
parent 8158bc28fb
commit b72bc7d8b5
5 changed files with 91 additions and 10 deletions

View File

@@ -5,7 +5,8 @@
<data dist="true" install="$(pkgdatadir)/scripts">
getlevel-nlwkn.sh
getlevel-wsv.sh
getweather.sh
getweather-brightsky.sh
getweather-openmeteo.sh
getweather-weatherapi.sh
</data>

33
scripts/getweather-brightsky.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
# see https://brightsky.dev
#AQHOME_TOOL="./aqhome-tool.sh"
AQHOME_TOOL="/usr/local/bin/aqhome-tool"
POS_CITY="$1"
STATION_ID="$2"
if test -z "$POS_CITY"; then
echo "Usage: $0 CITY STATION_ID"
exit 1;
fi
if test -z "$STATION_ID"; then
echo "Usage: $0 CITY STATION_ID"
exit 1;
fi
JSONFILE="/tmp/weather-brightsky-$POS_CITY.json"
#
# get current weather
#
if ( curl -s -S "https://api.brightsky.dev/current_weather?dwd_station_id=$STATION_ID" -o $JSONFILE ); then
$AQHOME_TOOL adddata -J $JSONFILE -c weather -d "brightsky/$POS_CITY" -N "Temperature" -v "@weather/temperature" -U "C"
$AQHOME_TOOL adddata -J $JSONFILE -c weather -d "brightsky/$POS_CITY" -N "Humidity" -v "@current/relative_humidity" -U "%"
fi

View File

@@ -2,7 +2,6 @@
# see https://open-meteo.com/en/docs/dwd-api
JSONFILE="/tmp/weather.json"
#AQHOME_TOOL="./aqhome-tool.sh"
AQHOME_TOOL="/usr/local/bin/aqhome-tool"
@@ -27,12 +26,14 @@ if test -z "$POS_LONG"; then
fi
JSONFILE="/tmp/weather-openmeteo-$POS_CITY.json"
#
# get current weather
#
if ( curl -s -S "https://api.open-meteo.com/v1/dwd-icon?latitude=$POS_LAT&longitude=$POS_LONG&current=temperature_2m,relative_humidity_2m" -o $JSONFILE ); then
$AQHOME_TOOL adddata -J $JSONFILE -c weather -d "$POS_CITY" -N "Temperature" -v "@current/temperature_2m" -U "@current_units/temperature_2m"
$AQHOME_TOOL adddata -J $JSONFILE -c weather -d "$POS_CITY" -N "Humidity" -v "@current/relative_humidity_2m" -U "@current_units/relative_humidity_2m"
$AQHOME_TOOL adddata -J $JSONFILE -c weather -d "open-meto/$POS_CITY" -N "Temperature" -v "@current/temperature_2m" -U "@current_units/temperature_2m"
$AQHOME_TOOL adddata -J $JSONFILE -c weather -d "open-meto/$POS_CITY" -N "Humidity" -v "@current/relative_humidity_2m" -U "@current_units/relative_humidity_2m"
fi

View File

@@ -0,0 +1,45 @@
#!/bin/bash
# see https://www.weatherapi.com
#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
JSONFILE="/tmp/weather-oweathermap-$POS_CITY.json"
#
# get current weather
#
if ( curl -s -S "https://api.openweathermap.org/data/2.5/weather?lat=$POS_LAT&lon=$POS_LONG&appid=$API_KEY&units=metric" -o $JSONFILE ); then
$AQHOME_TOOL adddata -J $JSONFILE -c weather -d "openweathermap/$POS_CITY" -N "Temperature" -v "@main/temp" -U "C"
$AQHOME_TOOL adddata -J $JSONFILE -c weather -d "openweathermap/$POS_CITY" -N "Humidity" -v "@main/humidity" -U "%"
fi

View File

@@ -2,7 +2,6 @@
# see https://www.weatherapi.com
JSONFILE="/tmp/weather1.json"
#AQHOME_TOOL="./aqhome-tool.sh"
AQHOME_TOOL="/usr/local/bin/aqhome-tool"
@@ -32,16 +31,18 @@ if test -z "$API_KEY"; then
exit 1;
fi
JSONFILE="/tmp/weather-weatherapi-$POS_CITY.json"
#
# 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"
$AQHOME_TOOL adddata -J $JSONFILE -c weather -d "weatherapi/$POS_CITY" -N "Temperature" -v "@current/temp_c" -U "C"
$AQHOME_TOOL adddata -J $JSONFILE -c weather -d "weatherapi/$POS_CITY" -N "Humidity" -v "@current/humidity" -U "%"
$AQHOME_TOOL adddata -J $JSONFILE -c weather -d "weatherapi/$POS_CITY" -N "Wetbulb" -v "@current/wetbulb_c" -U "C"
$AQHOME_TOOL adddata -J $JSONFILE -c weather -d "weatherapi/$POS_CITY" -N "pm2_5" -v "@current/air_quality/pm2_5" -U "ug/m3"
$AQHOME_TOOL adddata -J $JSONFILE -c weather -d "weatherapi/$POS_CITY" -N "pm10" -v "@current/air_quality/pm10" -U "ug/m3"
fi