Utility meter - no device_class or unit_of_measurement derived from integration sensor

I have numerous sensors working this way from the same source devices, and only this one is giving issues.

The source of the utitlity_sensor is an integration sensor:

- platform: integration
  source: sensor.kids_bedroom_aircon_power_draw
  unit_prefix: k
  name: Kids' Bedroom Aircon Power (Total)
  round: 2
  method: left

It has all the correct attributes:

Then I create the utility_meter sensor:

utility_meter:
  kids_bedroom_aircon_power_daily:
    source: sensor.kids_bedroom_aircon_power_total
    cycle: daily
    name: Kids' Bedroom Aircon Power (Daily)

But - no no device_class or unit_of_measurement - meaning I can’t use it in the energy dashboard - even if I add the missing attributes manually via customizations it gives an error: Unexpected device class

Capture

I know I can use the Total sensor in the energy dashboard - but would ideally like to resolve this issue so it aligns with my other sensors (I have about 20 sensors done in exactly the same fashion without issue).

I’ve tried looking through the .storage folder to see where the utility_sensor information is stored, but - can’t find anything referencing it.

I have tried deleting and recreatng the sensor multiple times - fixing/unfixing it via Statistics, etc.

1 Like

Hi,

I have exactly the same issue and somehow even more stranger. I have one source sensor for the watts, which I use in an integration to give me the kWh similar to what you have done in your description. After that I use the Utility Meter integration on 4 levels: hourly, daily, monthly and yearly cycle. The monthly and yearly give device_class: energy and unit_of_measurement: ‘kWh’, exactly as expected. The other 2, hourly and daily don’t do that. The numeric value though is correct for all of them…

state_class: total_increasing
source: sensor.cum_kwh_heat_pump
status: collecting
last_period: 0
last_valid_state: 0.040
meter_period: monthly
cron pattern: 0 0 1 * *
last_reset: 2023-07-05T21:46:05.274063+00:00
unit_of_measurement: kWh
device_class: energy
icon: mdi:counter
friendly_name: kWh Heat Pump MTD

vs

state_class: total_increasing
source: sensor.cum_kwh_heat_pump
status: collecting
last_period: 0
last_valid_state: 0.040
meter_period: daily
cron pattern: 0 0 * * *
last_reset: 2023-07-07T23:00:00.046418+00:00
icon: mdi:flash
friendly_name: Heat Pump Energy

I have multiple set-ups for other ‘consumers’ working flawlessly. I can’t find any typo’s, I have searched and searched, modified and tried but so far no results… I have no clue. A true bug perhaps?

btw I have seen that there is an open issue on the Utitlity Meter integration addressing this issue. I added my comments to it. Let’s hope that they will pick it up.

1 Like