Automation for Not Turning off TV if Spotify is playing on Apple TV

Hey All,

I have the automation below that I use that will turn off my TV if no occupancy has been detected for 5 mins. I want to stop the automation from working if Spotify is playing on the Apple TV. I’ve worked around this for now by just choosing to stop the automation from running if the Apple TV is playing anything, but I’d like it to be specific in that only when Spotify is not open.

Can anyone help or suggest what I should do?

Thanks

Automation;

alias: Living Room - Turn off TV & Lamp if room not occupied for 5 mins
description: ""
trigger:
  - type: not_occupied
    platform: device
    device_id: a4fa08fc067ac9a5d98596828ec797c9
    entity_id: d262b1289a530beb72bc89c20cc9c042
    domain: binary_sensor
    for:
      hours: 0
      minutes: 5
      seconds: 0
condition:
  - condition: and
    conditions:
      - condition: device
        device_id: f85c54f4fe5c59ba11911a4823a022a9
        domain: media_player
        entity_id: 9b5f557d3d486e81ea10f5b3bfe1f478
        type: is_on
      - condition: not
        conditions:
          - condition: device
            device_id: f85c54f4fe5c59ba11911a4823a022a9
            domain: media_player
            entity_id: 9b5f557d3d486e81ea10f5b3bfe1f478
            type: is_playing
action:
  - service: media_player.turn_off
    metadata: {}
    data: {}
    target:
      entity_id:
        - media_player.jem_home
        - media_player.sony_kd_43x80j
  - service: switch.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: switch.living_room_lamp
  - service: light.turn_off
    metadata: {}
    data: {}
    target:
      entity_id:
        - light.tv_ambient_lights_2
        - light.tv_light_strip
mode: single