This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Fronius inverter JSON integration
#46
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
Reply


Messages In This Thread
RE: Fronius inverter JSON integration - by victor.back - 25.12.2022, 09:42

Forum Jump: