Released: Openhab2 Amazon Echo Control Binding (controlling alexa from openhab2)

Tags: #<Tag:0x00007fd30f60ae98> #<Tag:0x00007fd30f60ad58> #<Tag:0x00007fd30f60abf0>

(Scott Rushworth) #689

I’m experiencing the same. I did get it to work for a little while. Probably time to get an issue created to track this one (my hands are full at the moment).

(Jason Wiseman) #690

Alexa SmartHome Devices:

Is it possible to control Alexa’s SmartHome Devices that are predefined within Alexa?

This rule tied to a virtual switch isn’t working so maybe its my syntax or maybe it’s not possible yet?

rule “Alexa Turns Fans ON”
Item All_Fans changed to ON
Echo_Living_Room_StartCommand.sendCommand(‘Fans On’)
Thread::sleep(3000) // 3 second wait
Echo_Living_Room_StartCommand.sendCommand(‘Fans On’)

Any help would be appreciated.

Best, Jay

(Cadbures) #691


Which version of Java are you using. if i can reproduce your issue on my device
I use
java version “1.8.0_171”
openhab2 Snapshot 2.3.0 installed via apt-get
It works well with the above setup


(Mark) #692

If you want Alexa make an announcement for testing then isn’t Speak channel the way to do it. Or I misunderstood your problem.

Anyway maybe the following is useful to you or someone else…

I found Alexa TTS unreliable if the play volume is undefined, which is often the case if Alexa wasn’t playing anything. Also, if Alexa is already playing something I return the volume setting to where is was before the fixed volume TTS announcement. Log info command is useful for debugging. So I did it like this:

Maybe if would be better if the rule started with when ‘Item’ changed from Off to On instead of just On as below.

rule 'Cistern pump On'
  Item CisternPump_Switch changed to ON
if (Echo_Player.state == PLAY) {
    val current_volume_echo = Echo_Volume.state as Number
    logInfo("Alexa" , 'Player state '+ Echo_Player.state + ' volume '+ Echo_Volume.state)
    Echo_Speak.sendCommand('The cistern pump is on')
  else {
    logInfo("Alexa" , 'Player state '+ Echo_Player.state + ' volume '+ Echo_Volume.state)
    Echo_Speak.sendCommand('The cistern pump is on')

(Ben) #693

It’s definitely a tough one as I believe I tried everything without luck. Thanks for your tests.
Amazon account looks fine.

(Ben) #694

Java information:

dpkg -l | grep java
ii  java-common                             0.56ubuntu2                                all          Base package for Java runtimes
ii  javascript-common                       11                                         all          Base support for JavaScript library packages
ii  nodejs                                  4.2.6~dfsg-1ubuntu4.1                      amd64        evented I/O for V8 javascript
ii  nodejs-dev                              4.2.6~dfsg-1ubuntu4.1                      amd64        evented I/O for V8 javascript (development files)
ii  oracle-java8-installer                  8u171-1~webupd8~0                          all          Oracle Java(TM) Development Kit (JDK) 8
ii  oracle-java8-set-default                8u171-1~webupd8~0                          all          Set Oracle JDK 8 as default Java

java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

Openhab version information:

dpkg -l | grep openhab
ii  openhab2                                2.3.0-1                                    all          openhab2

I must admit I am unsure whether snapshot might improve things.
Currently using:

deb stable main

(Cadbures) #695

Hi bezibaerchen,

Did you try with older addons, manually adding them to addons folder.


(Ben) #696

I tried org.openhab.binding.amazonechocontrol-2.3.0_RC3.jar

Where could I get hold of SNAPSHOT?

(Cadbures) #697

Hi bezibaerchen,

get it from here


(Ben) #698

Thanks for sharing. No luck with them either :frowning:

(Cadbures) #699

Only Difference i see is in your Java Version
Java HotSpot™ 64-Bit Server VM (build 25.171-b11, mixed mode)

Mine is java version “1.8.0_171”
Java™ SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot™ Client VM (build 25.171-b11, mixed mode)


(Ben) #700

I now went to OH 2.4 Snapshot with 2.4 version of binding. Same issues…

(Jason Wiseman) #701

Hi Mark,

Thanks for your reply; I did learn some things from your post about setting volume from what it was set to and pausing the player first. Good stuff . . .

What I’m looking for is actually how to send commands to Alexa via OH2 which intern controls Alexa connected devices.

My example is I say to Alexa, “turn on fans” which means it will turn on all the fans in the house.

I want to send this command to Alexa and it actually executes the command (not necessary speaks it, but actually does the command as if I asked it to).

Best, Jay

(Thomas) #702

@jwiseman: Here’s a couple ways to do it.

Method 1. Create “Routines” using the Amazon Alexa Mobile app.

Following your example, you would name a routine that turns on the fans and another that turns them off. Any devices registered in your Amazon account would be available to the routine, so each routine can control multiple fans.

Along with naming the routines in the mobile app, you also need to define the echo devices in your .items file and add the control actions to your .rules file. In your rules file you would use the Alexa Binding’s “startRoutine” command.

Method 2. Use the Hue Emulation Binding.
The Hue Emulation binding will allow you to use Alexa to control your devices. It’s what I use – Works great, very flexible, and not difficult to implement. The OpenHab2 docs has all the details.

  • Thomas

(Jason Wiseman) #703

Hi Thomas,

Thank you very much for this! I choose Method 1 and here’s the final product:

rule “Alexa Turns Fans ON”
Item All_Fans_Switch changed from OFF to ON
logInfo(“Status”, “ALEXA: Sets All Fans to ON”)
// Sets Echo Volume
val current_volume_echo = Echo_Living_Room_Volume.state as Number

    Echo_Living_Room_StartRoutine.sendCommand('turn routine fans on')
	Thread::sleep(2000)  // 2 second wait

	// Set individual fan states


Thank you again!

(Thomas) #704

You are welcome! It’s great to know it is working.

  • Thomas

(Jason Wiseman) #705

Monitoring Amazon Connection?

Has anybody wrote a script to monitor if the Amazon connection is connected OK to the binding?

it would be nice to get an email knowing that we need to log back into your Amazon account after a reboot or cleanup of the cache/tmp directories.

Monitoring = http://openhab:8080/amazonechocontrol/account1

Best, Jay

(Philipp) #706

Fantastic work! I’ve been using this binding for a few days now and I’m just thrilled.:grinning:

However, I have a problem with the PlayAlarmSound feature. No alarms are played. I have already tried several devices, but to no avail. An error message is not displayed in the logs.

Could you please give me a hint how to identify this problem?


(Thomas) #707


Check PaperUI->Configuration->items and confirm that all your declared Play Alarm Sound items are present.

Also check PaperUI->Configuration->Things and confirm all echo devices and the Amazon account are online.

For further help I suggest you post your .item and .rule code statements for the Play Alarm Sound items.

  • Thomas

(Philipp) #708

@Thomas: Thanks for your support! Here is my configuration:

OpenHAB Version:                 2.4.0 Build #1305
AmazonEchoControl Version:       2.4.0.SNAPSHOT


Bridge amazonechocontrol:account:account1 "Amazon Account" @ "Accounts" [amazonSite="", email="", password="Secret", pollingIntervalInSeconds=30]
    Thing echo                  LR_Echo             "Alexa"                     @ "Living Room"     [serialNumber="ABC"]
    Thing echo                  OF_Echo             "Alexa"                     @ "Office"          [serialNumber="DEF"]
    Thing echo                  BD_Echo             "Alexa"                     @ "Bedroom"         [serialNumber="GHI"]
    Thing echo                  BA_Echo             "Alexa"                     @ "Bathroom"        [serialNumber="JKL"]
    Thing wha                   APT_EchoMusicGroup  "Ground Floor Music Group"  @ "Music Groups"    [serialNumber="MNO"]
    Thing flashbriefingprofile  flashbriefing1      "Flash Briefing"            @ "Flash Briefings"


String  LR_EchoLivingRoom_PlayAlarmSound  "LR Echo Living Room Play Alarm Sound [%s]"  <siren> (gLR_Echo) {channel="amazonechocontrol:echo:account1:LR_Echo:playAlarmSound"} 
String  OF_EchoOffice_PlayAlarmSound      "OF Echo Office Play Alarm Sound [%s]"       <siren> (gOF_Echo) {channel="amazonechocontrol:echo:account1:OF_Echo:playAlarmSound"}


rule "Test Alarm"
    Item LR_MotionSensor changed to ON
    logWarn("test", "play alarm")


2018-07-01 22:10:41.190 [WARN ] [.eclipse.smarthome.model.script.test] - play alarm
2018-07-01 22:10:41.189 [ome.event.ItemCommandEvent] - Item 'OF_EchoOffice_PlayAlarmSound' received command ECHO:system_alerts_repetitive01
2018-07-01 22:10:41.207 [vent.ItemStateChangedEvent] - OF_EchoOffice_PlayAlarmSound changed from  to ECHO:system_alerts_repetitive01

As I said, I get no error message and the echo remains silent :no_mouth:. Other features like TTS work fine. So the account setup seems to be ok. The internal login page (https://hab:8080/amazonechocontrol/account1) confirms that. Also the PaperUI status for all echo things and items looks fine.

Any ideas?