Daily Archives: June 29, 2009

GNOME MQTT Panel Applet 0.1

We’ve been tracking our electricity usage for a few weeks now and have a web page of graphs which make it easier to work out when we’re using a lot of electricity.

Last 24 hours power usage
Last 24 hours power usage

I have a perl script running on one machine which reads the CurrentCost data from a serial port and publishes the temperature and instantaneous power consumption into an MQTT microbroker. On the webserver machine another perl script is subscribed to the temperature and power consumption topics and uses rrdtool to record the data and create not so pretty graphs.

I also wanted to be able to keep an eye on the current power usage so I put together a little gnome applet that connects to an MQTT server and subscribes to a single topic. You can run multiple applets connecting to different brokers or subscribing to different topics. Conceptually data moves from the current cost around the system like this:

mqtt-current-cost-diagram-export

One of the big advantages of using the broker is it neatly abstracts the data producers like the CurrentCost or a temperature sensor connected via an arduino from the consumers that process, record and render the data. Its easy to slip in additional sensors or replace existing ones with something which is quite different without having to make any changes on the processing and user interface side. When our new house gets built and we have a C-Bus system controlling the electrical system, state information from it will be added to the broker so it can be monitored easily.

I’ve never written a gnome applet before nor even done much gtk programming before so its still a bit rough around the edges. But it currently looks like this on a panel:

Temperature and Power Usage
Temperature and Power Usage
Preferences dialog
Preferences dialog

Tooltip with status information
Tooltip with status information

I still need to work on having the preferences saved between sessions.