Recording UK Gas and Electricity usage in InfluxDB

I’m not going to do the online recipe thing. Or at least I’m going to give you the thing you probably want before the context. If you want a free tool for accessing your UK smart energy meter readings you should install and register the Bright mobile app. Once you’ve done so my Rust crate can access their API to let you pull data from the command line for various uses including submitting the data into InfluxDB where you can build all kinds of interesting graphs and alerts.

Now if you want to learn about my bike ride through Provence where I learned about the importance of monitoring my energy usage read on…

When we still lived in the US, I tried to start recording our electricity and gas usage in InfluxDB, a tool for recording time based measurements that then allows for graphic and triggering alerts. It turned out to be too difficult for my taste. Despite having “smart” meters that were measuring and sending our usage data to our energy provider there was no sane way for me to retrieve that data. I would have had to automate a web-based login process to grab the data, not impossible but annoying and subject to breakage whenever the website changed.

Now we’re in the UK and after having smart meters installed I tried the exercise again. So I started searching for details about my energy provider. Turns out they provided an API for downloading data! Which they turned off about a year ago. Damn.

But all is not lost. In the US wherever you live determines your provider and you’re stuck with them, no choice whatsoever (capitalism?). The way energy is supplied in the UK is a bit different. You can switch provider basically whenever you like. In fact it is encouraged to keep looking for better prices and switch often. It’s a bit weird and I don’t totally understand it because the electricity and gas still comes down the same lines and through the same meters into the house, but it does mean that I could potentially switch to a provider that offers a better API.

Now am I going to switch to a potentially more expensive provider just to get access to my data? Probably not. But there is something else about this setup that is useful to me. As I said, the energy still comes through the same meters. If you switch provider you don’t switch meters. Regardless of the provider I use they can still see the usage data from my meter (or at least this is true with modern smart meters). How does that work? It appears that all meters report their data to a central place and then providers can register to pull data from there. But it isn’t just your provider. Other companies can, with permission, gain access to your data. And then if they choose to, pass it on to you. Knowing that it didn’t take long to find a company that provides the Bright mobile app for displaying your energy usage (regardless of your energy provider!) and crucially once you’ve gone through the registration process for the mobile app a sane REST API for accessing your usage data.

The API is pretty straightforward so I’ve built a Rust crate and CLI for downloading and displaying data from it. Most importantly the CLI includes an “influx” command that downloads usage data and outputs it in InfluxDB line protocol complete with various tags for the data. I used that to download all the data since my smart meters were installed (five months ago) and then also added it to the telegraf configuration on one of my servers so every hour it attempts to pull the most recent usage data. And now I can generate pretty graphs like the one at the top of this post.