Individual Service Calls On Set of Entities

i use the scheduler custom integration in several automations to create one-time scheduled events. While it has an option to automatically remove completed scheduled events, i sometimes manually turn off the event before it runs – which prevents that removal step from happening. after a while, i end up with like 30 cancelled scheduled events cluttering up home assistant.

i’m not trying to create a script that uses templates to iterate through those dead events and run the remove schedule service call on each one individually.

in searching for help, all the guidance seems to be geared toward using templates to get the set of entities and then run a single service call on all of the entities at once – that doesn’t work here because, for whatever reason, the scheduler remove schedule service call doesn’t like a list of entities like other services do.

if i were scripting this in some other language the logic would be:

  1. get list of entities based on partial id match
  2. for loop to run the service on each entity one at a time.

here’s what i have for step 1 – it works. i just can’t for the life of me figure out the syntax for step 2 – like i said, the only other posts i’ve seen that are sort of on point assume that a list of entities can be fed to the service calls en mass, and that doesn’t work here.

            {% set dead_schedule_entities = expand(integration_entities('scheduler') | select('match', 'switch.schedule_')) | selectattr('state', 'eq', 'off')| map(attribute='entity_id') | list %}
            {{ dead_schedule_entities }}

this is the service call i need to run on each separate entity:

        service: scheduler.remove
        metadata: {}
        data:
          entity_id: switch.schedule_roborock_scheduled_clean

any hints for achieving the ‘for loop’ step 2 above using jinja?