Release Candidate and Support: Amazon Echo Control Binding

Hello, I get the following picture when setting up AmazonEchoControl when I click on Login. What can I do there?
tmp and cache already deleted, no change.

yes many thanks that worked now

Just FYI, My net seems to have gone down last night and as a result the echo control binding was spamming errors & warnings like crazy, over 1000 failed connection attemtps and related log messages for about 2 hours straight.

2018-12-06 03:15:01.294 [WARN ] [mazonechocontrol.internal.Connection] - Request to url 'https://alexa.amazon.de/api/device-notification-state' fails with unkown error
java.net.UnknownHostException: alexa.amazon.de

2018-12-06 03:15:01.598 [WARN ] [mazonechocontrol.internal.Connection] - Request to url 'https://alexa.amazon.de/api/ascending-alarm' fails with unkown error
java.net.UnknownHostException: alexa.amazon.de

2018-12-06 03:15:01.694 [INFO ] [mazonechocontrol.internal.Connection] - Error getting device notification states {}
java.net.UnknownHostException: alexa.amazon.de

2018-12-06 03:15:01.772 [WARN ] [mazonechocontrol.internal.Connection] - Request to url 'https://alexa.amazon.de/api/bluetooth?cached=true' fails with unkown error
java.net.UnknownHostException: alexa.amazon.de

etc…
Memory usage went through the roof as well, see

The yellow block is the 2 hours worth of warning spam, during which the OH2 memory consumption climbed up to 900MB (from around 600MB, which is normal for my RasPi 3B+) Any chance of getting the requests a bit under control if there is no working internet connection?

Please define it as echo thing and give me feedback which channels are workung

1 Like

Is it possible to add the “DontDisturb”&“Disturb” commands somewhere in this binding?
Maybe with the “startCommand” channeltype?

How do you add the latest version after the .jar is downloaded? Thanks in advance

Hi,

I downloaded the latest Beta (org.openhab.binding.amazonechocontrol_2.4.0.201812011454.jar) and installed it. Now the amazon-Login-Screen appears when I go to amazonechocontrol. Unfortunately it comes up with an error after I log in. The link looks like (I modified some values - e. g. my token):

https://www.amazon.com/ap/maplanding?openid.assoc_handle=amzn_dp_project_dee_ios
&aToken=xxx
&openid.claimed_id=https%3A%2F%2Fwww.amazon.com%2Fap%2Fid%2Famzn1.account.xxx
&openid.identity=https%3A%2F%2Fwww.amazon.com%2Fap%2Fid%2Famzn1.account.xxx
&openid.mode=id_res
&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0
&openid.op_endpoint=https%3A%2F%2Fwww.amazon.com%2Fap%2Fsignin
&openid.response_nonce=2018-12-07T06%3A52%xxx
&openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fap%2Fmaplanding
&openid.signed=assoc_handle%2CaToken%2Cclaimed_id%2Cidentity%2Cmode%2Cns%2Cop_endpoint%2Cresponse_nonce%2Creturn_to%2Cns.pape%2Cpape.auth_policies%2Cpape.auth_time%2Coa2.access_token%2Coa2.token_type%2Coa2.scope%2Ccaptcha_verified%2Csigned
&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0
&openid.pape.auth_policies=http%3A%2F%2Fschemas.openid.net%2Fpape%2Fpolicies%2F2007%2F06%2Fnone
&openid.pape.auth_time=2018-12-07T06%3A52%3A27Z
&openid.sig=xxx
&serial=
&openid.oa2.access_token=xxxx
&openid.oa2.token_type=bearer
&openid.ns.oa2=http%3A%2F%2Fwww.amazon.com%2Fap%2Fext%2Foauth%2F2
&openid.oa2.scope=device_auth_access
&captcha_verified=1&

The page is saying:

Looking for Something?
We’re sorry. The Web address you entered is not a functioning page on our site

Any idea?

Regards,
Flip

PS: I’m located in DE but the link above shows amazon.com

Hi Paul,

just put the .jar-file in the addons-folder ( you can find an overview of the file structure here: https://www.openhab.org/docs/installation/linux.html#file-locations ). Then I changed the owner (chown openhab:openhab xxx.jar) and set rights to rw/rw/r (chmod 664 xxx.jar). Afterwards I restarted openhab. Please not that the Binding will not appear in Addons-section of Paper-UI. But if you look into the Bindings, you can see it.

If you wanna be sure, you can check console:

openhab-cli console
(default password is habopen)

bundle:list -s

and watch out for the Active Binding.

Regards,
Flip

@michi

Can Echo be an audio sink (so I can use playSound)?

No, only the predefined alarm sounds can be played.

That part is ok, the app login goes always to amazon.com. It seem that for some users the proxy server of the binding can not replace all urls and so it ends on the amazon server. Could you make the login again and save the html-pages of all login steps. If the url in the browser switch from your openhab to amazon, I would need the page before (Please remove private informations or sent it as PN).

I upgraded to the latest beta by placing the jar file into the addons folder.
The account Thing is not created. How do I create it?

Thank you!

Never mind, just found it. Simply add it with the + symbol in the inbox menu
Sorry!

This would be possible, but it is not yet implemented in the binding. But it should be possible to do it with a rest call (not tested) to the proxy server of the binding.

PUT http(s)://<youropenhab:yourport>/amazonechoncontrol/<youraccountthingid>/PROXY/api/dnd/status

e.g.: http://localhost:8080/amazonechoncontrol/account1/PROXY/api/dnd/status

with the json:
{"deviceSerialNumber":"XXXXXXXXXXXXXX","deviceType":"XXXXXXXXXXXXXX","enabled":true}

The device type and serial can you get from this page http(s)://<youropenhab:yourport</amazonechoncontrol/<youraccountthingid>

Would be nice to get feedback if this is working.

Hi Rainer,

The problem for this is, I have no good idea how this information can be provided in channel. Do you have any suggestion?

But you could use a REST call to get the informations about alarms.

http(s)://<youropenhab:<yourport>/amazonechocontrol/<youraccountid>/PROXY/api/notifications

e.g.:
http://localhost:8080/amazonechocontrol/account1/PROXY/api/notifications

Best regards,
Michael

Hello All,

The BETA 2.4 (9) is now merged in the master and is included in the daily snapshot builds starting from today.

Best regards,
Michael

4 Likes

thx for your answer. i am happy, that there could be a way to do this.

i tried to test this. But POST requests (in a external tool) are not so easy like GET in browser i guess, because of session-handling…

So i figured out a way, to do POST-requests in chrome-browser.

I typed in chrome-console:

fetch('http://openhab:8080/amazonechocontrol/[myaccountid]/PROXY/api/dnd/status', {
method: 'POST',        
headers: {
  'Accept': 'application/json',
  'Content-Type': 'application/json'
    },
body: JSON.stringify({deviceSerialNumber: '[myserial]', deviceType: 'ECHO', enabled: true})
   })
.then(function(res){ console.log(JSON.stringify(res.data)) })

but i got a error 500 back…in postman and also in chrome…hmmm

No, session handling is done by the binding proxy. But yes, you can not make a simple POST in the browser without any tool. My favorite tool is postman.

The deviceType is wrong. Echo is the type in my binding. It must be the code from amazon shown in the family column in the binding.

No for me because I’am not a java expert. But maybe anyone else can take a look in the code: https://github.com/openhab/openhab2-addons/blob/master/addons/binding/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java

The requests are started in the makeRequest function in line 411. Or the websocket connection https://github.com/openhab/openhab2-addons/blob/master/addons/binding/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/WebSocketConnection.java

But none of them should cause memory leaks.

1 Like