Utility_meter automatically add in new sensors

# Example configuration.yaml entry
    source: sensor.energy_in_kwh
    name: Sensor Name - Daily Energy
    cycle: daily
    source: sensor.energy_in_kwh
    name: Sensor Name - Monthly Energy
    cycle: monthly

How can i modify this code to automatically find all the sensors with energy (e.g Entity ID:
sensor.dbplug_56cf_energy) and all the entity ending with _energy
to automatically add as source to monthly and daily?

This is so that in future when new plugs are added, i will not forget to add in utility meter to check their daily/monthly limit.


You can’t.

The source option of the utility_meter does not support templates.

You could make a template sensor that’s the sum of all and provide that one sensor to a utility meter (or both).

You can annotate entities with a custom attribute/property via customize.yaml and scan the full states object to find them (or use a regex if you have some naming convention). This will happen in the value or state template of said sensor. Either way there will be a small amount of manual work.

1 Like