Sonos - updates to play media content ids (#32717)

* Update sonos.markdown

* Tiny tweak to fix the CI

---------

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
This commit is contained in:
Pete Sage 2024-05-13 09:05:18 -04:00 committed by GitHub
parent 3f2117c9b5
commit d4a98012a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -71,7 +71,7 @@ The favorites sensor provides the names and `media_content_id` values for each o
When calling the `media_player.play_media` service, the `media_content_type` must be set to "favorite_item_id" and the `media_content_id` must be set to just the key portion of the favorite item. When calling the `media_player.play_media` service, the `media_content_type` must be set to "favorite_item_id" and the `media_content_id` must be set to just the key portion of the favorite item.
Example service call: Example service call using the item id:
```yaml ```yaml
service: media_player.play_media service: media_player.play_media
@ -82,6 +82,17 @@ data:
media_content_id: "FV:2/31" media_content_id: "FV:2/31"
``` ```
Example using the Sonos playlist name:
```yaml
service: media_player.play_media
target:
entity_id: media_player.sonos_speaker1
data:
media_content_type: playlist
media_content_id: stevie_wonder
```
Example templates: Example templates:
{% raw %} {% raw %}
@ -119,7 +130,7 @@ Music services which require an account (e.g., Spotify) must first be configured
Playing TTS (text-to-speech) or audio files as alerts (e.g., a doorbell or alarm) is possible by setting the `announce` argument to `true`. Using `announce` will play the provided media URL as an overlay, gently lowering the current music volume and automatically restoring to the original level when finished. An optional `volume` argument can also be provided in the `extra` dictionary to play the alert at a specific volume level. Note that older Sonos hardware or legacy firmware versions ("S1") may not fully support these features. Additionally, see [Network Requirements](#network-requirements) for use in restricted networking environments. Playing TTS (text-to-speech) or audio files as alerts (e.g., a doorbell or alarm) is possible by setting the `announce` argument to `true`. Using `announce` will play the provided media URL as an overlay, gently lowering the current music volume and automatically restoring to the original level when finished. An optional `volume` argument can also be provided in the `extra` dictionary to play the alert at a specific volume level. Note that older Sonos hardware or legacy firmware versions ("S1") may not fully support these features. Additionally, see [Network Requirements](#network-requirements) for use in restricted networking environments.
An optional `enqueue` argument can be added to the service call. If `true`, the media will be appended to the end of the playback queue. If not provided or `false` then the queue will be replaced. An optional `enqueue` argument can be added to the service call. If `replace` or not provided then the queue will be replaced and the item will be replaced. If `add` the item will be appended to the queue. If `next` the item will be added into the queue to play next. If `play`, the item will be added into the queue and played immediately.
### Examples: ### Examples:
@ -186,6 +197,57 @@ data:
plex://{ "library_name": "Music", "artist_name": "M83", "album_name": "Hurry Up, We're Dreaming" } plex://{ "library_name": "Music", "artist_name": "M83", "album_name": "Hurry Up, We're Dreaming" }
``` ```
#### Sonos Music Library
If you have configured a Sonos music library; you can play music from it.
Play all albums by the Beatles.
```yaml
service: media_player.play_media
target:
entity_id: media_player.sonos
data:
media_content_type: album
media_content_id: A:ALBUMARTIST/Beatles
```
Play a specific album:
```yaml
service: media_player.play_media
target:
entity_id: media_player.sonos
data:
media_content_type: album
media_content_id: A:ALBUM/The Wall
enqueue: replace
```
Or add a specific album by a specific artist to the queue. This is useful in case you have multiple albums with the same name.
```yaml
service: media_player.play_media
target:
entity_id: media_player.sonos
data:
media_content_type: album
media_content_id: A:ALBUMARTIST/Neil Young/Greatest Hits
enqueue: add
```
Play all albums by a composer.
```yaml
service: media_player.play_media
target:
entity_id: media_player.porch
data:
media_content_type: composer
media_content_id: A:COMPOSER/Carlos Santana
enqueue: play
```
## Services ## Services
The Sonos integration makes various custom services available in addition to the [standard media player services](/integrations/media_player/#services). The Sonos integration makes various custom services available in addition to the [standard media player services](/integrations/media_player/#services).
@ -346,4 +408,4 @@ The Sonos speakers will attempt to connect back to Home Assistant to deliver cha
sonos: sonos:
media_player: media_player:
advertise_addr: 192.0.2.1 advertise_addr: 192.0.2.1
``` ```