core: missing volume control for homekit media player

Home Assistant release with the issue: 0.103

Operating environment (Hass.io/Docker/Windows/etc.): Hass.io

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

Description of problem: I have a media player based on the Denon integration:

media_player:
  - platform: denonavr
    host: 192.168.1.127
    name: AV Receiver
    show_all_sources: true
    timeout: 100

It works perfectly and I can control sources aswell as volume.

I also added it to the homekit integration:

homekit:
  auto_start: False
  filter:
    include_entities:
      - media_player.av_receiver
  entity_config:
    media_player.av_receiver:
      feature_list:
        - feature: on_off
        - feature: play_pause
        - feature: play_stop
        - feature: toggle_mute

and I specified device_class: tv to enable the TV remote.

The device shows up in homekit as TV (so far correct), but I can only switch it on/off or select the source. There are no options to change volume or play/pause. The documentation does not say much for this case. How can I debug and fix this problem?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 35 (19 by maintainers)

Most upvoted comments

I think I might be having a similar problem…

  auto_start: False
  filter:
    include_entities:
       [snip]
      - media_player.living_room_tv
      - media_player.bedroom_tv
  entity_config:
   media_player.living_room_tv:
      feature_list:
        - feature: on_off
        - feature: play_pause
        - feature: play_stop
        - feature: toggle_mute
   media_player.bedroom_tv:
      feature_list:
        - feature: on_off
        - feature: play_pause
        - feature: play_stop
        - feature: toggle_mute

For living_room_tv: supported_features: 69004 For bedroom_tv: supported_features: 21389

In both cases only power and input selection seem to work. All features in theory should work. I can control volume/mute for example in lovelace.

They are both using the universal media_player platform FWIW.

More exciting than that, its a bitfield. SUPPORT_VOLUME_MUTE is worth 8 (i.e. its the 4th bit).

>>> 85949 & 8
8

So the SUPPORT_VOLUME_MUTE bit is set. SUPPORT_VOLUME_SET is worth 4 and is also set. So i would expect to see a speaker.

Looking at the code again, I think feature_list: is ignored for TV’s. So it might be worth stripping that out in case its having a negative affect. I suspect that is unrelated though.

You said you can select the source. That is only done if you have SUPPORT_SELECT_SOURCE. Which means when homekit started something was in the supported_features field. So it’s not as likely to be a race where homekit is starting before the media_player has been setup or something. Though it is worth trying to turn off auto_start to see if manually starting homekit helps.

If you are comfortable with a text editor the relevant bit of code is here.

I would be tempted to find this bit:

        if CHAR_VOLUME_SELECTOR in self.chars_speaker:
            serv_speaker = self.add_preload_service(
                SERV_TELEVISION_SPEAKER, self.chars_speaker
            )

And make it:

        print("Checking for speaker support")
        if CHAR_VOLUME_SELECTOR in self.chars_speaker:
            print("Configuring speaker")
            serv_speaker = self.add_preload_service(
                SERV_TELEVISION_SPEAKER, self.chars_speaker
            )

Then restart and look at your logs. If you cannot find “Checking for speaker support” in your logs try _LOGGER.warning instead of print.

This will tell us whether homekit doesnt think it can support speakers for your media_player or whether its doing something that iOS can’t understand.