Beispiel: openWB mobile App für IOS+Android (Blynk - über Node-Red/MQTT)

Antworten
hominidae
Beiträge: 121
Registriert: Di Sep 03, 2019 4:13 pm

Beispiel: openWB mobile App für IOS+Android (Blynk - über Node-Red/MQTT)

Beitrag von hominidae » So Nov 24, 2019 9:51 pm

Hallo Gemeinde,

MQTT ist prima, aber MQTT-Dash unter ANdroid hat nicht so viele Möglichkeiten/Widgets.
Hier noch ein Experiment für eine andere "native" App (Android + IOS) auf dem SmartPhone oder Tablet.

Die App nennt sich Blynk (https://docs.blynk.cc/) und ist eigentlich gedacht für die Integration mit "kleinen" IoT-Devices (Arduino, ESP8266, RPi).
Als Verbindung zur App dient der Blynk-Service ... den gibt es auch als lokales Java-Programm (https://docs.blynk.cc/#blynk-server).
Ich nutze diesen lokal auf meinen NAS in einem Docker Container-

Die IoT Geräte verbinden sich als "Hardware" ebenfalls mit dem Server.
Ein- und Ausgaben werden dabei mit PINs, also echte Ein- und Ausgangs-Ports der Geräte verbunden.
Nun, da die openWB keine native Blynk-kompatible Hardware darstellt, nutzen wir einen Trick.
Wir "bauen" uns eine generische Hardware, die sich über WebServices mit dem Blynk-Server verbindet.
Auf Seiten der openWB nutzen wir das MQTT-Interface.
Beides zusammen packen wir in einen Node-Red Flow.

Das Grundprinzip: MQTT-Topics der openWB werden auf die Hardware-"Pins" der virtuellen Blynk-Hardware gemappt.
Unsere generische Node-Red Hardware hat keine echten PINS, aber Blynk erlaubt die Nutzung von "virtuellen" Pins (Vx).

In der App kann man sich im Server einzelne Projekte anlegen, das UI zusammenbauen und, wenn die Hardware mit dem Server verbunden ist, die Ein- und Ausgaben bedienen.

Hier als Beispiel ein kleines UI für 2 Ladepunkte (dargestellt im Edit-Modus, die V0, V1, ... sind die virtuellen PINs, die auf die UI-Elemente konfiguriert wurden):
Bild


...und in "Betrieb", LP1 lädt aktuell, LP2 ist nur eingesteckt:
Bild


...in der Mitte ist das SuperChart-Widget, das man auch in den Vollbild-Modus versetzten kann.
Einzelne Graphen können ein- oder ausgeblendet werden und man kann auch die einzelnen Graphen "abfahren" um die konkreten Werte am Schnittpunkt x/y anzuzeigen.
Dargestellt wird der Verlauf Leistung(W) von LP1, LP2 und EVU-gesamt.
Man kann die Anzeige auf verschiedene Zeiträume umstellen (live, 1h, 1d, ...)
Bild


...um Blynk Webservises im Node-Red zu nutzen, benötigt man das passende Modul: https://flows.nodered.org/node/node-red ... b-blynk-ws
Der Flow um die openWB mit diesem Blynk UI zu verbinden, sieht dann so aus:
Bild

Code: Alles auswählen

[{"id":"76b5500.0f70eb","type":"tab","label":"OpenWB - Blynk","disabled":false,"info":""},{"id":"20ab4480.c85c3c","type":"mqtt in","z":"76b5500.0f70eb","name":"from OpenWB","topic":"openWB/#","qos":"2","datatype":"auto","broker":"3f8c598e.c1f426","x":90,"y":340,"wires":[["6f1e4f90.4639f"]]},{"id":"4017e6eb.606e18","type":"blynk-ws-out-write","z":"76b5500.0f70eb","name":"To Blynk","pin":"0","pinmode":"1","client":"29422b14.487f94","x":1140,"y":340,"wires":[]},{"id":"6f1e4f90.4639f","type":"switch","z":"76b5500.0f70eb","name":"switch per topic","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"openWB/system/Timestamp","vt":"str"},{"t":"eq","v":"openWB/lp1/boolPlugStat","vt":"str"},{"t":"eq","v":"openWB/lp1/boolChargeStat","vt":"str"},{"t":"eq","v":"openWB/lp1/W","vt":"str"},{"t":"eq","v":"openWB/lp1/kWhChargedSincePlugged","vt":"str"},{"t":"eq","v":"openWB/lp2/boolPlugStat","vt":"str"},{"t":"eq","v":"openWB/lp2/boolChargeStat","vt":"str"},{"t":"eq","v":"openWB/lp2/W","vt":"str"},{"t":"eq","v":"openWB/lp2/kWhChargedSincePlugged","vt":"str"},{"t":"eq","v":"openWB/evu/W","vt":"str"}],"checkall":"true","repair":false,"outputs":10,"x":260,"y":340,"wires":[["3f9eb842.49c068"],["2a815bfc.44cf74"],["ff344afd.4db7e8"],["c6b376fc.409128"],["933d651c.992938"],["564561d5.8115a"],["2845ae2d.e531f2"],["1d4a21c1.129e7e"],["7faa8249.fd192c"],["3a452df3.749a52"]]},{"id":"950e6917.d99db8","type":"change","z":"76b5500.0f70eb","name":"Timestamp = V0","rules":[{"t":"set","p":"pin","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":80,"wires":[["4017e6eb.606e18"]]},{"id":"3f9eb842.49c068","type":"moment","z":"76b5500.0f70eb","name":"dd DD.MM.YY - HH:mm:ss","topic":"date","input":"payload","inputType":"msg","inTz":"Europe/Berlin","adjAmount":0,"adjType":"days","adjDir":"add","format":"dd DD.MM.YY - HH:mm:ss","locale":"DE","output":"payload","outputType":"msg","outTz":"Europe/Berlin","x":580,"y":80,"wires":[["950e6917.d99db8"]]},{"id":"7802e1e3.ac79c","type":"change","z":"76b5500.0f70eb","name":"LP1 gesteckt = V3","rules":[{"t":"set","p":"pin","pt":"msg","to":"3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":140,"wires":[["4017e6eb.606e18"]]},{"id":"2a815bfc.44cf74","type":"calculator","z":"76b5500.0f70eb","name":"LED x255","inputMsgField":"payload","outputMsgField":"payload","operation":"mult","constant":"255","x":600,"y":140,"wires":[["7802e1e3.ac79c"]]},{"id":"564561d5.8115a","type":"calculator","z":"76b5500.0f70eb","name":"LED x255","inputMsgField":"payload","outputMsgField":"payload","operation":"mult","constant":"255","x":540,"y":380,"wires":[["1f5b3955.f37fc7"]]},{"id":"1f5b3955.f37fc7","type":"change","z":"76b5500.0f70eb","name":"LP2 gesteckt = V8","rules":[{"t":"set","p":"pin","pt":"msg","to":"8","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":380,"wires":[["4017e6eb.606e18"]]},{"id":"ff344afd.4db7e8","type":"calculator","z":"76b5500.0f70eb","name":"LED x255","inputMsgField":"payload","outputMsgField":"payload","operation":"mult","constant":"255","x":600,"y":220,"wires":[["c1f74050.82beb"]]},{"id":"c1f74050.82beb","type":"change","z":"76b5500.0f70eb","name":"LP1 wird geladen = V4","rules":[{"t":"set","p":"pin","pt":"msg","to":"4","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":220,"wires":[["4017e6eb.606e18"]]},{"id":"2845ae2d.e531f2","type":"calculator","z":"76b5500.0f70eb","name":"LED x255","inputMsgField":"payload","outputMsgField":"payload","operation":"mult","constant":"255","x":560,"y":440,"wires":[["829e5c4.2ed4ea"]]},{"id":"829e5c4.2ed4ea","type":"change","z":"76b5500.0f70eb","name":"LP2 wird geladen = V9","rules":[{"t":"set","p":"pin","pt":"msg","to":"9","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":440,"wires":[["4017e6eb.606e18"]]},{"id":"c6b376fc.409128","type":"change","z":"76b5500.0f70eb","name":"LP1 Leistung = V5","rules":[{"t":"set","p":"pin","pt":"msg","to":"5","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":280,"wires":[["4017e6eb.606e18"]]},{"id":"1d4a21c1.129e7e","type":"change","z":"76b5500.0f70eb","name":"LP2 Leistung = V10","rules":[{"t":"set","p":"pin","pt":"msg","to":"10","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":520,"wires":[["4017e6eb.606e18"]]},{"id":"933d651c.992938","type":"change","z":"76b5500.0f70eb","name":"LP1 kWh seit anstecken = V6","rules":[{"t":"set","p":"pin","pt":"msg","to":"6","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":340,"wires":[["4017e6eb.606e18"]]},{"id":"7faa8249.fd192c","type":"change","z":"76b5500.0f70eb","name":"LP2 kWh seit anstecken = V11","rules":[{"t":"set","p":"pin","pt":"msg","to":"11","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":580,"wires":[["4017e6eb.606e18"]]},{"id":"3a452df3.749a52","type":"change","z":"76b5500.0f70eb","name":"EVU Leistung = V12","rules":[{"t":"set","p":"pin","pt":"msg","to":"12","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":660,"wires":[["4017e6eb.606e18"]]},{"id":"3f8c598e.c1f426","type":"mqtt-broker","z":"","name":"openWB","broker":"192.168.0.126","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"29422b14.487f94","type":"blynk-ws-client","z":"","name":"OpenWB on Blynk local","path":"ws://192.168.10.66:8080/websockets","key":"MH8Og5-Sb-DwWnjM7FCTL6t0t1wk0m1Q","dbg_all":false,"dbg_read":false,"dbg_write":false,"dbg_notify":false,"dbg_mail":false,"dbg_prop":false,"dbg_sync":false,"dbg_bridge":false,"dbg_low":false,"dbg_pins":"","multi_cmd":true,"proxy_type":"no","proxy_url":"","enabled":true}]

Antworten