mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-12 03:46:49 +00:00
Add get_queue action for Sonos (#34459)
* initial commit * add raw * add trailing pipe * tiny tweak --------- Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
This commit is contained in:
parent
54d292841d
commit
5ce443e82c
@ -342,6 +342,47 @@ Force start playing the queue, allows switching from another stream (such as rad
|
|||||||
| `entity_id` | yes | String or list of `entity_id`s that will start playing. It must be the coordinator if targeting a group.
|
| `entity_id` | yes | String or list of `entity_id`s that will start playing. It must be the coordinator if targeting a group.
|
||||||
| `queue_position` | yes | Position of the song in the queue to start playing from, starts at 0.
|
| `queue_position` | yes | Position of the song in the queue to start playing from, starts at 0.
|
||||||
|
|
||||||
|
### Action `sonos.get_queue`
|
||||||
|
|
||||||
|
Returns the media_players queue.
|
||||||
|
|
||||||
|
| Data attribute | Optional | Description |
|
||||||
|
| ---------------------- | -------- | ----------- |
|
||||||
|
| `entity_id` | no | media_player entity id. |
|
||||||
|
|
||||||
|
This example script does the following: get the queue, loop through in reverse order, and remove media containing the words "holiday".
|
||||||
|
|
||||||
|
{% raw %}
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- action: sonos.get_queue
|
||||||
|
target:
|
||||||
|
entity_id: media_player.living_room
|
||||||
|
response_variable: queue
|
||||||
|
- variables:
|
||||||
|
queue_len: '{{ queue["media_player.living_room"] | length }}'
|
||||||
|
- repeat:
|
||||||
|
sequence:
|
||||||
|
- variables:
|
||||||
|
title: '{{ queue["media_player.living_room"][queue_len - repeat.index]["media_title"].lower() }}'
|
||||||
|
album: '{{ queue["media_player.living_room"][queue_len - repeat.index]["media_album_name"].lower() }}'
|
||||||
|
position: '{{ queue_len - repeat.index }}'
|
||||||
|
- if:
|
||||||
|
- '{{ "holiday" in title or "holiday" in album }}'
|
||||||
|
then:
|
||||||
|
- action: sonos.remove_from_queue
|
||||||
|
target:
|
||||||
|
entity_id: media_player.living_room
|
||||||
|
data:
|
||||||
|
queue_position: '{{position}}'
|
||||||
|
until:
|
||||||
|
- condition: template
|
||||||
|
value_template: '{{queue_len == repeat.index}}'
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
{% endraw %}
|
||||||
|
|
||||||
### Action `sonos.remove_from_queue`
|
### Action `sonos.remove_from_queue`
|
||||||
|
|
||||||
Removes an item from the queue.
|
Removes an item from the queue.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user