Energy dashboard: example Fronius Gen24 & BYD storage


The Home Assistant Energy Dashboard shows all relevant energy data in a complete overview. Performance data from a wide range of manufacturers or components can be used as the basis for the dashboard. Only sensors with the corresponding performance data are required to supply the interface with data.


Initial setup

The energy dashboard is set up under "Settings", "Dashboards", "Energy":

The dashboard can be operated with sensors for the electricity grid: consumption and feed-in, with details on power generation from one or more inverters, as well as the performance data of a battery storage unit. Gas consumption, water consumption or power consumption of individual appliances can also be visualized.

So far so simple, but to be used in the Energy Dashboard, the sensors must meet certain criteria

Sensor requirements

The Energy Dashboard can use sensors with the property "state_class: total_increasing". The performance data for power consumption, feed-in, solar panels, battery storage or individual devices also require the unit ( unit_of_measurement) Wh or kWh and the device class (device_class) Energy:

  • state_class: total_increasing
  • unit_of_measurement: Wh or kWh
  • device_class: energy

A look at the developer tools / states tells us whether the sensor is ready for use in the energy dashboard:

Details on the properties and the database tables behind them, see: HA history: more than 10 days? Long Time Statistic (LTS)

The devil is in the detail

My setup consists of a smart meter, a Fronius Gen24 inverter with 2 strings: east/west and a BYD HVS battery. I also use a Hoymiles microinverter for the PV panels on my balcony.

Depending on how the sensors of the respective integrations are available, these may need to be prepared via a helper. As an example, the Fronius integration for the Gen24 inverter provides a total meter for all the energy produced: unfortunately, this includes the energy drawn from the battery. This means that the energy meter of the inverter cannot be used for the PV power of the panels in the "Solar panels" dashboard. According to the official Home Assistant documentation, battery systems are not supported:

Fronius Integration: "Battery systems" are not directly supported.

The official Home Assistant documentation recommends the use of a "Riemann Sum Integral Sensor" helper for the PV panels.

The sum integral sensor has a decisive disadvantage at this point: if Home Assistant is not available - even if only for an upgrade to a newer version - the sensor would not count the energy generated in the meantime. For this reason, I try to avoid the summation integral sensor as much as possible and prefer to use totalizers. In the case of the Fronius Gen24 inverter, the Modbus API also provides the total PV power generated by the panels for each MPPT tracker. The HACS integration "SunSpec" can be used to access the Modbus values as easily as possible:

For details on Modbus setup and Sunspec, see: Fronius: Data & settings via the network (Modbus).

The values relevant for the Energy Dashboard are provided by the device: "Multiple MPPT Inverter Extension Model":

The entity: Module 0 Lifetime Energy (sonsor.fronius_mppt_module_0_lifetime_energy) reflects the total generated energy of String 1 and Module 1 Lifetime Energy reflects the energy of String 2:

The entities can be included in the dashboard either directly and individually, or summarized via a helper. After initially integrating the PV panels without a battery via the total counter of the inverter and wanting to continue the statistical data, I combined the two MPPT values into one entity via a helper sensor:

Source code for the status template:

{% if states('sensor.fronius_mppt_module_0_lifetime_energy') | is_number  
states('sensor.fronius_mppt_module_1_lifetime_energy') | is_number
{{ (states("sensor.fronius_mppt_module_0_lifetime_energy") | float + states("sensor.fronius_mppt_module_1_lifetime_energy") | float)  }}
{% else %}
{{ states('sensor.pv_dach_energy') }}
{% endif %}

The "is_number" check ensures that the last available value is used, even if the integration should briefly provide no data: Which is not a problem for modules 0 and 1, but very much so for the values of modules 2 and 3:

Lifetime for modules 2 and 3: Battery charging and discharging:

The two MPPT Lifetime values of Module 2 and Module 3 are also interesting at this point:
Module 2 counts the energy with which a connected battery was charged and Module 3 the total energy that was drawn from the battery. However, the two values for the battery have a problem: the data is not always available and then alternates. The reason for this behavior is probably to be found in the Modbus implementation from Fronius.

Since the MPPT entity for discharging the battery is supplied relatively stably, I have created another template sensor for it:

Source code for the state template:

{% if states('sensor.fronius_mppt_module_3_lifetime_energy') | is_number  %}
{{ states("sensor.fronius_mppt_module_3_lifetime_energy") | float / 1000 }}
{% else %}
{{ states('sensor.byd_total_discharging') }}
{% endif %}

The "is_number" check is also used here: here this is essential, as it ensures that the last value called up is available: at least over longer phases. If the value is no longer updated, reloading the entire Sunspec integration will help:

At this point, I am unsure whether an integration that only provides the desired data temporarily can be the right solution. Using the MPPT tracker values for the battery is not a nice thing to do, but it gets even messier: using automation to restart the integration:

Workaround: watchdog for reloading the integration

The advantage of the total counter is certainly that data that has not been recorded is caught up if the total counter is available again. Combined with an automation for restarting the integration, the sensor constantly delivers for me. Here is the automation I use to monitor the integration and restart it in the event of an error:

alias: Sunspec MPPT Watchdog
description: ""
  - platform: time_pattern
    hours: /3
    enabled: true
  - platform: state
      - sensor.fronius_mppt_module_3_lifetime_energy
    to: unavailable
      hours: 0
      minutes: 30
      seconds: 0
  - condition: state
    entity_id: sensor.fronius_mppt_module_3_lifetime_energy
    state: unavailable
    enabled: true
  - service: homeassistant.reload_config_entry
    data: {}
      device_id: ???
mode: single
  stored_traces: 100

I prefer the Sunspec integration for the discharge meter and I still use a summation integral sensor for the charge meter, as the charge meter is only very rarely available. The charge meter is slightly higher than the discharge meter due to the charging losses, but in my opinion it is not quite as relevant for the long-term statistics. Not quite as relevant, especially as the discharge meter provides information on how much energy was made available by the battery and therefore did not have to be drawn from the grid due to the use of the battery.

Riemann sum integral sensor

The current power data is required as the basis for the sum integral sensor. The information from the Fronius integration for Byd is rather sparse here:

Although the power with current * voltage could be calculated here in a separate template sensor, it is better to use the Fronius SolarNet integration.

The Fronius SolarNet integration is a little more talkative here, but - as already mentioned - does not have a total meter either, but at least the power from the battery: "SolarNet power from the battery":

My Integration was registered in German, so: "Leistung von der Batterie" means: "power from the battery"

The value for SolarNet power from battery reflects the charging and discharging power. Positive values correspond to the discharging power, negative values to the charging power. For use in the energy dashboard, we need two different meters at this point, so we have created a separate template for the charge meter, which only uses the negative values:

Template sensor: "sensor.byd_charging"

{{ 0 - states('sensor.solarnet_leistung_von_der_batterie') | float if states('sensor.solarnet_leistung_von_der_batterie') | float < 0 else 0 }}

To create an energy meter from the power meter data, a "Riemann Sum Integral Sensor - Helper" can be created:



The Home Assistant Energy dashboard is great, especially as all relevant data for energy consumption and energy generation can be processed with very little effort. Compared to the web interface of certain inverter manufacturers, Home Assistant supports a wide range of manufacturers and also the possibility of evaluating the performance data of a wide range of consumers.

positive Bewertung({{pro_count}})
Rate Post:
{{percentage}} % positive
negative Bewertung({{con_count}})

THANK YOU for your review!

Questions / Comments

By continuing to browse the site, you agree to our use of cookies. More Details