---
title: "Media player"
description: "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."
canonical_url: "https://spook.boo/media-player"
---
# 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](#fade-volume) takes the volume somewhere slowly, over minutes or hours, with [Stop fade volume](#stop-fade-volume) to stop it. [Announce](#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](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.increase_volume) opens it in your Home Assistant, ready to run once.

![The Actions tool with Increase volume 👻 picked and filled in with an example.](https://spook.boo/images/screenshots/en/light/action-media-player-increase-volume.webp)

What **Try this action** opens, filled in with an example.

**Technical details**

| Action properties |
| --- |
| Action | Media player: Increase volume 👻 |
| Action name | `media_player.increase_volume` |
| Action targets | Yes, `media_player` entities that can set their volume |
| Action response | No response |
| Spook's influence | Newly added action |
| Tools | [Try this action](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.increase_volume) [![Open your Home Assistant instance and show the Actions tool with a specific action selected.](https://my.home-assistant.io/badges/developer_call_service.svg)](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.increase_volume) |

| Action data parameters |
| --- |
| Attribute | Type | Required | Default / Example |
| `step` | float | Yes | `5` |

**Example actions in YAML**

Five percent louder in the kitchen:

```yaml
action: media_player.increase_volume
target:
  entity_id: media_player.kitchen
data:
  step: 5
```

### 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](#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](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.decrease_volume) opens it in your Home Assistant, ready to run once.

![The Actions tool with Decrease volume 👻 picked and filled in with an example.](https://spook.boo/images/screenshots/en/light/action-media-player-decrease-volume.webp)

What **Try this action** opens, filled in with an example.

**Technical details**

| Action properties |
| --- |
| Action | Media player: Decrease volume 👻 |
| Action name | `media_player.decrease_volume` |
| Action targets | Yes, `media_player` entities that can set their volume |
| Action response | No response |
| Spook's influence | Newly added action |
| Tools | [Try this action](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.decrease_volume) [![Open your Home Assistant instance and show the Actions tool with a specific action selected.](https://my.home-assistant.io/badges/developer_call_service.svg)](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.decrease_volume) |

| Action data parameters |
| --- |
| Attribute | Type | Required | Default / Example |
| `step` | float | Yes | `5` |

**Example actions in YAML**

Ten percent quieter in the kitchen:

```yaml
action: media_player.decrease_volume
target:
  entity_id: media_player.kitchen
data:
  step: 10
```

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.

**Known limitations**

- A player with only volume up and down buttons, and no volume level to set, cannot be targeted.
- A player that does not report its volume, which many do while off, is left alone.

### 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](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.fade_volume) opens it in your Home Assistant, ready to run once.

**Technical details**

| Action properties |
| --- |
| Action | Media player: Fade volume 👻 |
| Action name | `media_player.fade_volume` |
| Action targets | Yes, `media_player` entities that can set their volume |
| Action response | No response |
| Spook's influence | Newly added action |
| Tools | [Try this action](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.fade_volume) [![Open your Home Assistant instance and show the Actions tool with a specific action selected.](https://my.home-assistant.io/badges/developer_call_service.svg)](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.fade_volume) |

| Action data parameters |
| --- |
| Attribute | Type | Required | Default / Example |
| `volume_level` | float | Yes | `0.3` |
| `duration` | string | Yes | `00:15:00` |
| `interval` | number | No | 1 |

`volume_level` goes from 0 to 1, the same as for `media_player.volume_set`. `interval` is in seconds, 1 at least. When the duration does not divide evenly by it, the steps are a little further apart, so they still spread evenly over the duration. A duration shorter than the interval is a single step.

Each step is a `media_player.volume_set`, carrying the context of whoever called `media_player.fade_volume`, as if they had called it themselves. Whoever calls it has to be allowed to control every media player it is aimed at, or no fade starts. The action returns once the fades are started, and does not wait for them to finish.

**Example actions in YAML**

A wake-up alarm in the bedroom, up to 40% over fifteen minutes:

```yaml
action: media_player.fade_volume
target:
  entity_id: media_player.bedroom
data:
  volume_level: 0.4
  duration:
    minutes: 15
```

The living room down to silent over half an hour at bedtime, a step every 10 seconds:

```yaml
action: media_player.fade_volume
target:
  area_id: living_room
data:
  volume_level: 0
  duration: "00:30:00"
  interval: 10
```

**Known limitations**

- Nothing about a fade is stored. A restart of Home Assistant, or reloading Spook, stops every fade where it is.
- A player can report its volume late, and rounded to a scale of its own. So a change by somebody else that leaves it between the step before and the latest one, give or take 2 percent, is taken for that, and the fade goes on.
- Muting is left alone: a muted player fades all the same, and Spook does not unmute it. It comes back at the volume the fade got to.
- Fading to 0 leaves a player playing, silently. Stopping or turning it off is up to the next action.
- A step already sent when somebody else changes the volume still lands, and can land after their change. Nothing is sent after it.

### Stop fade volume

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

The fades started with [Fade volume](#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](#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](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.stop_fade_volume) opens it in your Home Assistant, ready to run once.

**Technical details**

| Action properties |
| --- |
| Action | Media player: Stop fade volume 👻 |
| Action name | `media_player.stop_fade_volume` |
| Action targets | Yes, `media_player` entities |
| Action response | No response |
| Spook's influence | Newly added action |
| Tools | [Try this action](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.stop_fade_volume) [![Open your Home Assistant instance and show the Actions tool with a specific action selected.](https://my.home-assistant.io/badges/developer_call_service.svg)](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.stop_fade_volume) |

This action takes no data, only targets.

**Example actions in YAML**

The bedroom wake-up alarm, stopped:

```yaml
action: media_player.stop_fade_volume
target:
  entity_id: media_player.bedroom
```

**Known limitations**

- The last step of a fade ends the fade. Once it is sent, there is nothing left to stop.
- A step already sent is not called back, and can land after the stop.

### 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](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.announce) opens it in your Home Assistant, ready to run once.

**Technical details**

| Action properties |
| --- |
| Action | Media player: Announce 👻 |
| Action name | `media_player.announce` |
| Action targets | Yes, `media_player` entities that can play media |
| Action response | Optional, what was done on each player |
| Spook's influence | Newly added action |
| Tools | [Try this action](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.announce) [![Open your Home Assistant instance and show the Actions tool with a specific action selected.](https://my.home-assistant.io/badges/developer_call_service.svg)](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.announce) |

| Action data parameters |
| --- |
| Attribute | Type | Required | Default / Example |
| `media` | map | Yes, or the two below |  |
| `media_content_id` | string | Instead of `media` | `media-source://media_source/local/doorbell.mp3` |
| `media_content_type` | string | Instead of `media` | `audio/mpeg` |
| `volume` | float | No | `0.6` |
| `timeout` | number | No | 30 |

`media` is what the media selector picks, the same as for `media_player.play_media`: a `media_content_id` and a `media_content_type`. Those two can be given on their own as well, without `media` around them. `volume` goes from 0 to 1, the same as for `media_player.volume_set`. `timeout` is in seconds, from 1 to 300, and counts from the moment the announcement is sent, so a spoken message that is still being made counts towards it.

Each step is a media player action of Home Assistant: `media_player.volume_set`, `media_player.volume_mute` and `media_player.play_media`, carrying the context of whoever called `media_player.announce`, as if they had called them themselves. A player that can make announcements gets `announce: true`, and the announcement volume of its integration in `extra`: `volume` from 1 to 100 for Sonos, `announce_volume` from 0.01 to 1 for Squeezebox, `announce_volume` from 1 to 100 for Music Assistant, and `overlay_absolute_volume` from 1 to 100 for Bang & Olufsen. A volume of 0 is the quietest each of them takes, as they read 0 as no volume at all. Whoever calls it has to be allowed to control every media player it is aimed at, or nothing plays.

The action waits until every player that gets its volume back is done, or reached its timeout, and Spook tried to put its volume back. A player that makes announcements is not waited for. Ask for the response, and it says per player what was done:

```yaml
media_player.kitchen:
  announce: false
  volume: 0.6
  finished: true
  volume_restored: true
```

`announce` says whether the player got it as an announcement, `volume` the volume it played at, or `null` when Spook left the volume alone, like on a player that makes announcements without an announcement volume Spook knows of. `finished` is `false` when the timeout ran out rather than the player saying it was done. `volume_restored` is `true` when this announcement put the volume and the mute back, and `false` when the player stayed out of reach until the timeout, so they could not be put back. It is `null` when there was nothing to put back: no volume was set, an announcement still playing on the player puts it back, or somebody changed the volume meanwhile. Both are `null` on a player that makes announcements, which Spook does not wait for. A player that went out of reach before it was its turn is left out. When one player fails to play it, the others still play theirs, and the action fails once every player has its volume back.

**Example actions in YAML**

The doorbell chime at 60% on the kitchen and living room speakers, each back to its own volume after:

```yaml
action: media_player.announce
target:
  entity_id:
    - media_player.kitchen
    - media_player.living_room
data:
  media:
    media_content_id: media-source://media_source/local/doorbell.mp3
    media_content_type: audio/mpeg
  volume: 0.6
```

A spoken "the washing machine is done" at 40%, made by text-to-speech:

```yaml
action: media_player.announce
target:
  entity_id: media_player.kitchen
data:
  media:
    media_content_id: media-source://tts/tts.home_assistant_cloud?message=The+washing+machine+is+done
    media_content_type: provider
  volume: 0.4
```

**Known limitations**

- A player that makes announcements, in an integration without an announcement volume of its own, like ESPHome, plays it at the volume it has. The volume you give is left out for it.
- A player that never says it plays the announcement keeps the announcement volume until the timeout. A player that is only asked how it is doing every so often can miss a short chime altogether. A shorter timeout is the fix.
- A second announcement on a player that cannot make announcements cuts the first one short.
- What was playing on a player that cannot make announcements is stopped, and stays stopped.
- A player that changes what it plays by itself while the announcement is starting, like the next song coming up just then, can be taken for done early.
- Announcing on a player that is fading its volume stops the fade, the same as anybody else changing the volume does.
- Nothing about an announcement is stored. A restart of Home Assistant, or reloading Spook, while one plays leaves the announcement volume on the player.

### 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](https://spook.boo/misc#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](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.turn_on_for) opens it in your Home Assistant, ready to run once.

**Technical details**

| Action properties |
| --- |
| Action | Media player: Turn on for 👻 |
| Action name | `media_player.turn_on_for` |
| Action targets | Yes, `media_player` entities |
| Action response | No response |
| Spook's influence | Newly added action |
| Tools | [Try this action](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.turn_on_for) [![Open your Home Assistant instance and show the Actions tool with a specific action selected.](https://my.home-assistant.io/badges/developer_call_service.svg)](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.turn_on_for) |

| Action data parameters |
| --- |
| Attribute | Type | Required | Default / Example |
| `duration` | string | Yes | `00:15:00` |

**Example actions in YAML**

The bedroom receiver, for an hour:

```yaml
action: media_player.turn_on_for
target:
  entity_id: media_player.bedroom_receiver
data:
  duration: "01:00:00"
```

**Known limitations**

- The rules of [Turn on for](https://spook.boo/misc#turn-on-for) apply: only something plainly `on` or `off` is held. Something already on is left alone, and turning it off yourself ends the hold.
- A player that is `playing`, `paused`, `idle` or `standby` is not plainly on or off. It is refused when named, and passed over in an area.
- A player that cannot be turned both on and off is refused when named, and passed over in an area. There would be no way back.

### 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](https://spook.boo/misc#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](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.turn_off_for) opens it in your Home Assistant, ready to run once.

**Technical details**

| Action properties |
| --- |
| Action | Media player: Turn off for 👻 |
| Action name | `media_player.turn_off_for` |
| Action targets | Yes, `media_player` entities |
| Action response | No response |
| Spook's influence | Newly added action |
| Tools | [Try this action](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.turn_off_for) [![Open your Home Assistant instance and show the Actions tool with a specific action selected.](https://my.home-assistant.io/badges/developer_call_service.svg)](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.turn_off_for) |

| Action data parameters |
| --- |
| Attribute | Type | Required | Default / Example |
| `duration` | string | Yes | `00:30:00` |

**Example actions in YAML**

The living room receiver, off for half an hour:

```yaml
action: media_player.turn_off_for
target:
  entity_id: media_player.living_room_receiver
data:
  duration:
    minutes: 30
```

**Known limitations**

- The rules of [Turn off for](https://spook.boo/misc#turn-off-for) apply: only something plainly `on` or `off` is held. Something already off is left alone, and turning it on yourself ends the hold.
- A player that is `playing`, `paused`, `idle` or `standby` is not plainly on or off. It is refused when named, and passed over in an area.
- A player that cannot be turned both on and off is refused when named, and passed over in an area. There would be no way back.

### 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](https://spook.boo/climate#next-and-previous-preset-mode).

**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](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.next_source) or [try previous source](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.previous_source) opens it in your Home Assistant, ready to run once.

**Technical details**

| Action properties |
| --- |
| Action | Media player: Next source 👻 |
| Action name | `media_player.next_source` |
| Action targets | Yes, `media_player` entities that can select a source |
| Action response | No response |
| Spook's influence | Newly added action |
| Tools | [Try this action](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.next_source) [![Open your Home Assistant instance and show the Actions tool with a specific action selected.](https://my.home-assistant.io/badges/developer_call_service.svg)](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.next_source) |

| Action properties |
| --- |
| Action | Media player: Previous source 👻 |
| Action name | `media_player.previous_source` |
| Action targets | Yes, `media_player` entities that can select a source |
| Action response | No response |
| Spook's influence | Newly added action |
| Tools | [Try this action](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.previous_source) [![Open your Home Assistant instance and show the Actions tool with a specific action selected.](https://my.home-assistant.io/badges/developer_call_service.svg)](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.previous_source) |

| Action data parameters |
| --- |
| Attribute | Type | Required | Default / Example |
| `cycle` | boolean | No | `true` |
| `options` | list | No | All of the player's own |

Both work the same way:

- Without **Options**, they step through the player's own list, in the order the player gives it.
- With **Options**, they step through those, in the order you give them, and skip the rest.
- A player at a source that is not in that list, or that does not say, goes to the first one with next, and to the last one with previous.
- With **Cycle** on, the last goes round to the first, and the first back to the last. With **Cycle** off, a player at the end stays there, and is sent nothing.
- A player already where the step would take it, like one with a single source in the list, is sent nothing.
- Spook sets the new source the way `media_player.select_source` does.

**Example actions in YAML**

A button on the living room remote that takes the receiver through three sources, one press at a time, and back to `TV` after `Turntable`:

```yaml
triggers:
  - trigger: state
    entity_id: event.living_room_remote_button_1
    not_from: unavailable
    not_to: unavailable
actions:
  - action: media_player.next_source
    target:
      entity_id: media_player.living_room_receiver
    data:
      options:
        - TV
        - Spotify
        - Turntable
```

One source back, through all of the receiver's own:

```yaml
action: media_player.previous_source
target:
  entity_id: media_player.living_room_receiver
```

**Known limitations**

- A player that cannot select a source cannot be targeted. Named outright, it is refused with an error. Picked up through an area, a device, a floor or a label, it is passed over, and the others are stepped.
- Every option has to be one the player has. One it does not have refuses the whole call with an error that names it, and no player in the call is changed, not even the ones that have it. That check is Spook's: `media_player.select_source` hands any source to the player, listed or not.
- A player with an empty list of sources is sent nothing, also with **Options**.
- An option given twice is refused: at that source, there is no telling which of the two the player is at.
- Source names are the player's own, written exactly as it lists them, upper and lower case included.
- Whether a player that is off takes a source, or turns on for it, is up to the player.

### 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](#next-and-previous-source).

**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](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.next_sound_mode) or [try previous sound mode](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.previous_sound_mode) opens it in your Home Assistant, ready to run once.

**Technical details**

| Action properties |
| --- |
| Action | Media player: Next sound mode 👻 |
| Action name | `media_player.next_sound_mode` |
| Action targets | Yes, `media_player` entities that can select a sound mode |
| Action response | No response |
| Spook's influence | Newly added action |
| Tools | [Try this action](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.next_sound_mode) [![Open your Home Assistant instance and show the Actions tool with a specific action selected.](https://my.home-assistant.io/badges/developer_call_service.svg)](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.next_sound_mode) |

| Action properties |
| --- |
| Action | Media player: Previous sound mode 👻 |
| Action name | `media_player.previous_sound_mode` |
| Action targets | Yes, `media_player` entities that can select a sound mode |
| Action response | No response |
| Spook's influence | Newly added action |
| Tools | [Try this action](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.previous_sound_mode) [![Open your Home Assistant instance and show the Actions tool with a specific action selected.](https://my.home-assistant.io/badges/developer_call_service.svg)](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.previous_sound_mode) |

| Action data parameters |
| --- |
| Attribute | Type | Required | Default / Example |
| `cycle` | boolean | No | `true` |
| `options` | list | No | All of the player's own |

Both work the same way as [Next and previous source](#next-and-previous-source), with sound modes for sources. Spook sets the new sound mode the way `media_player.select_sound_mode` does.

**Example actions in YAML**

A button on the TV remote that goes through three sound modes, one press at a time, and back to `Standard` after `Music`:

```yaml
triggers:
  - trigger: state
    entity_id: event.tv_remote_button_2
    not_from: unavailable
    not_to: unavailable
actions:
  - action: media_player.next_sound_mode
    target:
      entity_id: media_player.living_room_tv
    data:
      options:
        - Standard
        - Movie
        - Music
```

**Known limitations**

- A player that cannot select a sound mode cannot be targeted. Named outright, it is refused with an error. Picked up through an area, a device, a floor or a label, it is passed over, and the others are stepped.
- Every option has to be one the player has. One it does not have refuses the whole call with an error that names it, and no player in the call is changed. That check is Spook's: `media_player.select_sound_mode` hands any sound mode to the player, listed or not.
- A player with an empty list of sound modes is sent nothing, also with **Options**.
- An option given twice is refused: at that sound mode, there is no telling which of the two the player is at.
- Sound mode names are the player's own, written exactly as it lists them, upper and lower case included.

### 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](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.seek_forward) or [try seek backward](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.seek_backward) opens it in your Home Assistant, ready to run once.

**Technical details**

| Action properties |
| --- |
| Action | Media player: Seek forward 👻 |
| Action name | `media_player.seek_forward` |
| Action targets | Yes, `media_player` entities that can seek |
| Action response | No response |
| Spook's influence | Newly added action |
| Tools | [Try this action](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.seek_forward) [![Open your Home Assistant instance and show the Actions tool with a specific action selected.](https://my.home-assistant.io/badges/developer_call_service.svg)](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.seek_forward) |

| Action properties |
| --- |
| Action | Media player: Seek backward 👻 |
| Action name | `media_player.seek_backward` |
| Action targets | Yes, `media_player` entities that can seek |
| Action response | No response |
| Spook's influence | Newly added action |
| Tools | [Try this action](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.seek_backward) [![Open your Home Assistant instance and show the Actions tool with a specific action selected.](https://my.home-assistant.io/badges/developer_call_service.svg)](https://my.home-assistant.io/redirect/developer_call_service/?service=media_player.seek_backward) |

| Action data parameters |
| --- |
| Attribute | Type | Required | Default / Example |
| `seconds` | float | Yes | `30` |

Both work the same way:

- The seconds are required, above zero, and need not be whole ones.
- They start from where the player is now. A player reports its position at a moment, not all the time, so while it plays, Spook adds the time since then, the same way the media control card moves its bar. A player that does not say when that moment was is taken at its word.
- Back stops at the start, and forward stops at the end, when the player knows how long what it plays is. A player already there is sent nothing.
- Spook sends the new position the way `media_player.media_seek` does.

**Example actions in YAML**

Two buttons on a remote: one skips 30 seconds forward, the other 10 seconds back:

```yaml
triggers:
  - trigger: state
    entity_id: event.living_room_remote_button_3
    not_from: unavailable
    not_to: unavailable
    id: forward
  - trigger: state
    entity_id: event.living_room_remote_button_4
    not_from: unavailable
    not_to: unavailable
    id: back
actions:
  - choose:
      - conditions:
          - condition: trigger
            id: forward
        sequence:
          - action: media_player.seek_forward
            target:
              entity_id: media_player.living_room_tv
            data:
              seconds: 30
      - conditions:
          - condition: trigger
            id: back
        sequence:
          - action: media_player.seek_backward
            target:
              entity_id: media_player.living_room_tv
            data:
              seconds: 10
```

**Known limitations**

- A player that cannot seek cannot be targeted. Named outright, it is refused with an error. Picked up through an area, a device, a floor or a label, it is passed over, and the rest still seek.
- Only a player that is playing, paused or buffering is sought. One that is off, idle or just on is left alone, even when it still holds the position of what it played last.
- A player that does not report its position is left alone.
- Without a length, like a live stream, forward has no end to stop at: the player decides how far it goes.
- The position is only as good as what the player reports. One that reports late, or not at all while it plays, lands where its own idea of the position says.


## Sitemap

See the full [sitemap](https://spook.boo/sitemap.md) for all pages.
