Fronius Integration - Smart Meter in Consumption Path

Hi everyone

I am getting aqainted with Home Assistant and need to achieve something that is completely over my head. I have read some of the documentation and even consulted ChatGPT, with no success.

My Fronius Smart Meter is in the consumption path, and I know I need to do the following in order for the energy dashboard to be accurate:

  • The Power grid entity provided by the Fronius API is positive on import and negative on export. Split it up into import- and export-power entities by using helpers with templates max(states('sensor.solarnet_power_grid') | float, 0) and max(0 - states('sensor.solarnet_power_grid') | float, 0).
  • Then use [Riemann sum] to integrate these import-/export-power entities into energy values (kWh).
  • Use these energy entities for Grid consumption and Return to grid in the energy dashboard configuration.

This is what I have done:

template:
  - sensor:
      - name: "Power Grid Import"
        unit_of_measurement: W
        device_class: power
        state: "max(states('sensor.solarnet_power_grid') | float, 0)"
      - name: "Power Grid Export"
        unit_of_measurement: W
        device_class: power
        state: "max(0 - states('sensor.solarnet_power_grid') | float, 0)"

sensor:
    - platform: integration
      source: sensor.power_grid_import
      name: "Total Power Grid Import Energy"
      unit_prefix: k
      method: left
    - platform: integration
      source: sensor.power_grid_export
      name: "Total Power Grid Export Energy"
      unit_prefix: k
      method: left

Unfortunately, Home Assistant gives me these errors:

statistics_not_defined

  • sensor.total_power_grid_import_energy

Entity unavailable

The state of these configured entities are currently not available:

  • sensor.total_power_grid_import_energy (unknown)

Unexpected device class

The following entities do not have the expected device class:

  • sensor.total_power_grid_export_energy

I have included some sensor state screenshots below. Any advice would be appreciated. Thank you in advance.


Hi :wave:!
Have a look at the template integration documentation. You are missing the {{ }} and probably also a state_class (measurement for power) in your state config. Template - Home Assistant

Template entities and Riemann sum integration can also be configured via “Helpers” in the UI - have a look, it may be less error prone.

Thanks for your help, I think it’s fixed. I had forgotten the {{ }} as you suggested. I then allowed around 20 minutes for data to start flowing in. The errors then cleared.