[SOLVED] Alexa binding adjust volume example

  • Platform information:
    • Hardware: Rapberry Pi 3 Model B Rev 1.2
    • OS: Openhabian - Raspbian GNU/Linux 9 (stretch)
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version: 2.3 stable
  • Issue of the topic: Does anyone have an example rule for adjusting the volume on the Amazon Alexa. I’m using binding-amazonechocontrol - 2.4.0 but have not been able to get the volume to adjust.

Something like this?

//Near the top of your rule file:
val EchoVolumeKitchen = 60        // Volume Level, should be in steps of 10.

//Somewhere in your rule file:
if(Echo_Kitchen_Volume.state!=UNDEF && Echo_Kitchen_Volume.state!=NULL) {

In which @H102 ofcourse assumes you have defined the Item Echo_Kitchen_Volume either in an .items file or via Habmin/Paper UI and linked it to the Volume channel of the Echo in the kitchen :slight_smile:

Thank-you much for your help. Here is more info.

Here is my items file:

String echoLivingRoomTTS
“Text to speech”

String echoLivingRoomAlarm
“Play Alarm Sound”

Dimmer echoLivingRoomVolume
“Volume [%.0f %%]”

And my rule:

rule “Test Echo Volume”
Item miniRemoteD received update ON
var PercentType currentVolume = echoLivingRoomVolume.state
val newVolume = 50
logInfo(“TestEcho”, “Current Volume: {}, New Volume: {}”, currentVolume.toString, newVolume.toString)
echoLivingRoomTTS.sendCommand(‘Switch was turned on’)

I hear “Switch was turned on” but the volume does not adjust

Can you adjust it via the Alexa website?

That binding is just sort of a hacky wrapper around the Alexa website, its not using any “official” APIs, so for a given function to work, you need to not only script it right, but the Alexa website has to have no changed and broken the functionality, and the function on the website has to work.

I wish Amazon had an official API for it. That kind of client-spoofing of internal API endpoints is just super unreliable long-term. I just tried with one of mine here, and there’s a few-second lag with the volume adjustment. Its possible its just not happening before the text-to-speech is done.

Ha! I guess I also needed to link the item in PaperUI. It’s now working. Thanks for the help guys!

1 Like

Glad you got it working.:+1:

Alexa binding tip: When looking for the channels to link and not seeing all of them you will need to click the “Show More” button on right side of page.:wink:

If you would please mark the topic solved by clicking the square box on the post that provided the solution and edit the title to start with [Solved].