From e7bfa36cab56d6db4334ba7af14a33f538849f38 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 25 Feb 2024 01:22:29 +0100 Subject: [PATCH] add first scripts to get water levels. --- 0BUILD | 1 + scripts/0BUILD | 10 ++++++++++ scripts/getlevel-nlwkn.sh | 34 ++++++++++++++++++++++++++++++++++ scripts/getlevel-wsv.sh | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 scripts/0BUILD create mode 100755 scripts/getlevel-nlwkn.sh create mode 100755 scripts/getlevel-wsv.sh diff --git a/0BUILD b/0BUILD index b3d7798..52aa168 100644 --- a/0BUILD +++ b/0BUILD @@ -168,6 +168,7 @@ apps devices etc + scripts diff --git a/scripts/0BUILD b/scripts/0BUILD new file mode 100644 index 0000000..0ebfb3c --- /dev/null +++ b/scripts/0BUILD @@ -0,0 +1,10 @@ + + + + + + getlevel-nlwkn.sh + getlevel-wsv.sh + + + diff --git a/scripts/getlevel-nlwkn.sh b/scripts/getlevel-nlwkn.sh new file mode 100755 index 0000000..52a36bc --- /dev/null +++ b/scripts/getlevel-nlwkn.sh @@ -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 diff --git a/scripts/getlevel-wsv.sh b/scripts/getlevel-wsv.sh new file mode 100755 index 0000000..c8fb84b --- /dev/null +++ b/scripts/getlevel-wsv.sh @@ -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 +