Release Candidate and Support: Amazon Echo Control Binding

May this help to solve the UNDEF volume issue:
I just noticed today that only Echo devices have the volume set to UNDEF: Echo Dot devices show the right volume level from the beginning.

I experience incorrect character encoding with Amazon Echo binding. See how the list of devices is shown (should be Deuxième étage and Rez-de-chaussée).

Any text coming from Amazon has this incorrect character set (name of songs, radios…). Any idea what is causing this issue? I read about UTF8 / ISO8859-1 charset issue…

@michi
Does the TTS feature fully support the SSML? This would help customizing a bit the speech of Alexa which terrible :alien: by default (at least in French)
See Amazon Alexa SSML reference
How should text be formatted to include the tags?

Hi everybody,

i’ve created a new thread since i’m having issues with the playMusicVoiceCommand.
But since my original thread went quite down on the list, i’ve decided to ask here:

Does anybody have an idea why the playMusicVoice command results in a bad request?
TTS is working.

Hello,

I was trying to install this binding to my openhab installation and I’ve got several errors. In the beginning it was one of the errors received by other users (No session id received), and then I decided to use nightly build (still the same No session id received).

Then I decided to change the java version from the Zulu8 (embedded in openhabian) to the oracle one.

After I did that I now get the login page time to time, but when I get it and I try to login (with captcha which always happens) I get the following error (got from the debug on openhab2)

My version is:
ii openhab2 2.4.0~20180802110936-1 all openhab2

[12:32:59] openhabian@openHABianPi:~$ java -version
java version “1.8.0_181”
Java™ SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot™ Client VM (build 25.181-b13, mixed mode)

12:25:06.738 [DEBUG] [amazonechocontrol.internal.Connection] - Login query String: appActionToken=cDh1qaJTenNVWr5oSK3JjZrDiu8j3D&appAction=SIGNIN&showRmrMe=ape%3AMQ%3D%3D&openid.return_to=ape%3AaHR0cHM6Ly9hbGV4YS5hbWF6b24uY29tLw%3D%3D&prevRID=ape%3AUEtWQlZCRUcyV1gzQUNSUU1RU1Y%3D&openid.identity=ape%3AaHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvYXV0aC8yLjAvaWRlbnRpZmllcl9zZWxlY3Q%3D&openid.assoc_handle=ape%3AYW16bl9kcF9wcm9qZWN0X2RlZQ%3D%3D&openid.mode=ape%3AY2hlY2tpZF9zZXR1cA%3D%3D&failedSignInCount=ape%3AMA%3D%3D&openid.claimed_id=ape%3AaHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvYXV0aC8yLjAvaWRlbnRpZmllcl9zZWxlY3Q%3D&pageId=ape%3AYW16bl9kcF9wcm9qZWN0X2RlZQ%3D%3D&openid.ns=ape%3AaHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvYXV0aC8yLjA%3D&showPasswordChecked=false&session-id=131-5145053-5932232
12:25:06.799 [DEBUG] [amazonechocontrol.internal.Connection] - Make request to https://www.amazon.com/ap/signin
12:25:06.911 [WARN ] [.eclipse.jetty.servlet.ServletHandler] - /amazonechocontrol/echo/ap/signin
java.lang.IllegalArgumentException: Empty cookie header string
at java.net.HttpCookie.parseInternal(HttpCookie.java:826) [?:?]
at java.net.HttpCookie.parse(HttpCookie.java:202) [?:?]
at java.net.HttpCookie.parse(HttpCookie.java:178) [?:?]
at org.openhab.binding.amazonechocontrol.internal.Connection.makeRequest(Connection.java:366) [208:org.openhab.binding.amazonechocontrol:2.4.0.201808020834]
at org.openhab.binding.amazonechocontrol.internal.AccountServlet.HandleProxyRequest(AccountServlet.java:453) [208:org.openhab.binding.amazonechocontrol:2.4.0.201808020834]
at org.openhab.binding.amazonechocontrol.internal.AccountServlet.doPost(AccountServlet.java:160) [208:org.openhab.binding.amazonechocontrol:2.4.0.201808020834]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) [24:javax.servlet-api:3.1.0]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [24:javax.servlet-api:3.1.0]
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:848) [78:org.eclipse.jetty.servlet:9.3.21.v20170918]
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:584) [78:org.eclipse.jetty.servlet:9.3.21.v20170918]
at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71) [175:org.ops4j.pax.web.pax-web-jetty:6.0.9]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [77:org.eclipse.jetty.server:9.3.21.v20170918]
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) [75:org.eclipse.jetty.security:9.3.21.v20170918]
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226) [77:org.eclipse.jetty.server:9.3.21.v20170918]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180) [77:org.eclipse.jetty.server:9.3.21.v20170918]
at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:284) [175:org.ops4j.pax.web.pax-web-jetty:6.0.9]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512) [78:org.eclipse.jetty.servlet:9.3.21.v20170918]
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) [77:org.eclipse.jetty.server:9.3.21.v20170918]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112) [77:org.eclipse.jetty.server:9.3.21.v20170918]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [77:org.eclipse.jetty.server:9.3.21.v20170918]
at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80) [175:org.ops4j.pax.web.pax-web-jetty:6.0.9]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134) [77:org.eclipse.jetty.server:9.3.21.v20170918]
at org.eclipse.jetty.server.Server.handle(Server.java:534) [77:org.eclipse.jetty.server:9.3.21.v20170918]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:333) [77:org.eclipse.jetty.server:9.3.21.v20170918]
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251) [77:org.eclipse.jetty.server:9.3.21.v20170918]
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:283) [69:org.eclipse.jetty.io:9.3.21.v20170918]
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:108) [69:org.eclipse.jetty.io:9.3.21.v20170918]
at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93) [69:org.eclipse.jetty.io:9.3.21.v20170918]
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303) [80:org.eclipse.jetty.util:9.3.21.v20170918]
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148) [80:org.eclipse.jetty.util:9.3.21.v20170918]
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136) [80:org.eclipse.jetty.util:9.3.21.v20170918]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671) [80:org.eclipse.jetty.util:9.3.21.v20170918]
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589) [80:org.eclipse.jetty.util:9.3.21.v20170918]
at java.lang.Thread.run(Thread.java:748) [?:?]
12:25:07.913 [DEBUG] [amazonechocontrol.internal.Connection] - Call to https://www.amazon.com/ap/signin succeeded
12:25:08.108 [DEBUG] [amazonechocontrol.internal.Connection] - Received content after login

Hi schaze,
I assume this is because there is an dynamic state description provider for these channels. But I don’t know any solution for this problem.
Regards,
Michael

Beta 2.4 (1) Version

Hi everybody,

I found a little bit time to prepare a new beta version. I have refactored the connection handling, so that I’am sure that no old connection can left in the memory. I do not know, if this fix any of the problems, because I do not have any problems in my installation.

I also tried to fix the “java.lang.IllegalArgumentException: Empty cookie header string” error.
I also do not know if this fix anything else, because I have never seen this problem in my installation.

And last but not least I tried to fix the problem with UNDEF volumn.

The download link can be find in the top most posting in this thread.

I also have added a feature for people with technical background know how:

It’s now possible to call all alexa api calls thought a http proxy which adds the session cookies.

Just use the url http(s)://[youropenhab]/amazonechocontrol/PROXY/[accountid]/ as prefix.

E.g. to get the latest commands spoken to alexa: http://localhost:8080/amazonechocontrol/account1/PROXY/api/activities?size=5&offset=0

E.g. to get all timers:
http://localhost:8080/amazonechocontrol/account1/PROXY/api/notifications

Maybe anybody else can provide a sample, how this can be used in a rule

The proxy server supports also PUT and POST verbs.

Regards,
Michael

1 Like

Will this also be in the snapshots? And thank you!

From experience with zwave, this is not correct. To update the Thing definitions for unmanaged Things, temporarily remove the file and then put it back.

No

For me, it works without deleting of the thing file. Anyone else can confirm this?

My Things are all managed, but my understanding was based on this discussion, so I thought even the unmanaged Things needed to be deleted to get an updated definition.

With this version, I still get the 500 error when going to the URL and ‘No session id received’ in the log, along with some stack traces (truncated to the first line here)…

2018-08-10 11:44:37.356 [ERROR] [org.glassfish.jersey.server.ServerRuntime$Responder] - An I/O error has occurred while writing a response message entity to the container output stream.
2018-08-10 11:44:37.334 [WARN ] [org.openhab.binding.amazonechocontrol.internal.Connection] - Illegal json:

The second one contains this (some blank lines removed)

<div id="auth-alert-window" class="a-box a-alert a-alert-error" aria-live="assertive" role="alert"><div class="a-box-inner a-alert-container"><h4 class="a-alert-heading">There was a problem</h4><div class="a-alert-content">
  <ul class="a-unordered-list a-vertical auth-error-messages" role="alert">
    <li id="auth-email-missing-alert"><span class="a-list-item">
      Please provide your email-address or mobile phone number
    </span></li>

    <li id="auth-email-invalid-email-alert"><span class="a-list-item">
      Invalid email address or mobile phone number
    </span></li>

    <li id="auth-password-missing-alert"><span class="a-list-item">
      Please enter your password
    </span></li>

    <li id="auth-guess-missing-alert"><span class="a-list-item">
      Enter the characters as they are given in the challenge.
    </span></li>
  </ul>
</div></div></div>
<!-- show a warning modal dialog when the third party account is connected with Amazon -->
<form name="signIn" method="post" novalidate action="https://www.amazon.com/ap/signin" class="auth-validate-form auth-clearable-form">
      <input type="hidden" name="appActionToken" value="549wWQjgJmTcFXoj2BaTMW9t8kIk4j3D" /><input type="hidden" name="appAction" value="SIGNIN" />

Setting up X redirection on the server, and logging into alexa.amazon.com was successful. The URL also gave the 500 exception.

Which version of java are you running? I’m wondering if the CookieManager may not be working properly in OpenJDK. I’ve tried OpenJDK 1.80_181 and Zulu build 1.8.0_163-b01 with the same results (Login failed: No session id received).

EDIT: Never mind. I’ve tried Oracle, OpenJDK and Zulu. All get the same error.

@michi First of all thank you for bringing this addon into openhab! I have been able to get it to work and can control music on my echo dot. The challenge I am having is with routines. I would like to be able to control specific routines that I have already set up in Alexa via Habpanel. I have not been able to get them to work though. Can you help to provide some example code for different routines so I can see what code I maybe missing? Currently I have the code set up like this.

`

String Echo_Living_Room_StartRoutine “Turn On Movie Mode” (Alexa_Living_Room) {channel=“amazonechocontrol:echo:account1:echodot1:startRoutine”}

`

Still getting the captcha login issue with the new beta, 500 when trying to log in. Back to 2.4 snapshot for now

its a one liner once you have your item setup which you do…
Here’s my morning routine rule (where “Start my Day” is the name of the routine in the Alexa App) with a friendly good morning message before blasting into it:



rule "Morning Andrew"
	when
		Time cron "0 40 07 ? * MON-FRI"
	then
			Alexa_Living_Room_Speak.sendCommand('Good Morning Andrew')
			Thread::sleep(3000)
			Alexa_Living_Room_StartRoutine.sendCommand("Start my day")
end

1 Like

Thank you. I got working in Habpanel! Using the following method

//Turn On Movie Mode
rule “Movie Mode On”
when
Item movie_lights changed to ON
then
Echo_Living_Room_StartRoutine.sendCommand(‘Turn On Movie Mode’)

end

//Turn Off Movie Mode
rule “Movie Mode Off”
when
Item movie_lights changed to OFF
then
Echo_Living_Room_StartRoutine.sendCommand(‘Turn Off Movie Mode’)

end

I may have missed it, but I haven’t seen an explanation for the error ‘Login failed: No session id received’. It looks like Amazon is either being picky about the user-agent string provided or the lack of javascript, but for whatever reason, a Captcha is triggered that the binding can’t respond to. There is some interesting discussion in this issue in what I believe is the GH repo of the original script. I’m surprised that this binding is working for anyone, but maybe it is regional (I’m in the US).

I’m not sure why the YOUR_OPENHAB/amazonechocontrol page returns a 500 error, but if there is always a Captcha coming up, then I do not see how this binding would ever work on my system, until some other form of authentication can be implemented. Hope this helps someone before they spend hours trying to troubleshoot why this binding isn’t working for them!

Hi Scott,

The reason for this is unknown, but no all users have this problem. I got feedback for a working installation from amazon.com too, so this is not the reason.
It happens, if the login page is requested, but no session-id cookie is set. It would be nice if a experienced user with a litte development skills would work with me to find out the problem.

The captcha is not shown all the time, from the feedback I got, I seems that 10-20% of the get the captcha for the first login. After entering the captcha one time, the following login works without captcha, at least for the most users. It seems that amazon stores some information to detect that the same client makes the request.

Regards,
Michael

Is there a way to stop playing music after a period of time? I have the routine below, but I don’t know which command to use to stop the music.

rule "Play a playlist on Pandora"
when
    Time cron "0 58 10 ? * *"
then
    sendCommand(Office_Echo_Provider, 'PANDORA')
    sendCommand(Office_Echo_PlayMusic, 'Sleep Radio')
    pushover("Playing Radio")
    
    radio_timer = createTimer(now.plusMinutes(30)) [|
 		sendCommand(Office_Echo_PlayMusic,STOP)
 	radio_timer = null
 	
 	]
end

Yes, please use the player channel for the stop command

rule "Play a playlist on Pandora"
when
    Time cron "0 58 10 ? * *"
then
    sendCommand(Office_Echo_Provider, 'PANDORA')
    sendCommand(Office_Echo_PlayMusic, 'Sleep Radio')
    pushover("Playing Radio")
    
    radio_timer = createTimer(now.plusMinutes(30)) [|
 		sendCommand(Office_Echo_Player,STOP)
 	radio_timer = null 	
 	]
end

Not tested, but should work.
Regards,
Michael

Items file:

Player Office_Echo_Player       "Player"    {channel="amazonechocontrol:echoshow:<my redacted ID>:player"}

I’ve tried without any success.

sendCommand(Office_Echo_Player,'Stop')
sendCommand(Office_Echo_Player,STOP)
sendCommand(Office_Echo_Player, STOP)