Decibels & Alexa

I’m having an interesting dilemma and I’ve decided to spit ball some ideas. Maybe you guys can think of something that I have not.


The problem

My physical receiver displays decibels for volume. I cannot change this. The range is -80dB to 25dB but I personally never go above 0dB but that’s besides the point.

The created media_player volume range is 0 to 1, like all media_players in home assistant.

I want to control my through voice commands through Alexa. She has 3 phrases to invoke volume commands:

Alexa, turn up the {x} volume

Alexa, turn down the {x} volume

Alexa, set the {x} volume to {level}

When you use all 3 commands, alexa ‘under the hood’ uses her own version of ‘set_volume’. She does not use a ‘volume up’ or ‘volume down’ command. So when you link her up to home assistant, she’s only using the ‘set_volume’ service. For volume up or down, she gets the current volume level and changes it by 10% in the commanded direction.

So the problem is, I cannot use all 3 commands as intended.

If I leave the volume control as is from a media player, volume up and volume down work as expected. But when I use set volume, it’s inverted. For example, if I say ‘Alexa, set the tv volume to 40’, she will set it to -60db. The levels are essentially inverted because my reciever’s range is negative instead of positive.

If I invert the volume. Everything is opposite. The volume up and down go awol due to state miss matches (whole different problem), but volume set will work. I.E. I can say ‘Alexa, set the tv volume to 40’ and she will set it to -40.

At this point I have a few ideas on how to fix this but I don’t like any of them because they don’t provide a single solution.

Anyone have other ideas I can try? Trying to think outside the box and I’m not getting anywhere with it.

I’m assumiong the volume up & down are just automations that capture the current volume and adds/subtracts 10% in response to an alexa command? If so then how do you get alexa to trigger those automations? How do those get converted to the equivalent negative values?

And in the working set up how are you converting the alexa “set the volume to 40” command to the correct negative dB equivalent?

No, Alexa just controls the media player. She sends over the value reported by the media player. Media_players in home assistant only report from 0 to 1. So, if my volume is at 0.4 and I say ‘increase’, alexa sends 0.5 to home assistant. No service, just straight to the media player.

So, I have 2 options.

  1. I can use the media player as is. Up and Down work as expected. Set does not, the value is off by 1 - volume_level.

  2. I can build a custom component that inverts the volume_level.

Might be the best to see this in the table, so you can fully understand the problem.

Custom component inverting volume_level.

The conversion is simply 1 - volume_level. That will take a level of 0.4 and convert it to 0.6.

This is the current behavior:

Phrase Current Volume On Receiver Current volume_level in Media Player Value From Alexa volume_level in Media Player Result On Receiver Actual volume direction Correct/Incorrect
Set volume to 30 NA NA 0.3 0.7 -30db NA Correct
turn up volume -30db 0.3 0.4 0.6 -40db DOWN Incorrect
turn down volume -30db 0.3 0.2 0.8 -20db UP Incorrect

No Custom Component, Just sending over the media_player

Phrase Current Volume On Receiver Current volume_level in Media Player Value From Alexa volume_level in Media Player Result On Receiver Actual volume direction Correct/Incorrect
Set volume to 30 NA NA 0.3 0.3 -70db NA Incorrect
turn up volume -30db 0.7 0.8 0.8 -20db UP Correct
turn down volume -30db 0.7 0.6 0.6 -40db DOWN Correct

So you can see, I’m in a catch 22. Not sure where to go other than make 2 damn media_players for voice control.

OK, I think see what you are saying now.

but back to my post above couldn’t you create an up, down and/or set volume automation and have alexa trigger the appropriate automation thru a routine?

I would think that it would easiest to make it so that the volume set command uses the inverted volume sent directly to the media player by alexa and then create a volume up and a volume down automation, triggered by alexa routines, to have HA (re)invert the volume up/down and then change the current volume by .1. As long as HA knows the current volume I would think it would be fairly easy to do it like that.

Maybe…? :thinking:

Yah, but then I don’t get the lazy nice phrases. I’m being particular here. My mother tries to have conversations with alexa and she doesn’t understand that you can’t really deviate from what alexa knows (for a routine). As a media player, alexa has a ton of different ways to say ‘turn up the tv’. Just trying to make it easier for my guests.

Ah, I see.

Could you come up with a few permutations that someone might reasonably use to turn the volume up or down and have those routines all trigger the same automations?

If not then that’s all I’ve got. :slightly_smiling_face:

Yah, I was thinking about catching all 0.1 increment changes and inverting them so that UP/DOWN work. And all ‘set volume to’ would work on any increment thats not 0.1.

Not sure what else I can do.