Reset speaker volume after music stops

I have a lot of Nest speakers around the house and my kids love to hear music on them, which is awesome. But then I then asks google for something later the that day I get blowed away because they of course didnt lower the volume again.

This is where this Blueprint comes in. It triggers if a speaker (you can choose one og multiple) state enters ‘off’ for a given time (default 1 min) and lowers the speaker to given volume (default 0.3 = 30%)

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

Blueprint Code

  name: Reset speaker volume after music stops
  description: After speaker has been turned off for x minutes it will has its volume reset to x
  domain: automation
      name: Media Players
      description: Select a media player or multiple media players
          domain: media_player
      name: Off time
      description: How long should the media player be off for before we reset the volume?
      default: '00:01:00'
      name: Reset volume
      description: The volume you want your media player to be reset to
      default: 0.3
          min: 0
          max: 1
          step: 0.1
          mode: slider
  platform: state
  entity_id: !input media_player
  from: 'playing'
  for: !input offtime
  - service: media_player.volume_set
      entity_id: '{{ trigger.entity_id }}'
      volume_level: !input reset_volume

2021-02-19: removed to: ‘off’ from trigger to handle more speaker types


Thnx Thomas,

I recognize the situation and think this is a great solution. I do have 2 questions for you:

  • How do I select multiple media players?
  • I get an error while executing, can you point me in the right direction for a solution?

Thanks in advance.

* Reset speaker volume after music stops: Error executing script. Unexpected error for call_service at pos 1: Error rendering data template: UndefinedError: 'trigger' is undefined

  • How do I select multiple media players?
    • use a comma like: entity_id: media_player.speaker1, media_player.speaker2
  • I get an error while executing, can you point me in the right direction for a solution?
    • you need to select an entity and not a device, maybe answer 1 will also fix this

Very cool. I too have kids (and a wife) who like to blast music. Thank you.

First of all, thank you for your quick response! I know enough!

Hi I use this for my Sonos, but it does not work ? could it be that this use “stop” and my speaker is not stoped, it´s in “pause” is it possible to change ? or that is not the problem ?

Look, developer tools - the state of what your media player’s state is when you stop it. Then you can change the trigger:

1 Like


I just came across your blueprint because I have written a similar one and wanted to share mine, but now there appears to be no need to share another one :slight_smile:

I do have one suggestion though, which might also help to tackle @johnniemalm’s problem:

If you remove the to: 'off' property in the trigger, the automation should work with a larger number of speakers. Sonos, Google Nest devices and other speakers have different ways of switching from a playback state to an idle or off state. If the off property is gone than all that matters is that the media player has not been playing for a certain amount of time.


seems like a nice idea


Nice one! However I can’t import the blueprint.

No valid blueprint found in the topic. Blueprint syntax blocks need to be marked as YAML or no syntax.

didnt knew about direct import. I normally copy paste myself… try now @Luitertje I have marked teh code as YAML now

Hmm not there yet.

while scanning a simple key in "<unicode string>", line 40, column 1: </code></pre> ^ could not find expected ':' in "<unicode string>", line 41, column 1: <p><strong>Changelog:</strong><br> ^

@Luitertje no idea why it looked at that part… removed it, so pls try again. and thx for the debugging :smiley:

Yes, it’s working now! Thanks!

1 Like

Thanks, did change it to paused, it works fine

1 Like

I just imported this blueprint, and it appears the “Off time” is asking me for a time of day, rather than a length of time. Is that normal?

havent seen that before no

Great idea.

Does this work with Alexa media players using the hacs Alexa plugin?


I dont have an alexa so cant test, but if its added as a media_player and has status “playing” while playing music… yes it so work then.