victron-raspi-openhab

Einrichtung der openHAB Umgebung und allgemeine Konfigurationsthemen.

Moderatoren: seppy, udo1toni

Antworten
steinadler
Beiträge: 69
Registriert: 29. Apr 2020 19:15
Answers: 0

victron-raspi-openhab

Beitrag von steinadler »

hi
ich mal wieder
bitte nicht lachen...

also
habe victron laderegler
daran einen raspi mit venus am laufen
dort per node den mqtt senden eingestellt

auf meinen anderen paspi, wo auch openhab läuft bekomme ich über mqqt explorer mitgeloggt folgendes topic
--com.victronenergy.solarcharger.ttyUSB0 - /Dc/0/Voltage--

auszug aus openhab log viewer
2023-04-08 10:14:42.910 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'mqtt:broker:Venus' changed from OFFLINE to ONLINE

2023-04-08 10:14:42.912 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'mqtt:topic:Venus:test' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE


mein thing

Code: Alles auswählen


{
    Thing topic test   "victron"                    
                     {         
      Channels: 
  Type number : Volter   "test"    [ stateTopic="com.victronenergy.solarcharger.ttyUSB0 - /Dc/0/Voltage" ,                transformationPattern="JSONPATH:$.Voltage" ]     
    }   
[mein items

Code: Alles auswählen

Number Volter               "Volt           [%.1f Watt]"                   (Strom)    { channel="mqtt:topic:Venus:Volter"}
fehlercode in openhab

2023-04-08 10:15:03.806 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.Voltage' in '49.5099983215332'

denke mir, dass ich die verschachtelung (JSONPATH) nicht richtig aufgelöst habe

danke und schönes osterfest...

Benutzeravatar
udo1toni
Beiträge: 15247
Registriert: 11. Apr 2018 18:05
Answers: 242
Wohnort: Darmstadt

Re: victron-raspi-openhab

Beitrag von udo1toni »

Also, das eine: Kannst Du das Topic beeinflussen? Das ist fürchterlich.

Und wegen des Wertes: Ich denke mal, Du wirst in MQTT Explorer unter dem Topic com.victronenergy.solarcharger.ttyUSB0 - /Dc/0/Voltage eine nackte Zahl geliefert bekommen, kein JSON. Lass also einfach die Transformation weg.
openHAB4.3.3 stable in einem Debian-Container (bookworm) (Proxmox 8.3.5, LXC), mit openHABian eingerichtet

steinadler
Beiträge: 69
Registriert: 29. Apr 2020 19:15
Answers: 0

Re: victron-raspi-openhab

Beitrag von steinadler »

danke ersteinmal

hatte (habe jetzt wieder) die einstellung

Channels:
Type number : Volter "test" [ stateTopic="test", transformationPattern="JSONPATH:$.test" ] (wegen topic)

ohne transformationPattern="JSONPATH:$.test" bekomme ich nichts mehr im viewer angezeigt, mit wenigstens die fehlermeldung


2023-04-08 11:01:49.023 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.test' in '49.5099983215332'

in node red habe ich den parser json dazwischen (dachte zum umwandeln)
aber ohne geht es auch nicht

das sendet node mit raspi1 Img.venus

8.4.2023, 11:04:56node: debug 1
com.victronenergy.solarcharger.ttyUSB0 - /Dc/0/Voltage : msg.payload : string[16]
"49.5099983215332"

das empfängt viewer am raspi2 mit openhab (mit jetzigem neuen topic)

2023-04-08 11:07:34.052 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.test' in '49.560001373291016'

die gemessenen volt stimmen, bekomme sie nur nicht in openhab angezeigt

Benutzeravatar
udo1toni
Beiträge: 15247
Registriert: 11. Apr 2018 18:05
Answers: 242
Wohnort: Darmstadt

Re: victron-raspi-openhab

Beitrag von udo1toni »

Bitte, es steht doch da, 49.5099983215332 ist nun mal kein JSON, sondern ein Wert, der alternativ als String oder als Number interpretiert werden kann. Du DARFST keine Transformation nutzen! Die Fehlermeldung ist da eindeutig.

Du kannst auch nicht einfach irgendwelche JSONpaths hinschreiben, die müssen exakt auf das gelieferte JSON angepasst sein (wenn denn ein JSON Objekt ankommt). $.test würde z.B. den Inhalt des Knotens "test" liefern, natürlich nur unter der Voraussetzung, dass dieser auch vorhanden ist.

Das Topic kann ebenfalls nicht irgendein beliebiges sein, es muss schon das sein, welches gesendet wird. Nur ist com.victronenergy.solarcharger.ttyUSB0 - /Dc/0/Voltage halt ein fürchterliches Topic. Das musst Du aber zuerst auf Senderseite anpassen (und anschließend eben auch in openHAB).

Du kannst im MQTT Explorer genau sehen, was in Mosquitto ankommt (linke Seite - Baumstruktur - Topic aufklappen bis zum gewünschten Wert. Rechts oben siehst Du unmittelbar das gewählte Topic und dessen aktuellen Inhalt (sowie auf Wunsch auch die vorherigen Inhalte).
Wenn der Inhalt so aussieht:

Code: Alles auswählen

49.5099983215332
handelt es sich einfach um einen diskreten Wert, den Du auch zwingend direkt so verwenden musst (allenfalls könntest Du eine Script Transformation nutzen, um z.B. das Komma zu verschieben oder fehlerhafte Werte auszusieben).
Sieht der Inhalt so aus:

Code: Alles auswählen

{"value":"49.5099983215332","city":"Konstantinopel"}
dann handelt es sich um ein JSON Objekt, welches Du mit JSONPATH transformieren kannst. Der String vor dem Doppelpunkt ist dann der Name des Wertes, den Du über JSONPATH ansprechen kannst. Hier also wahlweise $.value oder $.city.
openHAB4.3.3 stable in einem Debian-Container (bookworm) (Proxmox 8.3.5, LXC), mit openHABian eingerichtet

rbeudel
Beiträge: 253
Registriert: 6. Jun 2019 11:25
Answers: 1

Re: victron-raspi-openhab

Beitrag von rbeudel »

Ich habe mal meine things und items kopiert:

Code: Alles auswählen

Bridge mqtt:broker:venus "MQTT Broker VenusOS"[ host="192.168.1.107",port="1883", secure=false ]
Thing mqtt:topic:victron "Victron VenusOS" (mqtt:broker:venus) {
  Channels:
    Type number : V_AC_V_L1 "Victron Verbrauch L1" [ stateTopic="N/b827eb9a431d/system/0/Ac/Consumption/L1/Power", transformationPattern="JSONPATH:$.value"]
    Type number : V_AC_V_L2 "Victron Verbrauch L2" [ stateTopic="N/b827eb9a431d/system/0/Ac/Consumption/L2/Power", transformationPattern="JSONPATH:$.value"]
    Type number : V_AC_V_L3 "Victron Verbrauch L3" [ stateTopic="N/b827eb9a431d/system/0/Ac/Consumption/L3/Power", transformationPattern="JSONPATH:$.value"]
    Type number : V_AC_G_L1 "Victron Netz L1"      [ stateTopic="N/b827eb9a431d/system/0/Ac/Grid/L1/Power", transformationPattern="JSONPATH:$.value"]
    Type number : V_AC_G_L2 "Victron Netz L2"      [ stateTopic="N/b827eb9a431d/system/0/Ac/Grid/L2/Power", transformationPattern="JSONPATH:$.value"]
    Type number : V_AC_G_L3 "Victron Netz L3"      [ stateTopic="N/b827eb9a431d/system/0/Ac/Grid/L3/Power", transformationPattern="JSONPATH:$.value"]

    Type number : V_DC_Power "Victron DC Power"    [ stateTopic="N/b827eb9a431d/battery/1/Dc/0/Power", transformationPattern="JSONPATH:$.value"]
    Type number : V_DC_Volt "Victron DC Volt"      [ stateTopic="N/b827eb9a431d/system/0/Dc/Battery/Voltage", transformationPattern="JSONPATH:$.value"]
    
    Type number : V_Batt_Soc "Victron Batt Soc [%.0f %%]"    [ stateTopic="N/b827eb9a431d/system/0/Dc/Battery/Soc", transformationPattern="JSONPATH:$.value"]
    Type number : V_Batt_Temp "Victron Batt Temp"  [ stateTopic="N/b827eb9a431d/system/0/Dc/Battery/Temperature", transformationPattern="JSONPATH:$.value"]
    Type number : V_Batt_Curr "Victron Batterie Strom" [ stateTopic="N/b827eb9a431d/system/0/Dc/Battery/Current", transformationPattern="JSONPATH:$.value"]
    Type number : V_Batt_cell1 "Victron Batterie Zelle 1"  [ stateTopic="N/b827eb9a431d/battery/1/Voltages/Cell1", transformationPattern="JSONPATH:$.value"]
    Type number : V_Batt_cell2 "Victron Batterie Zelle 2"  [ stateTopic="N/b827eb9a431d/battery/1/Voltages/Cell2", transformationPattern="JSONPATH:$.value"]
    Type number : V_Batt_cell3 "Victron Batterie Zelle 3"  [ stateTopic="N/b827eb9a431d/battery/1/Voltages/Cell3", transformationPattern="JSONPATH:$.value"]
    Type number : V_Batt_cell4 "Victron Batterie Zelle 4"  [ stateTopic="N/b827eb9a431d/battery/1/Voltages/Cell4", transformationPattern="JSONPATH:$.value"]
    Type number : V_Batt_cell5 "Victron Batterie Zelle 5"  [ stateTopic="N/b827eb9a431d/battery/1/Voltages/Cell5", transformationPattern="JSONPATH:$.value"]
    Type number : V_Batt_cell6 "Victron Batterie Zelle 6"  [ stateTopic="N/b827eb9a431d/battery/1/Voltages/Cell6", transformationPattern="JSONPATH:$.value"]
    Type number : V_Batt_cell7 "Victron Batterie Zelle 7"  [ stateTopic="N/b827eb9a431d/battery/1/Voltages/Cell7", transformationPattern="JSONPATH:$.value"]
    Type number : V_Batt_cell8 "Victron Batterie Zelle 8"  [ stateTopic="N/b827eb9a431d/battery/1/Voltages/Cell8", transformationPattern="JSONPATH:$.value"]
    Type number : V_Batt_cell9 "Victron Batterie Zelle 9"  [ stateTopic="N/b827eb9a431d/battery/1/Voltages/Cell9", transformationPattern="JSONPATH:$.value"]
    Type number : V_Batt_cell10 "Victron Batterie Zelle 10"  [ stateTopic="N/b827eb9a431d/battery/1/Voltages/Cell10", transformationPattern="JSONPATH:$.value"]
    Type number : V_Batt_cell11 "Victron Batterie Zelle 11"  [ stateTopic="N/b827eb9a431d/battery/1/Voltages/Cell11", transformationPattern="JSONPATH:$.value"]
    Type number : V_Batt_cell12 "Victron Batterie Zelle 12"  [ stateTopic="N/b827eb9a431d/battery/1/Voltages/Cell12", transformationPattern="JSONPATH:$.value"]
    Type number : V_Batt_cell13 "Victron Batterie Zelle 13"  [ stateTopic="N/b827eb9a431d/battery/1/Voltages/Cell13", transformationPattern="JSONPATH:$.value"]
    Type number : V_Batt_cell14 "Victron Batterie Zelle 14"  [ stateTopic="N/b827eb9a431d/battery/1/Voltages/Cell14", transformationPattern="JSONPATH:$.value"]
    Type number : V_Batt_cell15 "Victron Batterie Zelle 15"  [ stateTopic="N/b827eb9a431d/battery/1/Voltages/Cell15", transformationPattern="JSONPATH:$.value"]
    Type number : V_Batt_cell16 "Victron Batterie Zelle 16"  [ stateTopic="N/b827eb9a431d/battery/1/Voltages/Cell16", transformationPattern="JSONPATH:$.value"]
    Type number : V_Batt_cell_div "Victron Batterie Zelle Drift"  [ stateTopic="N/b827eb9a431d/battery/1/Voltages/Diff", transformationPattern="JSONPATH:$.value"]

    Type number : V_Sys_Stat "Victron Sys Status"  [ stateTopic="N/b827eb9a431d/system/0/SystemState/State", transformationPattern="JSONPATH:$.value"]
    Type number : V_Raspi_Temp "Victron Raspi Temperatur" [ stateTopic="N/b827eb9a431d/temperature/29/Temperature",  transformationPattern="JSONPATH:$.value"]
    Type number : V_ESS_SOC "Victron tatsächlicher SOC Limit" [ stateTopic="N/b827eb9a431d/settings/0/Settings/CGwacs/BatteryLife/SocLimit",  transformationPattern="JSONPATH:$.value"]}

Code: Alles auswählen

Group Victron         "Victron"                          <energy>      (boilerroom)  ["Inverter"]
Group:Number:SUM        Gesamtverbrauch "Gesamtverbrauch [%.0f W]"               <energy>        (Victron)
 Number V_AC_V_L1      "Victron Verbrauch L1 [%.1f W]"                 (Victron, Gesamtverbrauch) ["Energy"]   { channel="mqtt:topic:victron:V_AC_V_L1" }
 Number V_AC_V_L2      "Victron Verbrauch L2 [%.1f W]"                 (Victron, Gesamtverbrauch) ["Energy"]   { channel="mqtt:topic:victron:V_AC_V_L2" }
 Number V_AC_V_L3      "Victron Verbrauch L3 [%.1f W]"                 (Victron, Gesamtverbrauch) ["Energy"]   { channel="mqtt:topic:victron:V_AC_V_L3" }
 Number V_AC_G_L1      "Victron Netz L1 [%.1f W]"                      (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_AC_G_L1" }
 Number V_AC_G_L2      "Victron Netz L2 [%.1f W]"                      (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_AC_G_L2" }
 Number V_AC_G_L3      "Victron Netz L3 [%.1f W]"                      (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_AC_G_L3" }

 Number V_DC_Power     "Victron Battery Power [%.0f W]"                (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_DC_Power" }
 Number V_DC_Volt      "Victron Battery Volt [%.2f V]"                 (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_DC_Volt" }

 Number V_Batt_Soc     "Victron Battery Soc [%.0f %%]"  <battery>      (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_Batt_Soc" }
 Number V_ESS_SOC     "Victron tatsächlicher Soc Limit [%.0f %%]"  <battery>      (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_ESS_SOC" }
 Number V_Batt_Temp    "Victron Battery Temp [%.1f °C]" <temperatur>   (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_Batt_Temp" }
 Number V_Batt_Curr    "Victron Battery Strom [%.1f A]" <text> (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_Batt_Curr" }
 Number V_Raspi_Temp   "Victron Raspi Temperatur [%.1f °C]" <temperatur> (Victron) ["Energy"] { channel="mqtt:topic:victron:V_Raspi_Temp" }

 Number V_Sys_Stat     "Victron Status [MAP(VictronSystemState.map):%s]" (Victron) ["Energy"] { channel="mqtt:topic:victron:V_Sys_Stat" }
 Number  V_Batt_cell1      "Victron Batterie Zelle 1 [%.3f V]"                 (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_Batt_cell1" }
 Number  V_Batt_cell2      "Victron Batterie Zelle 2 [%.3f V]"                 (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_Batt_cell2" }
 Number  V_Batt_cell3      "Victron Batterie Zelle 3 [%.3f V]"                 (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_Batt_cell3" }
 Number  V_Batt_cell4      "Victron Batterie Zelle 4 [%.3f V]"                 (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_Batt_cell4" }
 Number  V_Batt_cell5      "Victron Batterie Zelle 5 [%.3f V]"                 (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_Batt_cell5" }
 Number  V_Batt_cell6      "Victron Batterie Zelle 6 [%.3f V]"                 (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_Batt_cell6" }
 Number  V_Batt_cell7      "Victron Batterie Zelle 7 [%.3f V]"                 (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_Batt_cell7" }  
 Number  V_Batt_cell8      "Victron Batterie Zelle 8 [%.3f V]"                 (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_Batt_cell8" } 
 Number  V_Batt_cell9      "Victron Batterie Zelle 9 [%.3f V]"                 (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_Batt_cell9" }
 Number  V_Batt_cell10      "Victron Batterie Zelle 10 [%.3f V]"                 (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_Batt_cell10" }
 Number  V_Batt_cell11      "Victron Batterie Zelle 11 [%.3f V]"                 (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_Batt_cell11" }
 Number  V_Batt_cell12      "Victron Batterie Zelle 12 [%.3f V]"                 (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_Batt_cell12" }
 Number  V_Batt_cell13      "Victron Batterie Zelle 13 [%.3f V]"                 (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_Batt_cell13" }
 Number  V_Batt_cell14      "Victron Batterie Zelle 14 [%.3f V]"                 (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_Batt_cell14" }
 Number  V_Batt_cell15      "Victron Batterie Zelle 15 [%.3f V]"                 (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_Batt_cell15" }
 Number  V_Batt_cell16      "Victron Batterie Zelle 16 [%.3f V]"                 (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_Batt_cell16" }
 Number  V_Batt_cell_div      "Victron Batterie Zelle Drift [%.3f V]"                 (Victron) ["Energy"]   { channel="mqtt:topic:victron:V_Batt_cell_div" }
Kann man sicher noch optimieren
Viele Grüße,
Ralf


Debmatic und Openhab in Proxmox VM debian x86_64

Antworten