OpenHab adding values into a table to be visualized by Grafana

Hello Guys,
this Question covers OpenHab and Grafana.
Hopefully not to much Grafana, if yes i may consult the Grafana Forum as well then.
But i try it here first to get a first idea how so solve what i plan to do.
My Heating setup contains 6 of these Homematic HM-TC-IT-WM-W-EU and 2 Homematic HM-LC-Sw4-DR to open or close the underfloor heating pipes.
My Heat Meter is a red “Minocal” (https://www.minol.at/ablesung-minocal.html) counting in KWh.

So i managed to graph the Homematic stuff in Grafana very easy cause all values are automatically logged by OpenHab.

What i would like to add is a graph of my used KWh.
Unfortunately this red ugly box is stupid and just shows the number on the display, no way extracting this automatically, but ok this is something i accepted already.

So i thought about getting these numbers into a graph. And can imagine of a table with 3 columns (date, time, KWh) or 2 having then date and time combined. I plan fill these data first step manually in when i read the from the display.
And Grafana can use this data then to paint the graph.

Here it becomes difficult for me. I am looking for a way filling these data into a table as easy as possible and had the hope i can do this in grafana, but that seems not possible. So maybe this is then possible via OpenHab, but also here i have not found hint to accomplish this.

Hopefully one of you can give me a hint how to get this data into a table, how i can create one and fill in data. My used persistence in OpenHab is “mapdb”.

Thank You

1 Like

I would suggest to do it in openHAB. An item that sores the kwh another for date & time and a third one to apply the values. Just create a setpoint and an apply button and a rule that takes your entered value and the actual date and time items.

Then you have every thing in openHAB

This can be done in OH but it’s going to be pretty unfriendly from a user perspective.

You will either need to pass the data to OH (e.g. through the OH REST API Docs add-on), build a custom HABPanel widget to allow you to enter this data, or build a very clunky UI using sitemap elements to enter the data. The problem is there is no way to enter free text in a sitemap so you are stuck with sliders and setpoints. So, for example, to enter a date/time you will need 5-6 separate sliders/setpoints to enter the hh, mm, ss, YYYY, MM, DD separately.

Mapdb is wholly unsuitable for this. Only OH can talk to it meaning Grafana cannot, and it only saves one value, the most recent one, so there is no data to chart in the first place.

Hello Rich and Thomas,
thanks for your replies.

@rikoshak: After your comment i was looking into the persistence a bit closer and stuck there, cause in OpenHab in the configuration tab -> system -> persistence i have the value mapdb (but can switch to influxdb or rrd4j, both are also installed, i checked this in the Add-ons menu).
In Grafana at the Data Source Tab for OpenHab i have Influxdb, but i guess this is then grafanas own DB, right?

So since i did all this a few month have passed already and it seems i simply forgot how i have set this up.

Rich, would you suggest to switch in OH to influxdb, this seems more suiteable for what i plan?
Is there then a way using an 3rd party windows or mac tool to edit values in the OH DB? Even that would be ok for the first solution.
My absolute final dream would be to automate this all.
So i already have a Pi zero w + noir camera in my heating camber an moitoneyeos is running on it. Every time the number of KWh changes it takes a picture with date / time. So currently i end up with a lot of picture where i can extract the information from, but this is a manual process.
Final i am looking for a solution recognizing the KWh change and writting this with date/time directly into the OH table which is then visualized by grafana.
And writting my values i have on pictures to a DB manually is now my first attempt.

And i see i definitive need help here :-/ So all your replies are much appreciated!

Thanks
Andi

You are persisting values already (the ones from the Homematic devices), why don’t you use the same persistence service for the Kwh?
Once you have the reading of the values automated (I would start working on this) just persist the values with your selected persistence, By using a persitence service of openHAB you do not need to care about the actual date/time (as it is already done for your Homematic devices).
The persistence service you have set in PaperUI isa only the DEFAULT Service, you can have more then one in use (and you do have more then one in use)…

Hey aksnet,

you can achieve this quiet easy using influxDB.

  1. Install an InfluxDB (Don’t know your setup. It works on a Raspberry Pi 2, If you don’t store that much data)
  2. Install InfluxDB Persistence Service and configure it for your needed item(s)
  3. You can add values to InfluxDB using the InfluxDB API. See writing-data-using-the-http-api
  4. For Visualization you can connect Grafana with this InfluxDB instance.

Hopefully that helps.
Pascal

Hi Guys,
many many thanks for all the Input.
I guess as @opus suggested i will focus now on getting the values automated.
The “problem” with OpenHab is if everything is setup and working just fine you start forgetting some things you already done and supposed to know :slight_smile:

I will let you know my results.

Thanks again
Andreas

Not necessarily. Grafana is a separate program that can make charts based on data in a database. It works with InfluxDB among many other databases.

InfluxDB is a separate program that saves time series data. Basically, rather than a bunch of tables and columns, it stores a timestamp and value for each configured Item.

rrd4j is an embedded database available for OH. It stores the data similarly to InfluxDB except it only stores numbers and it decimates the data as it gets old so that the database never grows.

MapDB is an embedded database available for OH that only stores the most recent value for configured Items.

Use all three if it makes sense. See Design Pattern: Group Based Persistence. I personally use InfluxDB to store the data from the Items that I want to create charts and MapDB for restoreOnStartup.

InfluxDB is a separate program. See their docs for how to add data.