This is (almost, kind of) an API for Amazon
Echo. Video Demonstration
This code is not for the faint of heart. I wrote it in about three
hours, the day after I got my Echo, and there are a lot of
improvements to be made. The original goal was just a
proof-of-concept, to see if I could make Echo do what I wanted. My
goal with releasing the source is to help out other like-minded Echo
owners.
- Wolfram Alpha API Key: this is used for converting the
plain-text numbers that Echo records (e.g., "seventy three") into
integers that can be used to set the temperature. Maybe there's
another Node package out there to do this, but this seemed like the
easiest way to get it working. Get a key here.
- Username for your Hue: if you're not messing with Hue, then
don't worry about it. This was pretty easy to do in the Node REPL by
loading node-hue-api and just typing in the
commands. Later versions of this app should generate a new username
(assuming it doesn't have one saved) and save it for use later.
I haven't integrated with any actual Amazon login systems yet. For
now, in order to connect this application to your Echo, you'll need to
do the following:
- Using Chrome, go to http://echo.amazon.com and sign in.
- Open the developer tools (Cmd+Shift+J on Mac, or Ctrl+Shift+J on
Windows).
- On the page, click on your Todo list.
- In the network tab, clear all entries.
- Add a new todo to the list. You should see a POST request in the
network tab to https://pitangui.amazon.com/api/todos.
- Right click on this request in the list, and select "Copy as cURL".
- In a text editor, paste the cURL command from your clipboard, and
copy the entire Cookie: ... header (excluding the "Cookie: "
text).
- Open api/echo/.credentials.json in your text editor (relative to
wherever you checked out this repo).
- Highlight PasteEchoCookieHere and paste from your
clipboard. This string has quotes in it; make sure to escape them
before saving the file.
- Replace CsrfValueGoesHere with the CSRF value from the cookie
string (should be a large integer).
Other credentials are located in api/nest/.credentials.json and
api/hue/.credentials.json. Your Nest credentials are the same ones
you use to log in to the app, and the username for Hue is explained
above (in "Prerequisites").
This is a Node app, so (after adding the required credentials) running
the app is really just two steps:
- Run npm install to install required packages.
- Run node app to run the app.
- actual Amazon login (rather than this cookie hack)
- better credential management overall
- look for a better way of converting "seventy three" to 73
- automatic creation of usernames for Hue (should be trivial, but it
would be good to add it)
- "global" commands (that don't require a prefix)
- maybe get rid of the whole prefix idea altogether
- "scenes" (tasks that can call subtasks; i.e., set the lights and
temperature)