From a334643378b6547ee36f40cd61e84785254aa46c Mon Sep 17 00:00:00 2001 From: Yannik Hampe Date: Tue, 18 Jan 2022 16:13:44 +0100 Subject: [PATCH] utilize automatic script detection for second inverter in json module --- modules/wr2_json/main.sh | 27 --------------------------- modules/wr_json/main.sh | 14 ++++++++++---- 2 files changed, 10 insertions(+), 31 deletions(-) delete mode 100755 modules/wr2_json/main.sh diff --git a/modules/wr2_json/main.sh b/modules/wr2_json/main.sh deleted file mode 100755 index 24cc210e5..000000000 --- a/modules/wr2_json/main.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -OPENWBBASEDIR=$(cd "$(dirname "$0")/../../" && pwd) -RAMDISKDIR="${OPENWBBASEDIR}/ramdisk" -DMOD="PV" -#DMOD="MAIN" -Debug=$debug - -#For Development only -#Debug=1 - -if [ ${DMOD} == "MAIN" ]; then - MYLOGFILE="${RAMDISKDIR}/openWB.log" -else - MYLOGFILE="${RAMDISKDIR}/nurpv.log" -fi - -openwbDebugLog ${DMOD} 2 "PV URL : ${wr2jsonurl}" -openwbDebugLog ${DMOD} 2 "PV Watt: ${wr2jsonwatt}" -openwbDebugLog ${DMOD} 2 "PV kWh : ${wr2jsonkwh}" - -bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.json.device" "inverter" "${wr2jsonurl}" "${wr2jsonwatt}" "${wr2jsonkwh}" "2" >>"$MYLOGFILE" 2>&1 -ret=$? - -openwbDebugLog ${DMOD} 2 "RET: ${ret}" - -cat "${RAMDISKDIR}/pv2watt" diff --git a/modules/wr_json/main.sh b/modules/wr_json/main.sh index bae0456ff..03153e312 100755 --- a/modules/wr_json/main.sh +++ b/modules/wr_json/main.sh @@ -15,11 +15,17 @@ else MYLOGFILE="${RAMDISKDIR}/nurpv.log" fi -openwbDebugLog ${DMOD} 2 "PV URL : ${wrjsonurl}" -openwbDebugLog ${DMOD} 2 "PV Watt: ${wrjsonwatt}" -openwbDebugLog ${DMOD} 2 "PV kWh : ${wrjsonkwh}" +inverter_num=${1:-1} +[[ "$inverter_num" -gt 1 ]] && config_prefix="wr$1" || config_prefix="wr" +declare -n "config_url=${config_prefix}jsonurl" +declare -n "config_watt=${config_prefix}jsonwatt" +declare -n "config_kwh=${config_prefix}jsonkwh" -bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.json.device" "inverter" "${wrjsonurl}" "${wrjsonwatt}" "${wrjsonkwh}" "1" >>"$MYLOGFILE" 2>&1 +openwbDebugLog ${DMOD} 2 "PV URL : ${config_url}" +openwbDebugLog ${DMOD} 2 "PV Watt: ${config_watt}" +openwbDebugLog ${DMOD} 2 "PV kWh : ${config_kwh}" + +bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.json.device" "inverter" "$config_url" "$config_watt" "$config_kwh" "$inverter_num" >>"$MYLOGFILE" 2>&1 ret=$? openwbDebugLog ${DMOD} 2 "RET: ${ret}"