How to add individual devices on the Energy Dashboard?

Hi!

I’m trying to add two Blitzwolf (Tuya; BW-SHP13) Zigbee smart plugs to the Energy Dashboard.

afbeelding

However, it does not let me (link):

afbeelding

I am using the Riemann sum integral:

  - platform: integration
    source: sensor.droger_stekker_2_electrical_measurement
    name: DrogerTotaal
    unit_prefix: k
  - platform: integration
    source: sensor.koelkast_garage_stekker_1_electrical_measurement
    name: KoelkastGarageTotaal
    unit_prefix: k

Which creates the following sensors:

 state_class: total_increasing
source: sensor.droger_stekker_2_electrical_measurement
unit_of_measurement: kWh
friendly_name: DrogerTotaal
icon: mdi:chart-histogram
device_class: energy
 state_class: total_increasing
source: sensor.koelkast_garage_stekker_1_electrical_measurement
unit_of_measurement: kWh
friendly_name: KoelkastGarageTotaal
icon: mdi:chart-histogram
device_class: energy

They do appear correctly on my normal lovelace dashboards:

afbeelding
afbeelding

Any idea on how I can make them appear in my Energy Dashboard? Am I missing the ‘last_reset’? If so, how can I add this?

Extra info:

  • Using MariaDB
  • Using 'Generic x86-64’ installation of Home Assistant

hi. yes - probably it is due to the “last_reset” which is missing here.
I haven’t tried it by myself yet - but you could create a sensor template where you inherit the properties of this sensor (state & attributes)…

this is just some code I’ve found here in the forum to add some of my solaredge sensors into the energy dashboard.

Maybe, you can just modify it for your needs?

  customize_glob:
    sensor.*_power_yearly_kwh:
      last_reset: '1970-01-01T00:00:00+00:00'
      device_class: energy
      state_class: measurement
    sensor.*_power_yearly:
      last_reset: '1970-01-01T00:00:00+00:00'
      device_class: energy
      state_class: measurement
      
utility_meter:
  imported_power_yearly:
    source: sensor.solaredge_imported_power
    cycle: yearly 
  exported_power_yearly:
    source: sensor.solaredge_exported_power
    cycle: yearly 

template:
  - sensor:
    - name: "Imported Power Yearly kWh"
      unique_id: imported_power_yearly_kwh
      state_class: measurement
      device_class: energy  
      unit_of_measurement: 'kWh'
      state: "{{(states('sensor.imported_power_yearly') | float) / 1000}}"  
    - name: "Exported Power Yearly kWh"
      unique_id: exported_power_yearly_kwh
      state_class: measurement
      device_class: energy    
      unit_of_measurement: 'kWh'
      state: "{{(states('sensor.exported_power_yearly') | float) / 1000}}" 

I’m pretty sure, since introducing the state class “total_increasing”, the attribute last_reset is no longer required.

Did you wait for 2 hours after creating your energy sensors for them to show up in the energy dashboard?

The required statistics for these sensors are only calculated once every hour.

Did you wait for 2 hours after creating your energy sensors for them to show up in the energy dashboard?

A few weeks actually (went on holiday) :sweat_smile: Still doesn’t appear, even after restarts.

How did you add state_class and device_class. The integration-sensor doesn’t have those.

In case you added those through customizing this only works with the new templates (as seen in the first answer here).

Anything in the logs?

They are automatically created by what I wrote in the config. So no customization by me.

  - platform: integration
    source: sensor.droger_stekker_2_electrical_measurement
    name: DrogerTotaal
    unit_prefix: k
  - platform: integration
    source: sensor.koelkast_garage_stekker_1_electrical_measurement
    name: KoelkastGarageTotaal
    unit_prefix: k

Nothing special shows up in the logs unfortunately.

I just found the following in the logs and I have no idea what this means:

Logger: homeassistant.components.sensor.recorder
Source: components/sensor/recorder.py:359
Integration: Sensor (documentation, issues)
First occurred: October 1, 2021, 10:12:00 PM (2 occurrences)
Last logged: October 1, 2021, 10:12:00 PM

The unit of sensor.drogertotaal (kWh) does not match the unit of already compiled statistics (None). Generation of long term statistics will be suppressed unless the unit changes back to None
The unit of sensor.koelkastgaragetotaal (kWh) does not match the unit of already compiled statistics (None). Generation of long term statistics will be suppressed unless the unit changes back to None

It means the unit of the entries for your sensor in the database changed from no unit to kWh.

Since they are inconsistent, the sensor will not show.

The only way to remedy this is either editing the database, or start over by giving your sensor a different name then before.

That might be worth a try. However, they do appear correctly on lovelace dashboards with the correct unit_of_measurement set to kWh (I’ve updated the original post).

Also I do use MariaDB and I have no idea how to access that database. I am unable to find the location since I am using a ‘Generic x86-64’ installation of Home Assistant instead of Pi or Docker.

It doesn’t matter how they appear in Lovelace. The unit is saved with every data point in the statistics table, which is used for the energy dashboard. And it doesn’t match, as per your log.

Can’t help you with mariadb.

Hi Guys,

I have known all the issues above. wondering why I could not add any other socket device to my energy tab.
All ‘settings’ where there. But a no show in adding devices. Turned out I had to put the sensor in recorder.yaml after that (and a restart) I could select the device, it created an ‘warning/error’ at first (the yellow square) that it couldn’t get statistics but of course that was because of the lack of data, it disappeared after an hour…

oh, warning, all (ALL!!!) my data has been lost (at least in the energy tab) after adding the additional devices…
Looks like a total reset of the energy board…

Hope some of you can get it working too.

Regards Frank

I don’t have recorder.yaml is that a default file or something you added to HA?

Anyone know how to do it with n zigbee2mqtt device?
i have that socket what reports usage, but doenst show up on energy page.

regards