No data on energy dashboard

Hi.
I have a new Shelly 3EM that monitors power consumption of my heat pump. The heat pump is a 3-phase pump and I want to see the overall consumption of the pump. So I have a template that calculates power and energy of all three phases together into one new sensor.

    - name: "Overall Power"
      unit_of_measurement: "W"
      device_class: power
      state: >
        {{ [ states('sensor.faze1_hneda_power_3'),
             states('sensor.faze2_cerna_power_3'),
             states('sensor.faze3_seda_power_3') ]
             | map('float') | sum }}
      availability: >
        {{ not 'unavailable' in 
           [ states('sensor.faze1_hneda_power_3'), 
             states('sensor.faze2_cerna_power_3'),
             states('sensor.faze3_seda_power_3') ] }}
    - name: "Overall Energy"
      unit_of_measurement: "kWh"
      state_class: measurement
      device_class: energy
      state: >
        {{ [ states('sensor.faze1_hneda_energy_3'),
             states('sensor.faze2_cerna_energy_3'),
             states('sensor.faze3_cerna_energy_3') ]
             | map('float') | sum }}
      availability: >
        {{ not 'unavailable' in 
           [ states('sensor.faze1_hneda_energy_3'), 
             states('sensor.faze2_cerna_energy_3'), 
             states('sensor.faze3_cerna_energy_3') ] }}

But to be able to use it the energy dashboard, I had to also customize it and provide last_reset info

sensor.overall_energy:
  last_reset: "2021-08-05T08:05:00+00:00"
  state_class: measurement

With that, I was able to add the custom sensor to the energy dashboard, but it does not show any data even after a day. But when I read the data manually from the sensor via Developer Tools, it has the correct value in it.
image

Any idea why I don’t see the data on the energy dashboard?

Shouldn’t the state_class for Overall Energy be
state_class: total_increasing
instead of measurement?

I don’t know honestly… That is a solution I found in some other topic here on the forum. But I can give it a try for sure.

Posisbly similar… I have a measuring powerplug/switch (Gosund SP1). In order to get the usage out I had to add (so on TOP of the switch)

  1. template sensor to get the value from the switch in the state
  2. integration sensor to start collection statistics from above state value
    the two are shown here:
 - platform: template
    sensors:
      gosund_1_consumption:
        friendly_name: "GosundPlug1 current consumption"
        unit_of_measurement: 'W'
        device_class: power
        value_template: "{{ states.switch.gosundplug1.attributes.current_consumption }}"
  - platform: integration
    source: sensor.gosund_1_consumption
    name: gosund_plug_1
    method: left
    round: 2
    unit_prefix: k

Tested and works. Thanks a lot!

Hi, can you please elaborate a bit…
when I add state_class to my template sensor, it is refused by HA…hence I felt forced to use a two-sensor approach

  - platform: template
    sensors:
      gosund_1_consumption:
        friendly_name: "GosundPlug1 current consumption"
        unit_of_measurement: 'W'
        device_class: power
        state_class: total_increasing
        value_template: "{{ states.switch.gosundplug1.attributes.current_consumption }}"

results in:
“Invalid config for [sensor.template]: [state_class] is an invalid option for [sensor.template]. Check: sensor.template->sensors->gosund_1_consumption->state_class. (See ?, line ?).”

So I found out that I was using the old way of templating
I managed to change it into this below but it is not shown for the Energy dashboard …any idea what I am doing wrong?

template:
  - sensor:
    - name: gosund_plug_test
      unit_of_measurement: 'kW'
     device_class: energy   
      state_class: total_increasing
      state: "{{ states.switch.gosundplug3.attributes.current_consumption / 1000 }}"  

image

As far I understood, the Energy dashboard is displaying “Energy” and only lists those entities matching Energy.
Energy = kWh
Power = kW

You have unit_of_measurement: kW thus Power, not Energy.