Ha-Bridge Set Media Player Volume via dim command

Has anybody got Volume setting of a media player via Ha Bridge working and can give me an example, or better still a way to look this stuff up myself?

Under Dim URL I have

http://localhost:8123/api/services/media_player/volume_set

and Content Body Dim

{"volume_set":"${intensity.percent}", "entity_id":"media_player.kitchen_avr"}

This is the bit I have been just guessing at.

I can see in developer tools that my current volume for this device is

"volume_level": 0.86

Anyone got any ideas for me?

I am also looking for the answer to this. Did you get this to work? If so could you post your findings?
There really is not much information or documentation on the HA-Bridge which is a shame.

Not quite, sorry. The first part of the body should be “volume_level” as below, but that’s about it.

{"volume_level":"${intensity.math(X/100)}", "entity_id":"media_player.kitchen_avr"}

This sets the volume to “0” on my AVR (volume_level: 1 in HASS) with any numerical input. 0 is the loudest it can go and the minimum volume is - 80 (which Hass reports as “volume_level: 0.19”) so after thinking about it tonight I reckon it’s got something to do with the negative decimal number and is probably to do with my AVR.

At the moment I am trying to work out how to convert a number between 1 and 100 from the Alexa input to a number between 0 and -0.8 but I think I need to find some sort of online calculator to test with. This is where I’m at.

{"volume_level":"${intensity.math(-(X/100+.2))}", "entity_id":"media_player.kitchen_avr"}

or

between 1 and 0.19

I’m fairly sure this is what needs to be sent in the body, but I don’t know how to translate this other than what I have already tried.

{
  "description": "Set a media player's volume level",
  "fields": {
    "entity_id": {
      "description": "Name(s) of entities to set volume level on",
      "example": "media_player.living_room_sonos"
    },
    "volume_level": {
      "description": "Volume level to set",
      "example": 60
    }
  }
}

Another step, progress. Still no solution.

{"volume_level":"${intensity.math(X/255)}", "entity_id":"media_player.hoolio"}

Value needs to be divided by 255, not 100 as it’s a pretend light. This now gives me two steps in volume control, anything above an input value of 35 sets the media player at maximum volume, anything below sets it to minimum volume.

Have you found any solutions @mchinery ?

I have an answer @mchinery - you need to put a decimal point before the $ and use percent.

{"volume_level":".${intensity.percent}", "entity_id":"media_player.kitchen_avr"}

I ended up asking on Ha-Bridge github and got a quick reply from the developer.

@BarryHampants that worked great. Thanks for posting back your findings. I can now set the volume on my Sonos.
For anyone that may review this and have the same issue I have added a photo of my setup in HA-Bridge

1 Like

Apparently the reason is that Ha Bridge is unable to create a decimal value using .math so I guess the voice commands were being rounded to either 1 or 0.

I’ve tried several of my media players now and so far it works with all of them, using both Alexa and Google Home.

Hi @mchinery,

Could you please send back your post with the screenshot of your Sonos volume setup through HA-bridge. It’s not available anymore.

Thank you very much.