Help with media player and HomeKit control

Tags: #<Tag:0x00007f3f2038e440>

Hello everyone!

Just discovered how to configure HomeKit and Google assistant to show my media player TV as a real TV entity so I can change input and so on.

I’ve successfully configure all of mine TVs but the old LG running Netcast OS. The problem is that since there is no turn on action, I cannot send a valid turn on command to the TV. I was using a template switch to send a broadlink ir code to turn it on.

I was trying to figure out a workaround and discovered that a HomeKit command is logged on the events database, like this:

image

My question is: is it possible to trigger an automation with this event so I can call the old turn on script and my problems would be solved :slight_smile:

Thanks!

Hi, can I ask how you managed to get your media player from HA to work with HomeKit, I’ve been trying that for a while now???

Hello @barns102!

You need to set this on customize.yaml:

media_player.your_media_player:
  device_class: tv

And then on homekit config:

entity_config:
  media_player.your_media_player:
    name: "TV"
    feature_list:
      - feature: on_off
      - feature: play_pause
      - feature: play_stop
      - feature: toggle_mute

You will get something like this:

Including source select, very neat!

Hurrah, you’re a Star!!!

Thank you so much, that certainly worked, in that I can now see a media player tool in my HomeKit App. But there are still some problems.

1 - I can’t turn the TV on, I toggle the switch on, and nothing happen although the App says its on. Then if I toggle it off the TV comes on. I guess it’s sending the off command (which is the same as on??)

2 - I can’t control the volume

3 - I have an input select feature, but no inputs show up so I can’t select any.

Do you have any more suggestions.

Thank You - Thank You - Thanks You!!! :slight_smile:

Hello sir! I am glad I could help.

What media player TV component do you use? Since I use LG WebOS, there is a separate turn on command that I can send using a Broadlink RM Mini. To turn off it is simple internal command to the WebOS.

I’m also unable to set the volume of my TV from the Home App, not sure why but it seems tricky.

I’ve found that this solves the problem, you might need to remove this media_player entity that you have set on HomeKit, restart HA, add this to your customize.yaml, add back again the device to HomeKit and restart HA:

media_player.your_media_player:
  device_class: tv
  source_list: [DTV,HDMI 1,HDMI 2,HDMI 3,HDMI 4]

You need to check on your dev_state the available sources and add them as the code above. You don’t need to enable all of them, I’ve only exposed the sources I want to show on the Home App (there were dozens of them, they were all apps installed on my TV). Here is my entity properties as for now (using the smart_ir media player custom component since that’s a “dumb” TV):

Good luck!

Hi @Schneider

You mentioned being able to set up this media player HomeKit button to send commands using your broadlink RM. Could you possibly paste that element of your configuration? Thank you

Edit: @barns102 were you able to get that tv icon in HomeKit to send broadlink commandsv

There are 2 things you need (possibly 3 depending on what your HomeKit config is)

Firstly setup the SamrtIR config, here’s mine:

switch 4:

  • platform: broadlink
    host: !secret lounge_rm_host
    mac: !secret loung_rm_mac

media_player 2:

  • platform: smartir
    name: Barns TV
    unique_id: barns_tv
    device_code: 0
    controller_data: !secret lounge_rm_host

Secondly you need to make sure that you have the following in your customise.yaml

media_player.barns_tv:
device_class: tv

If you include and exclude devices to HomeKit, then of course you need to make sure your media_player is exposed.

Does this make sense?

Hello!

@barns102 got it right, just follow his steps.

My config is a little different, since I don’t need all my sources exposed on the Home app:

Customize:

media_player.tv_dinamica:
  device_class: tv
  source_list: [TV,HDMI 1,HDMI 2,HDMI 3,HDMI 4]

Media Player:

- platform: smartir
  name: "TV Dinâmica"
  unique_id: "tv_dinamica"
  device_code: 1040
  controller_data: 192.168.1.41
  power_sensor: binary_sensor.energia_tv_dinamica

HomeKit:

filter:
  include_entities:
    - media_player.tv_dinamica
entity_config:
  media_player.tv_dinamica:
    name: "TV dinâmica"
    feature_list:
      - feature: on_off
      - feature: play_pause
      - feature: play_stop
      - feature: toggle_mute

If you are using broadlink to control a “dumb” TV, as my example above, you will need to have this:

Broadlink switch:

- platform: broadlink
  host: 192.168.1.41
  mac: '34:5A:3A:7F:6B:01'
  timeout: 15
  friendly_name: "RM Mini sala 303"
  type: rm_mini

SmartIR component that you can find it here: https://github.com/smartHomeHub/SmartIR/blob/f4e87f7f3e0ed2f1b1cceda149a6797dc902cbe3/docs/MEDIA_PLAYER.md

If you have a meda player compatible TV, as one of mines LG WebOS, you can add it as a native media_player component and follow the instructions above.

Good luck!

1 Like

Hi @Schneider!

Thank you for replying, I wish that I has this sorted out in my head as well as you do!

I tried patching together what you posted but my HA collapsed and my config file hates me :(:nauseated_face: I was wondering if you could take a look at what I have, and tell me how far from working code? I’m trying to control a ‘dumb as a rock tv’ with the broadlink IR device sending commands but looking like a HomeKit tv.

here’s the nightmare franked-code for your amusement!

homekit:
  auto_start: false
  filter:
   include_entities:
     - media_player.tv_bedroom
    exclude_entities:
      - automation.start_homekit
      - sensor.illumination_7811dcb7d9e9
      - input_boolean.xiaomi_vacuum_cleaner
    
entity_config:
  media_player.tv_bedroom:
    name: "TVbedroom"
    feature_list:
      - feature: on_off
      - feature: volume_up
      - feature: volume_down

- platform: broadlink
    host: 10.0.0.22
    mac: 'XXX:Secret?:XX'
    type: 'rm_mini'
    switches:
      tv:
        friendly_name: "tv_bedroom"
        command_on: 'JgAsAQADiJ6anpkABOwAA4yemp6ZAAdhAAOMnpmemgAE6wADjZ6Zn5kAB2AAA4yemZ+ZAATrAAOOnZqemQAHXwADjp2anpkABOsAA4+dmZ6aAAdfAAOOnZqemQAE6wADjZ6anpkAB18AA4+dmaGXAATrAAONnpmemgAHXwADjZ6anpoABOoAA4+cmp6ZAAdhAAOMn5iemgAE7AADjJ6ZnpoAB2EAA4yemZ6ZAATwAAOLnpeemQAHYQADjJ6ZnpoABOsAA46dmZ6aAAdfAAONnpqemQAE7QADjpyZnpkAB2AAA46dmZ6aAATrAAOPnJqdmgAHYAADjpyanpkABOwAA46cmp6ZAAdhAAOMnpmemgAE7AADjJ6anpkAB2AAA4yemp6ZAATsAAONnpmemQANBQAAAAAAAAAAAAAAAA=='
        command_off: 'JgAwAAAEH5+YAAE/mQADqwAEJp2YAAE/mQAGIQAEJJ6YAAFAmAADrAAEI5+ZAAE/mAANBQAAAAAAAAAA=='
        volume_up: 'placeholderIRcode!'
        volume_down: 'placeholderIRcode!'

Hello sir!

I am sorry to hear that you are still having problems with that :frowning:

As I can see on your configs, you don’t actually have a media_player entity configured, just the broadlink switch (tv). This will not do the trick, you need a media_player in order to work.

I also have a dumb TV, you just need to use the custom component SmartIR first. Have you managed to make it work?

Thanks.

I’m also looking for a little help controlling my Sony Bravia TV. HA can see and control the TV fine but I can’t seem to expose this to Homekit.

media_player:

  • platform: braviatv
    host: 192.168.1.186

homekit:
filter:
include_entities:
- switch.kitchen_blind
- switch.heat_pump
- light.tv_backlight
- light.bedroom_bed_light
- light.lh_bedside_lamp
- light.rh_bedside_lamp
- sony_bravia_tv
entity_config:
media_player.sony_bravia_tv:
name: “TV”
feature_list:
- feature: on_off
- feature: play_pause
- feature: play_stop
- feature: toggle_mute

homeassistant:
customize: !include customize.yaml

In the customize.yaml I have the following

media_player.sony_bravia_tv:
device_class: tv

I think this should be correct???

Hello!

It seems that you misspelled the entity ID on include_entities. You wrote - sony_bravia_tv instead of - media_player.sony_bravia_tv.

1 Like

Second pair eyes for the win!!! Thank you sir

1 Like

I am having the same issue with a smartir media_player being controlled from Google Assistant (via Nabu Casa). Volume control doesn’t work from Google. My Google Home Hub shows volume buttons for the device but they do nothing. Voice commands have no effect.

I’m confused by what you said above… you said you’re unable to set the volume, but follow up saying that removing the media_player, editing customize.yaml, and then adding the media_player back works. I tried that (syncing devices to Google in between each step) but still no luck.

media_player:
  # Yamaha Surround (old)
  - platform: smartir
    name: Living Room Receiver
    unique_id: living_room_receiver
    device_code: 1120
    controller_data: 192.168.86.48
media_player.living_room_receiver:
  device_class: speaker

Hello!

Volume control still does not work using SmartIR or even the WebOS media player components.

In the previous message I was trying to help Douganator to simply show the media player as a TV on HomeKit, not controlling the volume. He was having trouble with that.

Thanks.

Thanks for the clarification!

I found a related issue about this on GitHub and it sounds like the problem is that Google Assistant (and I guess HomeKit) volume control only works for entities that have absolute volume and not relative volume. Although there’s a slim chance that a semi-recent change in HA could change that. And if not, I had an idea that might work to allow relative volume control while reporting absolute volumes to Google/HomeKit, so I suggested it to the smartir author.

1 Like

This won’t help with HomeKit, but I figured out how to make it work in Google Assistant and opened a Pull Request: https://github.com/home-assistant/home-assistant/pull/26585

I’m sure the logic will be very similar for HomeKit, if someone was inclined to try and fix it.

Great job! That’s really useful! Thanks a lot.