Your template monitors more entities than is necessary. The template begins with states which means Home Assistant will listen for state-changes of all entities in your system. Your template is actually only interested in the state-changes of the entities contained within the group.
The following template performs the same function but focuses exclusively on the group’s members:
- platform: template
sensors:
count_of_speakers_on:
friendly_name: Count of Speakers On
unit_of_measurement: 'on'
value_template: "{{ expand('group.all_avr_speakers')|selectattr('state','eq','on')|list|count }}"
FWIW, I use this method to create several Template Sensors that report open doors, unlocked locks, illuminated lights, active appliances, etc. In my case, the entity’s state reports the names of the active entities (comma-separated) and an attribute reports the quantity.
… and if there’s any doubt in your mind, simple paste your template into the Template Editor and observe the last line in the results pane. It will report:
This template listens for all state changed events.