From f62657b82308fb67c0bb8d1fcc5addf4a1b98e63 Mon Sep 17 00:00:00 2001 From: Jochen Neidhardt Date: Mon, 1 May 2023 15:36:48 +0200 Subject: [PATCH] add support for dynamic tariffs in mindispaly --- loadvars.sh | 12 + modules/extopenwb/main.sh | 19 + runs/initRamdisk.sh | 8 + runs/mqttsub.py | 41 ++- runs/updateConfig.sh | 14 + sofortlademodus.sh | 35 +- web/display/minimal/checklock.php | 17 + web/display/minimal/index.php | 440 ++++++++++++++++++++--- web/display/minimal/minimal.css | 33 ++ web/display/minimal/minimalgauge.js | 114 +++--- web/display/minimal/pricechart.js | 222 ++++++++++++ web/display/minimal/processAllMqttMsg.js | 82 ++++- web/display/minimal/setupMqttServices.js | 56 ++- web/settings/misc.php | 59 ++- web/settings/sofortconfig.php | 7 +- 15 files changed, 1018 insertions(+), 141 deletions(-) create mode 100644 web/display/minimal/checklock.php create mode 100644 web/display/minimal/pricechart.js diff --git a/loadvars.sh b/loadvars.sh index 804e456a0..b0fa75ecb 100755 --- a/loadvars.sh +++ b/loadvars.sh @@ -1839,6 +1839,14 @@ loadvars(){ mqttconfvar["config/get/sofort/lp/6/etBasedCharging"]=lp6etbasedcharging mqttconfvar["config/get/sofort/lp/7/etBasedCharging"]=lp7etbasedcharging mqttconfvar["config/get/sofort/lp/8/etBasedCharging"]=lp8etbasedcharging + mqttconfvar["config/get/sofort/lp/1/etChargeMaxPrice"]=lp1etchargemaxprice + mqttconfvar["config/get/sofort/lp/2/etChargeMaxPrice"]=lp2etchargemaxprice + mqttconfvar["config/get/sofort/lp/3/etChargeMaxPrice"]=lp3etchargemaxprice + mqttconfvar["config/get/sofort/lp/4/etChargeMaxPrice"]=lp4etchargemaxprice + mqttconfvar["config/get/sofort/lp/5/etChargeMaxPrice"]=lp5etchargemaxprice + mqttconfvar["config/get/sofort/lp/6/etChargeMaxPrice"]=lp6etchargemaxprice + mqttconfvar["config/get/sofort/lp/7/etChargeMaxPrice"]=lp7etchargemaxprice + mqttconfvar["config/get/sofort/lp/8/etChargeMaxPrice"]=lp8etchargemaxprice mqttconfvar["config/get/pv/lp/1/socLimitation"]=stopchargepvatpercentlp1 mqttconfvar["config/get/pv/lp/2/socLimitation"]=stopchargepvatpercentlp2 mqttconfvar["config/get/pv/lp/1/maxSoc"]=stopchargepvpercentagelp1 @@ -1850,6 +1858,10 @@ loadvars(){ mqttconfvar["config/get/display/chartBatteryMinMax"]=displayspeichermax mqttconfvar["config/get/display/chartPvMax"]=displaypvmax mqttconfvar["config/get/display/showHouseConsumption"]=displayhausanzeigen + mqttconfvar["config/get/display/showPrice"]=displayshowprice + mqttconfvar["config/get/display/showRfidPad"]=displayshowrfidpad + mqttconfvar["config/get/display/pinRequired"]=displaypinaktiv + mqttconfvar["config/get/display/allowSetMaxPrice"]=displayallowsetmaxprice mqttconfvar["config/get/display/chartHouseConsumptionMax"]=displayhausmax mqttconfvar["config/get/display/chartLp/1/max"]=displaylp1max mqttconfvar["config/get/display/chartLp/2/max"]=displaylp2max diff --git a/modules/extopenwb/main.sh b/modules/extopenwb/main.sh index 912390e16..1a5f1242c 100755 --- a/modules/extopenwb/main.sh +++ b/modules/extopenwb/main.sh @@ -35,7 +35,9 @@ if [[ $(wc -l <"$outputname") -ge 5 ]]; then echo "$boolPlugStat" > "$RAMDISKDIR/plugstat" echo "$boolChargeStat" > "$RAMDISKDIR/chargestat" soc=$(<"$RAMDISKDIR/soc") + socEnabled=$(<"$RAMDISKDIR/socvorhanden") mosquitto_pub -h "$ip" -r -t "openWB/set/lp/$chargepcp/%Soc" -m "$soc" + mosquitto_pub -h "$ip" -r -t "openWB/set/lp/$chargepcp/boolSocConfigured" -m "$socEnabled" fi if (( chargep == "2" ));then echo "$VPhase1" > "$RAMDISKDIR/llvs11" @@ -49,7 +51,9 @@ if [[ $(wc -l <"$outputname") -ge 5 ]]; then echo "$boolPlugStat" > "$RAMDISKDIR/plugstats1" echo "$boolChargeStat" > "$RAMDISKDIR/chargestats1" soc=$(<"$RAMDISKDIR/soc1") + socEnabled=$(<"$RAMDISKDIR/soc1vorhanden") mosquitto_pub -h "$ip" -r -t "openWB/set/lp/$chargepcp/%Soc" -m "$soc" + mosquitto_pub -h "$ip" -r -t "openWB/set/lp/$chargepcp/boolSocConfigured" -m "$socEnabled" fi if (( chargep == "3" ));then echo "$VPhase1" > "$RAMDISKDIR/llvs21" @@ -80,6 +84,21 @@ if [[ $(wc -l <"$outputname") -ge 5 ]]; then mosquitto_pub -h "$ip" -r -t "openWB/set/isss/ClearRfid" -m "1" fi + cpEnabled=$(<"$RAMDISKDIR/lp${chargep}enabled") + etEnabled=$(<"$RAMDISKDIR/mqttetprovideraktiv") + etPriceList=$(<"$RAMDISKDIR/etprovidergraphlist") + etGlobalPrice=$(<"$RAMDISKDIR/etprovidermaxprice") + etCurrentPrice=$(<"$RAMDISKDIR/etproviderprice") + etMode=$(<"$RAMDISKDIR/mqttlp${chargep}etbasedcharging") + etLocalPrice=$(<"$RAMDISKDIR/mqttlp${chargep}etchargemaxprice") + mosquitto_pub -h "$ip" -r -t openWB/set/lp/$chargepcp/ChargePointEnabled -m "$cpEnabled" + mosquitto_pub -h "$ip" -r -t openWB/set/awattar/boolAwattarEnabled -m "$etEnabled" + mosquitto_pub -h "$ip" -r -t openWB/set/awattar/pricelist -m "$etPriceList" + mosquitto_pub -h "$ip" -r -t openWB/set/awattar/MaxPriceForCharging -m "$etGlobalPrice" + mosquitto_pub -h "$ip" -r -t openWB/set/awattar/ActualPriceForCharging -m "$etCurrentPrice" + mosquitto_pub -h "$ip" -r -t openWB/config/set/sofort/lp/$chargepcp/etBasedCharging -m "$etMode" + mosquitto_pub -h "$ip" -r -t openWB/config/set/sofort/lp/$chargepcp/etChargeMaxPrice -m "$etLocalPrice" + mosquitto_pub -h "$ip" -r -t "openWB/set/isss/parentWB" -m "$myipaddress" if (( chargepcp == "1" )); then mosquitto_pub -h "$ip" -r -t "openWB/set/isss/parentCPlp1" -m "$chargep" diff --git a/runs/initRamdisk.sh b/runs/initRamdisk.sh index cb1eb6e31..86c852ef6 100755 --- a/runs/initRamdisk.sh +++ b/runs/initRamdisk.sh @@ -535,6 +535,14 @@ initRamdisk(){ "mqttlp6etbasedcharging:-1" \ "mqttlp7etbasedcharging:-1" \ "mqttlp8etbasedcharging:-1" \ + "mqttlp1etchargemaxprice:-1" \ + "mqttlp2etchargemaxprice:-1" \ + "mqttlp3etchargemaxprice:-1" \ + "mqttlp4etchargemaxprice:-1" \ + "mqttlp5etchargemaxprice:-1" \ + "mqttlp6etchargemaxprice:-1" \ + "mqttlp7etchargemaxprice:-1" \ + "mqttlp8etchargemaxprice:-1" \ "mqttevuglaettungakt:-1" \ "mqtthausverbrauch:-1" \ "mqtthausverbrauchstat:-1" \ diff --git a/runs/mqttsub.py b/runs/mqttsub.py index 2f37133a8..8814976b9 100755 --- a/runs/mqttsub.py +++ b/runs/mqttsub.py @@ -171,6 +171,7 @@ def map_run(message: str, device_number: int, option: str): "device_speichersocbeforestop": create_topic_handler(int_range_validator(0, 100)), "device_maxeinschaltdauer": create_topic_handler(int_range_validator(0, 100000)), "device_mineinschaltdauer": create_topic_handler(int_range_validator(0, 100000)), + "device_mindayeinschaltdauer": create_topic_handler(int_range_validator(0, 100000)), "device_manual_control": create_topic_handler(int_range_validator(0, 1), ( write_ramdisk_action("smarthome_device_manual_control"), republish_action)), "mode": create_topic_handler(int_range_validator(0, 1), @@ -289,7 +290,7 @@ def on_message(client: mqtt.Client, userdata, msg: mqtt.MQTTMessage): f.write(msg.payload.decode("utf-8")) f.close() client.publish("openWB/config/get/SmartHome/maxBatteryPower", - msg.payload.decode("utf-8"), qos=0, retain=True) + msg.payload.decode("utf-8"), qos=0, retain=True) RAMDISK_PATH.joinpath("rereadsmarthomedevices").write_text("1") if (msg.topic == "openWB/config/set/SmartHome/logLevel"): if (int(msg.payload) >= 0 and int(msg.payload) <= 2): @@ -394,12 +395,20 @@ def on_message(client: mqtt.Client, userdata, msg: mqtt.MQTTMessage): subprocess.run(sendcommand) if (("openWB/config/set/sofort/lp" in msg.topic) and ("etBasedCharging" in msg.topic)): devicenumb = re.sub(r'\D', '', msg.topic) - if (1 <= int(devicenumb) <= 8 and 0 <= int(msg.payload) <= 1): + if (1 <= int(devicenumb) <= 8 and 0 <= int(msg.payload) <= 2): client.publish("openWB/config/get/sofort/lp/"+str(devicenumb)+"/etBasedCharging", msg.payload.decode("utf-8"), qos=0, retain=True) sendcommand = ["/var/www/html/openWB/runs/replaceinconfig.sh", "lp" + str(devicenumb)+"etbasedcharging=", msg.payload.decode("utf-8")] subprocess.run(sendcommand) + if (("openWB/config/set/sofort/lp" in msg.topic) and ("etChargeMaxPrice" in msg.topic)): + devicenumb = re.sub(r'\D', '', msg.topic) + if (1 <= int(devicenumb) <= 8 and float(msg.payload) >= -50 and float(msg.payload) <= 95): + client.publish("openWB/config/get/sofort/lp/"+str(devicenumb)+"/etChargeMaxPrice", + msg.payload.decode("utf-8"), qos=0, retain=True) + sendcommand = ["/var/www/html/openWB/runs/replaceinconfig.sh", "lp" + + str(devicenumb)+"etchargemaxprice=", msg.payload.decode("utf-8")] + subprocess.run(sendcommand) if (("openWB/config/set/sofort/lp" in msg.topic) and ("chargeLimitation" in msg.topic)): devicenumb = re.sub(r'\D', '', msg.topic) if (3 <= int(devicenumb) <= 8 and 0 <= int(msg.payload) <= 1): @@ -1236,11 +1245,27 @@ def on_message(client: mqtt.Client, userdata, msg: mqtt.MQTTMessage): f = open('/var/www/html/openWB/ramdisk/parentCPlp2', 'w') f.write(msg.payload.decode("utf-8")) f.close() + if (msg.topic == "openWB/set/awattar/boolAwattarEnabled"): + client.publish("openWB/global/awattar/boolAwattarEnabled", msg.payload.decode("utf-8"), qos=0, retain=True) + f = open('/var/www/html/openWB/ramdisk/mqttetprovideraktiv', 'w') + f.write(msg.payload.decode("utf-8")) + f.close() if (msg.topic == "openWB/set/awattar/MaxPriceForCharging"): if (float(msg.payload) >= -50 and float(msg.payload) <= 95): + client.publish("openWB/global/awattar/MaxPriceForCharging", msg.payload.decode("utf-8"), qos=0, retain=True) f = open('/var/www/html/openWB/ramdisk/etprovidermaxprice', 'w') f.write(msg.payload.decode("utf-8")) f.close() + if (msg.topic == "openWB/set/awattar/ActualPriceForCharging"): + client.publish("openWB/global/awattar/ActualPriceForCharging", msg.payload.decode("utf-8"), qos=0, retain=True) + f = open('/var/www/html/openWB/ramdisk/etproviderprice', 'w') + f.write(msg.payload.decode("utf-8")) + f.close() + if (msg.topic == "openWB/set/awattar/pricelist"): + client.publish("openWB/global/awattar/pricelist", msg.payload.decode("utf-8"), qos=0, retain=True) + f = open('/var/www/html/openWB/ramdisk/etprovidergraphlist', 'w') + f.write(msg.payload.decode("utf-8")) + f.close() if (msg.topic == "openWB/set/houseBattery/W"): if (float(msg.payload) >= -30000 and float(msg.payload) <= 30000): f = open('/var/www/html/openWB/ramdisk/speicherleistung', 'w') @@ -1329,14 +1354,26 @@ def on_message(client: mqtt.Client, userdata, msg: mqtt.MQTTMessage): client.publish("openWB/evu/faultStr", msg.payload.decode("utf-8"), qos=0, retain=True) if (msg.topic == "openWB/set/lp/1/%Soc"): if (float(msg.payload) >= 0 and float(msg.payload) <= 100): + client.publish("openWB/lp/1/%Soc", msg.payload.decode("utf-8"), qos=0, retain=True) f = open('/var/www/html/openWB/ramdisk/soc', 'w') f.write(msg.payload.decode("utf-8")) f.close() if (msg.topic == "openWB/set/lp/2/%Soc"): if (float(msg.payload) >= 0 and float(msg.payload) <= 100): + client.publish("openWB/lp/2/%Soc", msg.payload.decode("utf-8"), qos=0, retain=True) f = open('/var/www/html/openWB/ramdisk/soc1', 'w') f.write(msg.payload.decode("utf-8")) f.close() + if (msg.topic == "openWB/set/lp/1/boolSocConfigured"): + client.publish("openWB/lp/1/boolSocConfigured", msg.payload.decode("utf-8"), qos=0, retain=True) + f = open('/var/www/html/openWB/ramdisk/mqttsocvorhanden', 'w') + f.write(msg.payload.decode("utf-8")) + f.close() + if (msg.topic == "openWB/set/lp/2/boolSocConfigured"): + client.publish("openWB/lp/2/boolSocConfigured", msg.payload.decode("utf-8"), qos=0, retain=True) + f = open('/var/www/html/openWB/ramdisk/mqttsoc1vorhanden', 'w') + f.write(msg.payload.decode("utf-8")) + f.close() set_pv_match = re.match(r"^openWB/set/pv/([12])/(.*)$", msg.topic) if set_pv_match is not None: pv = files.pv[int(set_pv_match.group(1)) - 1] diff --git a/runs/updateConfig.sh b/runs/updateConfig.sh index 4e52964e1..2fedc38f6 100755 --- a/runs/updateConfig.sh +++ b/runs/updateConfig.sh @@ -1302,6 +1302,11 @@ updateConfig(){ echo "lp${i}etbasedcharging=1" >> $ConfigFile fi done + for i in $(seq 1 8); do + if ! grep -Fq "lp${i}etchargemaxprice=" $ConfigFile; then + echo "lp${i}etchargemaxprice=0" >> $ConfigFile + fi + done if ! grep -Fq "plz=" $ConfigFile; then echo "plz=36124" >> $ConfigFile fi @@ -1506,6 +1511,15 @@ updateConfig(){ if ! grep -Fq "displaylp2max=" $ConfigFile; then echo "displaylp2max=22000" >> $ConfigFile fi + if ! grep -Fq "displayshowprice=" $ConfigFile; then + echo "displayshowprice=0" >> $ConfigFile + fi + if ! grep -Fq "displayshowrfidpad=" $ConfigFile; then + echo "displayshowrfidpad=0" >> $ConfigFile + fi + if ! grep -Fq "displayallowsetmaxprice=" $ConfigFile; then + echo "displayallowsetmaxprice=0" >> $ConfigFile + fi if ! grep -Fq "displaypinaktiv=" $ConfigFile; then echo "displaypinaktiv=0" >> $ConfigFile fi diff --git a/sofortlademodus.sh b/sofortlademodus.sh index 891a52b24..bc4c170b7 100755 --- a/sofortlademodus.sh +++ b/sofortlademodus.sh @@ -10,28 +10,27 @@ sofortlademodus(){ fi if (( etprovideraktiv == 1 )); then actualprice=$( diff --git a/web/display/minimal/index.php b/web/display/minimal/index.php index fbd54a75f..f2a06abdf 100644 --- a/web/display/minimal/index.php +++ b/web/display/minimal/index.php @@ -1,5 +1,5 @@ - + @@ -19,15 +19,14 @@ + - - + - + +
- -
- - -
LP1
-
0
-
0
-
- - - +
+ +
+ + +
LP1
+
0
+
0
+
+ + + +
-
-
- - -
LP2
-
0
-
0
-
- - - +
+ + +
LP2
+
0
+
0
+
+ + + +
-
- -
- - -
0
-
0
-
- - - + +
+ + +
0
+
0
+
+ + + +
+ +
+ 0 && $displayshowrfidpadold > 0) { ?> +
+ +
+ + 0) { ?> +
+ + +
+ + 0) { ?> +
Preis: 25 ct/kWh
+
Limit LP1: 95 ct/kWh
+
Limit LP2: 95 ct/kWh
+
+ +
+ +
+
+ + + @@ -103,10 +182,10 @@ +
+
+ +
+
+
+ + +
+
+
+
+
+ +
+
+
+ + +
+
+
+
+
+ +
+
+
+ + +
+
+

@@ -1393,12 +1438,18 @@ function visibility_displaypinaktiv() { function visibility_displaytheme() { switch ($('#displaytheme').val()) { case '0': // Cards + hideSection('#displayprice'); + hideSection('#displayrfidpad'); + hideSection('#displaysetmaxprice'); showSection('#displaygauge'); for (let cp = 1; cp < 9; cp++) { showSection('#displaylp' + cp); } break; case '2': // Minimal + showSection('#displayprice'); + showSection('#displayrfidpad'); + showSection('#displaysetmaxprice'); hideSection('#displaygauge'); for (let cp = 1; cp < 3; cp++) { showSection('#displaylp' + cp); @@ -1408,6 +1459,9 @@ function visibility_displaytheme() { } break; case '3': // Gauges + hideSection('#displayprice'); + hideSection('#displayrfidpad'); + hideSection('#displaysetmaxprice'); showSection('#displaygauge'); for (let cp = 1; cp < 3; cp++) { showSection('#displaylp' + cp); @@ -1417,6 +1471,9 @@ function visibility_displaytheme() { } break; default: + hideSection('#displayprice'); + hideSection('#displayrfidpad'); + hideSection('#displaysetmaxprice'); hideSection('#displaygauge'); for (let cp = 1; cp < 9; cp++) { hideSection('#displaylp' + cp); diff --git a/web/settings/sofortconfig.php b/web/settings/sofortconfig.php index 62c48eba2..0acc338d2 100644 --- a/web/settings/sofortconfig.php +++ b/web/settings/sofortconfig.php @@ -162,11 +162,14 @@ Aus +
- Aktiviert/Deaktiviert Preisbasiertes Laden + Aktiviert/Deaktiviert Preisbasiertes Laden. "Global": Limit gilt Ladepunktübergreifend. Lokal: Preis kann für jeden Ladpunkt individuelll eingestellt werden.