Auslesen der Daten über hhtp requests (JSON)

In diesen Blog Eintrag geht um das Auslesen der Daten per http request mit NodeRed.


:!: Leider hat diese Vorgehensweise bei mir in Bezug auf die Werte der einzelnen Strings nicht zufriedenstellend funktioniert. Diese Werte sind per http request nicht als aktueller Wert sondern nur in einer Historie für die Vergangenheit abrufbar. Aus diesem Grund nutze ich nun die Möglichkeit die Daten per Modbus TCP abzufragen. Dieses Vorgehen ist in der Installationsanleitung beschrieben.


Grundlagen

Die Fronius Wechselrichter stellen mehrere Schnittstellen zur Abfrage der Systemdaten zur Verfügung:

  • Fronius Push Service
  • Fronius Solar API (JSON) (hier verwendet)
  • Modbus RTU
  • Modbus TCP (verwendet in der Installationsanleitung)


Auf dieser Internetseite findet ihr die Dokumentation der Schnittstellen: https://www.fronius.com/de/sol…n/fronius-solar-api-json-


In der folgenden Tabelle hatte ich mir damals alle relevanten Informationen aus der Schnittstellen Spezifikation rausgesucht JSON.pdf

NodeRed aufrufen und konfigurieren

  • Ruft über euren Browser NodeRed auf: IP:1880 oder HOSTNAME:1880 -> Login mit den von euch definierten Benutzerdaten
  • Installation der Erweitungen über Palette verwalten / installeren: node-red-contrib-influxdb, node-red-contrib-moment


Aufbau des Flows

  • Beginn steht immer ein inject Node der die Abfrage auslöst. Ich habe hier 10 Sekunden für Werte wie z.B. die aktuelle Leistung verwendet und 10 Minuten für Zählerstände usw.
  • In der ersten Zeile wird das Datum für die Abfrage der historischen Daten angepasst damit die Daten abgefragt werden können
  • Es folgt ein http request Node der die Daten beim Wechselrichter abholt
  • Im function Node werden die Daten aufbereitet und in ein Array gespeichert
  • Zum Schluss speichert der influxdb out Node die Daten in der InfluxDB


Import des Flows


Ihr könnt folgenden Flow importieren, jedoch müsst ihr diese Punkte Anpassen:


  • IP-Adresse des Wechselrichters der http request Nodes
  • Datenbank, Benutzername und Passwort der influxdb out Nodes


Code
[{"id":"dd6ae5f8.d2213","type":"http request","z":"51122c73.230094","name":"Fronius","method":"GET","ret":"obj","paytoqs":false,"url":"","tls":"","persist":false,"proxy":"","authType":"","x":880,"y":160,"wires":[["51601551.d1ce14"]]},{"id":"61610f35.48c678","type":"inject","z":"51122c73.230094","name":"5 Minuten","topic":"","payload":"","payloadType":"date","repeat":"300","crontab":"","once":false,"onceDelay":0.1,"x":250,"y":160,"wires":[["823ed700.05f838"]]},{"id":"d47551ab.00d378","type":"http request","z":"51122c73.230094","name":"","method":"GET","ret":"obj","paytoqs":false,"url":"http://192.168.16.24/solar_api/v1/GetPowerFlowRealtimeData.fcgi","tls":"","persist":false,"proxy":"","authType":"","x":870,"y":280,"wires":[["a8164f9.ffbf93"]]},{"id":"591f6e95.47f85","type":"influxdb out","z":"51122c73.230094","influxdb":"a609b286.bc25d","name":"","measurement":"string","precision":"","retentionPolicy":"","x":1260,"y":160,"wires":[]},{"id":"a8164f9.ffbf93","type":"function","z":"51122c73.230094","name":"","func":"var msg_Power = {};\nvar msg_Statistic = {};\n\n// Sollte P_PV = NULL sein muss 0 gesetzt werden\nif (msg.payload.Body.Data.Site.P_PV === null) {msg.payload.Body.Data.Site.P_PV = 0}\nif (msg.payload.Body.Data.Site.rel_SelfConsumption === null) {msg.payload.Body.Data.Site.rel_SelfConsumption = 0}\n\nmsg_Power.payload = [\n {\n P_Grid : msg.payload.Body.Data.Site.P_Grid,\n P_Load : -1 * msg.payload.Body.Data.Site.P_Load,\n P_PV : msg.payload.Body.Data.Site.P_PV,\n P_PV_Self : (msg.payload.Body.Data.Site.P_PV/100)*msg.payload.Body.Data.Site.rel_SelfConsumption,\n },\n];\n\n\nmsg_Statistic.payload = [\n {\n n_Autonomy : msg.payload.Body.Data.Site.rel_Autonomy,\n n_Self_Consumption : msg.payload.Body.Data.Site.rel_SelfConsumption,\n },\n];\n\n\nreturn [msg_Power,msg_Statistic];\n","outputs":2,"noerr":0,"x":1030,"y":280,"wires":[["308a6a6.13a5c16"],["2e1350ca.f89e8"]]},{"id":"823ed700.05f838","type":"moment","z":"51122c73.230094","name":"","topic":"","input":"","inputType":"msg","inTz":"Europe/Berlin","adjAmount":"1","adjType":"hours","adjDir":"subtract","format":"YYYY-MM-DDTHH:MM:ss","locale":"de_DE","output":"","outputType":"msg","outTz":"Europe/Berlin","x":480,"y":160,"wires":[["2f5e1fbe.3ebcd8"]]},{"id":"2f5e1fbe.3ebcd8","type":"change","z":"51122c73.230094","name":"","rules":[{"t":"set","p":"url","pt":"msg","to":"http://192.168.16.24/solar_api/v1/GetArchiveData.cgi?Scope=System&Channel=Voltage_DC_String_1&Channel=Voltage_DC_String_2&Channel=Current_DC_String_1&Channel=Current_DC_String_2&Channel=PowerReal_PAC_Sum","tot":"str"},{"t":"set","p":"url","pt":"msg","to":"$.url & \"&StartDate=\" & $.payload & \"+00:05\" & \"&EndDate=\" & $.payload &\"Z\" ","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":160,"wires":[["dd6ae5f8.d2213"]]},{"id":"51601551.d1ce14","type":"function","z":"51122c73.230094","name":"","func":"var msg1 = {};\n\n//Ermittlung der Timeslots zur Abfrage der Variablen. Timeslot 0 ist dann der aktuellste\nvar timeslot = Object.keys(msg.payload.Body.Data['inverter/1'].Data.Current_DC_String_1.Values)\n\n// String 1\nvar Current_DC_String_1 = msg.payload.Body.Data['inverter/1'].Data.Current_DC_String_1.Values[timeslot[0]]\nvar Voltage_DC_String_1 = msg.payload.Body.Data['inverter/1'].Data.Voltage_DC_String_1.Values[timeslot[0]]\nvar Power_DC_String_1 = Current_DC_String_1 * Voltage_DC_String_1\n \n//String 2\nvar Current_DC_String_2 = msg.payload.Body.Data['inverter/1'].Data.Current_DC_String_2.Values[timeslot[0]]\nvar Voltage_DC_String_2 = msg.payload.Body.Data['inverter/1'].Data.Voltage_DC_String_2.Values[timeslot[0]]\nvar Power_DC_String_2 = Voltage_DC_String_2 * Current_DC_String_2\n\n// Gesamtleistung AC & DC\nvar Power_AC_Sum = msg.payload.Body.Data['inverter/1'].Data.PowerReal_PAC_Sum.Values[timeslot[0]]\nvar Power_DC_Sum = Power_DC_String_1 + Power_DC_String_2\n\n// Wirkungsgrad berechnen\nvar Efficiency_ACDC = (Power_AC_Sum / Power_DC_Sum) * 100\n\n\n// Daten inkl. Wirkungsgrad ins Array schreiben\nif (Efficiency_ACDC > 0){\n msg1.payload = [\n {\n //String 1\n Current_DC_String_1 : Current_DC_String_1,\n Voltage_DC_String_1 : Voltage_DC_String_1,\n Power_DC_String_1 : Power_DC_String_1,\n \n //String 2\n Current_DC_String_2 : Current_DC_String_2,\n Voltage_DC_String_2 : Voltage_DC_String_2,\n Power_DC_String_2 : Power_DC_String_2,\n \n // Gesamtleistung AC & DC\n Power_AC_Sum : Power_AC_Sum,\n Power_DC_Sum : Power_DC_Sum,\n \n Efficiency_ACDC : Efficiency_ACDC,\n }\n ];\n}\n\n// Daten ohne Wirkungsgrad ins Array schreiben\nelse{\n msg1.payload = [\n {\n //String 1\n Current_DC_String_1 : Current_DC_String_1,\n Voltage_DC_String_1 : Voltage_DC_String_1,\n Power_DC_String_1 : Power_DC_String_1,\n \n //String 2\n Current_DC_String_2 : Current_DC_String_2,\n Voltage_DC_String_2 : Voltage_DC_String_2,\n Power_DC_String_2 : Power_DC_String_2,\n \n // Gesamtleistung AC & DC\n Power_AC_Sum : Power_AC_Sum,\n Power_DC_Sum : Power_DC_Sum,\n\n }\n ];\n}\n\n\n\nreturn (msg1);","outputs":1,"noerr":0,"x":1030,"y":160,"wires":[["591f6e95.47f85"]]},{"id":"db730ec2.ae01c","type":"inject","z":"51122c73.230094","name":"10 Sekunden","topic":"","payload":"","payloadType":"date","repeat":"10","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":280,"wires":[["d47551ab.00d378","d874d7b8.1d9e98"]]},{"id":"308a6a6.13a5c16","type":"influxdb out","z":"51122c73.230094","influxdb":"a609b286.bc25d","name":"","measurement":"power","precision":"","retentionPolicy":"","x":1270,"y":240,"wires":[]},{"id":"2e1350ca.f89e8","type":"influxdb out","z":"51122c73.230094","influxdb":"a609b286.bc25d","name":"","measurement":"statistic","precision":"","retentionPolicy":"","x":1270,"y":320,"wires":[]},{"id":"90bce599.3c387","type":"http request","z":"51122c73.230094","name":"","method":"GET","ret":"obj","paytoqs":false,"url":"http://192.168.16.24/solar_api/v1/GetPowerFlowRealtimeData.fcgi","tls":"","persist":false,"proxy":"","authType":"","x":850,"y":480,"wires":[["31044ba4.07e8e4"]]},{"id":"31044ba4.07e8e4","type":"function","z":"51122c73.230094","name":"","func":"var msg_Energy = {};\n\nmsg_Energy.payload = [\n {\n E_PV_Total : msg.payload.Body.Data.Inverters['1'].E_Total/1000\n },\n];\n\nreturn [msg_Energy];","outputs":1,"noerr":0,"x":1010,"y":480,"wires":[["93db2e7a.a76608"]]},{"id":"b6a6c31d.0faad8","type":"inject","z":"51122c73.230094","name":"10 Minuten","topic":"","payload":"","payloadType":"date","repeat":"600","crontab":"","once":false,"onceDelay":0.1,"x":250,"y":540,"wires":[["58193a72.e014a4","8930d79e.d5f1a8","90bce599.3c387"]]},{"id":"93db2e7a.a76608","type":"influxdb out","z":"51122c73.230094","influxdb":"a609b286.bc25d","name":"","measurement":"energy","precision":"","retentionPolicy":"","x":1270,"y":500,"wires":[]},{"id":"58193a72.e014a4","type":"http request","z":"51122c73.230094","name":"","method":"GET","ret":"obj","paytoqs":false,"url":"http://192.168.16.24/solar_api/v1/GetInverterRealtimeData.cgi?&Scope=Device&Datacollection=CommonInverterData&DeviceID=1","tls":"","persist":false,"proxy":"","authType":"","x":850,"y":600,"wires":[["8112dcba.e20f1"]]},{"id":"8112dcba.e20f1","type":"function","z":"51122c73.230094","name":"","func":"var msg_Status = {};\n\n\nmsg_Status.payload = [\n {\n StatusCode : msg.payload.Body.Data.DeviceStatus.StatusCode,\n ErrorCode : msg.payload.Body.Data.DeviceStatus.ErrorCode,\n },\n];\n\n\n\nreturn [msg_Status];","outputs":1,"noerr":0,"x":1010,"y":600,"wires":[["26ec22da.4bf0f6"]]},{"id":"26ec22da.4bf0f6","type":"influxdb out","z":"51122c73.230094","influxdb":"a609b286.bc25d","name":"","measurement":"status","precision":"","retentionPolicy":"","x":1270,"y":600,"wires":[]},{"id":"8930d79e.d5f1a8","type":"http request","z":"51122c73.230094","name":"","method":"GET","ret":"obj","paytoqs":false,"url":"http://192.168.16.24/solar_api/v1/GetMeterRealtimeData.cgi?&Scope=System","tls":"","persist":false,"proxy":"","authType":"","x":850,"y":540,"wires":[["c171927.7a4b6f"]]},{"id":"c171927.7a4b6f","type":"function","z":"51122c73.230094","name":"","func":"var msg_Energy = {};\n\nmsg_Energy.payload = [\n {\n E_Grid_Consumption : msg.payload.Body.Data['0'].EnergyReal_WAC_Plus_Absolute/1000,\n E_Grid_Feedin : msg.payload.Body.Data['0'].EnergyReal_WAC_Minus_Absolute/1000,\n },\n];\n\nreturn [msg_Energy];","outputs":1,"noerr":0,"x":1010,"y":540,"wires":[["93db2e7a.a76608"]]},{"id":"d874d7b8.1d9e98","type":"http request","z":"51122c73.230094","name":"","method":"GET","ret":"obj","paytoqs":false,"url":"http://192.168.16.24/solar_api/v1/GetMeterRealtimeData.cgi?&Scope=System","tls":"","persist":false,"proxy":"","authType":"","x":870,"y":400,"wires":[["70942e17.43a64"]]},{"id":"70942e17.43a64","type":"function","z":"51122c73.230094","name":"","func":"var msg_Grid = {};\n\n\nmsg_Grid.payload = [\n {\n Current_AC_Phase_1 : msg.payload.Body.Data['0'].Current_AC_Phase_1,\n Current_AC_Phase_2 : msg.payload.Body.Data['0'].Current_AC_Phase_2,\n Current_AC_Phase_3 : msg.payload.Body.Data['0'].Current_AC_Phase_3,\n\n Voltage_AC_Phase_1 : msg.payload.Body.Data['0'].Voltage_AC_Phase_1,\n Voltage_AC_Phase_2 : msg.payload.Body.Data['0'].Voltage_AC_Phase_2,\n Voltage_AC_Phase_3 : msg.payload.Body.Data['0'].Voltage_AC_Phase_3,\n\n Voltage_AC_PhaseToPhase_12 : msg.payload.Body.Data['0'].Voltage_AC_PhaseToPhase_12,\n Voltage_AC_PhaseToPhase_23 : msg.payload.Body.Data['0'].Voltage_AC_PhaseToPhase_23,\n Voltage_AC_PhaseToPhase_31 : msg.payload.Body.Data['0'].Voltage_AC_PhaseToPhase_31,\n\n PowerReal_P_Phase_1 : msg.payload.Body.Data['0'].PowerReal_P_Phase_1,\n PowerReal_P_Phase_2 : msg.payload.Body.Data['0'].PowerReal_P_Phase_2,\n PowerReal_P_Phase_3 : msg.payload.Body.Data['0'].PowerReal_P_Phase_3,\n },\n];\n\n\n\nreturn [msg_Grid];","outputs":1,"noerr":0,"x":1030,"y":400,"wires":[["ee4617b8.405ac"]]},{"id":"ee4617b8.405ac","type":"influxdb out","z":"51122c73.230094","influxdb":"a609b286.bc25d","name":"","measurement":"grid","precision":"","retentionPolicy":"","x":1260,"y":400,"wires":[]},{"id":"a609b286.bc25d","type":"influxdb","z":"","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"fronius","name":"","usetls":false,"tls":""}]

Wechselrichter:

Fronius Symo 6.0-3-M


Verschaltung/Module:

MPPT1:
Hausdach 50 Grad Neigung, 185 Grad Süd: 7 * Axitec AXIworldpremium X HC BLK 400 Wp

MPPT2 (Serielle Verschaltung):

Garagendach 45 Grad Neigung, 95Grad Ost: 5 * Axitec AXIworldpremium X HC BLK 400 Wp

Garagendach 45 Grad Neigung, 275Grad West: 5 * Axitec AXIworldpremium X HC BLK 400 Wp mit Tigo TS4-R-O

Datenlogger mit Node-Red InfluxDB und Grafana