Automating play/pause of any/all playing mediaplayers except one - template/wildcard ideas

Hi All,
My mpd TTS notification mediaplayer speaks over the top of playing media on other media players. I’m trying to make a neat/efficient solution to pause media that is playing, and resume when the notification finishes. I’ve got a pair of automations that work when attached to a singular other media player. Now i’d like to expand it to include any/all media players in the house that are on.

here are my current automations:

  - alias: 'tts_notification_music_pause'
    trigger:
      - platform: event
        event_type: automation_triggered
        event_data:
          name: notify_interrupt_test
    condition:
      condition: state
      entity_id: media_player.top_room
      state: 'playing'
    action:
      - service: media_player.media_pause
        entity_id: media_player.top_room  

  - alias: 'tts_notification_music_resume'
    trigger:
      - platform: state
        entity_id: media_player.mpd_notify
        to: 'off'
    condition:
      condition: state
      entity_id: media_player.top_room
      state: 'paused'
    action:
      - service: media_player.media_play
        entity_id: media_player.top_room

I’m wondering if there is a way to use templating or wildcards to have:

  • the condition entity id equivalent to " all playing media players except
    media_player.mpd_notify

  • the action resume media playback on the respective players - again excluding the media_player.mpd_notify.

ultimately i would also like the the first automation’s trigger to be similar - all automations starting ‘automation.notification…’ should trigger it

i’ve seen some examples here of similar templating, but only to group together sensors or battery levels, nothing like this.

Any insight would be very much valued :slight_smile: