Also von vorne nach hinten: Am Ladepunkt ist ein Fahrzeug angesteckt. Das steht im MQTT-Topic openWB/chargepoint/4/get/connected_vehicle (die 4 bitte durch die richtige ID ersetzen.) Da steht dann drin, welche ID des Fahrzeugs gerade eingesteckt ist (bei mir die 1). Dementsprechend steht dann in openWB/vehicle/1/charge_template, welches das Ladeprofil dieses Fahrzeugs ist - bei mir mal wieder die 1. Und dieses Ladeprofil hat einen charge_mode_selected, den man - wie im UI - auf die verschiedenen Werte setzen kann. Das macht der folgende Flow, in dem man meine "1" bitte durch das jeweilig in Frage kommende Ladeprofil-ID ersetzen muss:
Dummerweise ist das ganze Ladeprofil inklusive des Lademodus in einem JSON enthalten, wir wollen aber nur den charge_mode ändern und die restlichen Parameter so lassen, wie sie konfiguriert sind. Aus diesem Grund lesen wir beim Start (oder Deploy) von nodeRed das für uns in Frage kommende Ladeprofil und speichern sie im Flow-Memory. Jede Änderung im UI der openWB wird auch hier repliziert, so dass man auch weiterhin im UI den Lademodus verstellen kann. Die Inject-Nodes nehmen nun das im Flow-Memory gespeicherte Ladeprofil, überschreiben den Lademodus und schicken das Ganze an die openWB.
Fertig.
Code: Alles auswählen
[{"id":"1c7d19cb.3a689e","type":"tab","label":"Lademodus","disabled":false,"info":""},{"id":"2b0e1eac.981b3a","type":"mqtt in","z":"1c7d19cb.3a689e","name":"","topic":"openWB/vehicle/template/charge_template/1","qos":"2","datatype":"json","broker":"c4cb83c8.1bd0c","x":210,"y":180,"wires":[["42a478c7.ef2d1","390baace.f0176e"]]},{"id":"42a478c7.ef2d1","type":"debug","z":"1c7d19cb.3a689e","name":"LP_Lademodus","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":620,"y":240,"wires":[]},{"id":"390baace.f0176e","type":"change","z":"1c7d19cb.3a689e","name":"","rules":[{"t":"set","p":"ladepunkt","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":180,"wires":[[]]},{"id":"acba89a9.19cf78","type":"inject","z":"1c7d19cb.3a689e","name":"PV","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":400,"wires":[["808c7784.8ee8a8"]]},{"id":"808c7784.8ee8a8","type":"change","z":"1c7d19cb.3a689e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"ladepunkt","tot":"flow"},{"t":"set","p":"payload.chargemode.selected","pt":"msg","to":"pv_charging","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":400,"wires":[["722d1e87.171a5"]]},{"id":"824c0ab.1fc64f8","type":"inject","z":"1c7d19cb.3a689e","name":"Sofort","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":360,"wires":[["d0015579.193b98"]]},{"id":"d0015579.193b98","type":"change","z":"1c7d19cb.3a689e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"ladepunkt","tot":"flow"},{"t":"set","p":"payload.chargemode.selected","pt":"msg","to":"instant_charging","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":360,"wires":[["722d1e87.171a5"]]},{"id":"722d1e87.171a5","type":"mqtt out","z":"1c7d19cb.3a689e","name":"","topic":"openWB/set/vehicle/template/charge_template/1","qos":"","retain":"","broker":"c4cb83c8.1bd0c","x":770,"y":440,"wires":[]},{"id":"ac9d59de.41ef8","type":"inject","z":"1c7d19cb.3a689e","name":"Standby","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":480,"wires":[["4a8799c8.414be"]]},{"id":"4a8799c8.414be","type":"change","z":"1c7d19cb.3a689e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"ladepunkt","tot":"flow"},{"t":"set","p":"payload.chargemode.selected","pt":"msg","to":"standby","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":480,"wires":[["722d1e87.171a5"]]},{"id":"7d9c7562.4fbfbc","type":"inject","z":"1c7d19cb.3a689e","name":"Stop","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":520,"wires":[["5d2428f6.b2e39"]]},{"id":"5d2428f6.b2e39","type":"change","z":"1c7d19cb.3a689e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"ladepunkt","tot":"flow"},{"t":"set","p":"payload.chargemode.selected","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":520,"wires":[["722d1e87.171a5"]]},{"id":"4845d175.9e13c8","type":"inject","z":"1c7d19cb.3a689e","name":"Zielladen","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":440,"wires":[["3358c83a.0e265"]]},{"id":"3358c83a.0e265","type":"change","z":"1c7d19cb.3a689e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"ladepunkt","tot":"flow"},{"t":"set","p":"payload.chargemode.selected","pt":"msg","to":"scheduled_charging","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":440,"wires":[["722d1e87.171a5"]]},{"id":"9c428ab0.c46f2","type":"comment","z":"1c7d19cb.3a689e","name":"Holt das aktuellen Ladeprofils und speichern der Werte im Flow-Memory (wird auch bei Deploy aufgerufen)","info":"","x":400,"y":120,"wires":[]},{"id":"6aeacc41.a580ec","type":"comment","z":"1c7d19cb.3a689e","name":"Nimmt das Ladeprofil aus dem Flow-Memory und ändert den Lademodus entsprechend der Inject-Node","info":"","x":400,"y":300,"wires":[]},{"id":"826eb5cf.eb4d38","type":"comment","z":"1c7d19cb.3a689e","name":"Die Template-ID in den beiden MQTT-Nodes muss durch die jeweilig korrekte ersetzt werden","info":"","x":360,"y":40,"wires":[]},{"id":"c4cb83c8.1bd0c","type":"mqtt-broker","name":"OpenWB","broker":"192.168.8.11","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"30","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""}]