I’m experimenting with Home Automation using Python. For those of you curious about how it works and how confused you’ll need to get, I wanted to provide this little tutorial/follow-along. You don’t have to participate and you can skip bits you don’t care about.
NOTE: The purpose of this post is to show you the workings behind the workings, you aren’t going to have to get your hands this dirty to work with most home automation systems.
Python-Hue and Python-Homeassistant
I’ll be demonstrating talking to a Hue hub and my local Home Assistant install. If you’re using some other hub (Wink, etc) it is left as an exercise for the reader to find the appropriate ways to talk to that API. You should still be able to follow along in spirit.
Dumb vs Smart?
The prefix, “Smart”, for a light bulb, motion sensor or pretzel mulcher is generally an allusion to a device that can participate in smart home automation.
The minimum bar for “Smart” is providing information to a controller, usually wirelessly. The next step is being able to be controlled the same way.
Motion sensor: A “dumb” sensor sits between the light it controls and the electricity supply. It acts like a physical switch. No motion? No power to the light. When it senses motion, it closes the switch and current flows to the light.
Whereas a “Smart” sensor detects motion and turns it into information that it sends to an intermediate device. Which will be called a “controller”, “gateway” or “hub” depending on precisely what that thing does.
In order for the sensor to turn a light on or off, a virtual connection is made by configuring or programming something to say “When the sensor sees motion, take this action”.
The fundamental value in “Smart” is the ability (and perhaps desire) to make decisions such as “if the sensor sees motion and it is dark then turn on the patio light”.