Utility meters don't show up when created in yaml but do when created in ui

I’ve created some utility meters in UI (helper). As the number is growing and there is much copy & paste, I want to make it easier and more (human) readable so I decided to continue by defining new ones in yaml.
My preferred way: subfolders and topic related yaml files:
config/entities/utility_meters/electricity.yaml (water.yaml… you name it)

The problem:

  1. utility meters create in UI (helper) are shown and usable immediately (as expected)
  2. utility meters from a custom component (I think it’s a Solaredge addon/integration), defined in yamls, included via
homeassistant:
  packages: !include_dir_named packages

→ OK (shown as entities and usable)

  1. MY new utility meters like this one
utility_meter:
  ###### Eigenverbrauch ######
  eigenverbrauch_hourly_valid:
    source: sensor.eigenverbrauch_strom
    name: Eigenverbrauch (hourly)
    cycle: hourly
    periodically_resetting: false

don’t show up at all. Yes, I restarted in different ways:

  • dev-tools → reload yaml
  • dev-tools → all yamls
  • dev-tools → restart HA
  • reboot the whole PC

again and again.

I have tried different ways either:

  • use the utility meter in configuration.yaml directly → NOK
  • move the strom.yaml to /config and include like template: !include templates.yaml (templates work fine) → NOK
  • define the utility meter in existing yaml from packages folder (see above: UMs from the solaredge component work fine) → NOK
  • move strom.yaml to packages folder → NOK
  • move strom.yaml to my preferred folder structure (see above) and include with different approaches (dir_named, merge, …) → NOK

current version of HA 2023.12.4.

Do you have any idea how to create and include my yamls to get it work?

Thanks a lot!
Andi

have you looked in the homeassistant.log file to see if there are related errors?

if you want to use !include then you need to do this (using your example structure):

in configuration.yaml (assuming you have a folder ‘entities/utility_meters/’ in your config folder)

utility_meter: !include_dir_merge_list entities/utility_meters/

then put the strom.yaml file in the above folder and put this in that file

  eigenverbrauch_hourly_valid:
    source: sensor.eigenverbrauch_strom
    name: Eigenverbrauch (hourly)
    cycle: hourly
    periodically_resetting: false

and I think it should work after restarting HA

thanks for your reply. Unfortunately no entry in the log(s). merge_list doesn’t work. I have tried all options for include, without success.
Any other logs I could look into?

Yeah, my bad I used the wrong include.

try this instead:

utility_meter: !include_dir_merge_named entities/utility_meters/

those aren’t lists they are dictionaries so you need to use “named” and not “list”.

I just tested it on my config and it works.

Is there any way to get a log of the loading of this config? I have a similar symptom but I’ve just placed the utility_meter: section directly in my configuration.yaml. It loads fine and there is nothing in the system log. None of the utility meter sensors gets created. I can create these through the UI, except I can’t use the cron: syntax there. I’m trying to use this to track the run times of some sump pit pumps. I have a working on duration calculation and a cycle count. Then I am trying to do the following:

utility_meter:
  pit_pump_hourly_runtime:
    source: sensor.pit_pump_on_duration
    name: Pit Pump Hourly Run Time
    cycle: hourly
  pit_pump_hourly_cycle_count:
    source: sensor.pit_pump_cycle_count
    name: Pit Pump Hourly Cycle Count
    cycle: hourly

The underlying sensors seem fine, but the utility meters don’t create.

Any suggestions for troubleshooting appreciated

Apparently this is user error. Utility Meters only load when you completely restart HA, they are not responsive to YAML reload. I’m not sure if that’s documented, I never found it, but I found some others with the same issue.

2 Likes

Hi there - I found this thread because of the exact same issue - I tried putting quotes around the name and then did a Dev Tools → All YAML Configuration, and all of a sudden it appeared in my entities

1 Like