Harmony HUB 'emulation' on Home Assistant to provide a Homekit TV Accessory

Hi all,

I am trying to configure a media player entity with the media player template integration.

The goal is to end up with a “dummy” media player entity with an on/off button and selectable sources.
(Apple tv, Playstation 5, Playstation 3, Switch and Record Player)

That way I can add this new media player entity to Homekit as a TV accessory.
The handling of what happens when selecting an input would be handled with automations and scripts. That’s the easy part.

I can’t seem to get this new media player entity set up the way I want it.
I can create the entity, but I can’t seem to make the sources selectable.

Configuration in configuration.yaml:

# This will create a media player entity for the Harmony Hub TV Accessory in Homekit
      harmony_emulator:
        friendly_name: Harmony Emulator
        device_class: tv
        current_source_template: "{{ states('input_select.select_option') }}"
        value_template: >
          {% if is_state("input_select.select_option", "Apple tv", "Playstation 5", "Playstation 3", "Switch", "Record Player") -%}
            on
          {%- else -%}
            off
          {%- endif %}
        turn_on:
          service: input_select.select_option
          data:
            option: Apple tv
          target:
            entity_id: input_select.harmony_emulator
        turn_off:
          service: input_select.select_option
          data:
            option: Power Off
          target:
            entity_id: input_select.harmony_emulator
        inputs:
          Apple TV:
            service: input_select.select_option
            data:
              option: Apple tv
            target:
              entity_id: input_select.harmony_emulator
          Playstation 5:
            service: input_select.select_option
            data:
              option: Playstation 5
            target:
              entity_id: input_select.harmony_emulator
          Playstation 3:
            service: input_select.select_option
            data:
              option: Playstation 3
            target:
              entity_id: input_select.harmony_emulator
          Switch:
            service: input_select.select_option
            data:
              option: Switch
            target:
              entity_id: input_select.harmony_emulator
          Record Player:
            service: input_select.select_option
            data:
              option: Record Player
            target:
              entity_id: input_select.harmony_emulator

This is what I get the entity to look like in developer tools:

source_list:
  - source 1
  - source 2
  - source 3
  - source 4
  - source 5
source: Apple tv
entity_picture_local: null
device_class: tv
friendly_name: Harmony Emulator
supported_features: 67968

When trying to select an input source on the newly created entity. It won’t let me.
It just shows ‘off’ and nothing is selectable. Also the power button won’t do a thing.

I think in theory, it does not even need the service call to the input.select helper. Since this would just mirror the behaviour of the media.player entity.

1 Like

Found a good starting point here:

Hi there, I’m not familiar with the Template Media Player integration, I assume you’re referring to a custom component?

I can see a problem with your value_template. You need to include the list of states in square brackets.

I’m also not sure if you have the correct input_select entity, as further along you have referenced input_select.harmony_emulator.

If this is the entity you want to get the state from, your value_template should be:

        value_template: >
          {% if is_state("input_select.harmony_emulator", ["Apple tv", "Playstation 5", "Playstation 3", "Switch", "Record Player"]) -%}
            on
          {%- else -%}
            off
          {%- endif %}

You will also need to correct the input_select in the current_source_template.

When writing templates, you should copy them into the Deveolper Tools > Template tool to ensure they render correctly and behave as expected.