Homekit new options TV Source

Why do you have that limit?

yes, the ha TV is added automatically in the remote app, no steps were required for that

Strange I don’t have it in the remote app

The HomeKit component only allows 100 entities per instance. To get 100 more a more I would need a 2nd server to run a differently named bridge. I’m sure this is a limit placed by apple for 3rd party support.

1 Like

Ok, im using a harmony hub to control my TV. And I got this so far to show>

I had one of the inputs working but, after messing around to try to get them all to work I brok it and can’t figure out how to get it back. Unfortunately I couldn’t get the volume to show up in the remote app or as a media player in the remote app.
Here’s my universal media player config and what I did to get this to at least show. If anybody is interested in trying a few different configs.

media_player:

  - platform: universal
    name: remote
    children:
      - media_player.remote
    commands:
      turn_on:
        service: switch.turn_on
        data:
          entity_id: switch.vizio
      turn_off:
        service: switch.turn_off
        data:
          entity_id: switch.vizio
      volume_up:
        service: remote.send_command
        entity_id: remote.living_room
        data:
          device: '56316526'
          command: VolumeUp
      volume_down:
        service: remote.send_command
        entity_id: remote.living_room
        data:
          device: '56316526'
          command: VolumeDown
      volume_mute:
        service: switch.turn_on
        data:
          entity_id: switch.mute
      select_source:
       
        service: homeassistant.turn_on
        data_template:
          entity_id: >
            {% if is_state('input_select.tv_input', 'PS4') %} # HDMI1
            script.vizio_hdmi1
            {% elif is_state('input_select.tv_input', 'Dish') %} # HDMI2
            script.vizio_hdmi2
            {% elif is_state('input_select.tv_input', 'Apple TV') %} # HDMI3
            script.vizio_hdmi3
            {% elif is_state('input_select.tv_input', 'PS3') %} # HDMI4
            script.vizio_hdmi4
            {% endif %}

customize.yaml

media_player.remote:
  device_class: tv
  source_list: [PS4,Dish,Apple TV,PS3]

input_select.yaml

  tv_input:
    options:
      - Select Input
      - PS4
      - Dish
      - Apple TV
      - PS3
    initial: Select Input

automation.yaml

- id: tv_input
  alias: Tv input
  initial_state: 'on'
  hide_entity: true
  trigger:
    platform: state
    entity_id: input_select.tv_input
  action:
    - service: homeassistant.turn_on
      data_template:
        entity_id: >
         {% if is_state('input_select.tv_input', 'PS4') %}
         script.vizio_hdmi1
         {% elif is_state('input_select.tv_input', 'Dish') %}
         script.vizio_hdmi2
         {% elif is_state('input_select.tv_input', 'Apple TV') %}
         script.vizio_hdmi3
         {% elif is_state('input_select.tv_input', 'PS3') %}
         script.vizio_hdmi4
         {% endif %}

Please let me know if anybody makes any progress or has a suggestion on what else I could try.

Thanks and good luck!

I was able to get my three TVs showing up in HomeKit with selectable sources. I based the media players around the Harmony remote. This took me a while so I wanted to share my working config. It seemed to be very picky about quotes and types.

media_players.yaml:

- platform: universal
  name: Media Room TV
  commands:
    turn_on:
      service: remote.turn_on
      entity_id: remote.media_room_harmony
      data:
        activity: Watch Computer
    turn_off:
      service: remote.turn_off
      entity_id: remote.media_room_harmony
    select_source:
      service: remote.turn_on
      data_template:
        entity_id: remote.media_room_harmony
        activity: >-
          {% if source == 'Computer' %}
            Watch Computer
          {% elif source == 'Apple TV' %}
            Watch Apple TV
          {% elif source == 'Blu-ray' %}
            Watch Blu-ray
          {% elif source == 'Playstation' %}
            Play PS4
          {% elif source == 'Xbox' %}
            Play Xbox One X
          {% elif source == 'Nintendo Switch' %}
            Play Nintendo Switch
          {% else %}
            Watch Computer
          {% endif %}
  attributes:
    state: remote.media_room_harmony
    source: input_select.media_room_tv

input_selects.yaml:

media_room_tv:
  name: Media Room TV Input
  options:
    - Computer
    - Apple TV
    - Blu-ray
    - Playstation
    - Xbox
    - Nintendo Switch
    - Power Off

automations.yaml:

- id: '1356121322963'
  alias: Update Media Room Input Select
  trigger:
    platform: state
    entity_id: remote.media_room_harmony
  condition: []
  action:
  - service: input_select.select_option
    data_template:
      entity_id: input_select.media_room_tv
      option: >-
        {% if trigger.to_state.attributes.current_activity ==  'Watch Computer' %}
          Computer
        {% elif trigger.to_state.attributes.current_activity ==  'Watch Apple TV' %}
          Apple TV
        {% elif trigger.to_state.attributes.current_activity ==  'Watch Blu-ray' %}
          Blu-ray
        {% elif trigger.to_state.attributes.current_activity == 'Play PS4' %}
          Playstation
        {% elif trigger.to_state.attributes.current_activity == 'Play Xbox One X' %}
          Xbox
        {% elif trigger.to_state.attributes.current_activity == 'Play Nintendo Switch' %}
          Nintendo Switch
        {% else %}
          Power Off
        {% endif %}

customize.yaml:

media_player.media_room_tv:
  friendly_name: Media Room TV
  source_list: [Computer,Apple TV,Blu-ray,Playstation,Xbox,Nintendo Switch]
  device_class: tv

I could never get it working properly when using the input_select to define the source_list. The sources only started reliably showing up when I added them explicitly to cutomize.yaml as above. I still use the input_select to store the current source via automation.

Have not yet tried volume up/down but that should be straightforward to add via harmony as well.

6 Likes

For the record, I do see these messages in the log sometimes:

2019-05-29 12:51:34 WARNING (SyncWorker_0) [homeassistant.components.homekit.type_media_players] media_player.living_room_tv: Sources out of sync. Restart HomeAssistant

But they appear to be harmless and do not affect the functionality. Not sure why they are being triggered though. I was seeing them when using the input_select for the source_list as well.

Right, I’m having issues with this as well. rPi 3, Hassio, 0.94.x
I too am getting the following errors:

2019-05-29 12:51:34 WARNING (SyncWorker_0) [homeassistant.components.homekit.type_media_players] media_player.living_room_tv: Sources out of sync. Restart HomeAssistant

…but they do not seem completely harmless. After initially working correctly, with all sources appearing as expected in the Home app, after a while (usually if I’ve left home and come back again) the sources get all mucked up. In each media player in Home the sources do not appear correctly and instead start appearing as separate Homekit entities (with little house icons, and no selectable options). This is when I usually notice the error message appearing, although I need to test further to confirm they are linked. Restarted Home Assistant seems to fix it temporarily but after a while it mucks up again.

I’m using a Broadlink RM3 for my IR control with script selection:

configuration.yaml:

media_player:
  - platform: universal
    name: AV Receiver
    children:
      - media_player.living_room_tv
    commands:
      turn_on:
        service: script.av_receiver_switch_on
      turn_off:
        service: script.av_receiver_switch_off
      volume_up:
        service: script.av_receiver_volume_up
      volume_down:
        service: script.av_receiver_volume_down
      select_source:
        service: script.turn_on
        data_template:
          entity_id: >
            {% if source ==  'PC' %}
              script.av_receiver_PC
            {% elif source ==  'Cast' %}
              script.av_receiver_cast
            {% elif source ==  'XBOX 360' %}
              script.av_receiver_xbox_360
            {% elif source ==  'Audio' %}
              script.av_receiver_audio
            {% elif source ==  'USB' %}
              script.av_receiver_usb
            {% elif source ==  'TV' %}
              script.av_receiver_tv
            {% else %}
            {% endif %}
    attributes:
      state: binary_sensor.av_receiver
      source: input_select.av_receiver
      source_list: input_select.av_receiver|options
  - platform: universal
    name: TV
    children:
      - media_player.living_room_tv
    commands:
      turn_on:
        service: script.tv_switch_on
      turn_off:
        service: script.tv_switch_off
      select_source:
        service: script.turn_on
        data_template:
          entity_id: >
            {% if source ==  'TV' %}
              script.tv_input_tv
            {% elif source ==  'HDMI' %}
              script.tv_input_hdmi
            {% else %}
            {% endif %}
    attributes:
      state: binary_sensor.tv
      source: input_select.tv
      source_list: input_select.tv|options
input_select:
  av_receiver:
    name: Source
    icon: mdi:login
    options:
      - 'PC'
      - 'Cast'
      - 'XBOX 360'
      - 'Audio'
      - 'USB'
      - 'TV'
  tv:
    name: Source
    icon: mdi:login
    options:
      - 'TV'
      - 'HDMI'

customize.yaml:

media_player.av_receiver:
  icon: mdi:audio-video
  device_class: tv
  source_list: [PC,Cast,XBOX 360,Audio,USB,TV]
media_player.tv:
  icon: mdi:television
  device_class: tv
  source_list: [TV,HDMI]

Rather than using an automation to update input_select I am integrating the update process into each source’s script:

scripts.yaml:

'av_receiver_xbox_360':
  alias: AV Receiver XBOX 360
  sequence:
    - service: broadlink.send
      data:
        host: 192.168.1.193
        packet: 'JgBmAFATFRIWESkTKRIpEigTKRIVEhUTFBMWEigTKBMVEhYAAplQEhYSFRIoEykSKRMoEygTFBMVExQTFRIpEygTFBMVAAKaTxMVExQTKBMoEygTKRIpExQTFRIVExQTKBMoExUTFAANBQAA'
    - service: input_select.select_option
      data:
        entity_id: input_select.av_receiver
        option: 'XBOX 360'

Any ideas where I might be going wrong?

Try removing source_list from the attributes of your media player. You are defining the source_list explicitly in your customize.yaml so you don’t need it there. I had similar problems when that was linked to the input_select. Things have been stable with the config I posted.

You could also try removing the children from your media players, unless there is a specific reason why you’re defining them. For the purposes of HomeKit I’m not sure they really affect anything since you’re overriding all the available methods anyway.

Also, for the record, I have an automation that starts up HomeKit 5 minutes after HA starts. That makes sure all the other components and entities are loaded. Just something else you could try…

1 Like

Thanks! Had to delete and re-add my media players to homekit to get it working but so far so good, have tried a few restarts and connecting/disconnecting to wifi and seems much more stable!

So, I think I know the answer, but I think I’m trying to do this backwards.

I dont use Homekit to control devices, I do use a homekit controller in HA to control a couple things, such as local control for my ecobee thermostats. I saw that my vizio tv’s are now homekit compatible. I’ve been able to add them to the Homekit controller in HA. But they have no entity’s. I believe that’s just because The homekit controller does not have a device class for TV? I really just want to be able to know if my tv is on or off, so that I can do other automatons in HA based on that.

I do have an apple TV and I can add the TV to my “real” homekit, but it just seems like an extra layer. Any suggestions?

I would just skip the HomeKit controller for your Vizio TV. Looks like there is a Vizio HA component, if you use that instead then you should get a media_player entity from which you can base automations, or use the media_player to create other virtual entities (e.g. input_boolean for simple on/off).

Ha, Actually I do use the vizio component already and it works pretty good. The setup is a little more complex than other setups, so for some users it’s a bit too much. Whereas the homekit setup is very simple. Also, for me at least after a few days of being “off” my logs get flooded with messages about being unable to contact the vizio service. When the firmware on my TVs autoupdate, they often break in HA until the next HA update of the vizio component. Sometimes I have to go through the vizio pairing setup again.

Was hoping to try out the homekit controller option to see if it was more stable. It seems to be rock solid with with my ecobee’s. I’m not looking for much of a remote control setup, but… if I was it would be nice to be able to do some basic contols without having to set up extra input booleans, selects, etc.

I use the Vizio component as well. It does work pretty well. I haven’t had any issues with needing to re-pair with updates to firmware or HA.

What I find lacking is the the “Source” listing in the vizio component doesn’t pull the source names from the TV. You only get HDMI-1, CAST, etc. ,not the names that are set in the TV - Xfininty, Fire TV, etc
I did look at the “homekit_controller-entity-map” file in .storage and it pulls the source names from the TV, so I am hoping that maybe if we get a Homekit controller for TV’s, it would be easily updated as sources are added to my TV’s

So I set up my tv on Homekit, I turned on the TV with the TV remote and turned it off with the TV remote. Homekit did not know the TV was turned on or off, so it did not turn on/off the input boolean I set up in homekit automation. am I missing something. If I turn on/off the TV with the standard IR remote of the TV does it not tell homekit that it is off/on?

Cory, this looks perfect! Would you be willing to share your scripts and switches? This looks like how I’d like to set up mine, but I’m struggling in some areas and think that seeing how you set up your scripts and switches might show me what I’m doing wrong.

Thanks!

Sure!

Do you use a harmony hub?

script.yaml #Example of a channel script

nbc:
  alias: NBC
  sequence:
  - service: remote.send_command
    entity_id: remote.living_room
    data:
      device: '56583809'
      command: '0'
  - service: remote.send_command
    entity_id: remote.living_room
    data:
      device: '56583809'
      command: '2'
  - service: remote.send_command
    entity_id: remote.living_room
    data:
      device: '56583809'
      command: '1'
  - service: remote.send_command
    entity_id: remote.living_room
    data:
      device: '56583809'
      command: Select
  - service: script.turn_off
    entity_id: script.nbc

Example of a tv on/off script


vizio_on:
  alias: Turn on TVs
  sequence:
  - service: remote.send_command
    entity_id: remote.living_room
    data:
      device: '56316526'
      command: PowerOn
  - service: remote.send_command
    entity_id: remote.living_room
    data:
      device: '56583809'
      command: Select


vizio_off:
  alias: Turn off Tv
  sequence:
  - service: remote.send_command
    entity_id: remote.living_room
    data:
      device: '56316526'
      command: PowerOff
- id: vizio_on
  alias: Vizio On
  trigger:
  - platform: state
    entity_id: input_boolean.vizio
    to: 'on'
  action:
  - service: script.turn_on
    entity_id: script.vizio_on

Automation to switch the input_boolean switch

- id: vizio_off
  alias: Vizio Off
  trigger:
  - platform: state
    entity_id: input_boolean.vizio
    to: 'off'
  action:
  - service: script.turn_on
    entity_id: script.vizio_off

customize.yaml # any options you want to show

media_player.vizio:
  friendly_name: Vizio TV
  source_list:
  - Select Input
  - PS4
  - Dish
  - AppleTV
  - FireStick

input_select.yaml

  tv_input:
    options:
      - Select Input
      - PS4
      - Dish
      - Apple TV
      - FireStick

media_player.yaml

  - platform: universal
    name: vizio
    commands:
      turn_on:
        service: homeassistant.turn_on
        data:
          entity_id: input_boolean.vizio
      turn_off:
        service: homeassistant.turn_off
        data:
          entity_id: input_boolean.vizio
      volume_up:
        service: script.turn_on
        entity_id: script.volume_up
      volume_down:
        service: script.turn_on
        entity_id: script.volume_down
      volume_mute:
        service: script.turn_on
        entity_id: script.mute
      select_source:
        service: script.turn_on
        data_template:
          entity_id: >
            {% if source == 'PS4' %}
              script.vizio_1
            {% elif source == 'Dish' %}
              script.vizio_2
            {% elif source == 'Apple TV' %}
              script.vizio_3
            {% elif source == 'FireStick' %}
              script.vizio_4
            {% else %}
              Select Input
            {% endif %}
    attributes:
      state: input_boolean.vizio
      source: input_select.tv_input

I believe that’s everything, I hope it helps!

2 Likes

@Corey_Maxim Thanks so much! This is a huge help. Yeah, I have a Harmony Hub.

I’m running into this problem when trying to restart: Component error: media_player.tv - Integration 'media_player.tv' not found.

I changed “vizio” to “tv” in the various spots. Not sure why it doesn’t like it.

Could you post your code?

Config

media_player.tv:
  friendly_name: TV
  source_list:
  - Select Input
  - tiniBooty
  - Apple TV
  - Xbox One
  - Nintendo Switch
  - PS4

media_player.yaml (I plugged in some, but not all, of the source scripts — but didn’t think it’d matter as a test, and don’t get the impression it’s affecting the error)

  - platform: universal
    name: tv
    commands:
      turn_on:
        service: homeassistant.turn_on
        data:
          entity_id: input_boolean.tv
      turn_off:
        service: homeassistant.turn_off
        data:
          entity_id: input_boolean.tv
      volume_up:
        service: script.turn_on
        entity_id: script.volume_up
      volume_down:
        service: script.turn_on
        entity_id: script.volume_down
      volume_mute:
        service: script.turn_on
        entity_id: script.mute
      select_source:
        service: script.turn_on
        data_template:
          entity_id: >
            {% if source == 'tiniBooty' %}
              script.vizio_1
            {% elif source == 'Apple TV' %}
              script.1571447473765
            {% elif source == 'Xbox One' %}
              script.1571506387245
            {% elif source == 'Nintendo Switch' %}
              script.vizio_4
            {% elif source == 'PS4' %}
              script.1571517302149
            {% else %}
              Select Input
            {% endif %}
    attributes:
      state: input_boolean.tv
      source: input_select.tv_input

input_select.yaml

tv_input:
    options:
      - Select Input
      - tiniBooty
      - Apple TV
      - Xbox One
      - Nintendo Switch
      - PS4

In messing with it, I didn’t try the input.boolean automations yet. But as the error seems to be that “media_player.tv” isn’t found, I don’t get the impression that’s affecting it. Especially as there’s no reference of “media_player” in that.

Thanks for taking a look!