Community
OpenEnergyMonitor

OpenEnergyMonitor Community

Accessing data from other devices

Is there an easy way to bring in the data from the EmonPi into something like grafana by way of InfluxDB? I have multiple dashboards in Grafana for other stuff and would like to integrate the power consumption into some of those graphs and dashboards. Ideally, Grafana has a data source plugin that can read the TSDB on the emonpi directly.

Welcome, Ian, to OEM.

My colleague @Bill.Thomson uses Grafana, I think he’ll be able to help you (and he’s in Oklahoma).

Hi Ian, and welcome aboard.

I use Influx and Grafana, and I’ve even got an emonPi, but I’ve not had a reason to get data from
the emonPi and send it to Influx.
(I use the emonPi as a test bed, but do my energy monitoring with another device)

I have done it the other way around, i.e. read the Influx database and send that data to the emonPi.

The emonPi uses a custom database, (it’s part of emonCMS) so as far as I know, no plug-in exists that does the job you’re asking about.

Someone may have a script to do that.

What this does suggest to me though is writing an emonhub Interfacer to send data to Grafana InfluxDB.

Perhaps also an Input Process to do the same.

@TrystanLea, @glyn.hudson thoughts?

That would be the suitable location to do it. Happy to accept a pull request if someone can put this together.

Grafana needs a data source, which is often InfluxDB, but could be Graphite, Prometheus or one of many other databases. So that seems to indicate an emonHub interfacer would need to send data to InfluxDB
(or the database in use, if not Influx) vice directly to Grafana.

Perhaps not the ideal solution, but a Python3 module exists for sending data to Influx, which Grafana could then easily read said data.

More info here: https://www.influxdata.com/blog/getting-started-python-influxdb/

Yes of course it does and that was actually what I was thinking of (post edited).

Im doing this . Its not pretty but works well.

My process is thus
Python script Polls local modbus tcp dev’s
This Node reports to Emonhub via socket interface.
Emon Hub template applies feed names as needed.
Emon Hubs posts to a centralized Mqtt server
I then have a python script that subscribes to the mqtt topic emon/
data from mqtt now has all relevant tags ie emon/lounge/irms1/x
I then write this directly into an influx DB via same python script.

Grafana has access to the influx data source .
Happy days Data is in Emoncms / emon hub and Grafana / Influx

You can also do some very complex routing in emon hub. ie also send data to a 2nd server via http/s
or use this trick to fettle data into multiple user accounts.

i should add im currently sending approx 100 datapoints per poll once a second per device

I know i use emon hub in a very non standard way but once configured is fire and forget and does not rely on node red etc…

This has been on my emonhub todo list since Trystan indicated he wasn’t keen on a influxdb engine for emoncms in this thread “InfluxDB as new timeseries engine”. I really want to try and use influxdb/grafana, reading the post linked by Bill, bulk upload to influxdb should be pretty straight forward.

2 Likes

However, since emon maintains its own time series database, it seems silly to duplicate the data and feed it to influx and then grafana… It would make more sense for grafana to read the existing time series data directly from emoncms and avoid the data duplication.

Indeed it would. But, as no plug-in exists to do the job, the only other way to accomplish that is
some type of “workaround.”

Agreed and look forward to you code to do that :slight_smile:

In the meantime, InfluxDB would have to be used.