Two devices must be turned on in an order (with a delay) and turned off in opposite order

I’ve got two switches controlling two different groups of equipment: musical gear (mixers, effects units, etc) and amplifiers plugged into two different Zigbee switches. I call them “music_gear” and “amps”.

Here’s the crux of the problem: if the music_gear powers up/down while the amps are on, I’ll hear a loud (undesirable) thump through the speakers. So, the music_gear should be powered on before the amps are turned on and amps should be powered off before music_gear is turned off (and there should be a delay while the amps power down). To complicate things, I sometimes use music_gear with headphones (so no need for the amps). Finally, I want to be able to use these with my Alexa. So, what I’m after is being able to utter:

  1. “Alexa, turn on amps” triggers music_gear_on and then amps_on
  2. “Alexa. turn off amps” just triggers amps_off
  3. “Alexa, turn on music gear” just triggers music_gear_on
  4. “Alexa, turn off music gear” triggers amps_off, then a delay of a couple of seconds, then music_gear_off

Now, I’ve written a script for #4, and it should be pretty easy to remove the delay and make #1. What I’m stuck on is how to aggregate these with the plain on/off functions of #2 and #3. Even if I have to resort to making trivial scripts for those (so that all four operations are scripts), I’m not sure how to abstract them into two pseudo/virtual devices (or maybe there’s no reason to even do that).

Here’s what I’ve got so far (for preventing turning off music_gear until amps have been off for at least a couple of seconds). Of course, it would be nicer if there were a way to only enter that 2-second delay if the amps were on, in the first place, but I’ve got bigger issues at the moment.

sequence:
  - type: turn_off
    device_id: 8aacc829f75bd752214fcbb416c4ef0b
    entity_id: switch.amps_switch
    domain: switch
  - wait_template: '{{ is_state("switch.amps_switch", "off") }}'
    timeout: '00:00:10'
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - type: turn_off
    device_id: acb41716bb752f7b3349f3f1fabfa4a2
    entity_id: switch.music_gear_switch
    domain: switch
mode: single
alias: Music Gear Off

You can do that with a choose block:

sequence:
  - choose:
      - alias: "Turn off the amp if it's on"
        conditions:
          - condition: state
            entity_id: switch.amps_switch
            state: 'on'
        sequence:
          - type: turn_off
            device_id: 8aacc829f75bd752214fcbb416c4ef0b
            entity_id: switch.amps_switch
            domain: switch
          - wait_template: '{{ is_state("switch.amps_switch", "off") }}'
            timeout: '00:00:10'
          - delay:
              hours: 0
              minutes: 0
              seconds: 2
              milliseconds: 0
  - type: turn_off
    device_id: acb41716bb752f7b3349f3f1fabfa4a2
    entity_id: switch.music_gear_switch
    domain: switch
mode: single
alias: Music Gear Off