Utiliy Meter not selectable in Energy Dashboard for Water Consumption

Hi there,

now I read my water meter and want to integrate it into the energy dashboard, but the utility meter I created isn’t selectable.

I use AI on the edge device and I get a m³ sensor. I have created a template sensor to convert it to liters:

- name: "Wassersensor Zählerstand Liter"
  unique_id: "f12a30bc-5704-4306-886f-1e45e7644454"
  unit_of_measurement: "L"
  state: "{{ states('sensor.watermeter_value')|float * 1000 }}"
  icon: "mdi:gauge"
  device_class: "water"
  state_class: "total_increasing"

Then I created a utility meter:

  energy_water_usage_liters_daily:
    source: sensor.wassersensor_zahlerstand_liter
    cycle: daily
    unique_id: "aa561bbc-6f8b-4b4c-a9d4-b00d38bae33f"
    periodically_resetting: True
    name: "Wasserverbrauch Liter Täglich"

In Energy Dashboard I can select the Liters template sensor, but not the utility meter.
Am I doing something wrong? If anyone can give me a hint that would be great.

Thanks!

How long has it been since you set up the utility meter? I think it can take a while for it to accumulate enough data to be selectable for the energy dashboard.

I’ve setup the sensors yesterday. The template sensor was selectable after a few minutes.

The utility meter isn’t selectable now, a day after.

Is the utility meter entity listed in the statistics panel?

Yes, the utility meter is listed in the statistics panel.

state_class: total_increasing
source: sensor.wassersensor_zahlerstand_liter
status: collecting
last_period: '242.0'
last_valid_state: '1108019.5'
meter_period: daily
cron pattern: 0 0 * * *
last_reset: '2023-10-13T22:00:00.020120+00:00'
unit_of_measurement: L
icon: mdi:counter
friendly_name: Wasserverbrauch Liter Täglich

I wonder that the device_class “water” isn’t inherit from the source sensor. My electricity, gas, solar utility meters inherits the device_class from the source sensor.

I had to manually add device class to utility meter as water so then it was visible.

How did you add the device_class? If I do I get an error:

Logger: aiohttp.server
Source: /usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py:403
First occurred: 21:02:23 (1 occurrences)
Last logged: 21:02:23

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 31, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/api/__init__.py", line 374, in post
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 2012, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2049, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/hassio/__init__.py", line 599, in async_handle_core_service
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: The system cannot restart because the configuration is not valid: Invalid config for [utility_meter]: [device_class] is an invalid option for [utility_meter]. Check: utility_meter->utility_meter->energy_water_usage_liters_daily->device_class. (See /config/configuration.yaml, line 83). 

I do know if there is a better way but I created a template based on the Utility Meter, that I could capture any errors and add the device class.

I did it with sensor customizations.

1 Like

Thanks for the help. Set the device_class via “customizing entities” didn’t work for me.
I had to set the device class in config/.storage/core.entity_registry and config/.storage/core.restore_state to get it working.

2 Likes

Thank you! I was banging my head on this all week. the customize.yaml file didn’t work for me either.