Utility Meter Naming from Yaml?

Good afternoon.

I’m trying to create a bunch of separate meters to get separate costs on different circuits. IE: How much is my water heater costing me, vs. my dryer, etc etc. I’m running into some annoyance on how utility meters defined in YAML are getting pulled into Home Assistant.

Here’s the definition for all power coming into the house:

um_hourly_el_grid:
  name: "Hourly - Electric - Grid"
  source: sensor.mains_123_1min
  unique_id: 20230131113201
  cycle: hourly
  tariffs: sensor.et_pepco_r

And the tarriff is defined in a sensor. This is my electric company’s standard offer service, that separates summer and winter rates, and nothing else. I’m not on time of use billing (yet).

- platform: template
  sensors:
    et_pepco_r:
      unique_id: '2023011901'
      value_template: >
        {% if now().month <= 3 and now().year <= 2023 %}
          {% if now().month >=6 and now().month <= 10 %}
              0.07592
            {% else %}
              0.03751
            {% endif %}
        {% else %}
          {% if now().month >=6 and now().month <= 10 %}
            0.07592
          {% else %}
            0.03948
          {% endif %}
        {% endif %}
      unit_of_measurement: "$/kWh"

When HA loads the meter, though, I get a new utility meter sensor with a mangled name and entity ID.

Why is HA doing this!? I clearly told it what I wanted those items to be, and I can’t find this behavior documented anywhere.

It has not changed the name, only the entity id. Entity ids can not contain dashes “-”.

Entity ids will be created from “slugified” names. This means they will be converted to lower case and any special characters or spaces will be replaced with underscores “_”.

Additionally the utility meter will create a sensor for every tariff with the slugified tariff appended to the entity id.

Reading through the doc again, this behavior is described, it’s just not clearly called out.

I assume there’s no way to disable this behavior, and the meters would have to then be added back together manually?

If you don’t want the energy split just don’t add any tariffs.