Logic Machine Forum
Fronius inverter JSON integration - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Fronius inverter JSON integration (/showthread.php?tid=2103)

Pages: 1 2 3


RE: Fronius inverter JSON integration - Firechief - 23.04.2021

When I try JSON call http://fronius/solar_api/v1/GetMeterRealtimeData.cgi?Scope=System via URL I get this response:

Code:
{
   "Body" : {
      "Data" : {
         "0" : {
            "Current_AC_Phase_1" : 3.9950000000000001,
            "Current_AC_Phase_2" : -1.4910000000000001,
            "Current_AC_Phase_3" : 0.82499999999999996,
            "Current_AC_Sum" : 3.3289999999999997,
            "Details" : {
               "Manufacturer" : "Fronius",
               "Model" : "Smart Meter TS 65A-3",
               "Serial" : "1987314142"
            },
            "Enable" : 1,
            "EnergyReactive_VArAC_Sum_Consumed" : 1143,
            "EnergyReactive_VArAC_Sum_Produced" : 608719,
            "EnergyReal_WAC_Minus_Absolute" : 176372,
            "EnergyReal_WAC_Plus_Absolute" : 597616,
            "EnergyReal_WAC_Sum_Consumed" : 597616,
            "EnergyReal_WAC_Sum_Produced" : 176372,
            "Frequency_Phase_Average" : 49.899999999999999,
            "Meter_Location_Current" : 0,
            "PowerApparent_S_Phase_1" : 938,
            "PowerApparent_S_Phase_2" : 295.5,
            "PowerApparent_S_Phase_3" : 148.09999999999999,
            "PowerApparent_S_Sum" : 1381.7,
            "PowerFactor_Phase_1" : 0.94499999999999995,
            "PowerFactor_Phase_2" : -0.61099999999999999,
            "PowerFactor_Phase_3" : 0.75700000000000001,
            "PowerFactor_Sum" : 0.78900000000000003,
            "PowerReactive_Q_Phase_1" : -306.5,
            "PowerReactive_Q_Phase_2" : -234,
            "PowerReactive_Q_Phase_3" : -96.700000000000003,
            "PowerReactive_Q_Sum" : -637.39999999999998,
            "PowerReal_P_Phase_1" : 886.5,
            "PowerReal_P_Phase_2" : -180.40000000000001,
            "PowerReal_P_Phase_3" : 112.09999999999999,
            "PowerReal_P_Sum" : 818.20000000000005,
            "TimeStamp" : 1619105985,
            "Visible" : 1,
            "Voltage_AC_PhaseToPhase_12" : 410.60000000000002,
            "Voltage_AC_PhaseToPhase_23" : 415.10000000000002,
            "Voltage_AC_PhaseToPhase_31" : 411.5,
            "Voltage_AC_Phase_1" : 237.40000000000001,
            "Voltage_AC_Phase_2" : 239.19999999999999,
            "Voltage_AC_Phase_3" : 237.80000000000001
         }
      }
   },
   "Head" : {
      "RequestArguments" : {
         "DeviceClass" : "Meter",
         "Scope" : "System"
      },
      "Status" : {
         "Code" : 0,
         "Reason" : "",
         "UserMessage" : ""
      },
      "Timestamp" : "2021-04-22T17:39:46+02:00"
   }

Maybe this helps


RE: Fronius inverter JSON integration - admin - 23.04.2021

If you can read JSON via HTTP requests then you can use it instead of Modbus.


RE: Fronius inverter JSON integration - Firechief - 23.04.2021

Daniel stated it is better to do this with a ModBus Profile, thats why I continued with this.


RE: Fronius inverter JSON integration - admin - 23.04.2021

What Daniel meant is that a profile should be used instead of a Modbus TCP script. If your device provides another way of supplying data then it can be used instead of Modbus.


RE: Fronius inverter JSON integration - Firechief - 23.04.2021

Can you give me an example of how to do this?


RE: Fronius inverter JSON integration - admin - 23.04.2021

What is the URL for JSON data from the meter?


RE: Fronius inverter JSON integration - Firechief - 23.04.2021

I think you mean these:

I found these on GitHub

http://fronius/solar_api/v1/GetActiveDeviceInfo.cgi?DeviceClass=System
http://fronius/solar_api/v1/GetInverterInfo.cgi
http://fronius/solar_api/v1/GetInverterRealtimeData.cgi?Scope=System
http://fronius/solar_api/v1/GetLoggerInfo.cgi
http://fronius/solar_api/v1/GetLoggerLEDInfo.cgi
http://fronius/solar_api/v1/GetMeterRealtimeData.cgi?Scope=System
http://fronius/solar_api/v1/GetPowerFlowRealtimeData.fcgi
http://fronius/solar_api/v1/GetStorageRealtimeData.cgi?Scope=System
http://fronius/solar_api/v1/GetArchiveData.cgi?Scope=System&StartDate=1.11.2016&EndDate=11.11.2016&SeriesType=DailySum&Channel=EnergyReal_WAC_Sum_Produced&Channel=InverterErrors
http://fronius/solar_api/v1/GetArchiveData.cgi?Scope=System&StartDate=1.11.2016&EndDate=1.11.2016&Channel=EnergyReal_WAC_Sum_Produced&Channel=EnergyReal_WAC_Minus_Absolute


RE: Fronius inverter JSON integration - admin - 23.04.2021

Try this script, adjust URL and group addresses as needed. You can add extra checkupdate calls as needed.
Code:
http = require('socket.http')
json = require('json')

url = 'http://fronius/solar_api/v1/GetMeterRealtimeData.cgi?Scope=System'

resp = http.request(url)
data = json.decode(resp).Body.Data['0']

grp.checkupdate('1/1/1', data.Current_AC_Sum)
grp.checkupdate('1/1/2', data.Current_AC_Phase_1)
grp.checkupdate('1/1/3', data.Voltage_AC_Phase_1)



RE: Fronius inverter JSON integration - Firechief - 23.04.2021

I copied and modified script and created resident script with 5s interval. Modified group addresses to the correct ones and activated the script, but i don't see any updates of the group addresses. No Error logs, Logs or Alerts

Code:
http = require('socket.http')
json = require('json')

url = 'http://192.168.100.189/solar_api/v1/GetMeterRealtimeData.cgi?Scope=System'

resp = http.request(url)
data = json.decode(resp).Body.Data['0']

grp.checkupdate('33/0/1', data.Current_AC_Sum)
grp.checkupdate('33/0/2', data.Current_AC_Phase_1)
grp.checkupdate('33/0/3', data.Current_AC_Phase_2)
grp.checkupdate('33/0/4', data.Current_AC_Phase_3)
grp.checkupdate('33/0/5', data.Voltage_AC_PhaseToPhase_12)
grp.checkupdate('33/0/6', data.Voltage_AC_PhaseToPhase_23)
grp.checkupdate('33/0/7', data.Voltage_AC_PhaseToPhase_31)
grp.checkupdate('33/0/8', data.Voltage_AC_Phase_1)
grp.checkupdate('33/0/9', data.Voltage_AC_Phase_2)
grp.checkupdate('33/0/10', data.Voltage_AC_Phase_3)



RE: Fronius inverter JSON integration - Daniel - 23.04.2021

This is sent only on change of value


RE: Fronius inverter JSON integration - admin - 23.04.2021

Add some extra logging and post what you get in Logs tab:
Code:
http = require('socket.http')
json = require('json')

url = 'http://192.168.100.189/solar_api/v1/GetMeterRealtimeData.cgi?Scope=System'

resp, code = http.request(url)
log(resp, code)
data = json.decode(resp).Body.Data['0']
log(data)

grp.checkupdate('33/0/1', data.Current_AC_Sum)
grp.checkupdate('33/0/2', data.Current_AC_Phase_1)
grp.checkupdate('33/0/3', data.Current_AC_Phase_2)
grp.checkupdate('33/0/4', data.Current_AC_Phase_3)
grp.checkupdate('33/0/5', data.Voltage_AC_PhaseToPhase_12)
grp.checkupdate('33/0/6', data.Voltage_AC_PhaseToPhase_23)
grp.checkupdate('33/0/7', data.Voltage_AC_PhaseToPhase_31)
grp.checkupdate('33/0/8', data.Voltage_AC_Phase_1)
grp.checkupdate('33/0/9', data.Voltage_AC_Phase_2)
grp.checkupdate('33/0/10', data.Voltage_AC_Phase_3)



RE: Fronius inverter JSON integration - Firechief - 23.04.2021

These values should change all the time as it's solar production and energy consumption.
What I want to monitor is real time (5-10s interval) data coming from the inverter and Smart Energy Meter so I can make a dashboard on the visu and maybe in the future actions depending on production or consumption.

this is the log:

Code:
Wiser for KNXLogoutStart pageLanguage:
English
1
Version: 2.5.1






CPU/IO: 0.12 0.06 0.08, Memory: 21%, KNX/TP: OK

* table:
["Current_AC_Phase_1"]
  * number: 1.312
["PowerReal_P_Phase_1"]
  * number: 190.8
["PowerFactor_Phase_1"]
  * number: 0.796
["PowerReal_P_Sum"]
  * number: -53.6
["Current_AC_Sum"]
  * number: 0.434
["PowerFactor_Phase_3"]
  * number: 0.328
["PowerReal_P_Phase_2"]
  * number: -283.6
["PowerReactive_Q_Phase_3"]
  * number: -112.7
["EnergyReactive_VArAC_Sum_Produced"]
  * number: 614904
["Current_AC_Phase_2"]
  * number: -1.412
["PowerApparent_S_Sum"]
  * number: 654.4
["TimeStamp"]
  * number: 1619170026
["Voltage_AC_PhaseToPhase_23"]
  * number: 416.4
["EnergyReal_WAC_Sum_Produced"]
  * number: 176646
["PowerFactor_Phase_2"]
  * number: -0.961
["Current_AC_Phase_3"]
  * number: 0.534
["PowerFactor_Sum"]
  * number: -0.156
["PowerReactive_Q_Phase_2"]
  * number: -81.9
["Voltage_AC_Phase_2"]
  * number: 240.5
["EnergyReal_WAC_Minus_Absolute"]
  * number: 176646
["Meter_Location_Current"]
  * number: 0
["Voltage_AC_Phase_3"]
  * number: 238
["EnergyReactive_VArAC_Sum_Consumed"]
  * number: 1143
["Voltage_AC_Phase_1"]
  * number: 238.7
["PowerApparent_S_Phase_2"]
  * number: 295.2
["EnergyReal_WAC_Sum_Consumed"]
  * number: 602167
["Visible"]
  * number: 1
["Voltage_AC_PhaseToPhase_31"]
  * number: 412.8
["Voltage_AC_PhaseToPhase_12"]
  * number: 412.8
["Frequency_Phase_Average"]
  * number: 50
["PowerApparent_S_Phase_3"]
  * number: 119.3
["Details"]
  * table:
   ["Manufacturer"]
    * string: Fronius
   ["Model"]
    * string: Smart Meter TS 65A-3
   ["Serial"]
    * string: 1987314142
["Enable"]
  * number: 1
["PowerReactive_Q_Sum"]
  * number: -339.9
["EnergyReal_WAC_Plus_Absolute"]
  * number: 602167
["PowerApparent_S_Phase_1"]
  * number: 239.7
["PowerReactive_Q_Phase_1"]
  * number: -145.1
["PowerReal_P_Phase_3"]
  * number: 39.2



RE: Fronius inverter JSON integration - Firechief - 23.04.2021

The log shows it updates every 5s but values in the group addresses are not updated.
Tried grp.update instead of grp.checkupdate, but no change.


RE: Fronius inverter JSON integration - Daniel - 23.04.2021

What datatypes do you use for your objects?


RE: Fronius inverter JSON integration - Firechief - 23.04.2021

Daniel,

14. 4-byte floating point in HL Objects, but manual states that they are int16 and some acc32?

I'm trying like this now in the script:

Code:
grp.update('34/0/1', (data.Current_AC_Sum) ,dt.float16)                        -- Totaal vermogen (A)
grp.update('33/0/2', (data.Current_AC_Phase_1) ,dt.float16)                    -- Stroom L1 (A)
grp.update('33/0/3', (data.Current_AC_Phase_2) ,dt.float16)                    -- Stroom L2 (A)
grp.update('33/0/4', (data.Current_AC_Phase_3) ,dt.float16)                    -- Stroom L3 (A)
grp.update('34/0/5', (data.Voltage_AC_PhaseToPhase_12) ,dt.float32)                            -- Spanning L1-L2 (V)
grp.update('33/0/6', (data.Voltage_AC_PhaseToPhase_23) ,dt.float32)                        -- Spanning L2-L3 (V)
grp.update('33/0/7', (data.Voltage_AC_PhaseToPhase_31) ,dt.float32)                        -- Spanning L3-L1 (V)
grp.update('34/0/8', (data.Voltage_AC_Phase_1) ,dt.float32)                    -- Spanning L1-N (V)
grp.update('33/0/9', (data.Voltage_AC_Phase_2) ,dt.float32)                    -- Spanning L2-N (V)
grp.update('33/0/10', (data.Voltage_AC_Phase_3) ,dt.float32)                    -- Spanning L3-N (V)


and in HL Objects:

group 1-4: 2 byte floating point
group 5-10: 4 byte floating point.

This gives the correct values in HL, but still no auto update of those groups.


RE: Fronius inverter JSON integration - admin - 23.04.2021

Use float32 for instantaneous values like voltage, current etc, use int64 for counter values. What is stated in the manual does not matter because you are not reading via Modbus.


RE: Fronius inverter JSON integration - Firechief - 23.04.2021

Thx,

Rebooted the HL and now everything is updating. thx for the help.


RE: Fronius inverter JSON integration - mxcxpx - 03.12.2021

attached find my json


RE: Fronius inverter JSON integration - admin - 03.02.2022

Check this: http://www.fronius.com/QR-link/0006
Otherwise ask Fronius support directly. This is not something that we can help you with.


RE: Fronius inverter JSON integration - mxcxpx - 06.02.2022

(23.04.2021, 07:52)admin Wrote: If you can read JSON via HTTP requests then you can use it instead of Modbus.

for me this works to
http://IP of inverter/solar_api/v1/GetPowerFlowRealtimeData.fcgi

but how to implement in LogicMchine.

sorry iam new and have to learn by doing.
thanks