From fcb575c775ed00d2a79007ff64d3dd2321f32d0d Mon Sep 17 00:00:00 2001 From: openhabian Date: Fri, 13 Oct 2023 18:58:48 +0200 Subject: [PATCH] setLocationAPI.bash Signed-off-by: openhabian --- build-image/openhabian.conf | 2 ++ functions/storm.house.bash | 17 ++++++++++++++--- includes/setLocation.bash | 3 --- includes/setLocationAPI.bash | 5 +++++ 4 files changed, 21 insertions(+), 6 deletions(-) delete mode 100755 includes/setLocation.bash create mode 100755 includes/setLocationAPI.bash diff --git a/build-image/openhabian.conf b/build-image/openhabian.conf index c307f26e1..29f3b2b1b 100644 --- a/build-image/openhabian.conf +++ b/build-image/openhabian.conf @@ -131,6 +131,8 @@ loggermodbusid=7 metertype=inverter meterip=192.168.178.102 metermodbusid=99 +meteruser= +meterpass= wallboxtype=openwb-pro wallboxip=192.168.178.200 wallboxid=1234567890abcdef diff --git a/functions/storm.house.bash b/functions/storm.house.bash index 5e0fd9ab5..c10a8ce69 100644 --- a/functions/storm.house.bash +++ b/functions/storm.house.bash @@ -26,6 +26,12 @@ setup_pv_config() { local inverterPNG="${OPENHAB_CONF:-/etc/openhab}/icons/classic/inverter.png" local srcfile local destfile + local device + local default + local ip + local mbid + local muser + local mpass if [[ ! -f /usr/local/sbin/setup_pv_config && $(whoami) == "root" ]]; then @@ -43,7 +49,7 @@ setup_pv_config() { case "${device}" in pv) default=${invertertype}; ip=${3:-inverterip}; mbid=${4:-${invertermodbusid}};; bat) default=${batterytype}; ip=${3:-batteryip}; mbid=${4:-${batterymodbusid}};; - meter) default=${metertype}; ip=${3:-meterip}; mbid=${4:-${metermodbusid}};; + meter) default=${metertype}; ip=${3:-meterip}; mbid=${4:-${metermodbusid}}; muser=${6:-${meteruserid}}; mpass=${7:-${meterpassid}};; esac @@ -51,8 +57,10 @@ setup_pv_config() { if [[ "${device}" == "bat" && "${2:-$batterytype}" == "hybrid" ]]; then file="inv/${5:-${invertertype}}" fi - if [[ "${device}" == "meter" && "${2:-${metertype}}" == "inverter" ]]; then - file="inv/${5:-${invertertype}}" + if [[ "${device}" == "meter" ]]; then + if [[ "${2:-${metertype}}" == "inverter" ]]; then + file="inv/${5:-${invertertype}}" + fi fi srcfile="${OPENHAB_CONF:-/etc/openhab}/${configdomain}/STORE/${device}/${file:-${default}}.${configdomain}" @@ -74,6 +82,9 @@ setup_pv_config() { mbid="${5:-${loggermodbusid}}" # diese ID muss angesprochen werden fi sed -i "s|%IP|${ip}|;s|%MBID|${mbid}|" "${destfile}" + if [[ "${device}" == "meter" && $# -ge 6 ]]; then + sed -i "s|%USER|${muser}|;s|%PASS|${mpass}|" "${destfile}" + fi fi done diff --git a/includes/setLocation.bash b/includes/setLocation.bash deleted file mode 100755 index 291604cb2..000000000 --- a/includes/setLocation.bash +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/bash - -/usr/bin/echo $@ > /etc/openhab/services/location.cfg diff --git a/includes/setLocationAPI.bash b/includes/setLocationAPI.bash new file mode 100755 index 000000000..adcc768da --- /dev/null +++ b/includes/setLocationAPI.bash @@ -0,0 +1,5 @@ +#!/usr/bin/bash + +#/usr/bin/echo $@ > /etc/openhab/services/location.cfg +/usr/bin/echo "org.openhab.i18n:location=${1}" > /etc/openhab/services/location.cfg +sed -i "s|location=.*|location=\"${1}\"|;s|apikey=.*|apikey=\"${2}\",|" "${OPENHAB_CONF:-/etc/openhab}/things/wetter.things"