Control your LIFX bulbs from the command line or AWS Iot Button.
- Set your LIFX Access token as an environment variable:
echo "export LifxAccessToken=0000ffff0000ffff0000ffff0000ffff0000ffff" >> ~/.bash_profile
- Run
npm install
- Run
npm link
💡 You can find the ID (also known as a selector) for a specific bulb using the LIFX List Lights API. You can also use the lifx-get function in this repo.
Toggles the light(s) power.
lifx-toggle --bulb=<bulb ID|all>
Example:
lifx-toggle --bulb=100010000001
This function invokes the toggleIt
function in index.js
.
Sets the light(s) parameters to change it's current state.
lifx-set --bulb=<bulb ID|all> --color=<string> --power=<on|off> --brightness=<number> --duration=<number>
Example:
lifx-set --bulb=100010000001 --color=red --power=on --duration=1
This function invokes the setIt
function in index.js
.
Gets the current states of the lights(s).
lifx-get --bulb=<bulb ID|all>
Example:
lifx-toggle --bulb=100010000001
This function invokes the getIt
function in index.js
.
lifx --bulb=<bulb ID|all> --click=<SINGLE|DOUBLE|LONG>
This function invokes the handler
function in index.js
. You can edit this function to decide which functions are triggered by different clicks of your IoT button or change the settings in iot-settings.json
.
- Create a CloudFormation template - Follow the AWS IoT Button AWS CloudFormation Quickstart developer guide to create a CloudFormation template. Add an additional role and function to trigger the
handler
function inindex.js
(see lifx.template.json for an example). - S3 - Compress this folder and upload it to S3 in the directory specified in your CloudFormation template.
- CloudFormation - Create a new stack, upload your template, and enter all environment variables.
- Click your button - Click your AWS IoT button to see your lights change. From Lambda in the AWS Console, you can access logs to check for any errors.