Here are last week’s articles:
- December 30, 2014: Google Calendar with Python
- December 30, 2014: Home Automation Control with Python, Insteon PowerLinc, and Raspberry Pi
- January 02, 2015: Insteon / FOSCAM IP Camera Face Recognition with Python and Raspberry Pi
In my last 2 articles, I have shared with you code from my home automation system (HAS) controller written in Python that allows you to access your Google Calendar for scheduling events and communicating with the Insteon PowerLinc USB modem for controlling your Insteon and X10 HAS devices from Raspberry Pi (or other dedicated computer).
In today’s article, I want to share with you some Python code that uses OpenCV to detect faces from the Insteon (or FOSCAM) IP Camera which you can get from SmartHome.com for about $79. At my house, I use this code to detect when my fiancee or I approach one of the exterior doors. When we do, my HAS will recognize us and will automagically unlock the door that we are approaching. To do that, I am using the MiLocks 3-in-1 deadbolt system which is also available at SmartHome.com and will run you about $100 per lock. You will also need the MorningLinc Insteon adapter which will allow you to communicate with the MiLocks deadbolts over RF. These are also available from SmartHome.com and will run you about $50. You will only need 1 which is capable of controlling multiple locks.
Before I share the code, I should say that this particular code does NOT include the ability to recognize one person from another like that found in my personal HAS controller. All this code is capable of doing is detecting a face and saving a screenshot of that face to the file system (regardless who the face belongs to). The reason I am not sharing the face matching code yet is because there are a lot of complex steps required to train the system to detect individuals. I am currently working on a way to simplify these tasks. It took me several weeks to prepare the system manually for recognizing my fiancee and I with an acceptable accuracy and to not unlock our doors due to any false positives. Once I get this process simplified, I will share the code.
As explained in yesterday’s article, I have been overhauling my home automation system (HAS) and have decided to release parts of my controller software written in Python and runs on Raspberry Pi. I have been working on breaking apart the controller software so that each piece can be ran standalone. For example, yesterday’s article showed how to read your Google Calendar with Python. By doing that, you can schedule events to occur in your HAS by simply adding items to your Google Calendar.
Today, I want to share with you some Python code that allows you to control Insteon & X10 devices in your HAS using the Insteon PowerLinc USB modem which you can get from http://www.smarthome.com/powerlinc-modem-insteon-2413u-usb-interface-dual-band.html for about $80. Since the PowerLinc requires an always-on computer to be connected to it, it’s recommended to use a low powered computer such as the Raspberry Pi. Since the code below is written in Python, you can also use it from Windows or Mac if you want. Just make sure you change the “port” property in the serial connection to match your environment. If you combine this code with yesterday’s code, you can schedule your lights and other appliances to turn on and off by scheduling items in your Google Calendar.
I’ve been doing a lot of work on my home automation system during the Christmas break. As part of that work, I have decided to break apart certain pieces of the “controller” (written in Python and running on a stack of Raspberry Pi’s) and share the code with everyone that might be looking for a place to get started doing something similar. I’m not going to share the code in its entirety, but I will be sharing bits and pieces of it that I have rewritten to be ran standalone. The next several articles will include code that can be ran on its own, but can also be combined with code from the other articles (and a little bit more) to produce a really nice and powerful home automation controller.
The first piece of my home automation system (HAS) that I want to share is the Python code that allows my HAS to monitor my Google Calendar. Whenever events popup on my calendar that my house needs to be aware of (such as leaving for a business trip or vacation and returning back home), my HAS will take actions accordingly. For example, whenever my fiancee and I are scheduled to leave the house for more than 24 hours, the HAS will wait until we leave and will shut off things such as the hot-water-heater, ice-machine, thermostat, etc… and will turn on other things such as the alarm (if we – or the house itself – haven’t already enabled it).