Back in November I bought (well, actually I signed up to a new deal with E.ON which included one) a Current Cost electricity monitor, and hooked it up to my server so I could gather the stats for Cacti. I do this by running a small perl script which looks as follows:
#!/usr/bin/perl
# /usr/local/bin/cc-classic.pl
use Device::SerialPort qw( :PARAM :STAT 0.07 );
$port = "/dev/currentcost";
$ob = Device::SerialPort->new($port)
or die "Can not open port $port\n";
$ob->baudrate(9600);
$ob->write_settings;
$ob->close;
open(SERIAL, "+>$port");
while ($line = <SERIAL>)
{
if ($line =~ m!<ch1><watts>0*(\d+)</watts></ch1>.*<tmpr>\s*(-*[\d.]+)</tmpr>!)
{
$watts = $1;
$temperature = $2;
print "watts:$watts temp:$temperature";
last;
}
}
close(SERIAL);
This would give me the two values I am interested in; watts and temperature (since it sits in the garage node 0 ;)) in Cacti’s format:
$ /usr/local/bin/cc-classic.pl
watts:761 temp:11.3
But today, I received my new unit, a Current Cost CC128. It’s main benefit is that it supports individual appliance monitors, which makes the output even more useful. So, armed with a draft copy of the CC128 XML output document, I prepared my script to read as follows:
#!/usr/bin/perl
# /usr/local/bin/cc-cc128.pl
use Device::SerialPort qw( :PARAM :STAT 0.07 );
$port = "/dev/currentcost";
$ob = Device::SerialPort->new($port)
or die "Can not open port $port\n";
$ob->baudrate(57600);
$ob->write_settings;
$ob->close;
open(SERIAL, "+>$port");
while ($line = <SERIAL>)
{
if ($line =~ m!<tmpr>\s*(-*[\d.]+)</tmpr>.*<ch1><watts>0*(\d+)</watts></ch1>!)
{
$watts = $2;
$temperature = $1;
print "watts:$watts temp:$temperature";
last;
}
}
close(SERIAL);
And guess what… that works just fine ;)
For those who read diff:
$ diff /usr/local/bin/cc-classic.pl /usr/local/bin/cc-cc128.pl
2c2
< # /usr/local/bin/cc-classic.pl
---
> # /usr/local/bin/cc-cc128.pl
10c10
< $ob->baudrate(9600);
---
> $ob->baudrate(57600);
17c17
< if ($line =~ m!<ch1><watts>0*(\d+)</watts></ch1>.*<tmpr>\s*(-*[\d.]+)</tmpr>!)
---
> if ($line =~ m!<tmpr>\s*(-*[\d.]+)</tmpr>.*<ch1><watts>0*(\d+)</watts></ch1>!)
19,20c19,20
< $watts = $1;
< $temperature = $2;
---
> $watts = $2;
> $temperature = $1;
Please note, the above only works with 1 sensor (the main transmitter), so it is likely to change in the future. For now it suits my need.
I’ve been using a 1 wire network for quite some time now, but when I deleted a directory to much on my server, I lost a lot of the stats that I had gathered. A couple of weeks ago I finally got my behind in gear again and rebuild my network, this time making sure it all gets backed up ;)
One day I’ll write something about how it’s all been done, but for now you’ll have to suffice with some pretty graphs.
Here’s the daily graph for the temperatures in our bedrooms for the past 24 hours:

And recently I added a Current Cost meter to my network, which gives me the shocking facts about my electricity usage for the past 24 hours:

The above graphs are updated hourly, and I’ve got other graphs too, extending the period of graphing. You can find them here for the time being.
Update 25.1.2009
And now you’re able to follow the stats on twitter: http://twitter.com/awoogadotnl
Node Zero… Every respectable technology enthusiast has one, and so do I. It started all the way back in 2001 when I came across The Automated Home website and it’s associated mailing list. I knew nothing about home automation, audio distribution, video sharing, etc but was keen to learn and introduce at home (often with great resistance from SWMBO ;)).
So I build my first node zero to accommodate some of my servers in the garage and distributed the network from there into the living room. Due to the fortunate location of the garage being adjacent to the living room it is the ideal place to put stuff without worrying about the illusive WAF :)
You can’t really call the cupboard a node zero though, but if you closed the doors, at least it hid the cat5 wiring from the switch and modem it housed.
Flash forward to 2004 and with an ever increasing gadget count it was time to upgrade node zero. My dad is blessed with the carpentry gene and so with my instructions he set off to partition the garage in two parts where I reserved myself a shelf for the 2nd incarnation of my node zero. On the shelf my two TiVo’s and their satellite receivers were placed, followed soon by a Xbox Media Center, a scart switch and a Kat5 transmitter. The result: spaghetti junction all over again :(
So with an increasing demand on convenience and accessibility, I had to make amends. Bring on 2008 where my dad performs yet another masterpiece and creates a purpose build rack for me. The rack houses all my stuff, and with some space left at the bottom I even have room left for more toys! :D

Find some more pictures in the gallery
Thanks to Lewis at Motoworld Ltd (who made us an p/x offer we couldn’t refuse), we are now the proud owners of another green family fun bus.
It’s a Vauxhall Signum 3.2V6 Elite in Bamboo Green with full black leather, cruise control, climate control and memory seats! Or in the words of Jeremy Clarkson, a dadsie car ;)
See some more pictures in the gallery
Just checked my card balance today, and I’ve just received a credit for £11.75 from Dell UK (in case you’re wondering why they would issue this, see this post for the reason). Will they add the 2nd refund later, or have they conveniently forgotten it? To be continued… ;)
Update 23.8.2007
Still no sign of that promised 2nd refund… A polite email is already heading their way :)
Update 4.9.2007
Finally! This morning (after chasing this for the past month) the 2nd £11.75 arrived on my credit card. About time too!