Energy: Not showing the expected entities for consumption

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

Same here, I can’t use my custom REST smart-meter sensor with the new Energy dashboards.

1 Like

Same issue :frowning: Can I covert it to a different template sensor?

Same here,

I have configured 5 sensors to manage my hoime consumption - production but I can not select in the combobox.

Anyone has achieved it?

it would help if you show your sensors.