Yesterday I received a small package I had ordered: the Plugwise Home Start kit. According to the box it is an energy management and control system. The idea is that you insert a sort of adaptor between a power socket and a device and using the Plugwise Source software you can monitor the power usage of the device. Furthermore, you can use the software to create schedule to turn the device on and off at a specific time.
The package contains the following:
- a USB adapter (called the Stick)
- a Circle+, the master adaptor that keeps track of the other devices in the network
- a Circle, the regular members of the Plugwise network
The Circles communicate to each other using the ZigBee protocol in the 2.4GHz range. According to the documentation, the range of each Circle is about 5m.
Unfortunately the Source software only runs on windows. Luckily some people have already analysed the protocol and written some software to control the Plugwise devices (see links below).
First steps
Plugging the USB dongle in gives the following output in /var/log/syslog
:
Nov 19 12:20:37 barabas kernel: [ 182.855742] usb 1-1.6.1.1.3: new full speed USB device number 14 using ehci_hcd Nov 19 12:20:37 barabas mtp-probe: checking bus 1, device 14: "/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.6/1-1.6.1/1-1.6.1.1/1-1.6.1.1.3" Nov 19 12:20:37 barabas mtp-probe: bus: 1, device: 14 was not an MTP device Nov 19 12:20:37 barabas kernel: [ 183.169370] usbcore: registered new interface driver usbserial Nov 19 12:20:37 barabas kernel: [ 183.169389] USB Serial support registered for generic Nov 19 12:20:37 barabas kernel: [ 183.169431] usbcore: registered new interface driver usbserial_generic Nov 19 12:20:37 barabas kernel: [ 183.169434] usbserial: USB Serial Driver core Nov 19 12:20:37 barabas kernel: [ 183.171310] USB Serial support registered for FTDI USB Serial Device Nov 19 12:20:37 barabas kernel: [ 183.171552] ftdi_sio 1-1.6.1.1.3:1.0: FTDI USB Serial Device converter detected Nov 19 12:20:37 barabas kernel: [ 183.171588] usb 1-1.6.1.1.3: Detected FT232RL Nov 19 12:20:37 barabas kernel: [ 183.171591] usb 1-1.6.1.1.3: Number of endpoints 2 Nov 19 12:20:37 barabas kernel: [ 183.171595] usb 1-1.6.1.1.3: Endpoint 1 MaxPacketSize 64 Nov 19 12:20:37 barabas kernel: [ 183.171598] usb 1-1.6.1.1.3: Endpoint 2 MaxPacketSize 64 Nov 19 12:20:37 barabas kernel: [ 183.171602] usb 1-1.6.1.1.3: Setting MaxPacketSize 64 Nov 19 12:20:37 barabas kernel: [ 183.171975] usb 1-1.6.1.1.3: FTDI USB Serial Device converter now attached to ttyUSB0 Nov 19 12:20:37 barabas kernel: [ 183.171998] usbcore: registered new interface driver ftdi_sio Nov 19 12:20:37 barabas kernel: [ 183.172002] ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver Nov 19 12:20:37 barabas modem-manager[901]: <info> (ttyUSB0) opening serial port... Nov 19 12:20:49 barabas modem-manager[901]: <info> (ttyUSB0) closing serial port... Nov 19 12:20:49 barabas modem-manager[901]: <info> (ttyUSB0) serial port closed Nov 19 12:20:49 barabas modem-manager[901]: <info> (ttyUSB0) opening serial port... Nov 19 12:20:55 barabas modem-manager[901]: <info> (ttyUSB0) closing serial port... Nov 19 12:20:55 barabas modem-manager[901]: <info> (ttyUSB0) serial port closed |
lsusb
gives:
Bus 001 Device 014: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC |
I couldn’t get the pairing to work under Linux (with the PlugwiseOnLinux scripts), Even though I corrected the MAC address in the python code. I then tried it in Windows where I failed at first also. After resetting the Circle+ and the Circle (removing/inserting them into the power outlet with 3 second intervals, as mentioned in the FAW on the plugwise website) I managed to pair the Circles. Looking back, I think I didn’t wait long enough for the pairing to work under Linux. During the trials in Windows I noticed that the pairing can take up to about 5 minutes…
Back in Linux I used python-plugwise (see links below) to turn the Circles on and off, e.g. this is how I turn my Circle+ off (note that I am a member of the dialout group, which is needed to communicate with /dev/ttyUSB0
):
$ plugwise_util -d /dev/ttyUSB0 -m 000D6F0000B1C117 -s off |
This is what I want! The only minor downside of python-plugwise is that it depends on the crcmod python library, which apparently is not package for Debian/Ubuntu. So installing using the python-setup framework as mentioned in the README is necessary.
Reading out the current power usage of my Circle works also:
$ plugwise_util -d /dev/ttyUSB0 -m 000D6F0000B85134 -p power usage: 2.27W |
So, no that it works, what am I going to do with the Plugwise modules? I’m going to use them in my backup scripts to switch the power to my external hard drives.
Making a .deb
I used checkinstall
to make a package of python-plugwise. In a working directory, first check out the source code of python-plugwise using mercurial, as mentioned on the web site:
$ hg clone https://bitbucket.org/hadara/python-plugwise |
Then run checkinstall
and don’t forget to fill in the details correctly. For example, the package name is ‘python’ by default, which you definitely don’t want, since that would overwrite Ubuntu’s default ‘python’ package. Also make sure that you remove the crcmod python library if you installed python-plugwise before, otherwise it won’t get packaged. The output below shows the final values, after I changed them.
$ sudo checkinstall -D python setup.py install checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran This software is released under the GNU GPL. ***************************************** **** Debian package creation selected *** ***************************************** This package will be built according to these values: 0 - Maintainer: [ lennart@karssen.org ] 1 - Summary: [ python-plugwise is used to control the Plugwise power switches as well as read out information on power usage. ] 2 - Name: [ python-plugwise ] 3 - Version: [ 0.2-hg-20111120 ] 4 - Release: [ 1 ] 5 - License: [ GPL ] 6 - Group: [ checkinstall ] 7 - Architecture: [ amd64 ] 8 - Source location: [ python-plugwise ] 9 - Alternate source location: [ ] 10 - Requires: [ python ] 11 - Provides: [ python-plugwise ] 12 - Conflicts: [ ] 13 - Replaces: [ ] Enter a number to change any of them or press ENTER to continue: |
You can check the contents of the package to make sure the crcmod
files are included using dpkg
:
$ dpkg --contents python-plugwise_0.2-hg-20111120-1_amd64.deb |
An idea for later: make an SNMP module that calls plugwise_util to get the power usage so that I can monitor the power usage of a device using Cacti.
Links
- The software I use: python-plugwise
- The blog of Maarten Damen, the guy that seems to have been the first one to analyse the plugwise protocol
- Another blog, also with info on the protocol
- PlugwiseOnLinux, a set of python scripts for pairing Plugwise and the Circles. Did not work with me at first, didn’t retry later
- PlugWeb, a PHP interface, for those wanting to control their Plugwise network via a web interface
- According to its website DomotiGa can also control Plugwise devices, but I haven’t tried it (yet)
Hey Sir, do you have a Protocol description for those PlugWise Devices?
Could you mail wahtever you got to StefanVoit@gmx.at
Is RWE hacking Plugwise now? Grtz Danny
Stefan, I sent you an e-mail.