Counting Watt usage of Tasmota Devices

Hello,
I was starting with a few Tasmota Devices months ago, and for these few devices I created a sensor to show the current Watts consumption:

      power_usage_watt_all:
        friendly_name: "Tasmota Watts"
        unit_of_measurement: 'Watt'
        value_template: "{{ states('sensor.tasmota06_energy_power') |float + states('sensor.tasmota07_energy_power') |float + states('sensor.tasmota08_energy_power')

Now, with more and more devices, this is is not very user friendly to maintain.
I guess there is a much easier way to create this? Maybe everything that has “Energy_power” in it will be added to the sensor?

Thanks for hints and nice sunday
Philipp

Adapting this: How to automatically include and sum the values of multiple Utility Meter Sensors

Gives you:

      value_template: >
        {% set ns = namespace(states=[]) %}
        {% for s in states.sensor %}
          {% if s.object_id.endswith('_energy_power') %}
            {% set ns.states = ns.states + [ s.state | float ] %}
          {% endif %}
        {% endfor %}
        {{ ns.states | sum }}
1 Like

Thanj you!

1 Like