Skip to content

Commit

Permalink
setLocationAPI.bash
Browse files Browse the repository at this point in the history
Signed-off-by: openhabian <openhabian@openHABian>
  • Loading branch information
openhabian authored and openhabian committed Oct 13, 2023
1 parent cd60c63 commit fcb575c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
2 changes: 2 additions & 0 deletions build-image/openhabian.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 14 additions & 3 deletions functions/storm.house.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,16 +49,18 @@ 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


file="${2:-${default}}"
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}"
Expand All @@ -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

Expand Down
3 changes: 0 additions & 3 deletions includes/setLocation.bash

This file was deleted.

5 changes: 5 additions & 0 deletions includes/setLocationAPI.bash
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit fcb575c

Please sign in to comment.