Release Candidate and Support: Amazon Echo Control Binding

Tags: #<Tag:0x00007f616f295900> #<Tag:0x00007f616f295798> #<Tag:0x00007f616f295630>

I am trying to use Alexa as a TTS device to speak
A Flash Briefing Profile has been set through Inbox and is online, but it only contains Save and Active

Amazon Echo Control – Amazon show one online device of type VOX and one of type unknown

Alexa is installed on a Raspberry Pi 3 running Stretch
(https://developer.amazon.com/docs/alexa-voice-service/register-a-product.html)

alexa.items
String Echo_Living_Room_TTS “Text to Speech”
Switch Test2 “Test switch” (GF_LivingDining)

Alexa.rules
rule “Test switch Alexa speak”
when Item Test2 changed
then
sendCommand(Echo_Living_Room_TTS,“Hello World”)
end

When switch the switch Test2 I get a message saying
Offline: waiting for connection to become available
Oh and I am using OpenHAB 2.4

What am I doing wrong?

If you restart openhab ( sudo systemclt stop openhab2 then sudo systemctl start openhab2) and watch the logs do you see where your echo/Amazon device changes from offline to online? If not you may need to check your setup my reviewing the steps in first post.

I am not sure I have configured all correctly.
In Paper UI my Amazon account shows online and I have add a thing Amazon Echo it shows online
Is a Raspberry Pi with the Amazon AVS Sample to be configured as an Amazon Echo?

amazonechocontrol:account:385cc033’ changed from OFFLINE (CONFIGURATION_PENDING): Wait for login to ONLINE

If setup is correct something like this will be in the logs when Amazon goes online:
‘amazonechocontrol:account:account1’ changed from OFFLINE (COMMUNICATION_ERROR): alexa.amazon.com to ONLINE

Notice the difference in your log vs this one? “Wait for login to ONLINE” vs"changed from OFFLINE to ONLINE.

Check that you have completed the logon steps.

1 Like

Thank you for your time and reply.
This is my log when I reboot OpenHAB. I think maybe I did the configuration wrong.
Can you point me to an easy to understand guide.

2019-10-15 17:41:34.666 [vent.ItemStateChangedEvent] - AmazonEcho_MusicVoiceCommand changed from NULL to

2019-10-15 17:41:34.670 [vent.ItemStateChangedEvent] - AmazonEcho_Start changed from NULL to

2019-10-15 17:41:34.673 [vent.ItemStateChangedEvent] - AmazonEcho_Title changed from NULL to

2019-10-15 17:46:23.430 [hingStatusInfoChangedEvent] - ‘amazonechocontrol:flashbriefingprofile:385cc033:1’ changed from ONLINE to UNINITIALIZED

2019-10-15 17:46:23.434 [hingStatusInfoChangedEvent] - ‘amazonechocontrol:flashbriefingprofile:385cc033:1’ changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)

2019-10-15 17:46:23.437 [hingStatusInfoChangedEvent] - ‘amazonechocontrol:echo:76ecc72a’ changed from ONLINE to UNINITIALIZED

2019-10-15 17:46:23.441 [hingStatusInfoChangedEvent] - ‘amazonechocontrol:echo:76ecc72a’ changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)

2019-10-15 17:46:23.443 [hingStatusInfoChangedEvent] - ‘amazonechocontrol:flashbriefingprofile:e7331fe7’ changed from ONLINE to UNINITIALIZED

2019-10-15 17:46:23.447 [hingStatusInfoChangedEvent] - ‘amazonechocontrol:flashbriefingprofile:e7331fe7’ changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)

2019-10-15 17:46:23.450 [hingStatusInfoChangedEvent] - ‘amazonechocontrol:account:385cc033’ changed from ONLINE to UNINITIALIZED

2019-10-15 17:46:23.469 [hingStatusInfoChangedEvent] - ‘amazonechocontrol:account:385cc033’ changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)

2019-10-15 17:46:25.038 [temChannelLinkRemovedEvent] - Link ‘AmazonEcho_Start => amazonechocontrol:echo:76ecc72a:startCommand’ has been removed.

2019-10-15 17:46:25.074 [temChannelLinkRemovedEvent] - Link ‘AmazonEcho_MusicVoiceCommand => amazonechocontrol:echo:76ecc72a:playMusicVoiceCommand’ has been removed.

2019-10-15 17:46:25.116 [temChannelLinkRemovedEvent] - Link ‘FlashBriefing1_Save => amazonechocontrol:flashbriefingprofile:385cc033:1:save’ has been removed.

2019-10-15 17:46:25.176 [temChannelLinkRemovedEvent] - Link ‘AmazonEcho_Title => amazonechocontrol:echo:76ecc72a:title’ has been removed.

2019-10-15 17:46:25.227 [temChannelLinkRemovedEvent] - Link ‘FlashBriefing1_Active => amazonechocontrol:flashbriefingprofile:385cc033:1:active’ has been removed.

2019-10-15 17:47:37.346 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘amazonControls.items’

2019-10-15 17:47:57.847 [.ItemChannelLinkAddedEvent] - Link ‘AmazonEcho_Start-amazonechocontrol:echo:76ecc72a:startCommand’ has been added.

2019-10-15 17:47:57.892 [.ItemChannelLinkAddedEvent] - Link ‘AmazonEcho_MusicVoiceCommand-amazonechocontrol:echo:76ecc72a:playMusicVoiceCommand’ has been added.

2019-10-15 17:47:57.965 [.ItemChannelLinkAddedEvent] - Link ‘FlashBriefing1_Save-amazonechocontrol:flashbriefingprofile:385cc033:1:save’ has been added.

2019-10-15 17:47:58.053 [.ItemChannelLinkAddedEvent] - Link ‘AmazonEcho_Title-amazonechocontrol:echo:76ecc72a:title’ has been added.

2019-10-15 17:47:58.139 [.ItemChannelLinkAddedEvent] - Link ‘FlashBriefing1_Active-amazonechocontrol:flashbriefingprofile:385cc033:1:active’ has been added.

2019-10-15 17:48:01.908 [hingStatusInfoChangedEvent] - ‘amazonechocontrol:account:385cc033’ changed from UNINITIALIZED to INITIALIZING

2019-10-15 17:48:01.971 [hingStatusInfoChangedEvent] - ‘amazonechocontrol:account:385cc033’ changed from INITIALIZING to OFFLINE (CONFIGURATION_PENDING): Wait for login

2019-10-15 17:48:02.032 [hingStatusInfoChangedEvent] - ‘amazonechocontrol:flashbriefingprofile:385cc033:1’ changed from UNINITIALIZED to INITIALIZING

2019-10-15 17:48:02.045 [hingStatusInfoChangedEvent] - ‘amazonechocontrol:flashbriefingprofile:e7331fe7’ changed from UNINITIALIZED to INITIALIZING

2019-10-15 17:48:02.061 [hingStatusInfoChangedEvent] - ‘amazonechocontrol:flashbriefingprofile:385cc033:1’ changed from INITIALIZING to UNKNOWN

2019-10-15 17:48:02.074 [hingStatusInfoChangedEvent] - ‘amazonechocontrol:flashbriefingprofile:e7331fe7’ changed from INITIALIZING to UNKNOWN

2019-10-15 17:48:02.179 [hingStatusInfoChangedEvent] - ‘amazonechocontrol:echo:76ecc72a’ changed from UNINITIALIZED to INITIALIZING

2019-10-15 17:48:02.189 [hingStatusInfoChangedEvent] - ‘amazonechocontrol:echo:76ecc72a’ changed from INITIALIZING to UNKNOWN

2019-10-15 17:48:04.888 [hingStatusInfoChangedEvent] - ‘amazonechocontrol:flashbriefingprofile:e7331fe7’ changed from UNKNOWN to ONLINE

2019-10-15 17:48:04.959 [hingStatusInfoChangedEvent] - ‘amazonechocontrol:flashbriefingprofile:385cc033:1’ changed from UNKNOWN to ONLINE

2019-10-15 17:48:05.172 [hingStatusInfoChangedEvent] - ‘amazonechocontrol:echo:76ecc72a’ changed from UNKNOWN to ONLINE

2019-10-15 17:48:05.427 [hingStatusInfoChangedEvent] - ‘amazonechocontrol:account:385cc033’ changed from OFFLINE (CONFIGURATION_PENDING): Wait for login to ONLINE

2019-10-15 17:48:08.738 [vent.ItemStateChangedEvent] - AmazonEcho_MusicVoiceCommand changed from NULL to

2019-10-15 17:48:08.751 [vent.ItemStateChangedEvent] - AmazonEcho_Start changed from NULL to

2019-10-15 17:48:08.754 [vent.ItemStateChangedEvent] - AmazonEcho_Title changed from NULL to

Are you setting this up all via PaperUI or using text files? Sorry I haven’t reviewed the setup sets in some time so not sure what’s recommended but I use text files.

For text you will need a Things file with your Amazon info like this:

Bridge amazonechocontrol:account:account1 "Amazon Account" [amazonSite="amazon.com", email="youremail@yahoo.com", password="YOUR Secret Password ", pollingIntervalInSeconds=30]
{
    Thing echo    Echo_Plus      "Alexa Living Room" [serialNumber="G090LA097387653v2"]
}

I will take a look through the setup again and see what’s new. If your usesing Paper UI look for a place to enter password and such.

EDIT:
Looks like a Things file may not be needed and everything can be done via PaperUI but not 100% sure b/c scrolling down it show’s a Things file example.

Are you getting to the Amazon account login page, after creating the Amazon Thing Account, (where it allows you to log in and shows your devices with serial numbers and such)? You may need to enter the local IP address of your OH server for this page to open, e.g. http://10.0.1.20:8080/amazonechocontrol/account1

I am setting Amazon up via Paper UI and I was getting the Amazon account login page and found the serial number
Amazon Echo Control - Amazon

App name: Henrik’s Open HAB Alexa Binding
Connected to: https://alexa.amazon.com Change
Check Thing in Paper UI

Device Serial Number State Thing Type Family
Henrik’s Alexa through Cortana 4ca16d670cea471cbcf549eed49*** Offline Not defined HALO A2R2GLZH1DFYQO
This Device c17215bb3b5c4bdd9d7a2f0d7c*** Online Not defined VOX A2TF17PFR55MTB
Henrik’s AVS Tutorials Project b78d6e58d4474afeac324d5d83*** Online [Amazon Echo]serialNumber=b78d6e58d4474afeac324d5d83***) UNKNOWN A16T4CDGXSPJ3B

There is no feedback from amazon, so the binding can not show the state for running flash briefing

Sorry, I don’t understand the question. What is, what you want to do?

I expect, that you use an old version of the binding. Please download the version from the top most posting.

At least you can try it, but I’am not sure. Can the Rasperberry Pi with the Amazon AVS Sample be controlled from the Alexa App? If so, it should work.

Hi Michael, I am not quite sure what you mean by controlling from Alexa App. I am new in this Alexa area. If I ask (Raspberry Pi with Amazon AVS Sample) Alexa, how are you I can see the activity in my Android Alexa app. Is that what you mean? I can also ask Alexa (Raspberry Pi) to turn on something or what the temperature is using [ “CurrentTemperature” ] in items file.

Thanks @michi - I use a motion sensor in the bathroom to play lounge music on my echo when something moves in the room. Unfortunately, I can no longer listen to my Flash briefing because the motion sensor always interferes when I don’t intercept it. So there is probably no way to solve the problem at the moment?

I use jython rules, but here’s how I do it to operate my fans by just saying “turn on (or off) the fan” from a room. It can be adapted pretty easily to do whatever you want based on the echo name and command, as is pretty simple so should be easily converted to old style rule syntax. My echo devices are all set up with this format:

String Echo_Bedroom_LastVoiceCommand              "Echo Bedroom Last Voice Command"                     (GAlexa_LastCommand)       {channel="amazonechocontrol:echo:echo_account:xxxxxxxxxx:lastVoiceCommand"}

and my fans like this:

Dimmer      Bedroom_Fan_Speed_Dimmer     "Bedroom Fan"                           {channel="isy:fanlinc:isy_ap:xxxxxx:load2"}

Here’s the actual rule:

@rule("Alexa Last Command")
@when("Member of GAlexa_LastCommand received update")
def alexaLastCommandEvent(event):
    #ignore groups
    if str(ir.getItem(event.itemName).type) == "Group":
        return
    #get "room" name, i.e. Echo_Bedroom_LastVoiceCommand becomes Bedroom
    echoName = event.itemName.replace("Echo_","").replace("_LastVoiceCommand","")
    echoCommand = event.itemState.toString()

    if echoCommand == "turn on the fan":
        events.sendCommand(echoName + "_Fan_Speed_Dimmer","100")
    elif echoCommand == "turn off the fan":
        events.sendCommand(echoName + "_Fan_Speed_Dimmer","OFF")

Edit:
I also needed to create dummy “turn on the fan” and “turn off the fan” routines so Alexa wouldn’t complain that it didn’t know what to do. Mine just have a switch called “AlexaDoNothing” that isn’t linked to anything that the routine just toggles on and off, but you can have it do anything you want like say something.

1 Like

Wow!
That’s just great!
I hope i will be able to adapt! I’ll give it a shot in the near future!
At the moment i have a CPU load issue i have to identify …

This looks very promising as I’ve been attempting to do this for a while.

I have the lastVoiceCommand in the Items files as shown in your example (obviously for my echo devices!) I.e:

String   Echo_Kitchen_LastVoiceCommand            "Last Voice Command"                                             (GAlexa_LastCommand)            { channel="amazonechocontrol:echo:account1:XXXXXXXXXXXXXXXX:lastVoiveCommand"}

also have added (for testing)

// Dummy Items so Alexa does not complain that it doesn't know what things are!
Switch Television "Dummy Television" [ "Switchable" ]

can you assist in how the following is ‘converted’ to a rule type code?

def alexaLastCommandEvent(event):
    #ignore groups
    if str(ir.getItem(event.itemName).type) == "Group":
        return
    #get "room" name, i.e. Echo_Bedroom_LastVoiceCommand becomes Bedroom
    echoName = event.itemName.replace("Echo_","").replace("_LastVoiceCommand","")
    echoCommand = event.itemState.toString()

Thank you.

Should have tried working it out really before asking the questions - was just being lazy!!

Here is the ‘converted’ code:

rule "Amazon Echo Last Command"
when
	Member of GAlexa_LastCommand received update	
then
	logInfo("amazonEcho.rules","Last Command triggered!" + triggeringItem.name)
	
    //get "room" name, i.e. Echo_Bedroom_LastVoiceCommand becomes Bedroom
    var echoName = triggeringItem.name.split("_").get(1)
    var echoCommand = triggeringItem.state.toString()

	logInfo("amazonEcho.rules","echoName: " + echoName + ", echoCommand: " + echoCommand)
end

have changed the .relace functions with .get as all my devices are set up as Echo_PlaceName_Command so .get(1) seems a bit easier to me than replacing the ‘Echo’ and the ‘Command’ parts.

Heads up. I made a working countdown timer for the next timer channel to display in HabPanel. I could use some help tidying up the rule. All the details are in this post: [Solved] Amazon Echo Binding: Next Timer Channel - Create a visual timer countdown for Habpanel like echo show

New beta version with new features: Preview and Beta: Amazon Echo Control
Best,
Michael

Love your work on this binding. One of the most useful bindings for me! Is there any news on when lists might become supported?

Be so awesome to be able to see items on your shopping list :grin:

1 Like