Homekit volume sliders not syncing


I’ve recently made all of my media_player’s volumes controllable through Homekit by defining them as lights and using the brightness slider to control the volume! Works great :ok_hand:t3: Except for one little issue, whenever I change the volume of a media player through something other than the Homekit brightness slider, that brightness slider doesn’t sync (if that makes any sense…)

Here’s a couple of examples to clarify what I’m trying to say:

  • If I turn up the volume of my Kitchen GH directly on the device, the volume stays the same on the Homekit brightness slider

  • I have a volume control/brightness slider that changes the volume for all the speakers at the same time with the ability to mute or unmute all of them with one click, but turning this up doesn’t affect the volume sliders/brightness levels of the individual media players…

I hope I’m not sounding overly complicated, and if anyone could give me a hand with this, I’d appreciate it greatly! Cheers :slight_smile:

I love you method, I would test it now

If you’re curious, here’s the code I used in the configuration.yaml:

  • platform: template #Kitchen

      friendly_name: "Kitchen Speaker"
      value_template: "{{ is_state('switch.kitchen', 'on') }}"
      level_template: "{{ (state_attr('media_player.kitchen', 'volume_level')|float * 255)|int }}"
        service: media_player.volume_set
          entity_id: media_player.kitchen
          volume_level: '0.3'
        service: media_player.volume_set
          entity_id: media_player.kitchen
          volume_level: '0'
        service: media_player.volume_set
          entity_id: media_player.kitchen
          volume_level: "{{ brightness / 255 }}"

The problem you are seeing is due to the media_player entity not updating its volume status to its “light” peer. What you need to do is to create an automation triggered by the media entity volume change event to update the light brightness to the new volume.

Hey, thanks for the tip! :slight_smile: Would you mind pointing me in the right direction as to what to actually do? :smiley: I’ve little experience in configuring automations directly in HA, otherwise I’ll just try and figure it out in Node Red :+1:

Although I don’t think it is very hard, you still need to read up a bit on templating to extract the value of the volume (likely an entity attribute) and insert as a variable into the automation which you would trigger whenever it changes. I am using a different platform and another homekit bridge to do the same thing and it is pretty straightforward. I could dig deeper into it for HA as I have done similar things in the past. Maybe when I have a bit more time…

I’m back!

Still haven’t found a solution to this problem since I started this convo back in March :joy:

I’ve been digging into it a bit more recently and have noticed a few things :

  • Changing the “brightness” of the speaker on the Home App changes the volume of the media player perfectly, but vice versa doesn’t work.

  • Changing the brightness of the speaker through Home Assistant also successfully changes the volume of the media player, but if I click away from that entity and come back to it, it’s “brightness” is back at 0

  • Changing the brightness of the speaker on the Home App does NOT change the brightness of the SAME ENTITY in Home Assistant… very confusing… :man_shrugging:t3:

I’ve tried all sorts of automations to try and get the speaker brightness to sync up on all platforms instantly, but alas, I have found nothing, there must be something wrong with my original code… :man_shrugging:t3:

Any help would be greatly appreciated, cause I have already searched every nook of Google I can, and I’m desperate for a solution

Peace & Love :v:t3::heart: