hue-config
allows the creation of custom scripts to control your Hue lights. You can then add these to the Alexa skill as custom 'devices' (see Sunrise as an example). All hosted on AWS as lambda functions, defined and deployed using AWS SAM.
Note this is really only transitions or other one-off api calls. TODO: integrate a full animation using the entertainment SDK.
The initial setup process might be a little time-consuming -- particularly if you do not have prior experience with AWS -- but afterwards updating and adding new animations is relatively straightforward.
To control your Hue lights via an Alexa skill, you will need to register as a developer with Hue and create a Hue 'app'.
- Head over to the Hue developer login page and create an account.
- Once signed in, go to your apps and click "Add new Remote Hue API app".
- Fill out the required fields of the form:
App name
: Any value you wantCallback URL
: Fill this withhttps://www.example.com
. We'll come back to this later.Application Description
: Anything you want
- Click "Submit"
- Go to the Alexa Skill development portal. Create an account if you haven't yet, using the same email as your Amazon account.
- Click "Create Skill"
- Fill in a skill name and click the "Smart Home" tile. Click "Create Skill" in the top right corner.
- Under step two "Smart Home service endpoint" of the next page, copy the field value of "Your Skill ID"
- Keep this tab open, we'll come back to it.
This project is built on top of SAM. This is due the many great benefits it offers, such as easy deployment and configuration, as well as the capability to run your functions locally.
- Follow the steps listed here, and install and set up the SAM CLI. This will take you through the CLI installation, including creating an AWS account and creating an Admin user with proper IAM roles if you haven't already done so.
- Set up your AWS credentials. You may leave the defaults as they are, we'll change that up later.
- Clone this repository (or better yet fork then clone so you can contribute your own improvements or animations).
- In the template file replace
<your skill id here>
with the skill id obtained in Alexa Skill Part 1 step 4. - Run
make build
in your terminal in the directory of the repository. - Run
sam deploy --guided
, saying yes to all prompts and setting 'us-east-1' as the region (if you are in NA). - Once the deployment is complete, make a note of the values of
Alexa
andAuthenticationAPI
in the output.
-
Copy the
ClientId
andClientSecret
from your Hue app's card. -
Navigate back to the Alexa Skill tab from Alexa Skill Part 1.
-
On the "Smart Home" tab, fill the "Default Endpoint" field with the ARN from the
Alexa
output obtained from the step above. -
On the Account Linking page, we can fill out these fields using your Hue Apps information:
-
Authorization URI: The URI to kick off the oAuth process with Hue. This is a URL with the following form:
https://api.meethue.com/oauth2/auth?clientid=<your_hue_clientid>&response_type=code&state=<random string>&appid=<your hue app name>&deviceid=<any unique name>&devicename=<any unique name>
-
Access Token URI
: The URI to get access tokens from Hue. Use theAuthenticationAPI
value obtained from the step above. -
Your Client ID
: TheClientId
from your Hue app. -
Your Secret
: TheClientSecret
from your Hue app. -
Your Authentication Scheme
: HTTP Basic -
Scope
: profile
-
-
Copy one of the Alexa Redirect URLs following depending on your region:
- North America:
https://pitangui.amazon.com/…
- EU and India:
https://layla.amazon.com/...
- Far East:
https://alexa.amazon.co.jp...
- North America:
- Change your Hue App's "Callback URL" to be the URL copied in the step above.
- Open the Amazon Alexa app on your phone.
- Navigate to Skills & Games > Your Skills
- Under the "Dev" dropdown, you should see your newly created skill. Tap it and follow the account link instructions.
- Discover devices. This should add all defined devices in the alexa file to your Alexa.
- You're done, have fun customizing your Hue lights 🎉
This is a rough first pass at this. Many things could be improved:
- Make things in the
sunrise
device configurable from the Amazon Alexa app, such as duration, colors, etc. - Improve error communication to deliver errors to Alexa via speech output.
- Refactor code to be able to host shared skill everyone can use, rather than having people deploy their own.