Energy: Not showing the expected entities for consumption

What does this mean? How does this answer my question? Should I put this snippet somewhere in my config? I’m not using legacy configuration right? I followed all instruction except for the fact that I can’t add a last_used_topic set to unix epoch 0 because I get errors. Is that really needed?

It updates all your sensors with _energy in the entity_id to have those three listed attributes. Which are required for an energy sensor to be used in the new Energy Management system.

You were shown exactly how to get working energy sensors.

You should put it exactly where shown in your config. Under homeassistant: in your configuration.yaml file.

1 Like

Ok, thank you. At first I didn’t realize that the light gray part was someting from another topic from someone with a similar problem so I thought you just reposted a question here.

The snippet you posted seemed to suggest I was using legacy mode? I don’t want to use legacy modes, so if you could point me to the modern way of doing this… :slight_smile: . Moreover, I want to also use the “current energy consumption” value and it says here: https://developers.home-assistant.io/docs/core/entity/sensor/#properties that I then have to use device_class: power (and for the cumulative value device_class: energy, so, I could do what you suggest, but I’d really like to understand why my solution does not work, since I followed all the instructions.

I’ll test your solution now and report back.

Edit: I don’t have the line homeassistant: in my configuration, so do I add it under default_config:? Two spaces indented? When I do that, I still don’t have the sensor show up sadly.

I’m pretty sure by now it is related to the last_reset value, my TP_link hs110 shows up in the list. It probably has this value set somewhere (although it does not show up in the attributes available in developers tools).

Perhaps it is good to mention that my mqtt sensors do not have a “unique_id”, could that have anything to do with it?

Btw, your help is highly appreciated :smile:

No it goes hard against the column margin.

You can’t use power sensors. Only energy sensors.

This was my new style template for my whole house energy meter :


template:
  - sensor:
      - name: "House electricity energy"
        unit_of_measurement: 'kWh'
        state: >
          {{ (states("sensor.mains_consumed_energy") | float + states("sensor.upstairs_consumed_energy") | float) + (states("sensor.extra_consumed_energy") | float)  | round(2) }}       
        device_class: energy
        state_class: measurement          

I tried to add a last_reset, but that results in an error when checking config. That is why I had to add it under homeassistant in configuration.yaml.

It seems the developers forgot to add that important piece to the new template style when creating the new energy function.

1 Like

Related, is state_class: measurement settable for rest sensors yet?

Seeing this error:

Invalid config for [sensor.rest]: [state_class] is an invalid option for [sensor.rest]. Check: sensor.rest->state_class. (See /config/configuration.yaml, line 582). Please check the docs at https://www.home-assistant.io/integrations/rest

I have a myenergi harvi to monitor the Grid CT and had hoped to use it for the new Energy dashboard

4 Likes

Ok, sorry for being such a noob but the first part of my config now looks like this:

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

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

And I get the error:

Setup failed for customize_glob: Integration not found.

Edti: Ah, so maybe in the future it will work when they add support for “last_reset”

1 Like

Try this :

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

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

Ah, ok, no power sensors, only cumulative values it is then.

oh, I saw this :

sensor:
  - platform: mqtt
    name: "Current usage"
    state_topic: "home/smart_meter/CURRENT_ELECTRICITY_USAGE"
    unit_of_measurement: 'kW'
    device_class: 'power'
    state_class: 'measurement'

  - platform: mqtt
    name: "Electricity used"
    state_topic: "home/smart_meter/ELECTRICITY_USED_TARIFF_ALL"
    unit_of_measurement: 'kWh'
    state_class: 'measurement'
    device_class: 'energy'

  - platform: mqtt
    name: "Gas consumed"
    state_topic: "home/smart_meter/HOURLY_GAS_METER_READING"
    unit_of_measurement: 'm3'
    state_class: 'measurement'

So it will need to be something like :

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

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


3 Likes

YEEESSS IT WORKS. Thank you. Indeed I already figured the last part out and changed the sensor name to end in “energy”. And indeed, I needed to add that homeassistant:

Thank you man, you are my hero today.

Can you add the homeassissant: line and indent ? Then it is really the solution.

1 Like

Same issue here …

It is not working anyway.
I’ve created the new-style sensor:

template:
  - sensor:
      - name: "power_all_new"
        unit_of_measurement: "Вт"
        state_class: measurement
        state: >
          {% set room = states('sensor.load_04cf8cdf3c867ea8')      | float %}
          {% set fridge = states('sensor.load_00158d00039c0362')    | float %}
         
          {{ (room + fridge) | round(1) }}

Also I’ve customized it like this:

sensor.power_all_new:
  last_reset: '1970-01-01T00:00:00+00:00'
  device_class: energy
  state_class: measurement

But this new sensor power_all_new still is not showing on the new energy consumption page.

New sensor indeed has the measurement option:

It seems that the sensor with unit kWh is needed. Not the ordinary Watts! It works now.

3 Likes

Indeed, I can add my gas usage when I alter the unit from m3 to kWh… I hope they start supporting m3 gas as well at some point! Actually gas is more relevant to me, I don’t see myself really using less electricity but gas I can see way to be smarter about it and adding isolation etc… Perhaps compute how much my house leaks energy by looking at gas usage as a function of outside temperature…

Some nice plot from peak usage etc (unit kW) would also be cool. But what we got is already really cool and there is a lot of potential, I’m really looking forward to new features in the future!

you can (should maybe, according to Frenck, prevent as much customization as possible ) also use this Can't set last_reset value for MQTT sensor · Issue #53988 · home-assistant/core · GitHub

using a ‘fake’ topic for the last_reset, and using

    <<: &energy
      unit_of_measurement: kWh
      value_template: >
        {{value|round(2)}}
      last_reset_topic: 'fake/last_reset'
#      last_reset_value_template: >
#        {{'1970-01-01T00:00:00+00:00'}}
#        {{as_datetime(0|timestamp_utc).isoformat()}}
      device_class: energy
      state_class: measurement

on all mqtt kWh sensors. Template sensors still need the customization

      last_reset: '1970-01-01T00:00:00+00:00'
      state_class: measurement

because these variables aren’t supported yet.

Note that even though the commented templates in my anchor are perfectly fine templates, they dont work in the mqtt config. No errors, simply no attribute is set for last_reset.

Same issue also for me :frowning:

Did it work?

If yes… Can you share?

For me this works:

homeassistant:
  customize_glob:
    sensor.myomnik_energy_total:
      unit_of_measurement: "kWh"     
      device_class: energy
      state_class: measurement
      last_reset: "1970-01-01T00:00:00+00:00"
1 Like