Energy: Expected data source not listed as metric is calculated in configuration.yaml

Hey everyone,
the header might let you thing “oh no not this topic again”, but hold your horses.

Lately I got my solar panels installed, using the SMA Solar Integration as a provider for data. This integration only provides the power generated by my panels and the current power absorbtion / provisioning from /to the grid. In terms of power consumption I can only see a daily aggregate. Thus I did the math and calculated the current power consumption of my home by substracting the current power provisioning and adding the current power absorbtion from / to the grid (of course at a time only one of these can occur) from the generated power of my panels.

  - sensor:
      - name: "current power consumption"
        unit_of_measurement: "W"
        state: >
          {% set generation    = states('sensor.grid_power') | float %}
          {% set provisioning = states('sensor.metering_power_supplied') | float %}
          {% set absorbtion = states('sensor.metering_power_absorbed') | float %}

          {{ (generation - provisioning + absorbtion) | round(1) }}

(e.g. generation = 173 W , provisioning = 0 W , absorbtion = 487 W , current power consumption = 660 W)

The result is the current power consumption of my home.

Now to my issue:
I cannot use that metric in the Energy tab of Home Assistant as it is not shown in the drop down menue. Any ideas of what I need to do so it’s available for selection?

Thanks in advance

Energy in ha requires energy sensors, not power sensors. Integrate power to get energy.

Hey there,
thanks for your response. I checked what you said and found the following: Link

Doing so didn’t chance anything. I set up the following in my configuration.yaml:

  - platform: integration
    source: sensor.currentpowerconsumption
    name: energy_spent
    unit_prefix: k
    round: 2
  - platform: integration
    source: sensor.metering_power_supplied
    name: energy_provided
    unit_prefix: k
    round: 2

Any more suggestions of what to do?

Thanks in advance!

I’m almost sure that the entity_id of your template sensor is sensor.current_power_consumption and not sensor.currentpowerconsumption

Yes youre right. Still the issue persists.
Same for the other metric „ energy_provided“.

Did you wait for some time for the sensors to get a value? Initially I had to wait 1 hour as far as I remember. Do the integration sensor show a value?

Yes they do. By now I have consumed more than 2 kWh and provided round about the same.

Still I cannot use them in my energy-tab of HA. :confused:

Are you running the latest version of Home Assistant? Can you please show the graph for the two integration sensors? Are the two sensors included in your recorder/history configuration?

You will need to go to Configuration > Customizations and select each of the sensors and set the correct attributes.

  • device_class: energy
  • state_class: measurement (should be set already)
  • last_reset: xxxxx (shold be set already)
  • unit_of_measurement: kWh (may or may not be set already)


I didn’t need to do this with the integration sensors. The integration integration should take care of it, but it was only in one of the recent .x versions that they changed it as far as I remember.

Hi all,

I’m running Home Assistant OS 6.2 and HA core version 21.8.8. (Supervisor 2021.6.8).

It was @sparkydave s answer that solved my problem. As of now my system is collecting the right data and displays it.

Thanks everyone

Then mark it as solution please.

Hi mate, i got the same issue.
I keep changing everything to KWh, Wh, , first tme it was listed in the energy dashboard, after that , I tried to change adding two entities, but bad luck not listed again.
firstly, I integrated with ESP, my codes are with ESp. Then all entities are shwon in ESP. energy symbol also shown in that. In develop tool , I saw the attributes are correct there is a reading as well. But inenergy dashboard, not listed still. Help me if you understand this completely.