Help for a beginner getting solar generation from Fronius Inverter

Glad to hear its working…

hey dave, cool setup, how/where did youget that weather card from?!

Hi,

That was Dark Sky but has since stopped working, I think they changed their system.
Im looking for a new one.

Its the Custom Dark Sky card but I use weather data from another provider, not Dark Sky

Oh cool, is it BOM? Looks like you have a pretty cool setup there!

yep, using BOM data. The only thing that is still Dark Sky is the icons for sunny, cloudy etc.

Hi Paul,

This works really well, I really like the lovelace card. I have one hiccup though, and was hoping you could help. I actually have two fronius inverters, and this obviously only retrieves data from one of them (device id=1). I preface what say on the basis that in no way am I a coder, but I did look up the Fronius API and there does appear to be a method to retrieve day from both systems using “system” rather than device ID. So I changed this command (??) but I it seems the data being returned doesn’t work with your coding as it not expecting 2 lots, Could you suggest what the code is to combine the data from outputs for a particular value? My Fronius ids are 1 and 2.

This is what the output according to the API is:

"Data" : {

"PAC" : {
"Unit" : "W",

"Values" : { "0" : 4330,

"1" : 3721 }

},
"DAY_ENERGY" : {

"Unit" : "Wh", "Values" : {

"0" : 6366,

"1" : 6000 }

},
"YEAR_ENERGY" : {

"Unit" : "Wh", "Values" : {

"0" : 1041607,

"1" : 42000 }

},
"TOTAL_ENERGY" : {

"Unit" : "Wh", "Values" : {

"0" : 3551131,

"1" : 43000

I’d made similar changes. You missed the last unit_of_measurement MW -> MWh on Total Power Since Installed

Hi Vatoe

Quick question… you have two inverters, do you also have a Fronius Smartmeter? If so, you can use the GetPowerFlowRealtimeData.fcgi JSON data to get what you want (rather than the inverter-based GetInverterRealtimeData.cgi JSON data Paul is using).

For example, in my setup, I use the following for current production:

sensor:
  - platform: rest
    resource: http://[my_fronius_ip]/solar_api/v1/GetPowerFlowRealtimeData.fcgi
    method: GET
    name: "Current Production"
    value_template: >-
      {{ value_json['Body']['Data']['Site']['P_PV'] | int / 1000 | round(3) }}
    unit_of_measurement: kW
    force_update: true

If you don’t have a Smartmeter, you can just pull data from each separate inverter, and them combine in another sensor. I use this method to combine to two sets of JSON data from solcast.com (my north-facing and west-facing arrays):

sensor:
  - platform: template
    sensors:
      estimated_pv:
        unit_of_measurement: kW
        value_template: "{{ (float(states.sensor.solcast_north.state) + float(states.sensor.solcast_west.state)) | round(3) }}"

Just replace sensor.solcast_north and sensor.solcast_west with the sensor names for your two inverters.

Thanks Ben.

I do have the smart meter, and your code for current production is spot on.
Do you have the code at all for the other sensors, total kw today, total kw year, total lifetime? Not sure if their is any sensor for total exported today as well?

Thanks for your help!

Hi Vatoe

You can get all the details of whats available through the Fronius API here.

I don’t have access to my system at the moment (and I don’t collect all the the data you’re asking about), but if you replace P_PV in my code with E_Day, E_Year, or E_Total, I think that’s what you’re looking for.

Good luck!

Awesome that did the trick! Thanks for all your help, appreciate it. Much more tidier combined stats.

edit: just for the benefit of anyone else chasing this - the round command in the code wont work unless we bracket the value line, so it looks like this:
{{ (value_json['Body']['Data']['Site']['E_Year'] | int / 1000 )| round(0) }} ~ I’m no coder, just read this from some other code snippet.

cheers

1 Like

Instead of calling the inverter for each sensor, a simpler solution:

### Solar monitor of Fronius Galvo
### Solor monitor single access
- platform: rest
  name: solar_data
  friendly_name: 'Solar Panels'
  json_attributes:
    - Body
    - Head
  resource: http://<ipaddr_of_inverter>/solar_api/v1/GetInverterRealtimeData.cgi?Scope=Device&DeviceId=1&DataCollection=CommonInverterData
  value_template: >-
    {% if is_state('sun.sun', 'above_horizon') %}
      'OK'
    {% else %}
      'Offline'
    {% endif %}
- platform: template
  sensors:
    solar_pac:
      friendly_name: 'Solar Power'
      value_template: '{{ (states.sensor.solar_data.attributes["Body"]["Data"]["PAC"]["Value"] | float /1000)|  round(2) }}'
      unit_of_measurement: 'kWh'
    solar_day:
      friendly_name: 'Solar Day Energy'
      value_template: '{{ (states.sensor.solar_data.attributes["Body"]["Data"]["DAY_ENERGY"]["Value"] | float /1000)| round(2) }}'
      unit_of_measurement: 'kWh'
    solar_year:
      friendly_name: 'Solar Year Energy'
      value_template: '{{ (states.sensor.solar_data.attributes["Body"]["Data"]["YEAR_ENERGY"]["Value"] | float /1000000)| round(2) }}'
      unit_of_measurement: 'MWh'
    solar_total:
      friendly_name: 'Solar Total Energy'
      value_template: '{{ (states.sensor.solar_data.attributes["Body"]["Data"]["TOTAL_ENERGY"]["Value"] | float /1000000)| round(2) }}'
      unit_of_measurement: 'MWh'

This a bit redundant with the use of safepay/Home-Assistant-Fronius above. But it still a good example of using rest platform to access json return data

1 Like

While strictly not on topic, but related to gathering stats re solar etc, anyone who has a powerwall 2, the same sort of info can be retrieved from its API. I would like to give credit to the original author, but seem to have lost where i found this. Anyway I’ll keep looking an edit if I find him;

- platform: rest
    resource: https://192.168.22.12/api/system_status/grid_status
    verify_ssl: false
    method: GET
    name: PW2 Grid Status
    scan_interval: 60
    value_template: "{{ value_json.grid_status == 'SystemGridConnected' }}"
    
  - platform: rest
    name: PW2 House now
    resource: https://192.168.22.12/api/meters/aggregates
    method: GET
    verify_ssl: false
    value_template: '{{ (value_json.load.instant_power / 1000 | int )|round(2) }}'
    unit_of_measurement: kWh

  - platform: rest
    name: PW2 Grid now
    resource: https://192.168.22.12/api/meters/aggregates
    method: GET
    verify_ssl: false
    value_template: '{{ (value_json.site.instant_power / 1000 | int )|round(2) }}'
    unit_of_measurement: kWh

  - platform: rest
    name: PW2 Solar now
    resource: https://192.168.22.12/api/meters/aggregates
    method: GET
    verify_ssl: false
    value_template: '{{ (value_json.solar.instant_power / 1000 | int )|round(2) }}'
    unit_of_measurement: kWh

  - platform: rest
    name: PW2 Battery now
    resource: https://192.168.22.12/api/meters/aggregates
    method: GET
    verify_ssl: false
    value_template: '{{ (value_json.battery.instant_power / 1000 | int )|round(2) }}'
    unit_of_measurement: kWh
    
  - platform: rest
    name: PW2 Battery Capacity
    resource: https://192.168.22.12/api/system_status/soe
    method: GET
    verify_ssl: false
    value_template: '{{ (value_json.percentage | float |round(0)) }}'
    unit_of_measurement: '%'
    scan_interval: 300

Just change the IP to the one of your Powerwall 2

I’ve just added the function to only call the API from sunrise to sunset in my custom component, so that will hopefully remove even more custom templating (at least, that’s the goal).

Dear Riccardo thanks por all that work. The total daily energy of the house (solar plus from the grid) its a relevant staff. Could you help me to get the total energy comsuption of the instalation. This number is at the web of Fronius but I can find where is the source.
Thanks and congratulation por your activity.

The total_energy sensor should give you what you want I believe.

Total energy is the total energy produced for the Fronius from the day of instalation. I want watch the total energy of the house each day (from grid and from Fronius) and I can not find the correct sensor. However the Solarweb.com yes it shows this value.

You want total daily consumed or total daily generated ?