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

development
binding
alexa
Tags: #<Tag:0x00007f15d6e36668> #<Tag:0x00007f15d6e36500> #<Tag:0x00007f15d6e363c0>

(Michael Geramb) #790

No

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


(Scott Rushworth) #791

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.


(Scott Rushworth) #792

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.


(George) #793

@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”}

`


(illnesse) #794

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


(Andrew Pawelski) #795

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


(George) #796

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


(Scott Rushworth) #797

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!


(Michael Geramb) #798

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


(Karen Mitchell) #799

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

(Michael Geramb) #800

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


(Karen Mitchell) #801

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)

(Michael Geramb) #802

Hi, sorry, there exist no STOP command. The player have a PAUSE command. OFF should work too (But makes no difference to alexa, both sent the same command).

sendCommand(Office_Echo_Player,PAUSE)

(Karen Mitchell) #803

That worked! Thank you!! I LOVE your binding!!


(omatzyo) #804

I’m having trouble with the bata version above. I use 2 factor authentication. After I’ve logged in using the captcha I get the following:

HTTP ERROR 404
Problem accessing /amazonechocontrol/account1/ap/signin. Reason:

    Not Found

Amazon does still send me the code to enter, but I have nowhere to put it.

This is not a problem with the previous release.


(M) #805

Is it possible to increase the alarm sound volume?

amazonechocontrol:echo:account1:echo1:volume is for the normal sound volume, isn’t it?


(KHONE) #806

Hi i have a Problem since a few days. TTS isn´t working anymore. Get the Error Message:
17:14:12.546 [ERROR] [rnal.common.AbstractInvocationHandler] - An error occurred while calling method ‘ThingHandler.handleCommand()’ on ‘org.openhab.binding.amazonechocontrol.handler.EchoHandler@521c6174’: POST url ‘https://alexa.amazon.de/api/behaviors/preview’ failed: Bad Request
org.openhab.binding.amazonechocontrol.internal.HttpException: POST url ‘https://alexa.amazon.de/api/behaviors/preview’ failed: Bad Request
at org.openhab.binding.amazonechocontrol.internal.Connection.makeRequest(Connection.java:404) [245:org.openhab.binding.amazonechocontrol:2.4.0.201808172154]
at org.openhab.binding.amazonechocontrol.internal.Connection.executeSequenceCommand(Connection.java:727) [245:org.openhab.binding.amazonechocontrol:2.4.0.201808172154]
at org.openhab.binding.amazonechocontrol.internal.Connection.textToSpeech(Connection.java:685) [245:org.openhab.binding.amazonechocontrol:2.4.0.201808172154]
at org.openhab.binding.amazonechocontrol.handler.EchoHandler.handleCommand(EchoHandler.java:420) [245:org.openhab.binding.amazonechocontrol:2.4.0.201808172154]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:?]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:?]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [94:org.eclipse.smarthome.core:0.10.0.201808011124]
at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [94:org.eclipse.smarthome.core:0.10.0.201808011124]
at com.sun.proxy.$Proxy216.handleCommand(Unknown Source) [245:org.openhab.binding.amazonechocontrol:2.4.0.201808172154]
at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:75) [101:org.eclipse.smarthome.core.thing:0.10.0.201808011124]
at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:49) [101:org.eclipse.smarthome.core.thing:0.10.0.201808011124]
at sun.reflect.GeneratedMethodAccessor156.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:?]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:?]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [94:org.eclipse.smarthome.core:0.10.0.201808011124]
at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [94:org.eclipse.smarthome.core:0.10.0.201808011124]
at java.util.concurrent.FutureTask.run(Unknown Source) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:?]
at java.lang.Thread.run(Unknown Source) [?:?]

have somebody any ideas how to fix this?


(Chris) #807

Hey guys,

for whatever reason the account thing is repeatedly signing out of Amazon. I notice as I all of a sudden repeatedly receive two factor verification SMS and at the same time Alexa related things are no longer reachable via my echo spot (naturally).

Works again after signing in for a day or two, then it signs out again. Any solutions available in the mean time? For me this issue simply kills this binding, sadly. Would it be worth a try to create a dummy Amazon account and use it to log in to the binding, thus cancelling out the possibility of causing it to lose the session when one logs into the same Amazon account from a different device?


(Ben) #808

Hi, there is no solution. Obviously not everyone has this issue. For me the binding is not really usable because of this issue too. I did ask for help several times in the past, but there is not a real solution. My binding is sometimes going back to online after it stayed offline for days, just because I dont care about the binding any more.


(Michael Geramb) #809

Hi, I’am wondering that it have ever worked with 2 factor authentication. Because I assume that the binding can not renew the session token after 5 days.

After I’ve logged in using the captcha I get the following:

HTTP ERROR 404
Problem accessing /amazonechocontrol/account1/ap/signin. Reason:

    Not Found

You are using the current beta version now? Have you tried to go back to the official release? What happens there?