Use influxdb more like it is intented by influxdb

Due to a fatal hardware failure I’m reinstalling my homeserver.

I think this is a good opportunity to do things “right” this time :slight_smile:

One things that always bothered me is the way how data is written to influxdb - because openhab does not use the features of influxdb how they are intented.

With the influxdb persistance service, every value is written on its own to the database with the item name as field key. So, if I have two sensors in kitchen and living room measuring temperature and humidity there will be single entries for fields kitchen_temp, kitchen_hum, liv_temp, liv_hum.

However, the “right” usage of influxdb would be two entries with:

  1. tag=kitchen and fields “temperature” and “humidity”
  2. tag=livingR and fields “temperature” and “humidity”

This database scheme allows for much better and more flexible filtering/visulization.

I’m aware this is not compatible to the way how openhab works internally, but anyhow: Has this already been discussed and are there any proposed solutions?

I have used rules with http post requests to the InfluxDB with the format you mention - this completely bypasses the OH persistence, but it works. I do not attempt to pull it back in to OH; I use it directly in Grafana. Presumably you could pull it back into OH with get requests. Clearly not as nice as the built in persistence, but possible.

You could use the in memory persisitence to keep enough data around for your rules. You already have a rule so you’d just need to add a few lines of code to persist the same data to to that in addition to the HTTP calls to InfluxDB. Or use a second full persistence DB for those Items you need data for in rules.