Updated InfluxDB binding with tags

Tags: #<Tag:0x00007f2fb4fe1d30> #<Tag:0x00007f2fb4fe1bf0>

Hi folks,

I am using the InfluxDB binding now for quiet a while. Unfortunately, there is no way to add additional tags to my saved data. As I understand the concept of InfluxDB, data points from different, but similar sources are written in the same measurement, and separated by tags. So for example the data from all my temperature sensors gets stored in one measurement. Later, I can query them by room, by manufacturer of the device, by item name, by charge number, or by whatever tag I have added. This also simplifies the creation of dashboard in Grafana, as I can say “Show me all data from measurement x, grouped by room / item name / whatever”. When I add new temperature sensors, I do not have to modify my graphs, alerting rules, etc.

So I have updated the InfluxDB binding from addons1 to the OpenHAB 2 ecosystem. These are the changes:

  • Add ability to add custom tags through item metadata
  • Add ability to add predefined tags through config
  • Fix bug that when using an alias name for the item, querying the database for that item was broken
  • Configurable through UI (and file, of course)
  • Update to the newest InfluxDB-java library with all of its dependencies
  • Add option to replace underscores “_” in item names / alias names with points “.”
  • Some minor bug fixes

The current work can be found here: https://github.com/dominikkv/openhab2-addons/tree/influxdb-neo

What we need to discuss is the following:

  • Name & namespace. I have used org.openhab.persistence.influxdb like the old one, is that OK?
  • How to add this to addons2? Just a simple PR?
  • Are there other feature wishes?
  • Are there other points you’d like to discuss?

I’m happy to hear your opinions :slight_smile:

Thanks
Dominik

7 Likes

I think i know what you are doing… i was thinking its a shame the data is written as separate measurements rather than using tags to determine what room the sensor is in etc… so this is great!

One thing though, InfluxDB server 2.x is in alpha https://www.influxdata.com/products/influxdb-overview/influxdb-2-0/
So the title of your binding version also confused me initially as i was thinking it was only for InfluxDB2.x…

Ill try to test this out in a day or so and give any feedback!

I was missing tags, too.

Great to see someone working on this. :+1:

I only took a glance at the README, but I think it would be nice to have some examples with temperature and humidity instead (or in addition to) your power example.
Because measuring temperature is properly the first thing anybody does in the smart home world.
And it would show how to work with different measurements.

Another note: Every user that will start using this approach will want to migrate the existing measurements to the new ones.
So a little info how to do this would be helpfull.

Fantastic work @dominikkv! Tags were dearly missed in openHab InfluxDB persistence.
I’ll have a good look and test the coming days.

Sure :smirk:
Changed that, thanks!

To be honest, I have written half of the example with temperature sensors, but then switched over to the power example. The reason is that for temperature, I could think of only one tag that would fit: room. Yeah one could add tags like manufacturer or device model, but that would only make sense if you use different sensors. Do you have ideas for other tags I could add?

Yup! I have done this with a small self-written Java program, but I don’t see any user friendly way of migrating your old data. InfluxDB s*cks at manipulating existing data :woozy_face:
Does someone have an idea?

@all: When cloning from Github, don’t forget that these changes are in the branch ‘influxdb-neo’ :slight_smile:

Beside room there could be a tag for floor.
And maybe one to differentiate between inside and outside.

And there could be temperature measurements that are not for room tempreatures.
Like temperature of heating or cooling equipment.

But I get your point.

Create a new database for the new binding…
Could your java program ask for the new tags for each series it finds in the old database?
Ie: Prompt for the tags to assign for each series ?
Also, check if the series has had data written into it in the last few days, and skip import into the new database if no data has been there for that period.

As for tags, i wonder if this type of metadata is being considered for OH3 - where each item/thing has a “room” or “floor” tag field…

As a newbie who started only two weeks ago with logging openhab data into influxdb I would sacrifice my existing data in a heartbeat to get tag support. Is there anywhere a .jar flying around that I could “borrow”?

2 Likes

Any updates on this?

Great work @dominikkv !

Have you thought adding a way to specify the retention policy to the item ?
I think I’m not the only one having items varying very frequently that are kept a few days before being downsampled.
I currently use a rule and a direct http post to influx but, as for tags, your update would make it a lot cleaner !