Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Home monitoring and automation framework built on XBees and RabbitMQ
JavaScript Python
branch: master

Fix incorrect timestamp when serializing with BSON

Need to explicitly specify timezone
latest commit 842df900cd
@blalor authored
Failed to load latest commit information.
schema making humidity not required
support Fix incorrect timestamp when serializing with BSON
ui Quick and dirty iPhone button for sprinkler
util Work-around for pytz bug
xbee correcting zb_tx_status
.gitignore ignoring sqlite3 databases
README.md Implementing logging with log4js-node
config.py Finalize weather publisher
consumer.py Switch from pickle to bson
crontab fixing crontab typo
db_logging_receiver.py
declare_exchanges.py Correct sys.path for message_logger
environmental_node_calibrator.py Implement external config repository
environmental_node_consumer.py make scripts executable
fuel_oil_tank_consumer.py make scripts executable
furnace_consumer.py include all furnace info in message to sensor_data
power_consumer.py make scripts executable
sprinkler_controller.py Prefix command to match updated RPC routing scheme
sprinkler_driver.py
startup.sh adding xbee_network_monitor to startup script
system layout.graffle initial commit
upload_data.py add config to upload furnace activity
voltometer_driver.py make scripts executable
wx_publisher.py Fix incorrect timestamp when serializing with BSON
xbee_device_config.py Add support for requests with multiple replies
xbee_device_config_data.py Adding support for "volt-o-meter"
xbee_gateway.py Fix incorrect timestamp when serializing with BSON
xbee_lt_sensor.py make scripts executable
xbee_network_monitor.py Improved event publishing
xbee_notes.txt Adding overview documentation
xmlrpc_server.py Use serializer_utils instead of pickle directly

README.md

Home Automator

Home monitoring and (fledgling) automation framework built on the RabbitMQ message broker.

Overview

I'm slowly making my house "smart". Currently active are:

  • temperature and humidity sensors throughout the house
  • a power monitor attached to the electric meter • an antique voltmeter reflecting real-time power consumption
  • a remotely-operated sprinkler controller for my lawn
  • an occasionally-working device in my fuel oil tank to measure volume
  • a furnace activity monitor and timer-based override

All of this data needs to go somewhere, and often several somewheres. Long-term data collection, event response, real-time analysis and graphing, and behavior modification (both for me and the house) are some of the goals I have for this system. It's been a work in progress over several years, frequently interrupted as I context-switch between this and other electronics, car, home, work and personal projects.

A few months ago I heard about RabbitMQ, started learning a bit more about message brokers, and realized that pub/sub was the ideal model for this system: multiple sources of information being presented to multiple consumers at once. I'd known for a while that I was reinventing the wheel by implementing my own — not terribly efficient — hub-and-spoke system for getting information from a sensor to a consumer, but it finally dawned on me that if I wanted to grow the system I needed a better backbone.

Currently, most of the devices have Arduino-based microcontrollers that communicate wirelessly with a central gateway using XBee modules.

system layout

Components

xbee_gateway.py

Receives XBee frames and publishes them to the raw_xbee_frames exchange. Also consumes messages from the xbee_tx queue to be transmitted as frames to remote XBee devices.

Sensor data handlers

The following scripts consume device-specific frames from the raw_xbee_frames exchange and publish usable to the sensor_data exchange. They are essentially device drivers.

  • environmental_node_consumer.py
  • fuel_oil_tank_consumer.py
  • furnace_consumer.py
  • power_consumer.py
  • xbee_lt_sensor.py

The furnace_consumer.py script also exposes some methods via RPC to control an override timer so that we can get enough hot water for a shower. It's a long story…

voltometer_driver.py

Consumes power monitor data published by power_consumer.py on the sensor_data exchange and transmits frames (via the xbee_tx queue) to an XBee/microcontroller device housed in an antique voltmeter (aka the "volt-o-meter") in the living room that reflects real-time power consumption.

wx_publisher.py

Invoked hourly to retrieve weather forecasts and current conditions, published to the weather exchange. Not really used at this time, but I'm hoping to be able stay ahead of the heating and cooling needs of the house by reacting to the weather.

Sensor data logger

  • db_logging_receiver.py stores data published on the sensor_data exhange to an sqlite3 database
  • upload_data.py periodically uploads the data to a more powerful server for graphing and longer-term trend analysis

xmlrpc_server.py

XML-RPC bridge to the messaging-based RPC mechanism used by furnace_consumer.py and sprinkler_driver.py. Python's XML-RPC library is so very handy, but I didn't like keeping track of multiple XML-RPC servers (one for each endpoint).

Sprinkler controller

Interfaces with the remotely-operated sprinkler controller I built. Sprinkler is (de-)activated via cron.

  • sprinkler_driver.py
  • sprinkler_controller.py

amqp_socketio_bridge.js

This is an AMQP-to-WebSocket gateway written in Node.js. The WebSocket part is actually an implementation detail under the covers of the very cool (and poorly documented) Socket.IO. There's some boilerplate code at the top of the file that shows how to hook the browser up so that you can subscribe to topics on an exchange and invoke RPC methods.

Several libraries are required:

Just install these in the current directory with npm

$ npm install socket.io@0.8.7
$ npm install amqp@0.1.1
$ npm install node-uuid@1.2.0
$ npm install node-static@0.5.9
$ npm install log4js@0.4.0

Then:

$ node amqp_socketio_bridge.js

Furnace Timer UI

Simple HTML and jQuery iPhone web app. Start the amqp_socketio_bridge.js and point your browser to http://localhost:8000/furnace_timer/.

Something went wrong with that request. Please try again.