Populating media player source automatically in dropdown? #68
Closed
iamthekings5
started this conversation in
General
Replies: 1 comment 2 replies
-
You can't dynamically add and remove options, but you can dynamically set the option type: dropdown
entity_id: media_player.lounge_google_tv_adb
options:
- entity_id: media_player.lounge_google_tv_adb
option: >-
{% set i = 0 %}{% set sources = state_attr(config.entity, "source_list")
%}{% if i < (sources | length) %}{{ sources[i] }}{% endif %}
tap_action:
action: perform-action
perform_action: media_player.select_source
target:
entity_id:
- media_player.lounge_google_tv_adb
data:
source: '{{ render(config.option) }}'
styles: |-
{% set i = 0 %}
{% set sources = state_attr(config.entity, "source_list") %}
{% if i >= (sources | length ) %}
:host {
display: none;
}
{% endif %}
value_attribute: source |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
For some reason I've decided I wanted to make a functional media player in a tile card. Everything is going according to plan, but my SpotifyPlus media player has dynamically changing list of sources I can stream to, like this:
source_list:
Is it possible for me to dynamically populate a drop down with this list that I can use to select sources? What would be the best way to approach this problem?
Beta Was this translation helpful? Give feedback.
All reactions