Howto: Fronius Integration with battery into Energy Dashboard

This is meant as a howto to integrate the following fronius components into the energy dashboard of HA 2021.12+:

  • Fronius Symo Hybrid
  • Fronius Smart Meter
  • BYD Battery

The integration is based on the new UI config with Fronius - Home Assistant

The config is like this:

The following items are directly from the fronius integration:

  • Grid consumption: Energy real consumed
  • Return to grid: Energy real produced

The solar panel and battery need to be built with template and Riemann sum integration:

template:
  - sensor:
      - name: "Battery Power Charging"
        unit_of_measurement: W
        device_class: power
        state: "{{ max(0, 0 - states('sensor.power_battery_fronius_power_flow_0_192_168_178_48') | float(default=0)) }}"
      - name: "Battery Power Discharging"
        unit_of_measurement: W
        device_class: power
        state: "{{ max(0, states('sensor.power_battery_fronius_power_flow_0_192_168_178_48') | float(default=0)) }}"
      - name: "Power Photovoltaics"
        unit_of_measurement: W
        device_class: power
        state: "{{ states('sensor.power_photovoltaics_fronius_power_flow_0_192_168_178_48') | 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

Explanation: The battery energy is not counted at the inverter, thus needs to be integrated from the power flow to and from the battery (negative means charging, positive means discharging). All defaults are added as the sensor turns unknown if the battery is in standby when empty.

The photovoltaics energy also needs to be integrated via Riemann sum, and while at it, also set that to 0 as the source from the power flow (sensor.power_photovoltaics_…) turns unknown at night.

The method is set to “left” for all the integration, as the graphs can be quite spikey (0, 2kW, 0), see:

In case you have an appliance which produces spikey consumption (like an on/off electrical boiler) you should opt for the left method to get accurate readings.

(from Integration - Riemann sum integral - Home Assistant)

Important: If there is a battery involved (as in this howto), the “Total energy” from the inverter cannot be used for the solar panels, as both energy from solar as well as energy from the battery is counted on the “Energy total” from the fronius component.

With that energy usage and distribution on a day with both direct usage and charging / discharging of the battery should look like this:

usage

energy-distribution

7 Likes

As a last bonus bit: To debug the following “raw” graphs helped me checking whether the hourly sums and the daily overview made sense:

Source:

type: history-graph
entities:
  - entity: sensor.power_battery_fronius_power_flow_0_192_168_178_48
  - entity: sensor.power_grid_fronius_power_flow_0_192_168_178_48
  - entity: sensor.power_load_fronius_power_flow_0_192_168_178_48
  - entity: sensor.power_production_now
  - entity: sensor.power_photovoltaics
  - entity: sensor.state_of_charge_fronius_storage_0_192_168_178_48
refresh_interval: 60
hours_to_show: 24
1 Like

Hi csett86!
Thank you, Great Job!
I have the same Fronius system with a BYD-battery, and I tried your yaml-file.
I’ve one problem: The 3 Sensors with the Riemann-Sum are visible in the list of the entities(1)
but not available in the settings of the energy dashboard (2).


Do you have any idea, what the problem could be?
I’m using the newest Home Assistant 2021.12.8, Frontend Version 20211229.0 - latest
(Sorry for my bad English)

Can you quickly confirm if the battery energy entities look like this with the attributes in the devtools of HA. Especially important is “device_class: energy”:

Other that, just a small one: The battery energy values start with “Total”, so can you quickly search in the dialogue that they really don’t show up:

storage-config

Hi csett86,
thank you for your answer.
You are right, the missing device_class was the problem.
I added it under the development-tools, no all is fine. I can see and select the Riemann-Sums in the energy-dashbord!


Thank you :+1:

That is still strange, as the device_class should be automatically there based on the device_class: power for the power sensors (“Battery Power Charging” and “Battery Power Discharging”).

Can you double-check in your config that both are set to device_class: power?

Hi csett86,
here is the Fronius-part of my configuration.yaml. Its, the same as yours, I think:

# Fronius
template:
  - sensor:
      - name: "Battery Power Charging"
        unit_of_measurement: W
        device_class: power
        state: "{{ max(0, 0 - states('sensor.power_battery_fronius_power_flow_0_192_168_178_23') | float(default=0)) }}"
      - name: "Battery Power Discharging"
        unit_of_measurement: W
        device_class: power
        state: "{{ max(0, states('sensor.power_battery_fronius_power_flow_0_192_168_178_23') | float(default=0)) }}"
      - name: "Power Photovoltaics"
        unit_of_measurement: W
        device_class: power
        state: "{{ states('sensor.power_photovoltaics_fronius_power_flow_0_192_168_178_23') | 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

Yesterday I was to optimistic. It was possible to add the three Riemann Sums in the configuration of the energy dashboard, but since I added the “device_class: energy” the values of the two Battery-Entities don’t change. The value is always the same.

I copied your code into my configuration.yaml. Maybe it’s a problem of indentation??? I’ll check that tomorrow.

Yes thats all the same (as you copied it), indentation is also the same as I copied it verbatim out of my working config. I am also running the same HA version as you, 2021.12.8 with frontend 20211229.0.
This leaves me a bit clueless at the moment (same as you I guess).

For completeness, here is my view in the devtools:

And a day with a little bit of charging and no discharging:

Thanks for your great introduction.

Please can your tell me what i have to do to get this graphics?

Best regards
Tom

Edit: Have found it.

Hi,

just in case anybody has problems with this:
For me it didn’t worked out using (didnt show up in the energy dashboard as an option):

So I used instead:

device_class: energy

Here my complete code. Thanks again @csett86. Really helped me out :smiley:

#FroniusEnergyDashboard
template:
  - sensor:
      - name: "Battery Power Charging"
        unit_of_measurement: W
        device_class: energy
        state: "{{ max(0, 0 - states('sensor.power_battery_fronius_power_flow_0_froniusgen24_home') | float(default=0)) }}"
      - name: "Battery Power Discharging"
        unit_of_measurement: W
        device_class: energy
        state: "{{ max(0, states('sensor.power_battery_fronius_power_flow_0_froniusgen24_home') | float(default=0)) }}"
      - name: "Power Photovoltaics"
        unit_of_measurement: W
        device_class: energy
        state: "{{ states('sensor.power_photovoltaics_fronius_power_flow_0_froniusgen24_home') | 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

Hi guys I am on the market for solar panel and inverter. reading a lot all about Fronius, and I mostly settle my mind on a Fronius Symo Gen 24 + mostly for the feature of 3Kw direct solar during power cut, (BYD batteries will come later), also look at ohmpilot and wattpilot, then I start to have some doubt on the latest.
I have now a shelly 1PM for the 3kw boiler-water tank resistor.

Does HA +shelly 1PM would not replace the Ohmpilot ?
Does you need a Fronius smart meter if no Ohmpilot ? Shelly 3EM does the same ?

Look like wattpilot 11 go does not need anything (fronius smart meter) in particular… but I could be wrong.

Your insight would be much appreciated.

Stephane

Ohmpilot is like a Dimmer for the heater. So it can do eg. 30% load if not more power was provided by the inverter.

The Smartmeter is used to determine difference of produced to consumed energy. It’s optional, but not that expensive and quite useful. Your inverter can then control a heater (or other) not only based on solar production, but eg. on net grid export - without any HA or other logic engine.

Thank you farmio for your answer.

I didn’t get the dimer side, was thinking only on/off, my mistake. will reconsider it.
(pulse with modulation from Fronius manual)
Ohmpilot need a compulsory fronius smart meter to work within Fronius only solution.

Which country are you from?

What I read everywhere, there is a shortage of Gen24 inverters. The waiting time for batteries are long as well. The same applies to Enwitec switchover boxes also.

I am disappointed with the Fronius’ capabilities. I think now that is overhyped. A 3 phase inverter is just biggest bullsh!t what they could come up, and nobody tells that all their 3 phase inverters are working as current generators and their meters thinking only that your grid does net consumption measurements. Most countries do not do net. Even you can have a meter from the supplier which does not calculate production/consumption with vector math, but it does algebraic sum for import and export separately.

If your grid does not count with net consumption and your meter is not vector sum, but algebraic then it is going to be a lot of wasted production for the suppliers’s advantage.

The other thing, these inverters are compatible only with BYD batteries. Not even any other single brand. As supply is low, it makes hard to find the battery, or you might have to wait a year for it.

The only one reason why I really regret getting a Fronius Gen24 Plus, is the fact, that Fronius thinks that loads are in a house balanced out. Which will never be the case. The selling phrase of being able to use a water kettle or hob/oven with the inverter in backup mode or from the battery is just poorly misleading.
The 3 phase inverter is a current generator, and outputs the same amount of current to each phase, so there is no unbalanced output. And there is no documentation how much unbalance the inverter can handle. Yes, the single phase backup with the a single socket sounds good, but it is the same as Huawei’s backup box, and having the loads which needs backup placed on the same single phase.

If I would have know before about Sungrow’s inverter and their backup capabilities and compatibility with other battery brands, then I would might go with one of these:

https://en.sungrowpower.com/productDetail/2702

For one single reason:

Provides 100% power to unbalance loads in
backup mode

I am not saying that Fronius is not good, but I am seeing now how they do misadvertise their products and its capabilities.

Just my five cents…

Hi @csett86,

thanks for your work. I have tried it and pasted your code with amended sensor names (mine have “solarnet” before) and amended the IP. I have had it running for today and was checking now the figures against the Fronius app but they do not match.

According to the fronius app I should have the following values for today:

  • photovoltaics production: 5,27kWh
  • consumption: 16,35kWh
  • battery was loaded to max 35% today

The energy dashboard shows me following:

It appears that the consumption is correct but it is missing the photovoltaics value.

When checking the energy dash board I am presented with following error message for the batteries:

So to conclude, I seem to have an issue with the photovoltaics and battery entity.

Please see below a screenshot of the entities in question below.



Maybe you have a clue what I am doing wrong. I can’t seem to find any typos or so.

Thanks in advance :slight_smile:

Please share the code what you actually used, then we might can advise otherwise it is hard to guess where you assigned entity names wrongly.

Hi Gábor,

sorry, here you go.

template:
  - sensor:
      - name: "Battery Power Charging"
        unit_of_measurement: W
        device_class: power
        state: "{{ max(0, 0 - states('sensor.solarnet_power_battery_fronius_power_flow_0_192_168_1_70') | float(default=0)) }}"
      - name: "Battery Power Discharging"
        unit_of_measurement: W
        device_class: power
        state: "{{ max(0, states('sensor.solarnet_power_battery_fronius_power_flow_0_192_168_1_70') | float(default=0)) }}"
      - name: "Power Photovoltaics"
        unit_of_measurement: W
        device_class: power
        state: "{{ states('sensor.solarnet_power_photovoltaics_fronius_power_flow_0_192_168_1_70') | 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

There is some mismatch from the images above and the names what you used in the template sensors.

On the image you have sensor.solarnet_power_battery and sensor.solarnet_power_photovoltaics and not the long names what you used in the pasted code. Please crosscheck that you have used the right entity names.

Otherwise, you don’t need the unit_prefix: k as all those integrations are for W and not for kW as the sources are in W!

1 Like

Hi @GSzabados,

thanks for the hint, I thought the addition behind the actual sensor name is important therefore I left it.

I have tested it now for half a day and the values seem to be quite promising :slight_smile:

However, I have encountered another problem now.

The code which was perfectly working was:

template:
  - sensor:
      - name: "Battery Power Charging"
        unit_of_measurement: W
        device_class: power
        state: "{{ max(0, 0 - states('sensor.solarnet_power_battery') | float(default=0)) }}"
      - name: "Battery Power Discharging"
        unit_of_measurement: W
        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: "{{ states('sensor.solarnet_power_photovoltaics') | float(default=0) }}"

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

I would like to have the friendly names for the Energy Dashboard in german, wherefore I have changed the friendly names from Battery charged, discharged and Total Photovoltaics. The code then looks likes this:

template:
  - sensor:
      - name: "Battery Power Charging"
        unit_of_measurement: W
        device_class: power
        state: "{{ max(0, 0 - states('sensor.solarnet_power_battery') | float(default=0)) }}"
      - name: "Battery Power Discharging"
        unit_of_measurement: W
        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: "{{ states('sensor.solarnet_power_photovoltaics') | float(default=0) }}"

sensor:
    - platform: integration
      source: sensor.battery_power_charging
      name: "Total Batterie geladen"
      method: left
    - platform: integration
      source: sensor.battery_power_discharging
      name: "Total Batterie entladen"
      method: left
    - platform: integration
      source: sensor.power_photovoltaics
      name: "Total Photovoltaik"
      method: left

Home Assistant now warns me that the sensor.total_batterie_geladen is having a negative value but is expecting a positive value. I can’t really understand why things work with one friendly name but not with another?

Something went wrong during the calculation. And it is not the friendly name causes the issue.

1 Like