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 - Erwin van der Zwart - 06.02.2022

Hi,

i have written a full script using the API a few years ago, i will post it later today when having access to my laptop…


RE: Fronius inverter JSON integration - Erwin van der Zwart - 07.02.2022

Code:
-- Load libs
require('socket.http')
require('json')

-- Set timeout
socket.http.TIMEOUT = 15

-- Get data from API
--data = socket.http.request('http://192.168.1.182/solar_api/v1/GetInverterRealtimeData.cgi?scope=System&collection=CommonInverterData')
--data = socket.http.request('http://192.168.1.182/solar_api/v1/GetInverterRealtimeData.cgi?scope=System&collection=CumulationInverterData')
--data = socket.http.request('http://192.168.1.182/solar_api/v1/GetInverterRealtimeData.cgi?scope=System&collection=3PInverterData')
data = socket.http.request('http://192.168.1.182/solar_api/v1/GetInverterRealtimeData.cgi?scope=System')

if data then
  function sum(t)
    local sum = 0
    for k,v in pairs(t) do
        sum = sum + v
    end
    sum = math.round(sum*0.001,2)
    return sum
    end
  decdata = json.pdecode(data)
  totaldata = decdata.Body.Data.TOTAL_ENERGY.Values
  yeardata = decdata.Body.Data.YEAR_ENERGY.Values
  daydata = decdata.Body.Data.DAY_ENERGY.Values
  currentdata = decdata.Body.Data.PAC.Values
  total = sum(totaldata)
  year = sum(yeardata)
  day = sum(daydata)
  current = sum(currentdata)
  previoustotal = storage.get('froniustotal')
  if previoustotal then
    if total > previoustotal then
      grp.checkupdate('32/1/5',total)
        previoustotal = storage.set('froniustotal', total)
    end
  else
    storage.set('froniustotal', total)
  end
  grp.checkupdate('32/1/6',year)
  grp.checkupdate('32/1/7',day)
  grp.checkupdate('32/1/8',current)
end

I use the storage to check the previous total, as the inverter can go in sleep mode when there is no sun, the API is not sending a valid value at that moment and i dont want to write a invalid value to my trend. So this part is needed if you might see strange values when removing it (:


RE: Fronius inverter JSON integration - mxcxpx - 08.02.2022

how to get the infomation from this webseite script into the logicmachine virtual groupe adresse?
thanks

http://192.168.0.187/solar_api/v1/GetPowerFlowRealtimeData.fcgi

{
"Body" : {
"Data" : {
"Inverters" : {
"1" : {
"Battery_Mode" : "normal",
"DT" : 99,
"E_Day" : 2853.699951171875,
"E_Total" : 2032.1309814453125,
"E_Year" : 137498.703125,
"P" : 172,
"SOC" : 57.400001525878906
}
},
"Site" : {
"BatteryStandby" : false,
"E_Day" : 2853.7000000000003,
"E_Total" : 2032.1310000000001,
"E_Year" : 137498.70000000001,
"Meter_Location" : "grid",
"Mode" : "bidirectional",
"P_Akku" : -705.40000000000009,
"P_Grid" : -0.95999999999999996,
"P_Load" : -171.03999999999999,
"P_PV" : 904.40000000000009,
"rel_Autonomy" : 100,
"rel_SelfConsumption" : 99.441860465116278
},
"Version" : "12"
}
},
"Head" : {
"RequestArguments" : {},
"Status" : {
"Code" : 0,
"Reason" : "",
"UserMessage" : ""
},
"Timestamp" : "2022-02-08T14:09:59+01:00"
}
}


RE: Fronius inverter JSON integration - admin - 08.02.2022

See Erwin's example in the previous post, it has exactly what you need.


RE: Fronius inverter JSON integration - mxcxpx - 09.02.2022

is ok. maybe you know how the procedere is from ip.fcgi to script.
i do not know but i will find it out


RE: Fronius inverter JSON integration - victor.back - 25.12.2022

Hi.

Is it possible to write this if condition in a modbus profile for automatic scale the values dependent on how big it is, for easier reading it? 

Code:
-- Total power ever
r1, r2, r3, r4 = mb:readregisters(509, 4)
if r1 then
  value = r1 * 0x1000000000000 + r2 * 0x100000000 + r3 * 0x10000 + r4
  currentvalue = grp.getvalue('32/1/55')
  if tonumber(currentvalue) ~= value then
    if value > 999999999 then
        units = 'GWh'
          value = value / 1000000000
    elseif value > 999999 then
          units = 'MWh'
          value = value / 1000000
        else
          units = 'KWh'
          value = value / 1000
        end
        value = string.format('%.2f', value) .. units
        grp.checkupdate('32/1/55', value)
  end
end



RE: Fronius inverter JSON integration - admin - 28.12.2022

You can use profile to read raw values then use a script to convert values to formatted strings. This cannot be done directly in the profile.


RE: Fronius inverter JSON integration - jose_dli - 20.09.2023

Hello,

I'm trying to create a modbus profile, but I'm having some trouble with scale factor: "address_scale". Without this scale factor, profile is working, but we get wrong values due to "live" multipliersd.

Testing register and his scale factor with the tool "read test", they are working properly. But I do not get response with both together in the profile.

    Holding register: 40293,  uint6--> 2260
    Holding register: 40256 ,  int16--> -2

    Tension on MPTT1: 2260 * 10^-2= 22.6 V; that is correct

I attach my profile, that it is created with map register of post #17.

Any help will be welcome.


RE: Fronius inverter JSON integration - admin - 20.09.2023

All scale registers must be added to the profile. Add "internal": true to scale register definition. Internal scale registers won't be visible in the mapping table, but will be read before reading other data registers.


RE: Fronius inverter JSON integration - jose_dli - 20.09.2023

Thanks, now it is working.

I attach the profiles in case anyone can use them as a basis.

Regards