this is a valid method, but, it is expensive. also, as I have experienced using something like that before, depending on your instance and startup sequence, it might need some tinkering to create the group only after all sensors are available.
for this particular reason, I made the group manually (we dont add sensors all the time, so this group is rather stable), and use this simple template sensor:
sensors_huidig_verbruik_summed:
friendly_name: Sensors huidig verbruik summed
unit_of_measurement: Watt
icon_template: mdi:plus-box-outline
value_template: >
{{expand('group.switches_sensors_actueel')
|map(attribute='state')|map('int')|sum}}
just an alternative…