spencerhance / lifx-iot-lambda-switch

Ridiculously unnecessary light switch for a LIFX wifi bulb, using an AWS IoT Button and AWS Lambda

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lifx-iot-lambda-switch

Ridiculously unnecessary light switch for a LIFX wifi bulb, using an AWS IoT Button and AWS Lambda

Why did I make this?

That's a great question. I actually made this about two years ago when I thought the hype for serverless architectures had peaked (lol). I wanted to try out something in the IoT space and get more experience with AWS without having to do something actually difficult.

Setup

  1. You'll need to purchase an AWS IoT Button
  2. You'll also need a LIFX lightbulb
  3. Follow the directions on the AWS docs to configure the button
  4. Follow the instructions to connect the button to lambda
  5. Generate an authentication method for the bulb. You can use OATH, but I just generated an API key here since that's way easier
  6. Upload this code to the lambda function from earlier
  7. Set a lambda environment variable called "API_KEY" with your API token
  8. Ta-da! You now have a $20 lightswitch that takes 7-10 seconds to work and is dependant on your wi-fi connection (I never said this was a good idea)

Usage

Once you follow the setup process, every time you press the IoT button, it will toggle all of your lights. That's because I used the "all" endpoint since I only had one light anyway. You can specify groups and more specific IDs as well. Check out the API Docs if you're interested.

Extensions

This script only has a single function regardless of how you press the button, but there's actually 3 possible states: SINGLE, DOUBLE, and LONG. These are received in the "clickType" field of the event. A possible extension would be to trigger different scenes or colors based on what type of click you used.

About

Ridiculously unnecessary light switch for a LIFX wifi bulb, using an AWS IoT Button and AWS Lambda

License:MIT License


Languages

Language:Python 100.0%