The smart home has been a dream of geeks since the lightbulb was created (we imagine.) Now, with dozens of apps in the stores controlling vastly different "so called smart" hardware interfaces, you can have a puzzle of connectivity. This may be good for you in your single life, but navigating this maze of apps will scare your roomate or significant other away when they just want to turn on a light bulb or play some tunes!
Who thought that it would be ok to set the scene of your house by launching the Hue app to turn on or off your colored lighting, the Wemo app for your white lighting, and a Sonos app for music playback and ending? What exactly was wrong with the light switch and volume knob?! Sure, you can buy yet ANOTHER smart home controller to tie these together, or install touch screen interfaces to your walls, but these go to yet another service and need to be configured an additional time. Plus, wall keypads are expensive and require you to hard-wire into a home's alternating current circuits. No bueno!
What we need is a simple way to turn off the lights and music (TBD with their API) when we go to bed; without having to look at a smartphone or launch an application at night! Why is that you ask? Well, I'm glad that you have. Did you know that there is nothing worse than looking at a white/blue color temperature backlit smartphone or tablet screen before you lay your eyes to sleep? This is due to your circadian rhythm, which will be thrown off as your brain will assume it's the middle of the afternoon after looking at that color lighting! Millions of years of evolution have programmed us this way, so don't think you can hack your biology!
The solution is easy. We are going to take the Amazon Invent IoT button and turn it into a one-touch off button for ALL of our smart home services - Hue, Wemo (and in their future API control of Sonos.) The key here is that we will not need another smart home hub or controller, but leverage the power of the AWS Cloud and software APIs for the devices!
Since we get modality out of the IoT button, a single or double press will be used to make the single switch act like two. So, when we get up in the morning, double-pressing the switch to trigger the second mode which will launch the reverse of the single press off scenario
Project Goals:
1. My girlfriend or mom can turn off the entire smart house with one button!
2. Your friends visiting (aka non nerds can easily turn off lights without switching off power from the lamps containing smart Zigbee lightbulbs (don't you hate when people visit your home and do this?!)
3. Profit.
4. Well, maybe not profit, but the ability to quickly turn the lights on and off is nice progression to the past.
Steps:
1. Setup your AWS IoT button
1a. on your WiFi network: https://aws.amazon.com/iot/button/
1b. then click on the Go to Button activation wizard. Setup the button to send an email.
2. Test to see if email from the AWS IoT handlers for send an mail upon press to a GMail account. You can see in the subject line what type of button press it was; single, double or long.
The output to email includes the device serial number; battery level; and push type:
{"serialNumber": "G030JFXXXX", "batteryVoltage": "1768mV", "clickType": "SINGLE"}
3. Setup or login to your IFTTT account and activate Gmail if you're using that like I am, or setup an email rule for another provider: https://ifttt.com/channels/gmail/triggers/86-new-email-in-inbox-from
Set a rule for "new email in inbox from no-reply@sns.amazonaws.com" Which will be searched for by IFTTT to trigger the actions.
You can "aim" or "then" this to Hue, or Wemo or really any other service that IFTTT taps into. Note, that since these are triggered via email, the button presses won't be instant, but work after a the polling time by the servers.
4. Once you've got IFTTT triggering for single button presses, see what you can do for a double or a long press by parsing that field out of the email. That's called modality and it lets one physical button create different events!
Although this is a cool hack, it's not as fast as your old light switch. This is because a lot happens when you press the button.
1. AWS IoT button wakes up from sleep
2. Connects to your WiFi Network
3. Sends a message to the AWS IoT servers
4. AWS IoT servers send the email
5. Email is received by Gmail
6. IFTTT Parses these emails (the longest time delay comes from this)
7. The IFTTT API is launched
8. The Hue or WeMo receives the signal from the server via API
9. The lights go out!
At the time of this writing, Sonos had not given us access to their API for speaker control. We will update this when we can setup audio events via the button as well.
You could make this run faster by eliminating steps in the middle. If you had a SmartThings bridge inside your house, you could write a script that goes directly from AWS into that platform, which would be fast. For even faster use, you can eliminate the Internet all together. Philips makes two types of switches that work peer-to-peer over Z-Wave which keeps it all local.
Happy hacking!
Comments