I broke down and took advantage of the Sears PM on Echo earlier this week and used my SYW point to get an Echo for $71. I don’t mind a few seconds delay and I’m not sure if the local hub solution will interfere with the physical HUE hub I already have. I’ll give your baby a try and see how it goes. Thanks for your effort.
I recorded a video of me turning lights on and off to show the speed in case anyone is unsure what delay people are referring to;
In the video I am actually turning a group of 3 light on and off - grouped on the Echo app, not on the Vera. The speed of turning a single light on and off is about the same, which says to me that the response time is mainly due to the echo processing your speech, rather than the time it takes to talk to your Vera.
Martin
I’ve updated the github page with full instructions for using the integration with Login For Amazon - that’s the mode where you don’t have to be running anything yourself - it’s all in Amazon’s free cloud.
Martin
Thanks for your efforts here Martin! Honestly… It doesn’t feel much slower than the bridge. Maybe a Sec or Two. I’m sure like others… my only complaint with the Bridge is the constraint of having to use “Turn On/Off” for every device. If the Amazon Gods allow full intergration where you can control using natural commands… using the cloud will be more attractive.
[quote=“martin12345, post:23, topic:189448”]I’ve updated the github page with full instructions for using the integration with Login For Amazon - that’s the mode where you don’t have to be running anything yourself - it’s all in Amazon’s free cloud.
Martin[/quote]
Thanks Martin for all your work on this!
I would suggest updating the first post that mentions OAuth to reflect this so those reading the thread, which will inevitably get longer, don’t give up when you suggest standing up an OAuth server.
Martin,
I’m rookie when it comes to development work. I’ve been looking at this all day and I’m stuck on creating the Alexa skill and what to do in the Interaction Model section. Can you share some samples or did I miss where those samples are? I’m attempting to use 100% amazon cloud and not run the oauth server. Thank you in advance!
UPDATE: I read over everything again… This is a connected home device we are setting up not a skill. Amazon has added the device to my Vera. Now I just need to figure out what’s wrong in the script I’m using from Martin.
[quote=“martin12345, post:1, topic:189448”]I have written a full Amazon Echo integration for the Vera - i.e. it gets added as a Device Link, and the devices can be controlled just by saying “Alexa, turn Living Room on” and so on. It doesn’t require you to be running any local server like the bridge solution. There’s a video of it in action here;
At the moment Amazon aren’t letting hobbyist developers push their code out to everyone, but instead tell us to share the code and then other people can copy it and request that it be added to their accounts. You can find the code and full instructions for doing that here if you are interested in doing the same thing yourself;
One thing to be aware of is that Amazon insist on login going through an OAuth server. Vera doesn’t support OAuth, so you can set up your own OAuth server to hold credentials, or use Login For Amazon and hard code the credentials. I deployed my own and configured it to link to Vera. You could in principle use my OAuth server, but that does mean you store your (encoded) connection details on my database. I’m trustworthy, but I’m not sure I would trust a stranger with my connection details if it was me, so you probably want to set up your own. If you are happy using mine then e-mail me at martin at milliesoft dot co dotuk for connection details.
Martin[/quote]
Martin,
I’m attempting to use your Lambda Function “alexa_lambda_amazon_oauth.js”. For now it’s failing likely due to my mistake. What all do I need to update in this function to have it use Login with Amazon and successfully connect to my Vera?
Have a look at the instructions at GitHub - mmillmor/AmazonEcho-to-Vera: Native Echo to Vera integration. They have steps and a different file for using Amazon as the OAuth. If you already tried those, what is the error that you are you hitting?
Martin
Martin,
I followed the instructions to the best of my abilities. I saw there was mention of embedding the oauth token into the script which I know I have not done which I’m suspecting is my issue. The only thing I’ve updated in the script is the hashed username and password. What I find in the logs is here;
discovery for accessToken (bunch of different characters follow here)
then
2016-01-15T19:53:31.547Z a6195b41-bbc1-11e5-9357-673486feb843 SyntaxError: Unexpected token W at Object.parse (native) at /var/task/index.js:350:25 at IncomingMessage. (/var/task/index.js:424:40) at IncomingMessage.emit (events.js:117:20) at _stream_readable.js:944:16 at process._tickCallback (node.js:442:13)
You don’t need to embed the oauth token in the script- it’s something that gets passed in from Amazon (and then never gets used in the script because it uses the encrypted password instead.
The error in the code is that the incoming message from the vera is not valid (line 350 is parsing the response from the first call to get . That would happen if you didn’t have your username and password right. You didn’t put your actual password in the script did you? You need to put your encoded password in the file.
Martin
I tried various combinations using the html page you provided to create a hash password. I wasn’t sure if I should include the username when generating the hash or not. Here are a couple of ways I’ve tested inputting the username and password and the results I got;
Example Username = testaccount1
Example Password = testpassword1
Example 1
HTML Page
Username = (I left this blank)
Password = eXample1
Lambda lines 12 and 13
var username=“testaccount1”;
var password=“57ef218c1b7666b671fbae000100a59048b1486d”;
Example 2
HTML Page
Username = testaccount1
Password = eXample1
Lambda lines 12 and 13
var username=“testaccount1”;
var password=“6f584a84799bd8f52c9964759c5b6168a9e22fdf”;
Following example 1 I get;
2016-01-15T22:42:29.265Z 4180dedd-bbd9-11e5-9216-977aad87fe00 SyntaxError: Unexpected token E
at Object.parse (native)
at IncomingMessage. (/var/task/index.js:381:27)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16 at process._tickCallback (node.js:442:13)
Following example 2 I get;
2016-01-15T22:45:16.695Z a4f895b7-bbd9-11e5-946d-756283e77d9d SyntaxError: Unexpected token W
at Object.parse (native)
at /var/task/index.js:350:25
at IncomingMessage. (/var/task/index.js:424:40)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16 at process._tickCallback (node.js:442:13)
Example 1 is wrong. You need to give the username and password to generate the hashed password. The response given (unknown character E at line 381) is the the response “ERROR:No data” not parsing correctly. Example 2 is the one that should work (the string you have is correct for the example usename and password).
With example 2, the error is also that the response coming back from the vera service is not understood as a valid message, and when we try to parse it, it gives an error . This time the error is coming back saying that it can’t get the list of your veras. To see why, can you edit the code at line 350. That line is
var Devices = JSON.parse(deviceTable);
immediately before that line, add the line;
log(“getDevices”,"About to parse: " + deviceTable);
That will show us the full string it is trying to parse (presumably an error from MCV). That should help me to tweak the code to make it work in whatever scenario you have that is different to mine.
Martin
Martin,
Thank you for your help. Here are the logs after inserting the code on line 350.
2016-01-16T15:29:25.354Z ebfaf7ab-bc65-11e5-b207-89ce2ea42c25 *************** getDevices *************
2016-01-16T15:29:25.354Z ebfaf7ab-bc65-11e5-b207-89ce2ea42c25 About to parse: WWW-Authenticate: MMSAuth error=“invalid session”
2016-01-16T15:29:25.354Z ebfaf7ab-bc65-11e5-b207-89ce2ea42c25 *************** getDevices End*************
2016-01-16T15:29:25.357Z ebfaf7ab-bc65-11e5-b207-89ce2ea42c25 SyntaxError: Unexpected token W
at Object.parse (native)
at /var/task/index.js:351:25
at IncomingMessage. (/var/task/index.js:425:40)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickCallback (node.js:442:13)
On line 400 I see a caution symbol that states “too many errors”.
function getSessionToken(server, AuthToken, AuthSigToken, cbfunc )
{
var options = {
hostname: server,
port: 443,
path: ‘/info/session/token’,
headers: {“MMSAuth”:AuthToken,“MMSAuthSig”:AuthSigToken}
};
Are you on UI7?
There’s one thing to try. At line 371, change
hostname: ‘vera-us-oem-authd11.mios.com’,
to
hostname: ‘vera-us-oem-autha11.mios.com’,
I may have been using the wrong server to get the auth token. No idea why it worked for me given that, but perhaps it’s more fussy on some firmware versions that others.
Martin
I am running 1.7.730
Updated to vera-us-oem-autha11.mios.com and I get what appears to be the same error;
2016-01-17T15:18:51.568Z 9cb73b30-bd2d-11e5-95fe-370571333912 *************** getDevices *************
2016-01-17T15:18:51.569Z 9cb73b30-bd2d-11e5-95fe-370571333912 About to parse: WWW-Authenticate: MMSAuth error=“invalid session”
2016-01-17T15:18:51.569Z 9cb73b30-bd2d-11e5-95fe-370571333912 *************** getDevices End*************
2016-01-17T15:18:51.572Z 9cb73b30-bd2d-11e5-95fe-370571333912 SyntaxError: Unexpected token W
at Object.parse (native)
at /var/task/index.js:351:25
at IncomingMessage. (/var/task/index.js:425:40)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickCallback (node.js:442:13)
From that number, I’m guessing you have a Vera Lite or Vera 3. I’m testing with a Vera Edge, but that shouldn’t matter.
The final piece of diagnostics we can do is to add logging output to the two calls to get the session and the Auth token. To do that, in the getAuthToken function, add the line
log("getAuthToken",body);
just before the line
var result = JSON.parse(body);
and in the getSessionToken function, change the line
response.on('end', function() { cbfunc(SessionToken);});
to
response.on('end', function() {log("sessionToken",SessionToken);cbfunc(SessionToken);});
That will print out the auth token first (which should be a message which contains the Identity and IdentitySignature, Server_Event, Server_Event_Alt and Server_Account_Alt values), and then will print out the session token which is just a string of characters. Don’t paste the values here as it would provide access to your machine, but if either of those is returning something other than that (e.g. an error message) then let me know.
Indeed, I have a Vera 3. The response appears to be a good response up to the getDevices section. There were no error messages. I removed the strings and provided the number of characters in the string that I removed. I also updated line 371 back to vera-us-oem-authd11.mios.com.
A close friend of mine has an Edge. I can try updating to use against his Edge rather than my Vera 3 if that helps.
2016-01-17T15:50:53.203Z 165b3a2f-bd32-11e5-82b3-bbc326aa26ab *************** getAuthToken *************
2016-01-17T15:50:53.204Z 165b3a2f-bd32-11e5-82b3-bbc326aa26ab
{
“Identity”: “REMOVED A 3075 CHARACTER STRING”,
“IdentitySignature”: “REMOVED A 345 CHARACTER STRING”,
“Server_Event”: “vera-us-oem-event12.mios.com”,
“Server_Event_Alt”: “vera-us-oem-event11.mios.com”,
“Server_Account”: “vera-us-oem-account12.mios.com”,
“Server_Account_Alt”: “vera-us-oem-account11.mios.com”
}
2016-01-17T15:50:53.204Z 165b3a2f-bd32-11e5-82b3-bbc326aa26ab *************** getAuthToken End*************
2016-01-17T15:50:53.686Z 165b3a2f-bd32-11e5-82b3-bbc326aa26ab *************** sessionToken *************
2016-01-17T15:50:53.686Z 165b3a2f-bd32-11e5-82b3-bbc326aa26ab REMOVED A 39 CHARACTER STRING
2016-01-17T15:50:53.686Z 165b3a2f-bd32-11e5-82b3-bbc326aa26ab *************** sessionToken End*************
2016-01-17T15:50:53.973Z 165b3a2f-bd32-11e5-82b3-bbc326aa26ab *************** getDevices *************
2016-01-17T15:50:53.974Z 165b3a2f-bd32-11e5-82b3-bbc326aa26ab About to parse: WWW-Authenticate: MMSAuth error=“invalid session”
2016-01-17T15:50:53.974Z 165b3a2f-bd32-11e5-82b3-bbc326aa26ab *************** getDevices End*************
2016-01-17T15:50:53.976Z 165b3a2f-bd32-11e5-82b3-bbc326aa26ab SyntaxError: Unexpected token W
I think I’ve got it! Your authentication is returning the two servers in a different order (12 then 11) to mine (11 then 12). That’s given me a hint about what to do. Line 348 is currently;
getSessionToken( authd11Server, AuthToken, AuthSigToken, function(AuthSessionToken) {
change it to;
getSessionToken( [b]Server_Account[/b], AuthToken, AuthSigToken, function(AuthSessionToken) {
and line 371 is
hostname: ‘vera-us-oem-autha11.mios.com’,
change it to
hostname: ‘vera-us-oem-autha.mios.com’,
I think that will then work (it still works for me when I do these changes, and I think it will make it work for you too)
Martin
YES!! SUCCESS!!
Thank you very much… this is exactly what I was looking for and it’s working!
Lights and dimming is working, scenes are a little touchy but some of them are working, could be something unrelated.
In short, I’m off and working!! I’m going to put some of the logging code back to what it was.
This is a very cool setup. Thank you for your time and dedication!
Glad you got it working. Thanks for your patience working through the teething problems - it has helped improve the code for everyone.
With the scenes, I find that it will often say that it could not operate that device and then do it anyway. I think it’s just the scenes taking longer to run that the confirmation period.
Martin