Today I started to add a the media_player universal entity to my setup. One thing I can’t get to work is the current source displayed in the overview. I’ve setup a source_list based on an input_select and the current source based on the selected value (state) from the input_select.
I thought the overview (shown on picture below) would show the current selected source from the source_list but it’s actually showing the current selected source from the children.
the select_source section calls the action to change the input_select. The attribute section looks at the input select and updates based on it’s state.
Thanks a lot for your reply and checking out the other thread I started. This is indeed the solution where I was looking for. The only thing I changed was I moved the select_source code to a script because select_source only accept 1 service.
Hmm, that’s a limitation of that component. That should be changed. Template switches can have more than 1 service, no reason the universal media player shouldn’t either.
I don’t know much about homekit. Sorry. I would assume yes because you’re creating a new media_player and ignoring the one crated by your tv integration.
and a input_select called beamer_source_list with the following options PS4, CCBeamer & RGB. But when I restart Home Assistant i get the following error “Error loading /config/configuration.yaml: invalid key: “OrderedDict([(‘source’, None)])” in “/config/mediaplayers.yaml”, line 19, column 0” whch points to an error for the option: {{ source }}
I’m now getting an error on the select_source attribute of the universal media_player integration. It expect a dictionary and to me, it looks like it gets a dictionary
invalid config for [media_player.universal]: expected a dictionary for dictionary value @ data[‘commands’][‘select_source’]. Got [OrderedDict([(‘service’, ‘input_select.select_option’), (‘data_template’, OrderedDict([(‘entity_id’, ‘input_select.beamer_source_list’), (‘option’, ‘{{ source }}’)]))]), OrderedDict([(‘service’, ‘media_player.select_source’), (‘data_template’, OrderedDict([(‘entity_id’, ‘media_player.optoma_beamer’), (‘source’, “{% mapper = {\n ‘PS4’:‘DIGITAL 1’,\n ‘CCBeamer’:‘DIGITAL 2’,\n ‘RGB’:‘RGB 1’} %}\n{{ mapper[source] if source in mapper else ‘DIGITAL 1’ }}\n”)]))])]. (See ?, line ?).
will post the complete code if I got it working for others
create a universal media_player as a proxy for the original media_player, map the commands you want to proxy. And add the configuration for select source. Which needs to be a script, since you need to call 2 services and supply the selected source as a variable.
for example (left out all other commands for brevity)
- platform: universal
name: Beamer
children:
- media_player.optoma_beamer #the original mediaplayer
commands:
select_source:
service: script.change_source # the script we create in step 4
data_template:
source: "{{ source }}" # supply the source as a variable
attributes:
source: input_select.beamer_source_list #get the source from the input_select created in step 2
source_list: input_select.beamer_source_list|options #get the possible sources from the input_select created in step 2
create a script to change the selected source on the input_select and select the new source on the mediaplayer
for example:
change_source:
sequence:
- service: input_select.select_option
data_template:
entity_id: input_select.beamer_source_list #the input_select created in step 2
option: >
{{ source }}
- service: media_player.select_source
data_template:
entity_id: media_player.optoma_beamer #the original media_player
source: >
{% set mapper = { #this is a variabe to map the aliases to the original sources of the original mediaplayer
'PS4':'DIGITAL 1',
'CCBeamer':'DIGITAL 2',
'RGB':'RGB 1'} %}
{{ mapper[source] if source in mapper else 'DIGITAL 1' }}
add a new media control card (or other) to see the proxy mediaplayer with the aliases for the services
Many thanks to @petro for figuring this out and explaining it to me
can’t help without a full configuration. If that’s your full configuration, you’re spacing is way off and you’re missing the platform. You’d also need to separate the select source service into a script and also select the correct input from the input_select.
This has been immensely helpful, thank you everyone. I’ve got this working except there’s one odd thing: the original source name (not my alias via the mapper) still shows up in the media control popup and in Lovelace cards (see the “CD” in the upper right, which I’ve aliased to “House Audio” in the dropdown via the method described in this thread):
And in the Lovelace view (as you can see, the drop down shows the correct “aliased” names, but the gray text under the entity name is still showing the original source name):
It’s not a dealbreaker, it’s just not a great user experience.
I thought maybe this was the “media title” attribute, but overriding that in the universal player had no effect. Here’s my current universal player configuration (the relevant bits, anyway):
This thread is super helpful! To rogersmj, looks like your last line doesn’t match anything else above. The earlier example implies that you should change the last line to
{{ mapper[source] if source in mapper else 'MEDIA PLAYER' }}