Howto: Fronius Integration with battery into Energy Dashboard

Data are correct, have you tried to delete and recreate the Riemann sum entities?

Yes, on entities page select the “battery power charging” (in column integration should have “template”) then press the gear icon and change the value

This whole thing is diving me crazy. That’s what it looks like after changing the unit to kWh.



I really do not understand, why the Fromiuis web.app shows 2.9 kW (which is valid to my opinion), the sensor states 0.0029 kW?! Even if the number is stranger than bevor, now the riemann summ is looking more valid:

I will leave it running for some time and report…

Something is changing… :thinking: But this can’t be true. I’ll give it some time.
Screenshot 2023-08-08 172013

I know… as I said the patience is the key because values takes time to get valid and if there is a bad calculation it will take a day or two to see if the fix worked…

Yes, these values are a bit higher…
I think it is because the values are in kWh instead of Wh. The battery is charging at 2.89 kWh (fronius app) but you entity is that value / 1000.

My suggest is to set the values in Wh and reset the data measured.
You can do it in “Developer Tools” → tab “Services” then select “Utility Meter: reset”.
Add the entities and press “call service”

If works I think that you’ll see it tomorrow

Finally found the solution. The clue was editing the yaml code.

That way didn’t work for me. Even if I still don‘t understand why, I‘m glad it‘s working now!

@crc-error79 thank you so much for your help!


1 Like

The yaml Code are correct with „W“.

You have to set the Riemann Integration settings to „left“ and „k“ when you create it.

I think I read every post in this topic, and I’m more confused than before.

Can we get one post that combines all configuration steps (included which settings to choose in the Riemann Sum integration)?

Honestly, it’s a huge pain in the a** to read the entire topic and still struggle how to configure this the right way. If we can combine all things together, I will open a pull/feature request to update the documentation for the Fronius integration.

2 Likes

Yes, please!
Is it possible to sum up in a, lets say, understandable was :slight_smile:

Thank you!

I’m a total beginner but this is what I got and I think it’s working:

My system:
Inverter 1: Fronius Symo GEN24 10.0 with 28x450W panels.
Inverter 2: Fronius Symo 15.0-3-M with 44x450W
Battery: BYD Premium HVM (three stacks of 19.3) Total storage: 57.96kWh

#Install Riemann sum integral sensor helper
Settings, Devices & services, Add Integration
Integration - Riemann sum integral sensor (helper)

#Create folder with files
Add folder named packages

#Add packages to main YAML Config file:

homeassistant:
  packages: !include_dir_named packages

Developer tools, Check Configuration, All YAML Configuration

Add file in packages

fronius.yaml

template:
  - sensor:
      - name: "Battery Power Charging"
        unit_of_measurement: kW
        device_class: power
        state: "{{ max(0, 0 - states('sensor.solarnet_power_battery') | float(default=0)) }}"
      - name: "Battery Power Discharging"
        unit_of_measurement: kW
        device_class: power
        state: "{{ max(0, states('sensor.solarnet_power_battery') | float(default=0)) }}"
      - name: "Power Photovoltaics"
        unit_of_measurement: W
        device_class: power
        state: "{{ max(0, states('sensor.solarnet_power_photovoltaics') |float(default=0) + states('sensor.solarnet_power_photovoltaics_2') | float(default=0)) }}"

sensor:
  - platform: integration
    source: sensor.battery_power_charging
    name: "Total Battery Energy Charged"
    unit_prefix: k
    method: left
  - platform: integration
    source: sensor.battery_power_discharging
    name: "Total Battery Energy Discharged"
    unit_prefix: k
    method: left
  - platform: integration
    source: sensor.power_photovoltaics
    name: "Total Photovoltaics Energy"
    unit_prefix: k
    method: left

#Add Packages to main YAML Config File

homeassistant:
  packages: !include_dir_named packages

Developer tools, Check Configuration, All YAML Configuration

#Create Helpers
Settings, Devices & services, Click on “Helpers” tab at the top.

Create Helper -
Integration - Riemann sum integral sensor (helper)
Name: Total Battery Energy Charged
Input Sensor: Battery Power Charging
Integration Method: Left
Precision: 3
Metric: none
Click on helper, Gear Icon
Icon: mdi:battery-arrow-up
Area: Garage

Create Helper -
Integration - Riemann sum integral sensor (helper)
Name: Total Battery Energy Discharged
Input Sensor: Battery Power Discharging
Integration Method: Left
Precision: 3
Metric: none
Click on helper, Gear Icon
Icon: mdi:battery-arrow-down
Area: Garage

Create Helper -
Integration - Riemann sum integral sensor (helper)
Name: Total Photovoltaics Energy
Input Sensor: Power Photovoltaics Aggregate
Integration Method: Left
Precision: 3
Metric: kilo
Click on helper, Gear Icon
Icon: mdi:solar-power-variant
Area: Roof

#Configure Dashboards:
Settings, Dashboards, Energy:

Add Consumption
Consumed Energy: Smart Meter 63A Real energy consumed
Add Return
Energy returned to the grid: Smart Meter 63A Real energy produced

Add Solar Production
Solar Production Energy: Total Photovoltaics Energy

Add Battery System
Energy going in to the battery: Total Battery Energy Charged
Energy coming out of the battery: Total Battery Energy Discharged

1 Like

Hello,

I have nearly the same combination.
1x Gen24
1x Symo
1x BYD battery
and I tried your config.

One hint in advance:
I think it should be

Otherwise I can not find a sensor called " Power Photovoltaics Aggregate".

My result:
grafik

My config:

Something seems to be wrong… But I have no idea what…

Thank you

Hi Lukas,

I added it as you said at first but already had two sensors with the same name:

I called this one aggregate as it combined the total solar output of the two systems with:
{{ states(‘sensor.solarnet_power_photovoltaics’) |float + states(‘sensor.solarnet_power_photovoltaics_2’) | float(default=0) }}

I recently broke the integration and had to restore from backup, following my notes I was able to get most of it back up. I just need the sun to come up feeding the Photovoltaics sensors and the battery charge sensor to complete the configuration.

I’ll let you know how it goes but everything looks right for me, I have both kW and kWh readings for the PV output and battery charge/discharge working.

Cheers,

Tac

Here is my Aggregate now (no sun):

The Riemann sum helper takes this data and makes the Total Photovoltaics Energy:

Which should only constantly increase, never decrease.

Cheers

Tac

I see an error in your config, you have values returning kkWh, they should be kWh.

Check that in the template fronius.yaml you used (Focus on the unit of measurement):

template:

  • sensor:
    • name: “Battery Power Charging”
      unit_of_measurement: kW

    • name: “Battery Power Discharging”
      unit_of_measurement: kW

    • name: “Power Photovoltaics”
      unit_of_measurement: W

And in the helper you used (focus on the Metric):

Integration - Riemann sum integral sensor (helper)
Name: Total Battery Energy Charged
Metric: none

Integration - Riemann sum integral sensor (helper)
Name: Total Battery Energy Discharged
Metric: none

Create Helper -
Integration - Riemann sum integral sensor (helper)
Name: Total Photovoltaics Energy
Metric: kilo

Cheers,

Tac

Hey Tac,

I think, I did not get you point…

This is the content of my fronius.yaml:

template:
  - sensor:
      - name: "Battery Power Charging"
        unit_of_measurement: kW
        device_class: power
        state: "{{ max(0, 0 - states('sensor.solarnet_leistung_von_der_batterie') | float(default=0)) }}"
      - name: "Battery Power Discharging"
        unit_of_measurement: kW
        device_class: power
        state: "{{ max(0, states('sensor.solarnet_leistung_von_der_batterie') | float(default=0)) }}"
      - name: "Power Photovoltaics"
        unit_of_measurement: W
        device_class: power
        state: "{{ max(0, states('sensor.solarnet_pv_leistung') |float(default=0) + states('sensor.solarnet_pv_leistung_2') | float(default=0)) }}"

sensor:
  - platform: integration
    source: sensor.battery_power_charging
    name: "Total Battery Energy Charged"
    unit_prefix: k
    method: left
  - platform: integration
    source: sensor.battery_power_discharging
    name: "Total Battery Energy Discharged"
    unit_prefix: k
    method: left
  - platform: integration
    source: sensor.power_photovoltaics
    name: "Total Photovoltaics Energy"
    unit_prefix: k
    method: left

The Riemann sums are taken over from here:

with my own sensors…

BR,
Lukas

Hi Lukas,

I noticed in your config:

I also had that when I configured my helpers and you have to make sure that when you make the helpers, the only one you change the metric from “none” to “kilo” is the Total Photovoltaics Energy.

Cheers,

Tac

Good morning,

aaah, got it.
I changed this. Now this is the result:

Battery is not discharging now, thats why this entitiy is not available by now.

But, anyway, it does not working:
grafik

My house is definitely now consuming 1.9 kWh :slight_smile:
And the battery is also not discharging 1.9 kWh :slight_smile:

Hm…

Energy vs. Power !
This chart is not showing what your house is currently consuming (kW), but what is has consumed since 0:00 (kWh).
It may be wrong on the first day, since it has no historical data.

Last dump of what I got working. Changed a few names for fewer conflicts with other names.

#Install Riemann sum integral sensor helper
Settings, Devices & services, Add Integration
Integration - Riemann sum integral sensor (helper)

#Create folder with files
Add folder named packages

#Add packages to main YAML Config file:

homeassistant:
  packages: !include_dir_named packages

Developer tools, Check Configuration, All YAML Configuration

Add file in packages

fronius.yaml

template:
  - sensor:
      - name: "Battery Power Charging"
        unit_of_measurement: kW
        device_class: power
        state: "{{ max(0, 0 - states('sensor.solarnet_power_battery') | float(default=0)) | round(3) }}"
      - name: "Battery Power Discharging"
        unit_of_measurement: kW
        device_class: power
        state: "{{ max(0, states('sensor.solarnet_power_battery') | float(default=0)) | round(3) }}"
      - name: "Power Photovoltaics Aggregate"
        unit_of_measurement: kW
        device_class: power
        state: "{{ (states('sensor.solarnet_power_photovoltaics') | float(default=0) + states('sensor.solarnet_power_photovoltaics_2') | float(default=0) ) / 1000 | round(3) }}"

sensor:
  - platform: integration
    source: sensor.battery_power_charging
    name: "Battery Energy Charged Counter"
    method: left
  - platform: integration
    source: sensor.battery_power_discharging
    name: "Battery Energy Discharged Counter"
    method: left
  - platform: integration
    source: sensor.power_photovoltaics_aggregate
    name: "Photovoltaics Energy Counter"
    method: left

Developer tools, Check Configuration, All YAML Configuration

#Create Helpers
Settings, Devices & services, Click on “Helpers” tab at the top.

Create Helper -
Integration - Riemann sum integral sensor (helper)
Name: Battery Energy Charged Total
Input Sensor: Battery Power Charging
Integration Method: Left
Precision: 3
Metric: none
Click on helper, Gear Icon
Icon: mdi:battery-arrow-up
Area: Garage

Create Helper -
Integration - Riemann sum integral sensor (helper)
Name: Battery Energy Discharged Total
Input Sensor: Battery Power Discharging
Integration Method: Left
Precision: 3
Metric: none
Click on helper, Gear Icon
Icon: mdi:battery-arrow-down
Area: Garage

Create Helper -
Integration - Riemann sum integral sensor (helper)
Name: Photovoltaics Energy Total
Input Sensor: Power Photovoltaics Aggregate
Integration Method: Left
Precision: 3
Metric: none
Click on helper, Gear Icon
Icon: mdi:solar-power-variant
Area: Garage

#Configure Dashboards:
Settings, Dashboards, Energy:

Add Consumption
Consumed Energy: Smart Meter 63A Real energy consumed
Add Return
Energy returned to the grid: Smart Meter 63A Real energy produced

Add Solar Production
Solar Production Energy: Photovoltaics Energy Total

Add Battery System
Energy going in to the battery: Battery Energy Charged Total
Energy coming out of the battery: Battery Energy Discharged Total

#TROUBLESHOOTING ONLY!
#Delete/Flush/Purge Broken Entities
Developer Tools, Services (Tab)
Service: recorder.purge_entities
Click the Green “+ Choose entity”
Fill in the entity to be purged
Click “Call Service”
Ctrl-F5 the web session and see if they have been purged (remove from fronius.yaml first before purging for example).

Tac

1 Like

Midday Update:

Looking good!

Working, moving on to other things.

1 Like

For anyone having troubles (as I did) getting it to work with adding the templates and sensors in the .yaml files (configuration.yaml or otherwise), I recommend you try it with adding it manually in Settings → Devices & services → Helpers, that way I got it working. See also the attached screenshots.

Guide:

  • Click +Create Helper → Template → Template a sensor. There enter the stuff that would normally go inside the .yaml file; e.g. State template: {{ max(0, 0 - states('sensor.solarnet_power_battery') | float(default=0)) }}, Unit of measurement: W, Device class: power, and so on.
  • After you’re done creating your templates (3 for Power), you also need to create your Sensors (for Energy). Now you do +Create Helper → Integration - Riemann sum integral sensor. Again, enter the data as you would in the .yaml. The source is always the sensors you’ve created with your template in the step before.
  • Once you’ve created your helpers (3 Templates, 3 Rieman sums). You can then set up everything in the Energy Dashboard and use the appropriate Sensors you created.
  • If you run into problems, use the Developer tools → States, to check if your sensors provide what you’re looking for.




2 Likes