Read JSON from Fronius Solar Inverter

Hi everybody

I just started using Home Assistant for my home. I already have a system in place (KNX as backbone) and like to move over to HASS.

I’d like to read the data from my Fronius Solar Inverter. On my current system i call the URL: http:///solar_api/v1/GetInverterRealtimeData.cgi?Scope=System and get a JSON that looks like this:

{
  "Body": {
    "Data": {
      "DAY_ENERGY": {
        "Unit": "Wh",
        "Values": {
          "1": 6554
        }
      },
      "PAC": {
        "Unit": "W",
        "Values": {
          "1": 1580
        }
      },
      "TOTAL_ENERGY": {
        "Unit": "Wh",
        "Values": {
          "1": 21559300
        }
      },
      "YEAR_ENERGY": {
        "Unit": "Wh",
        "Values": {
          "1": 2767925
        }
      }
    }
  },
  "Head": {
    "RequestArguments": {
      "DeviceClass": "Inverter",
      "Scope": "System"
    },
    "Status": {
      "Code": 0,
      "Reason": "",
      "UserMessage": ""
    },
    "Timestamp": "2020-04-30T16:04:23+02:00"
  }
}

I’d like to read out those values. How can I do that in HASS?

Best regards

By making some Restful sensors:

For example:


  - platform: rest
    resource: http:///solar_api/v1/GetInverterRealtimeData.cgi?Scope=System
    name: Total Energy
    value_template: '{{ value_json.Body["Data"]["TOTAL_ENERGY"]["Values"]["1"]|float /1000 }}|float /1000 }}'
    unit_of_measurement: kWh

I pasted you data in the left hand column here: http://jsonpathfinder.com/ then drilled down in the right hand column to find the path (displayed at the top of the right hand column) and then formatted it in bracket rather than dot notation (less likely to cause errors with key home assistant words like “value”) and divided by 1000 to give a better unit than Wh.

If you use the “minify” button in the left hand column you can copy and paste the result into the developer tools template editor to test your value_template:

The right hand end of the data is past the scroll window, but it ends in %}

There is a built-in integration for Fronius in HA. If you are starting from scratch I recommend this one.

And there is another one available also. That started out before the one that is included in HA now.

So unless you really want to play with parsing JSON it is dead simple to use one of those :slight_smile:

3 Likes

I didn’t even bother looking if there was an integration :man_facepalming: Doh!

Thanks a lot for the quick help! I would mark both as the correct solution if I could :wink:

Which one did you use?

I reckon @nilrog has the most appropriate answer.