add first scripts to get water levels.

This commit is contained in:
Martin Preuss
2024-02-25 01:22:29 +01:00
parent dce1b8698a
commit e7bfa36cab
4 changed files with 82 additions and 0 deletions

1
0BUILD
View File

@@ -168,6 +168,7 @@
apps apps
devices devices
etc etc
scripts
</subdirs> </subdirs>
<ifVarMatches name="option_with_avr" value="TRUE" > <ifVarMatches name="option_with_avr" value="TRUE" >

10
scripts/0BUILD Normal file
View File

@@ -0,0 +1,10 @@
<?xml?>
<gwbuild>
<data dist="true" install="$(pkgdatadir)/scripts">
getlevel-nlwkn.sh
getlevel-wsv.sh
</data>
</gwbuild>

34
scripts/getlevel-nlwkn.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/bash
# see https://www.pegelonline.nlwkn.niedersachsen.de/pdf/BenutzerhandbuchWebservicePegelonline.pdf
JSONFILE="/tmp/pegel-nlwkn.json"
AQHOME_TOOL="./aqhome-tool.sh"
# AQHOME_TOOL="/usr/local/bin/aqhome-tool"
STATION_ID="$1"
WATER_NAME="$2"
LOCATION="$3"
if test -z "$STATION_ID"; then
echo "Usage: $0 STATION_ID WATER_NAME LOCATION"
exit 1;
fi
if test -z "$WATER_NAME"; then
echo "Usage: $0 STATION_ID WATER_NAME LOCATION"
exit 1;
fi
if test -z "$LOCATION"; then
echo "Usage: $0 STATION_ID WATER_NAME LOCATION"
exit 1;
fi
#
# 106 for Fuhse/Wathlingen
#
if ( curl -s -S https://bis.azure-api.net/PegelonlinePublic/REST/station/$STATION_ID/datenspuren/parameter/1/tage/-1?key=9dc05f4e3b4a43a9988d747825b39f43 -o $JSONFILE ); then
$AQHOME_TOOL addjsondata -J $JSONFILE -c pegel -d "$WATER_NAME/$LOCATION" -N "current" -v "@getPegelDatenspurenResult/Parameter/Datenspuren/AktuellerMesswert" -U "@getPegelDatenspurenResult/Parameter/Einheit"
fi

37
scripts/getlevel-wsv.sh Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
# see https://www.pegelonline.wsv.de/webservice/guideRestapi
JSONFILE="/tmp/pegel-wsv.json"
AQHOME_TOOL="./aqhome-tool.sh"
# AQHOME_TOOL="/usr/local/bin/aqhome-tool"
STATION_ID="$1"
WATER_NAME="$2"
LOCATION="$3"
if test -z "$STATION_ID"; then
echo "Usage: $0 STATION_ID WATER_NAME LOCATION"
exit 1;
fi
if test -z "$WATER_NAME"; then
echo "Usage: $0 STATION_ID WATER_NAME LOCATION"
exit 1;
fi
if test -z "$LOCATION"; then
echo "Usage: $0 STATION_ID WATER_NAME LOCATION"
exit 1;
fi
#
# b475386c-30cc-453a-b3b7-1d17ace13595 for Aller at Celle
#
if ( curl -s -S https://www.pegelonline.wsv.de/webservices/rest-api/v2/stations/$STATION_ID/W/currentmeasurement.json -o $JSONFILE ); then
$AQHOME_TOOL addjsondata -J $JSONFILE -c pegel -d ""$WATER_NAME/$LOCATION"" -N "current" -v "@value" -U "cm"
fi