Clear a Sonos queue if the device has been paused for a while

Simple automation to clear a Sonos queue if the device has been paused for a specified time. This brings the media player back into “idle” state, otherwise it will always show a queued song. I have my devices set to a 6 hour timeout.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

blueprint:
  name: Clear Paused Sonos Queue
  description: Clear a Sonos queue if the device has been paused for a specified time
  domain: automation
  input:
    target_media_players:
      name: Sonos Devices
      description: The Sonos devices to clear
      selector:
        entity:
          domain: media_player
          integration: sonos
          multiple: true
    duration:
      name: Duration
      description: How long should the device be paused before clearing the queue
      selector:
        duration:

trigger:
  - platform: state
    entity_id: !input target_media_players
    to: paused
    for: !input duration

action:
  - service: media_player.clear_playlist
    target:
      entity_id: '{{ trigger.entity_id }}'
2 Likes

I am getting following error when running the automation created based on this blueprint:
Error: Template rendered invalid entity IDs:
Any ideas?

What version of Home Assistant are you running?

Hi, I am running the latest version Home Assistant 2023.7.3

Any movement here? I’m getting the same error message as Botap. I’m running Home Assistant 2023.9.0. I have a large Sonos setup and would love to make this work. Any help or direction is appreciated.

Thank you. This is just what I’ve been looking for, and it works perfectly!

Does anyone have this working with the move 2? I can’t seem to find a good way to clear queue or stop the device from being in a paused state.