Why can't I add a generated electricity statistics sensor in the Energy panel?

Hello everyone,

I have a question I’d like to seek some help with. I have been generating electricity accumulation sensors through two steps, and I used to be able to add and track them normally in the Energy panel. However, recently, when I added a new one, the generated electricity accumulation sensor already had the ‘total’ and ‘energy’ attributes, but I couldn’t find it in the list to add to the Energy panel. I would appreciate any help or suggestions!

Here is my configuration process and the parameters of the generated sensor:

sensor:
  - platform: template
    sensors:
      dishwasher_power:
        value_template: "{{ states('sensor.cuco_cp2d_ff81_electric_power')|float * 1}}"
        unit_of_measurement: "W"
        device_class: power
        friendly_name: Dishwasher Current Power

sensor:
  - platform: integration
    source: sensor.dishwasher_power
    name: Dishwasher Energy Spent
    unit_prefix: k
    round: 2
    method: left

Thank you!

This needs: state_class: measurement. Which the legacy template sensor platform does not support. You should be using the new format for template sensors.

Thank you for your reply. Is it okay to modify it as such? Thanks again!

  - sensor:
      - name: "Dishwasher Current Power"
        unit_of_measurement: "W"
        state: "{{ states('sensor.cuco_cp2d_ff81_electric_power')|float * 1}}"
        state_class: measurement
        device_class: power

Why are you just copying the state of another sensor?

If it is because it is missing the attributes just use customize to add the attributes to the source sensor sensor.cuco_cp2d_ff81_electric_power.

The reason I did this is because the original unit of this sensor was “watt”, which seemed unable to integrate in the second step I mentioned above to obtain the power consumption value. Some of my other power sensors are in kW units. I want to establish a unified template to convert to W for calculation. When the unit is kW, divide by 1000 (I remember Integration - Riemann sum integral seems to require W as the unit, I don’t know if my understanding is correct). Thank you again for your reply!

No that is not correct. It can use W or kW.

Which integration supplied the unit ‘watt’?

That needs to be fixed.

This sensor is really not very standardized, so the newbie in me only thought of this method to create a new sensor to handle it. Looks like a lot of my previous understanding was wrong, thanks for the correction!

Yes but how did you create it?

Well, it’s a power sensor provided on a smart plug(outlet). Based on my previous knowledge, I just thought of creating a new sensor with a value *1, as you just looked at the correction.

Ok last time, which integration did you use to add your smart plug?

Xiaomi MIoT Auto and Gateway 3