Integrations

Media player

Spook adds actions that turn the volume of a media player up or down by exactly the step you give, fade it over minutes or hours, play an announcement at a volume of its own and put the volume back after, turn a media player on or off for a while, step it to its next or previous source or sound mode, and skip forward or back by a number of seconds.

The media player integration is how Home Assistant controls speakers, televisions, receivers and everything else that plays.

Home Assistant has volume up and volume down, but how far those go is up to the player: its own step, or the press of its own button. Spook adds a step you choose. Fade volume takes the volume somewhere slowly, over minutes or hours, with Stop fade volume to stop it. Announce plays a chime or a spoken message at a volume of its own, and puts the volume back once it is done. It also adds a way to turn a player on or off for a while.

Home Assistant can pick a source or a sound mode, but not step to the next one. A remote button that takes the receiver from TV to Spotify to Turntable has to be a template. Spook adds that step as well.

Home Assistant can seek to a position, but not 30 seconds on from here. Spook adds that too.

Actions

Spook adds thirteen actions for media players. You find them wherever you add an action, marked with a 👻.

Increase volume

Turns the volume of a media player up by exactly the step you give, stopping at full volume.

One speaker jumps ten percent on volume up, the next one two. A "louder" button that works the same on every speaker in the house needs a step you pick. Without this action, that is a template that reads the volume, adds to it, and keeps it under full. With it, it is one step.

How to use it

  1. Open the automation or script that should turn it up, and select Add action.
  2. Search for increase volume, and select Media player: Increase volume 👻.
  3. Under Targets, choose the media player.
  4. Set Step, in percent of full volume, like 5.
  5. Select Save.

Just want to see it work? Try this action opens it in your Home Assistant, ready to run once.

The Actions tool with Increase volume 👻 picked and filled in with an example.
What Try this action opens, filled in with an example.

Decrease volume

Turns the volume of a media player down by exactly the step you give, stopping at silent.

The "quieter" button to go with Increase volume. Also handy for a doorbell that should turn the music down a bit, not off.

How to use it

  1. Open the automation or script that should turn it down, and select Add action.
  2. Search for decrease volume, and select Media player: Decrease volume 👻.
  3. Under Targets, choose the media player.
  4. Set Step, in percent of full volume, like 10.
  5. Select Save.

Just want to see it work? Try this action opens it in your Home Assistant, ready to run once.

The Actions tool with Decrease volume 👻 picked and filled in with an example.
What Try this action opens, filled in with an example.

Increase volume and Decrease volume work the same way:

  • The step is required, in percent of full volume, and need not be a whole one: 2.5 is a fine step. A step that would go past full volume or silence stops there.
  • Home Assistant's own media_player.volume_up and media_player.volume_down remain for when the player's own step will do.
  • Muting is left alone: turning the volume of a muted player changes the level it comes back at.

Fade volume

Fades the volume of media players from where it is to a level you give, over minutes or hours.

media_player.volume_set goes there at once. A wake-up alarm that starts quiet, or music that dies down at bedtime, usually ends up as a script with a loop in it. This action sends the steps itself: one every interval, spread evenly over the duration, the last one exactly on the level asked for. The steps on the way are rounded to whole percents, and a step that would change nothing is not sent.

Somebody else changing the volume of a player stops its fade, and Spook leaves the volume where they put it. A player turned off, becoming unavailable, or no longer saying its volume stops its fade too. A new fade on a player replaces the one running on it.

Spook does not turn a player on to fade it. Named outright, anything that is not a media player is refused with an error, and so is a player that cannot fade: one that is unavailable, one that cannot be set to a volume level, or one that does not say its volume, like many players while they are off. Picked up through an area, a device, a floor, a label or a group, these are passed over. A media player group helper fades member by member, each from its own volume.

How to use it

  1. Open the automation or script that should fade the volume, and select Add action.
  2. Search for fade volume, and select Media player: Fade volume 👻.
  3. Under Targets, choose the media players, or a whole area.
  4. Set Volume to where it should end, from 0 for silent to 1 for full volume.
  5. Set Duration to how long the fade takes, like 00:15:00 for fifteen minutes.
  6. Optionally, set Interval to the time between two steps. It is 1 second unless you set it.
  7. Select Save.

Just want to see it work? Try this action opens it in your Home Assistant, ready to run once.

Stop fade volume

Stops the volume fades running on media players: Spook sends them no step after this.

The fades started with Fade volume stop by themselves when somebody else changes the volume. This is for stopping one on purpose: when the alarm is snoozed, or somebody turns the music back up from an automation of their own. Players that are not fading are left alone.

The targets work the same as for Fade volume: entity_id: all and anything named outright that is not a media player are refused with an error, and whoever calls it has to be allowed to control every media player it is aimed at.

How to use it

  1. Open the automation or script that should stop the fade, and select Add action.
  2. Search for stop fade volume, and select Media player: Stop fade volume 👻.
  3. Under Targets, choose the media players, or a whole area.
  4. Select Save.

Just want to see it work? Try this action opens it in your Home Assistant, ready to run once.

Announce

Plays a chime or a spoken message on media players at a volume of its own, and puts each player's volume back once it is done.

media_player.play_media plays it at whatever volume the player has. The doorbell at 60 percent is a script everyone writes: remember the volume, set it, play the chime, wait, put the volume back. The wait is a guess, and two rings at once put the first ring's volume back for good. This action does all of it, for every player on its own.

What happens depends on the player:

  • A player that can make announcements, like Sonos, Music Assistant, Squeezebox, Bang & Olufsen or an ESPHome voice assistant, gets one. It ducks what it was playing, and resumes it by itself. Spook never touches its own volume, as that would turn up what it was playing too. Sonos, Squeezebox, Music Assistant and Bang & Olufsen take an announcement volume of their own, and get the volume you give that way. For them, a volume of 0 is the quietest they play, not silence. Any other player that makes announcements, like an ESPHome voice assistant, plays it at the volume it has. Spook does not wait for these: there is nothing to put back.
  • Any other player gets the volume you give. Spook remembers its volume and whether it is muted, sets the volume, and unmutes it. Then it plays the announcement, waits until the player says it is done, and puts the mute and the volume back as they were. Spook also tries that last step when the player takes too long, when playing fails, or when the script running it is stopped. The player stops what it was playing for the announcement, and stays stopped after. Spook does not try to start it again: what a player says it was playing is often not something it can be told to play again. A playlist from an app, a radio stream or an input on a receiver would start over from the top, or start the wrong thing, which is worse than silence.

A player is done once it played the announcement and stops playing it: it goes idle, paused or off, or on to something else. Every player says that much. How long a sound lasts is something many players never say, and a spoken message still being made has no length yet at all. A player that never says it plays the announcement, like one that is only asked how it is doing every so often, keeps the announcement volume until the timeout.

Two announcements on the same player both play right away, the second cutting the first short. The volume from before the first one goes back once the last one is done. Announcements on different players never wait for each other.

Somebody changing the volume during the announcement keeps it: Spook only puts the volume and the mute back when the player is still at the volume Spook set. A player that went out of reach gets its volume back once it is within reach again, if that is before the timeout runs out. One that stays away keeps the announcement volume, and the response says volume_restored: false.

Without a volume, Spook leaves the volume and the mute alone. It waits for the announcement to finish on a player that cannot make announcements, and answers at once for one that can. A player that cannot set its volume, or does not say what it is, like many players while they are off, plays the announcement at the volume it has.

Named outright, anything that is not a media player is refused with an error, and so is a player that is unavailable or cannot play media. Picked up through an area, a device, a floor, a label or a group, these are passed over. A media player group helper announces member by member, each with its own volume to go back to.

How to use it

  1. Open the automation or script that should make the announcement, and select Add action.
  2. Search for announce, and select Media player: Announce 👻.
  3. Under Targets, choose the media players, or a whole area.
  4. Under Media, pick what to play: a sound from your media, or a text-to-speech message.
  5. Optionally, set Volume to how loud it should be, from 0 for silent to 1 for full volume.
  6. Optionally, set Timeout to the longest it waits for a player to finish. It is 30 seconds unless you set it.
  7. Select Save.

Just want to see it work? Try this action opens it in your Home Assistant, ready to run once.

Turn on for

Turns media players on for a while, and turns them back off when the time is up. Spook stores when each one is due back, so a restart of Home Assistant in between does not stop that.

It is Turn on for, with the same rules, for media players only. Named outright, anything that is not a media player is refused with an error. Picked up through an area, a device, a floor, a label or a group, it is passed over.

How to use it

  1. Open the automation or script that should do this, and select Add action.
  2. Search for turn on for, and select Media player: Turn on for 👻.
  3. Under Targets, choose the media players.
  4. Set Duration to how long they should stay on, like 00:15:00 for fifteen minutes.
  5. Select Save.

Just want to see it work? Try this action opens it in your Home Assistant, ready to run once.

Turn off for

Turns media players off for a while, and turns them back on when the time is up. Spook stores when each one is due back, so a restart of Home Assistant in between does not stop that.

It is Turn off for, with the same rules, for media players only. Named outright, anything that is not a media player is refused with an error. Picked up through an area, a device, a floor, a label or a group, it is passed over.

How to use it

  1. Open the automation or script that should do this, and select Add action.
  2. Search for turn off for, and select Media player: Turn off for 👻.
  3. Under Targets, choose the media players.
  4. Set Duration to how long they should stay off, like 00:30:00 for half an hour.
  5. Select Save.

Just want to see it work? Try this action opens it in your Home Assistant, ready to run once.

Next and previous source

Steps a media player to its next source, like from TV to Spotify, or back to the previous one. Only through the sources you pick, if you like.

Think of a button on a remote that takes the living room receiver from TV to Spotify to Turntable, one press at a time. Home Assistant can do that for a select, with select.select_next, but not for the sources of a media player. Without this, that button is a template that finds the source in the list, takes the one after it, and starts over at the end. This action does the step for you, the same way it does for the presets of a thermostat.

How to use it

  1. Open the automation or script that should do this, and select Add action.
  2. Search for next source, and select Media player: Next source 👻. Or search for previous source, and select Media player: Previous source 👻, to go the other way.
  3. Under Targets, choose the media players.
  4. Leave Cycle on to go round at the end. Turn it off to stop there.
  5. Leave Options empty to step through all of the sources it has, or fill in the ones to step through, in order, like TV, Spotify and Turntable.
  6. Select Save.

Just want to see it work? Try next source or try previous source opens it in your Home Assistant, ready to run once.

Next and previous sound mode

Steps a media player to its next sound mode, like from Standard to Movie, or back to the previous one. Only through the sound modes you pick, if you like.

Think of a button that takes the TV from Standard to Movie to Music, one press at a time. Home Assistant can set a sound mode, but not step to the next one. Without this, that button is a template that finds the sound mode in the list, takes the one after it, and starts over at the end. This action does the step for you, the same way it does for the sources.

How to use it

  1. Open the automation or script that should do this, and select Add action.
  2. Search for next sound mode, and select Media player: Next sound mode 👻. Or search for previous sound mode, and select Media player: Previous sound mode 👻, to go the other way.
  3. Under Targets, choose the media players.
  4. Leave Cycle on to go round at the end. Turn it off to stop there.
  5. Leave Options empty to step through all of the sound modes it has, or fill in the ones to step through, in order, like Standard, Movie and Music.
  6. Select Save.

Just want to see it work? Try next sound mode or try previous sound mode opens it in your Home Assistant, ready to run once.

Seek forward and backward

Skips what a media player is playing forward or back by the number of seconds you give, like 30 seconds past an ad in a podcast, or 10 seconds back to hear that line again.

Home Assistant can seek, but only to a position: media_player.media_seek wants to know where to go, not how far. Thirty seconds on from here is a template that reads the position, works out how far the player got since it last said, adds 30, and keeps it before the end. These actions do that for you.

How to use it

  1. Open the automation or script that should do this, and select Add action.
  2. Search for seek forward, and select Media player: Seek forward 👻. Or search for seek backward, and select Media player: Seek backward 👻, to go the other way.
  3. Under Targets, choose the media players.
  4. Set Seconds, like 30.
  5. Select Save.

Just want to see it work? Try seek forward or try seek backward opens it in your Home Assistant, ready to run once.

Missing something here?

An action, an entity or a repair this integration should have? Say so. Stuck, or found a bug? There is help.