Homekit new options TV Source

I just noticed a mistake I made and I got rid of the error, but I don’t see the “TV” in HomeKit yet (but that could just be HA and HomeKit not playing nicely and have nothing to do with this config — I’m dealing with larger issues than this).

What I did wrong is that I had media_player.tv stuff in my media_player.yaml and not in my customize.yaml. I had just misread or misunderstood your previous directions. BUT, I’m a step forward, so that’s great. Now to find out why it’s not appearing…

Did you use - platform: universal in your media_player.yaml?

Yes, pretty much a copy/paste from yours with the exception of changing vizio to tv:

  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: >

Are you getting any errors in the log?

I can’t see anything related to this:

5:56 PM config_entries.py (WARNING) - message first occurred at 8:45 AM and shows up 409 times
plex: Error on device update!
5:44 PM components/plex/media_player.py (ERROR) - message first occurred at 1:09 PM and shows up 3 times
No player associated with active session
5:44 PM components/plex/media_player.py (WARNING) - message first occurred at 11:26 AM and shows up 13 times
Error on retrieving data: empty response
3:10 PM components/waze_travel_time/sensor.py (WARNING) - message first occurred at 8:44 AM and shows up 12 times
plex: Error on device update!
3:07 PM components/plex/media_player.py (ERROR)
Update for sensor.teslie_temperature_sensor_outside fails
1:15 PM components/tesla/sensor.py (ERROR)
Update for sensor.plex fails
1:13 PM components/plex/sensor.py (ERROR) - message first occurred at 11:26 AM and shows up 2 times
Update for sensor.plex fails
1:13 PM components/plex/sensor.py (ERROR) - message first occurred at 10:51 AM and shows up 36 times
Update for media_player.plex_chrome_5 fails
1:10 PM components/plex/media_player.py (ERROR) - message first occurred at 12:32 PM and shows up 8 times
Update for media_player.plex_chrome_5 fails
1:09 PM components/plex/media_player.py (ERROR) - message first occurred at 11:57 AM and shows up 9 times
Update for media_player.plex_living_room fails
11:26 AM components/plex/media_player.py (ERROR)
- platform: universal

Just to be clear, do you actually have that line line in media_players.yaml though, above the line “name: tv”? Missing that line would cause the exact error you got earlier (required key for platform).

I assume you have exposed the device to homekit in homekit.yaml?

Also, have you added device_class:tv to customize.yaml?

The entry in customize.yaml should look like this:

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

Finally, are you able to control the media player fully from the HA web interface? If not, get that working first. Find it in the dev states menu and make sure it successfully switches sources, powers on/off, volume, etc…

See earlier in the thread for my full config.

@anthonygillet _ Yeah, that was a copy/pasta error. I have - platform: universal in the media_player.yaml

In the config, I have:

homekit:
  safe_mode: true 
  port: 51829
  filter: 
    include_domains:
      - switch
      - media_player
      - sensor
      - alarm_control_panel
      - climate
      - remote
      - light

I didn’t have device_class: tv, but I have since put that in and restarted HA, but I haven’t seen a change yet.

RE: Control the media player — Yeah, it’s a Harmony Hub, and I get certain commands to work with it.

Thanks for the ideas!

1 Like

Thanks for the work here and all the examples everyone! I’ll post mine as well. This is for a Vizio Soundbar. It’s connected to both my TV (over Optical) and Amazon Echo Dot (on Aux 1). I control it over a homemade IR blaster built with an esp8266 with some custom firmware.

configuration.yaml

media_player:
  - platform: universal
    name: Soundbar
    children:
      - media_player.living_room
      - media_player.everywhere
    commands:
      turn_on:
        service: mqtt.publish
        data:
          topic: 'irblaster/tx'
          # The following command is the correct command for on/off, but HomeKit
          # has a quirk where it tries to make sure the soundbar is on before sending
          # volume commands. But since the on/off IR codes are the same this ends
          # up turning the sound bar off. I'm working around this by just sending the
          # volume up command since it also will turn on the sound bar.
          # payload: "{\"type\":\"NEC\",\"code\":\"FF02FD\"}"
          payload: "{\"type\":\"NEC\",\"code\":\"FF827D\"}"
      turn_off:
        service: mqtt.publish
        data:
          topic: 'irblaster/tx'
          payload: "{\"type\":\"NEC\",\"code\":\"FF02FD\"}"
      volume_up:
        service: mqtt.publish
        data:
          topic: 'irblaster/tx'
          payload: "{\"type\":\"NEC\",\"code\":\"FF827D\"}"
      volume_down:
        service: mqtt.publish
        data:
          topic: 'irblaster/tx'
          payload: "{\"type\":\"NEC\",\"code\":\"FFA25D\"}"
      volume_mute:
        service: mqtt.publish
        data:
          topic: 'irblaster/tx'
          payload: "{\"type\":\"NEC\",\"code\":\"FF12ED\"}"
      select_source:
        service: mqtt.publish
        data_template:
          topic: 'irblaster/tx'
          payload: >-
            {"type":"NEC","code":"
            {%- if source == 'Optical' -%}
              FF13EC
            {%- elif source == 'Aux 1' -%}
              FF8D72
            {%- elif source == 'USB' -%}
              FF857A
            {%- elif source == 'Bluetooth' -%}
              FF44BB
            {%- elif source == 'Aux 2' -%}
              FF4DB2
            {%- elif source == 'Digital' -%}
              FF936C
            {%- endif -%}"}

customize.yaml

media_player.soundbar:
  device_class: tv
  source_list:
    - Optical
    - Aux 1
    - USB
    - Bluetooth
    - Aux 2
    - Digital

automations.yaml - Automation to automatically switch my soundbar to Aux 1 when I’m using the whole house audio group on Alexa (using alexa_media_player) and switch it back to Optical when done.

- alias: Soundbar to Aux when the Everywhere group is playing
  trigger:
  - platform: state
    entity_id: media_player.everywhere
    to: 'playing'
  - platform: state
    entity_id: media_player.everywhere
    from: 'playing'
  action:
  - service: mqtt.publish
    data_template:
      topic: 'irblaster/tx'
      payload_template: >-
        {"type":"NEC","code":"
        {%- if trigger.to_state.state == 'playing' -%}
          FF8D72
        {%- else -%}
          FF13EC
        {%- endif -%}"}

Everything works including volume control via the phone’s volume buttons while in the Remote app.

The one quirk it has is that after opening the Remote app, the first time I press a volume button, the soundbar turns off. I suspect this is the Remote app’s way of trying to make sure the soundbar is on, but the IR code for the ‘on’ command is the same as the ‘off’ command. Luckily, the volume IR codes also turn the soundbar back on, so subsequent volume button presses turn the soundbar back on. I’ve worked around this quirk by just sending the volume up IR code for turn_on since it appears that also can turn the soundbar on.

Continuing the discussion from Homekit new options TV Source:

Hello Team,
I have two harmony hubs. I have switches and scripts running all my activities and controls and all are working well. I got this far in trying to create a HomeKit tv source, but can’t get the inputs to work nor the commands to run each activity.

Here is my switches and configuration file.
Right now I am using the Harmony Bridge Mac app to run activities now.


Hey everyone. Any idea if there are plans to implement support for remote direction keys, back/ok button, etc?

Without this, you still need to use a physical remote to use your TV which kinda make the integration a bit pointless.

1 Like

For some reason my remote app has stopped showing my Soundbar media player as an option. Any one else see this with recent iOS or HA versions? I still see the device in the Home app, but now have no way to change the volume.

Hi @h4nc did you ever managed to fix this? I’m in the very same situation :frowning:

Unfortunately no, but I’m still watching this topic in case someone finds a solution.

Follow this one too then: https://github.com/home-assistant/core/issues/30479

2 Likes

@anthonygillet hi there anthony, thanks for sharing your code. I wonder if you would mind helping me try get this working if I send you my text files? I’ve edited the four yaml files you mentioned, but I’m not having any luck getting harmony showing as a media player in home assistant.

@h4nc specially this: https://github.com/home-assistant/core/issues/30479#issuecomment-612583140

it happens to be pretty tricky and if depends what “remote” you happen to check

1 Like

Thanks, so in conclusion it seems like it makes a difference if you look at the “Remote” app or the “remote” from the control center. I did not have time to check it yet (I think I already deleted that test media player).
@kitus did you find your media player in the control center remote?

Yep. While in remote.app there was no trace of it, in control center I did find it. Note that I’m using HA to expose a media player to HomeKit because I wanted to be able to control the playback audio volume of my OVR from my Apple Watch. I really don’t care about the rest of the controls because it definitely is not a TV set anyway.
To your question: in does appear in Control Center yes.
To my use case: this is useless because the watch does not care about the fact that the AVR is now appearing in control center :unamused:

Thanks for your answer, let’s hope this will be possible in the future and both remotes show the same entities.

BTW: What does OVR stand for?

My bad. I intended to say AVR. Apologies for that :frowning:

1 Like