Mute the rest of this track.
-
Comments:
- here.
Working from home means that I don’t use my AirPods as much as I used to: I’m happy to mostly listen to the music my partner (who has worked from home for over a decade) wants to listen to. Lately, that has been NonStop80s.
We play this through the IKEA Symphonisk stereo pair in the dining room, several metres away from the office. The sound is good, and it’s nice not having it come out of the computer speaker.
Because I’m a nut, I have all of this hooked up to Home Assistant, and have one nice automation that will turn off the music that is playing on that speaker when the TV in that room is turned on.
Sometimes the tracks that are played on NonStop80s are really bad. For instance, Snooker Loopy, by Chas and Dave is an absolute piece of shit song. If it weren’t a streaming station, I’d just hit skip.
What would be nice is to be able to have the speakers stop playing, and start playing again when the next track comes on.
Enter “Mute the rest of this track”.
alias: Mute the rest of this track
sequence:
- condition: state
entity_id: media_player.dining_room_sonos
state: playing
- condition: template
value_template: ''
- service: media_player.volume_mute
data:
is_volume_muted: true
entity_id: media_player.dining_room_sonos
- delay: '1'
- wait_for_trigger:
- platform: state
entity_id: media_player.dining_room_sonos
timeout: ''
- service: media_player.volume_mute
data:
is_volume_muted: false
entity_id: media_player.dining_room_sonos
mode: single
icon: 'mdi:volume-mute'
description: Mute the media player until the media_title attribute changes.
fields:
timeout:
description: Amount of time to stay muted if the track does not change
example: 300
This is a script that you can use in Home Assistant to do just that. It will (iff the dining_room_sonos
is unmuted, and currently playing), mute that speaker until something else on the speaker changes.
This could be a track change, or a volume change, or anything else. It’s deliberately loose, so that if it was muted, and someone changes the volume, it unmutes immediately.
After a configurable (default 300 seconds) timeout, it will unmute.
I was trying to make it so that you could provide the named media_player
entity, but there still seem to be places where you can’t use templates (but need to provide the string directly). I was able to get the conditions to use the variable, but was not able to figure out how to use them in the service calls…and to be honest, I don’t really need it to apply to other players.