Home automation with Python

(This article has been translated to Serbo-Croatian by WHGeeks)

I'm working on a Python library for some home automation tasks. The goal is to produce a toolkit to simplify the construction of distributed software systems controlling real-world systems such as lighting, security, heating and entertainment.

My inital target environment is the home, since that is the hardware I have readiest access to. I've been thinking about this for a while, and when I refurbished my house I had the opportunity to rewire it with this in mind, although it would also be possible to retrofit much of this. Parts of the system could also be useful in other environments or applications.

I currently have an RPC layer which allows objects to be exposed to a TCP/IP network. Objects support remote method calls as well as simple event subscription and delivery. There is a system to discover objects on the network advertising certain interfaces. There is a framework to define which objects should run on a particular host and for multiple objects to share a single Python interpreter where desired.

The architecture I have used consists of several layers; a layer of interface objects talking to hardware, a layer of control objects representing devices and state in the real world, and finally a layer to interact with the user and implement their commands.

Subset of supported hardware:

  • Advantech PCI-1751 Digital IO card (8255 compatible):
    A low-voltage digital IO card connected up to a number of conventional wall-mounted light switches, the door bell, and recessed magnetic sensors on some doors.
  • Quasar 3108 RS232 I/O Board:
    A serial controlled board with relays capable of switching mains power and opto-isolated inputs. This provides the interface to the home security system, flue fan, central heating and door chime.
  • OpenDMX USB:
    A DMX-512 interface based on an open design, controlling up to 512 channels of lighting. My house uses five 12-channel DMX dimmers to provide sixty 230V AC lighting circuits, each with 256 levels of dimming. Each circuit can provide 4.5A (1kW) and of course circuits can be easily ganged in software. There are rounded 3-pin wall sockets to connect table and floor standing lamps so every light in the house and garden is computer controlled.
  • Nokia N800:
    The N800 makes a very nice portable user-interface with an 800x480 touch screen, WiFi and a Python interpreter. Sadly not much is working on this yet due to time constraints.

The software currently interfaces with and controls our lighting, TV, DVB-t PVR, HiFi, security system, fire alarm, doorbell, various fans for chimneys and bathrooms and our weather station. Another installation controls a proprietary lighting system and a tap-free bath with digital temperature and water level control.

I am considering open-sourcing the code. If you're interested, please contact me and let me know what you're working on.