home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.97k stars 29.04k forks source link

Homekit TV remote ON/OFF does not work but works in Home App #105272

Open TonsiTT opened 7 months ago

TonsiTT commented 7 months ago

The problem

I have a native media player from webOS TV integration and one using the media player template. Both work fine when controlled via haos or the Home app in iOS. However, for some reason, the on/off and mute buttons don't work in the iOS remote widget/app. Both of these funtionalites function as intended when controlled via Home app

What version of Home Assistant Core has the issue?

core-2023.12.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Homekit Bridge

Link to integration documentation on our website

https://www.home-assistant.io/integrations/homekit/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 7 months ago

Hey there @bdraco, mind taking a look at this issue as it has been labeled with an integration (homekit) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `homekit` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign homekit` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


homekit documentation homekit source (message by IssueLinks)

TonsiTT commented 7 months ago

A way to manually map the on/off and mute, similar to the other buttons, would solve this problem once and for all.

DenisG1994 commented 7 months ago

A way to manually map the on/off and mute, similar to the other buttons, would solve this problem once and for all.

Also mapping volume up/down would be pretty usefull.

sbasmanov commented 7 months ago

I'm not sure if this is related, but I never had any success with getting 'mute' button to appear in iOS remote widget. I tried to setup universal media player with all attributes & commands - no luck. And because of this I can't ask Siri to silence tv - it says I don't have devices that support this feature.

TonsiTT commented 7 months ago

I'm not sure if this is related, but I never had any success with getting 'mute' button to appear in iOS remote widget. I tried to setup universal media player with all attributes & commands - no luck. And because of this I can't ask Siri to silence tv - it says I don't have devices that support this feature.

It is the same for me. Even with devices such as Android TV and LG webos which have native haos integrations, the media player doesn't work with mute in homekit. So at the least, it isn't an issue with universal media player.

DenisG1994 commented 7 months ago

I'm not sure if this is related, but I never had any success with getting 'mute' button to appear in iOS remote widget. I tried to setup universal media player with all attributes & commands - no luck. And because of this I can't ask Siri to silence tv - it says I don't have devices that support this feature.

Same here! Let’s see if those features can be added 🤞🏻

sbasmanov commented 7 months ago

Btw, I've never seen on/off buttons in iOS remote widget, even for ATV. I'm changing state only from home app (or control center) and then control volume, play/pause and arrows through widget.

Also mapping volume up/down would be pretty usefull.

@DenisG1994 what You mean? Volume up/down in iOS widget goes to media_player volume up/down commands where You can execute anything.

DenisG1994 commented 7 months ago

Btw, I've never seen on/off buttons in iOS remote widget, even for ATV. I'm changing state only from home app (or control center) and then control volume, play/pause and arrows through widget.

Also mapping volume up/down would be pretty usefull.

@DenisG1994 what You mean? Volume up/down in iOS widget goes to media_player volume up/down commands where You can execute anything.

I’m talking about this https://github.com/home-assistant/core/issues/36679#issuecomment-1554235599 Meaning that it could be usefull in some cases to be able to detect the volume up/down button press.

Here is a screenshot of the buttons we were talking about. image

sbasmanov commented 7 months ago

Ah, ok. Got it. Yes, these two buttons exist only for ATV - I just checked on my phone. Never seen for any HA exported accessory. I remember now, that I opened FR before, but it was closed: https://github.com/home-assistant/core/issues/81677 About volume buttons - yes, they never sent as event. I believe this is how HK works. But there is simple workaround - create universal media player, set existing player as child and override volume commands:

      volume_up:
        service: SERVICE
        data: SERVICE_DATA
      volume_down:
        service: SERVICE
        data: SERVICE_DATA

This way You can call any script every time volume keys pressed in iOS widget.

sbasmanov commented 7 months ago

Ok, now I remember details. I have old ATV3 and recently got new ATV4K gen 3. So, with old ATV3 I've never seen mute and power buttons. Then I found somewhere, that these buttons available only for AirPlay2 devices. So, it seems that HK bridge have to emulate AirPlay2 device to get those buttons working. I think this is not easy, so nobody wants to bother with it just to get two buttons on remote.

DenisG1994 commented 7 months ago

Ah, ok. Got it. Yes, these two buttons exist only for ATV - I just checked on my phone. Never seen for any HA exported accessory. I remember now, that I opened FR before, but it was closed: #81677 About volume buttons - yes, they never sent as event. I believe this is how HK works. But there is simple workaround - create universal media player, set existing player as child and override volume commands:

      volume_up:
        service: SERVICE
        data: SERVICE_DATA
      volume_down:
        service: SERVICE
        data: SERVICE_DATA

This way You can call any script every time volume keys pressed in iOS widget.

Yes, the workaround work great (also allow to have a more “complete” device in HA and not only on Apple home). But for someone maybe a simple button remapping is enough… For the AirPlay 2 I don’t know… The screenshot above is from an Universal media_player exposed by HA, the buttons are present but not working 🤷🏼‍♂️

sbasmanov commented 7 months ago

The screenshot above is from an Universal media_player exposed by HA, the buttons are present but not working 🤷🏼‍♂️

Hmmm... Looks like I missing something. Can You please share Your config (media player part) and supported_features value from states page? My player have supported_features: 69000.

DenisG1994 commented 7 months ago

Here is the media_player config

- platform: universal
  name: TV&Devialet
  children:
    - media_player.televisore
    - media_player.devialet
  active_child_template:
    media_player.televisore
  commands:
    turn_on:
      service: media_player.turn_on
      target:
        entity_id: media_player.televisore
    turn_off:
      service: media_player.turn_off
      target:
        entity_id: media_player.televisore
    volume_up:
      service: media_player.volume_up
      target:
        entity_id: media_player.devialet
    volume_down:
      service: media_player.volume_down
      target:
        entity_id: media_player.devialet
    volume_mute:
      service: media_player.volume_mute
      data:
        is_volume_muted: "{{ is_volume_muted }}"
      target:
        entity_id: media_player.devialet
    select_sound_mode:
      service: media_player.select_sound_mode
      data:
        sound_mode: "{{ sound_mode }}"
      target:
        entity_id: media_player.devialet
    media_play:
      service: media_player.media_play
      target:
        entity_id: media_player.televisore
    media_pause:
      service: media_player.media_pause
      target:
        entity_id: media_player.televisore
    media_stop:
      service: media_player.media_stop
      target:
        entity_id: media_player.televisore
    media_previous_track:
      service: media_player.media_previous_track
      target:
        entity_id: media_player.televisore
    media_next_track:
      service: media_player.media_next_track
      target:
        entity_id: media_player.televisore
    media_play_pause:
      service: media_player.media_play_pause
      target:
        entity_id: media_player.televisore  
    select_source:
      service: media_player.select_source
      data:
        source: "{{ source }}"
      target:
        entity_id: media_player.televisore  
  attributes:
    state: media_player.televisore
    source_list: media_player.televisore|source_list
    source: media_player.televisore|source
    volume_level: media_player.devialet|volume_level
    is_volume_muted: media_player.devialet|is_volume_muted
    sound_mode: media_player.devialet|sound_mode
    sound_mode_list: media_player.devialet|sound_mode_list
  device_class: tv
  unique_id: TV&Devialet

And here you have the media_player available attributes (supported features value is 90041): image

sbasmanov commented 7 months ago

Great. Thank You very much. I'll try to find out, what features must be enabled to get those buttons. Seems it inherits some extra features from childs that affect how HK understands device. Before, I created pure universal media player with all commands defined (except sound_mode) with stubs and it never showed full widget on phone. I have HomePod mini connected to HA and it shows supported_features: 448439.

DenisG1994 commented 6 months ago

Great. Thank You very much. I'll try to find out, what features must be enabled to get those buttons. Seems it inherits some extra features from childs that affect how HK understands device. Before, I created pure universal media player with all commands defined (except sound_mode) with stubs and it never showed full widget on phone. I have HomePod mini connected to HA and it shows supported_features: 448439.

Hey! just noticed that another media_player entity (not generated by the universal platform) but from an hacs integration (Skyq media_player) has the same buttons on top of the remote widget, obviously not working like the other one 🤔 Have you been able to make those buttons appear on your device?

image

Screenshot 2023-12-19 alle 22 07 11
meluvalli commented 5 months ago

My volume works, however I can't mute and/or toggle TV on/off via remote. The buttons show, but are grayed out and not selectable. As others have said, I can turn TV on off in HomeKit, just not in remote app.

My HomeKit config:

- name: HASS Office TV
  id: c8b78ca1-190a-4ef2-9b51-77f989e94cab
  port: 10123
  mode: accessory
  filter:
    include_entities:
      - media_player.office_tv
  entity_config:
    media_player.office_tv:
      name: "Office TV"
      feature_list:
        - feature: on_off
        - feature: play_pause
        - feature: play_stop
        - feature: toggle_mute
joaodforce commented 2 months ago

I have the same issue, Im using the native HASS Samsung integration, adding the TV via the home KIT Bridge works well enough, on/off via the app and Siri work, but mute and power toggle buttons are Disabled in remote widget.

The directional buttons don't work, however I do Get events for them in the Event hub. so mapping them to actual commands is possible.

However with the mute toggle and the power button being disabled I cannot get around that in any way. seem like there are some characteristics missing on the media player definition

https://github.com/home-assistant/core/blob/dev/homeassistant/components/homekit/type_media_players.py

Volume +/- also didn't work, I didn't had feature_list configured at all, so I expected adding the feature list config would allow me to map it with the event hub, however I added all the feature list options, and the volume +/- now work, but the mute and power buttons are still greyed out. I expected at least the mute button to work considering the toggle_mute option.

- name: HASS Lounge TV
  port: 56320
  mode: accessory
  filter:
    include_entities:
      - media_player.samsung_sala
  entity_config:
    media_player.samsung_sala:
      name: Lounge TV
      feature_list:
        - feature: on_off
        - feature: play_pause
        - feature: play_stop
        - feature: toggle_mute
Trilis29 commented 2 months ago

But on homekit app power toggle works, seems strange

TonsiTT commented 2 months ago

But on homekit app power toggle works, seems strange

Strange indeed. But as someone commented above, its a matter of the implementation not being upgraded to emulate Airplay2 devices. So guess we will have to wait until then

Kebo2r commented 4 weeks ago

This is the last missing piece for my setup! If the mute and power buttons for the remote widget could be mapped I'd be set! Hope this is something that can be brought. Thanks for all the work these things take!

davewatson91 commented 1 week ago

Also missing this - hopefully it's a possibility soon!