In last week’s post we detailed the Glowstick that provides a bridge between your Smart Meter and your wifi network. Your energy and gas usage is logged to a cloud service which can be accessed via an API. In this post we continue to show you how you can perform Smart Meter Data Analytics with Splunk.

Glowmarkt API

The Glowmarkt API is documented here. Prior to accessing the the data endpoints an OAuth must be performed. In a future blog post we will detail how this can be coded using python and the Splunk Add-On Builder.

Glowmarkt Add-On for Splunk

We have released an initial version of an add-on that connects to the Glowmarkt API and pulls through a live electricity usage reading. Further development is planned to also retrieve gas usage.

Once you have installed the Glowmarkt device and setup an account, you can download the add-on and configure it to pull your energy data into Splunk. The add-on is available from Splunkbase here.

Add-on Configuration

Once the add-on is installed your credentials (setup using the Bright smartphone app) should be added via the Configuration tab. Click Add and then input your username and password.

Then from the Inputs tab Create New Input should be clicked. Most of the options are self-explanatory. The default for applicationId should be left as is, leaving resourceId as the remaining option to complete. A future version of the Add-on will retrieve this programmatically but for now consult the API documentation and use either a curl command or the provided postman collection to retrieve the Electricity Consumption resourceId.

Screenshot showing how to add an input to collect Electricity Consumption data.
Add an input to colect Electricity Consumption Data

Smart Meter Data Analytics

Now we have the data in Splunk we can start to write some searches. This early version of the add-on writes the data received from the API straight through without modification. The “data” payload of the API response contains two values in an array, one representing the timestamp of the event and the the other the live electricity consumption at that time. A future version of the add-on will write a separate field to represent the live reading and the timestamp value will set the event time.

Visualising the data

With the data in it’s current form we need to pull the second value from the data array, this is the live meter reading in Watts. We convert this to kilowatts and then use the timechart command to tranform the data for visualisation. We keep the span at 30s so that each data point represents a reading from the API (1:1). No actual aggregation should therefore occur.

index=main sourcetype="glowmarkt:electricity:current" 
|eval elecLive=mvindex('data{}{}',1)
|eval elecLiveKw=elecLive/1000
|timechart span=30s max(elecLiveKw) as elecLiveKw

This produces the following timechart:

timechart screenshot showing live electricity usage - smart meter data analytics
timechart of live electricity consumption

This data can also be used for a single value visulisation, as shown below.

single value visualisation screenshot showing live electricity usage - smart meter data analytics
Single value visualisation with trend indicator

The search below can be setup as an alert search to warn you if consumption stays high over a prolonged period of time. While this is just scraping the surface of the potentially useful analytics that can be performed it is useful way to let Splunk keep an eye on your energy usage.

index=main sourcetype="glowmarkt:electricity:current" earliest=-15m
|eval elecLive=mvindex('data{}{}',1)
|stats avg(elecLive) as avgWatts

The screenshots below show an example alert setup, tune the values to suit. If you want to alert if your usage stays above 3kw for 10 minutes then change the custom trigger to be “search avgWatts > 3”.

Conclusion

With this initial setup some useful analytics and alerting can be performed. In future posts we will look at extending the analytics further. Subscribe to the mailing list to ensure you get notified when they are posted.


For 2021 we’ve committed to posting a new Splunk tip every week!

If you want to keep up to date on tips like the one above then sign up below:

Subscribe to our newsletter to receive regular updates from iDelta, including news and updates, information on upcoming events, and Splunk tips and tricks from our team of experts. You can also find us on Twitter and LinkedIn.

Subscribe

* indicates required
Posted by:Stuart Robertson

Stuart Robertson is the Consulting Director at iDelta. He is one of the initial founders of iDelta and has worked there since formation in 2001. Stuart holds various certifications in Core Splunk and ITSI. Stuart also holds a Bsc(Hons) in Computing Science from the University of Glasgow.