Dear community:
I’m having some issues with the universal media play defined below. The player delegate commands to 3 child players depending on the selected source, while everything else works great the select_source command doesn’t work. No matter which child is active, I can see the correct input source and get a list of sources to choose from, however when I click on a new source the script “harmony_power_control” isn’t called.
- platform: universal
name: Living Room Media Hub
unique_id: livingroom_mediahub
device_class: receiver
state_template: >
{% set act = state_attr('remote.livingroom_mediahub', 'current_activity') %}
{% if act in ['IP Radio', 'FM Radio'] %}
{{ states('media_player.livingroom_radio') | default('playing')}}
{% elif act == 'Music' %}
{{ states('media_player.ma_livingroom_musicstreamer_dlna') | default('idle') }}
{% elif act == 'Movie' %}
{{ states('media_player.livingroom_zidooplayer') | default('idle') }}
{% else %}
{{ states('remote.livingroom_mediahub')}}
{% endif %}
attributes:
source_list: remote.livingroom_mediahub|activity_list
source: remote.livingroom_mediahub|current_activity
is_volume_muted: input_boolean.livingroom_mediahub_mute
volume_level: number.livingroom_mediahub_volume
children:
- media_player.ma_livingroom_musicstreamer_dlna
- media_player.livingroom_zidooplayer
- media_player.livingroom_radio
active_child_template: >
{% set a = state_attr('remote.livingroom_mediahub', 'current_activity') %}
{% set children = {
'Music': 'media_player.ma_livingroom_musicstreamer_dlna',
'Movie': 'media_player.livingroom_zidooplayer',
'IP Radio': 'media_player.livingroom_radio',
'FM Radio': 'media_player.livingroom_radio'
} %}
{% set target = children.get(a) %}
{# Only return the entity if it is actually 'online' (not unavailable/unknown) #}
{% if target and states(target) not in ['unavailable', 'unknown'] %}
{{ target }}
{% else %}
{# Fallback to a 'safe' state or nothing #}
none
{% endif %}
commands:
turn_on:
action: script.turn_on
target:
entity_id: script.harmony_power_control
data:
variables:
power: true
turn_off:
action: script.turn_on
target:
entity_id: script.harmony_power_control
data:
variables:
power: false
volume_set:
action: number.set_value
target:
entity_id: number.livingroom_mediahub_volume
data:
value: "{{ volume_level }}"
volume_up:
action: number.set_value
target:
entity_id: number.livingroom_mediahub_volume
data:
value: >
{% set current = states('number.livingroom_mediahub_volume') | float(0) %}
{{ [current + 0.02, 1.0] | min }}
volume_down:
action: number.set_value
target:
entity_id: number.livingroom_mediahub_volume
data:
value: >
{% set current = states('number.livingroom_mediahub_volume') | float(0) %}
{{ [current - 0.02, 0.0] | max }}
volume_mute:
action: script.harmony_toggle_mute
select_source:
action: script.turn_on
target:
entity_id: script.harmony_power_control
data:
variables:
power: true
activity: "{{ source }}"
The 3 child players:
- media_player.ma_livingroom_musicstreamer_dlna: from music assistant integration with supported_features: 7796671
- media_player.livingroom_zidooplayer: from zidoo integration and the supported_features: 221115
- media_player.livingroom_radio is defined as below with supported_features 16433:
- platform: universal
name: "Living Room Radio"
unique_id: livingroom_radio
state_template: >
{% set act = state_attr('remote.livingroom_mediahub', 'current_activity') %}
{% if act in ['IP Radio', 'FM Radio'] %}
{{ 'paused' if is_state('input_boolean.livingroom_mediahub_mute', 'on') else 'playing' }}
{% else %}
off
{% endif %}
commands:
media_next_track:
action: remote.send_command
target: { entity_id: remote.livingroom_mediahub }
data:
device: "AV Receiver"
command: >
{% set act = state_attr('remote.livingroom_mediahub', 'current_activity') %}
{{ 'Net/UsbRight' if act == 'IP Radio' else 'NextPreset' }}
media_previous_track:
action: remote.send_command
target: { entity_id: remote.livingroom_mediahub }
data:
device: "AV Receiver"
command: >
{% set act = state_attr('remote.livingroom_mediahub', 'current_activity') %}
{{ 'Net/UsbLeft' if act == 'IP Radio' else 'PrevPreset' }}
media_play:
action: script.harmony_toggle_mute
media_pause:
action: script.harmony_toggle_mute
media_play_pause:
action: script.harmony_toggle_mute
What I don’t understand is the select_source command is defined in parent universal player, and my understanding is that if the child player doesn’t support it it falls back to parent - and in fact no matter which child player is playing I can see the correct source and source list.
Any suggestion is appreciated!