homesmarts
is a python program to allow me to use a cheap Amazon Dash button as a lightswitch for my Phillips Hue lights. Rather than spend $60 on an "official" Phillips Hue switch, I decided to buy multiple $5 Amazon Dash buttons and hack them to operate my Hue lights (instead of order things off Amazon). It runs on my Raspberry Pi 3.
This idea was heavily incluenced from:
- Ted Benson's original blog on how he hacked Amazon Dash buttons to track baby data
- The "listen for ARP requests" code was based on Bob Steinbeiser's comment from the above blog
- rabbitmq-server: Implementation of AMQP
- pika: Pika Python AMQP Client Library
- phue: A Phillips Hue python library
To install on a Debian system (I'm running everything on my Raspberry Pi):
- Install and run
rabbitmq-server
- Clone this repository
First off, I highly recommend you read Ted Benson's original blog. It's a great read and does a great job giving an overview how everything works together. (Keep in mind, we'll be interacting with Phillips Hue lights instead of tracking baby poops. :)
IMPORTANT
: Before running anyhomesmarts
python program for the first time, be sure to press your Phillips Hue bridge button. This allows thephue
library to create a Hue username so it can access the Phillips Hue API.
- Discover MAC address for all Dash buttons. You can run dash-listener, which should log unknown MAC addresses to standard output.
- Edit your local homesmarts_config.yaml with your own details. Be sure to include:
- IP address of your Phillips Hue bridge
- Defaults to use for when toggling your Phillips Hue lights under
light-defaults
YAML section - Add all Amazon Dash buttons to your
switches
YAML section. Each Amazon Dash button can be associated with a single light (usinglight_id
) or a group of lights (usinggroup_id
).
- Once everything is configured, run:
sudo python homesmarts/dash_listener.py
Here are some links I found to be very helpful when writing and setting up homesmarts
:
- Phillips Hue: Developer's Getting Started
- Phillips Hue: Full Phillips Hue API (
NOTE
: requires user registration) - phue: A Phillips Hue python library
- RabbitMQ Tutorial
Be sure you have the correct IP address for your bridge in homesmarts_config.yaml
. Also be sure you press the Bridge's button before running the program the first time.
You need to run dash_listener.py
with sudo privileges to enable listening for all ARP requests.
It isn't necessary. I wanted to get experience with AMQP / enterprise messaging. Originally I planned on separate executables; one for listening for ARP messages (which requires sudo
privileges) and publishes messages to the queue, and one for processing the messages (which could be run without sudo
.
However, I later opted to keep everything in a single executable to make my life easier... but I still wanted to keep my AMQP code as a reference.