Gas! Gas! Gas!

Continuing from my how to create your own (gas) smart meter post…

Now that I have all the meter reading values I can produce a D3 graph comme ├ža:

Not massively useful I’ll admit but it’s a start. What I’d like to see is how much gas I’m using a day. So I’ll need to group the values by day and map them to another form. Map? Group? That sounds like a job for Scala!

The stored data is very simple:

A little bit of Scala allows us to workout the amount of gas consumed each day. I’m not saying this is the best way to do it – more just an excuse to use Scala.

Actually, as the boiler runs in the morning and the evening, I’d like to see the difference between am and pm usage.

(I have another version of these methods which are curried but I thought they were a bit nuts to show publicly).

At which point the data becomes a bit too structured making it difficult to feed to D3. So we flatten it again to:

Then we can get our daily usage graph:

Gridlines correspond to the right-hand axis so you can see cost. That’s a lot of gas being burned.