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%)
Blueprint Code
blueprint:
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
input:
media_player:
name: Media Players
description: Select a media player or multiple media players
selector:
entity:
domain: media_player
offtime:
name: Off time
description: How long should the media player be off for before we reset the volume?
default: '00:01:00'
selector:
time:
reset_volume:
name: Reset volume
description: The volume you want your media player to be reset to
default: 0.3
selector:
number:
min: 0
max: 1
step: 0.1
mode: slider
trigger:
platform: state
entity_id: !input media_player
from: 'playing'
for: !input offtime
action:
- service: media_player.volume_set
data:
entity_id: '{{ trigger.entity_id }}'
volume_level: !input reset_volume
Changelog:
2021-02-19: removed to: ‘off’ from trigger to handle more speaker types
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
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 ?
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
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.
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> ^