Hi,
i try to find a possibility to show a list of buttons in my dashboard. The list will be dynamic - the result of a search.
Target:
I want to provide my kids a list of spotify albums (based on a search) in the dashboard.
It should be possible to select one of the albums to play the album on a speaker.
Pieces of the puzzle
- With SpotifyPlus it is possible to search for albums.
action: spotifyplus.search_albums
data:
entity_id: media_player.spotifyplus_configuration
criteria: beatles
limit_total: 3
The result is a list of albums:
In the list the images, IDs, URLs, Names … are in a list of items.
user_profile:
country: <country code>
display_name: <name>
email: <mail>
id: <id>
product: premium
type: user
uri: spotify:user:<id>
result:
date_last_refreshed: <timestamp>
href: null
limit: 3
next: null
offset: 0
previous: null
total: 902
items:
- album_type: album
artists:
- external_urls:
spotify: https://open.spotify.com/artist/<id>
href: https://api.spotify.com/v1/artists/<id>
id: <albumID>
name: The Beatles
type: artist
uri: spotify:artist:<id>
available_markets:
- AR
- DE
- EC
external_urls:
spotify: https://open.spotify.com/album/<id>
href: https://api.spotify.com/v1/albums/<id>
id: <id>
image_url: https://i.scdn.co/image/<id>
images:
- url: https://i.scdn.co/image/<id>
height: 640
width: 640
- url: https://i.scdn.co/image/<id>
height: 300
width: 300
- url: https://i.scdn.co/image/<id>
height: 64
width: 64
name: The Beatles (Remastered)
release_date: "1968-11-22"
release_date_precision: day
restrictions: {}
total_tracks: 30
type: album
uri: spotify:album:<id>
- album_type: album
artists:
- external_urls:
spotify: https://open.spotify.com/artist/<id>
href: https://api.spotify.com/v1/artists/<id>
id: <albumID>
name: The Beatles
type: artist
uri: spotify:artist:<id>
available_markets:
- AR
- DE
- UK
external_urls:
spotify: https://open.spotify.com/album/<id>
href: https://api.spotify.com/v1/albums/<id>
id: <id>
image_url: https://i.scdn.co/image/<id>
images:
- url: https://i.scdn.co/image/<id>
height: 640
width: 640
- url: https://i.scdn.co/image/<id>
height: 300
width: 300
- url: https://i.scdn.co/image/<id>
height: 64
width: 64
name: The Beatles
release_date: "1969-09-26"
release_date_precision: day
restrictions: {}
total_tracks: 30
type: album
uri: spotify:album:<id>
<cut>
- There is also a possibility to play a album by the href with SpotifyPlus.
service: media_player.play_media
data:
entity_id: media_player.spotifyplus_john_s
media_content_type: album
media_content_id: spotify:album:0LhYYU14RU6IPQ9vVMu3Yk
- There is a custom:auto-entities and custom:layout-card HACS Integrations which is used in this post to list radio stations based on a (dynamic) file list in a sensor.
Problem:
I did not find a possibility to load the search result of the action spotifyplus.search_albums
into the list {%- for item in <add search result here> -%}
of the post.
type: custom:auto-entities
card:
type: custom:layout-card
layout_type: custom:grid-layout
layout:
grid-template-columns: auto auto auto auto auto auto
grid-template-rows: auto
filter:
template: >
{%- set ns = namespace(results = []) -%}
{%- for item in <add search result here> -%}
<rework data>
{%- set
ns.results = ns.results + [
{
"image": image,
"alt_text": name,
"type": "picture",
"tap_action": {
"action": "perform-action",
"perform_action": "<play>",
"data": {
"media_id": name
}
},
"styles": {
"card": {
"margin": "1px",
"padding": "1px"
}
}
}
]-%}
{% endfor %}
{{ ns.results }}
All of my researches are not successfull. I did not bring the pieces together .
Question:
How can i provide the search result as list into the dynamic button creation?
Are there any other possibilities?
Thanks four your help.
busdi