Apply same condition to multiple automations - Configuration "Blocks"

Hi,
I was wondering if there is a more DRY way to apply the same condition (or trigger) to multople automations, rather than copy and pasting the same condition into all automations.

- alias: Media player paused
  trigger:
    - platform: state
      entity_id: media_player.tv
      to: 'paused'
  condition:
    condition: template
    value_template: "{{states.media_player.tv.attributes.media_content_type != 'music' }}"
  action:
    service: light.turn_on
    entity_id: light.living_room_table_lamp


- alias: Media player idle
  trigger:
    - platform: state
      entity_id: media_player.tv
      to: 'idle'
  condition:
    condition: template
    value_template: "{{states.media_player.tv.attributes.media_content_type != 'music' }}"
  action:
    service: light.turn_on
    entity_id: light.living_room_table_lamp

- alias: Media player playing
  trigger:
    platform: state
    # entity_id: media_player.plex_web_chrome
    entity_id: media_player.tv
    to: 'playing'
    for:
      seconds: 5
  condition:
    condition: template
    value_template: "{{states.media_player.tv.attributes.media_content_type != 'music' }}"  
  action:
    - service: media_player.turn_off
      entity_id: media_player.soundtouch
    - service: light.turn_off
      entity_id: light.living_room_table_lamp

I think this could be achieved with a new concept. The idea is derived from the way unit tests can be grouped in Javascript.
Example:

describe('it works as expected', () => {
    it(...);
    it(...);
});

These describe blocks group similar unit tests together. They can be nested as well.
I was wondering if a similar syntax can be achieved for automations. For example:

- block: 
    alias: "Blcok with condition that is imposed on all automations within the block'
    condition: 
      condition: template
        value_template: "{{states.media_player.tv.attributes.media_content_type != 'music' }}"
    entities:
        - alias: Media player idle
          trigger:
            - platform: state
              entity_id: media_player.tv
              to: 'idle'
          action:
            service: light.turn_on
            entity_id: light.living_room_table_lamp

Is there a workaround or better way to do this? This would help keep the configuration DRY. Let me know what you think.

Stupid idea?
Existing way of accomplishing this?
Just bouncing ideas hoping to get feedback.

It would be a little tricky to implement and I think you’d need to come up with a use case where you would need to apply the same condition more than say 4 times to make it seem worthwhile. If it is just cut and pasted 2-3 times it’s not really worth it.

This could be useful, but in your case you have an easy work around.

Combine your first two automations by having two triggers instead of 1. The actions and conditions are the same, so it makes sense.

If you wanted to combine all 3, you could use template actions. Template action the light turn on/off, and then have a condition in the automation and if ‘playing’, then do the media player turn off. (note, I’m not positive that the syntax is 100% correct). Also, I took out the “delay”, but you could add it back in to the action with either a 5 second or 0 second delay with a template.

- alias: Media player playing
  trigger:
    platform: state
    entity_id: media_player.tv
  condition:
    condition: template
    value_template: "{{states.media_player.tv.attributes.media_content_type != 'music' }}"  
  action:
    - service_template: >
        {{light.turn_off if trigger.to_state.state == 'playing' else light.turn_on}}
      entity_id: light.living_room_table_lamp
    - condition:
      conditions:
        - condition: state
          entity_id: media_player.tv
          state: 'playing'
    - service: media_player.turn_off
      entity_id: media_player.soundtouch

There will always be automations that are somehow related. Whether that is by room, or depending on weather or some other relationship.
I agree, easier to copy and paste (sacrifice some good principles) in favour of time consuming implementation with little use.

I like this idea. Not sure if complicating an otherwise simple automation is necessary though.