Energy: Not showing the expected entities for consumption

Solved!!!

You are gorgeous!

I am able to choose the sensors now. Regarding this, I wonder if I am using the right way to import the xml data using rest, maybe there is another method cleaner?

I have some Tuya devices that measure power (in W); and I am trying to represent that in kWh using the integration (Reiman sum integral). Set as follows:

- platform: integration
  source: sensor.tuya_tv_current_consumption
  name: tuya_tv_energy
  unit_prefix: k
  round: 2

The energy now shows in kWh as follows:

but when trying to select it from the energy dropdown, it is not showing. Am I missing something?

1 Like

Looks like you need to add the device_class Energy Management in Home Assistant - #119 by dgaust

Work like charm…thanks

This solved my problem as well. Thank you

A thread dedicated for the specific issue with REST sensors can be found here: State_class: “measurement” for platform: rest - #3 by jonasgustavsson

1 Like

I’m unable to add the Slimmelezer gas measurements in the Energy tab. Do any of you struggle with this too? I get this:

Unexpected unit of measurement

The following entities do not have the expected units of measurement ‘kWh’, ‘m³’ or ‘ft³’:

I have already taken care of the reset time. Any advice is greatly appreciated.

  customize_glob:
    sensor.*consumed*:
      last_reset: '1970-01-01T00:00:00+00:00'
      device_class: energy
      state_class: measurement

* sensor.gas_consumed (m3)

be sure to have the unit set to m³ and not m3.

you should no set the last_reset any longer as this is taken car of by the correct state_class

lastly, thought not a deal breaker, try to set all attributes directly on the sensor config, and not via customize, if at all possible. Not sure if the sensors you use are from the integration Slimme Lezer, or template sensors. If the latter, set the attributes in the template. If the former, doesnt that integration set the state_class?

Hi @Mariusthvdb,

I have tried quite a few times.

The last_reset was necessary for the Energy tab to accept the Slimmelezer as a source for energy consumption. Many people in this topic have done the same. I’m puzzled by why it wouldn’t work before.

Regarding the gas: I’ve tried with the m3 in the customize_glob. That has not solved the problem. Also I wouldn’t have the slightest idea where or how to edit the state class for Slimmelezer. Do you know?

Also I think template sensors aren’t allowed in the energy tab.

Yes they are. This is my energy consumption in energy tab :

    - name: "House electricity energy"
      unique_id: '0a7476cc-d6c1-40ba-8ae1-606518c3497f'
      unit_of_measurement: 'kWh'
      state: >
        {{ ((states("sensor.mains_consumed_energy") | float(0)) + (states("sensor.upstairs_consumed_energy") | float(0)) + (states("sensor.extra_consumed_energy") | float(0)) )| round(2) }}       
      availability: >
        {{ not 'unavailable' in 
        [ states('sensor.mains_consumed_energy'), 
          states('sensor.upstairs_consumed_energy'),
          states('sensor.extra_consumed_energy') ] }}        
      device_class: energy
      state_class: total_increasing  

this seems a very clear message. the unit is incorrect. it really should be and if the entity doesn’t have that, you should either be able to set it in the customize, or preferably, check in the core repo on the integration and file an issue there.
did you check here https://www.zuidwijk.com/initial-setup-slimmelezer/ ?

sure template sensors are allowed, as long as they fit the bill. that is, are of the correct state_class and have the correct unit

      - unique_id: lights_total_device_energy
        name: Lights total device energy
        state: >
          {{states('sensor.lights_inside_total_device_energy')|float(0) +
            states('sensor.lights_outside_total_device_energy')|float(0)}}
        unit_of_measurement: kWh
        icon: mdi:lightbulb-group-outline
        device_class: energy
        state_class: total_increasing

working just fine in the panel

the state_classes have been fixed in core HA to set the last_reset, so you shouldn’t need to set that manually.

btw, if yours in a total sensor, the state_class should be total_increasing.

what does your sensor look like in dev tools states?

@francisp Thank you. That means that creating a measure that basically copies my sensor.gas_consumed could work.

@Mariusthvdb I have the following in developer tools:

unit_of_measurement: m³
friendly_name: Gas Consumed
device_class: energy
last_reset: '1970-01-01T00:00:00+00:00'

That looks live I have the right unit of measurement set up, does it not?

Yes. Now take out the last_reset, and add the correct state_class and you’re done.

Solved it…

Downloaded the new firmware for Slimmelezer, downloaded that and removed slimmelezer and all the extra settings I made manually. That did the trick.

Thanks for helping out :smiley:

yeah, that was what we figured :wink:
great you got it working. cool.

Hi, have problem with my 2xBlitzwolf sph2 wifi (mqtt) smart plug sensors. How to solve this? In my configuration.yaml not have these sensors. Get from mqtt integration. TY

Go to developer tools → state and show what you have for these blitzwolf sph2

Have a lot of error and must fix. But don’t know how…
In my configuration.yaml try this:

customize_glob:
sensor.*_energy:
last_reset: ‘1970-01-01T00:00:00+00:00’
device_class: energy
state_class: measurement

but nothing changed I think.

is already not correct

unit_of_measurement: W
friendly_name: Blitzwolf 2 ENERGY Power
device_class: power