Pulling existing InfluxDB metrics into openHAB2?

Hi everyone!

I have an existing (non-openHAB) data collection system that’s collecting a range of weather sensor data and storing it in InfluxDB metrics.

I’m adding an openHAB2 installation to do some home automation control. I want to be able to script openHAB to use some of the weather sensor data I’m already collecting, for both scripting and for display in the UI (things like showing current temps, etc.)

Looking at the persistence documentation, it seems like persistence generally assumes that new data points are generated in openHAB and then saved to the persistence store. The exception being when a script/rule makes a specific query to the persistence engine for historical data.

Is there any way to change that focus around so I can subscribe to InfluxDB data inside openHAB2? Would something like this need a standalone InfluxDB binding, or can this be done within the existing scope of the Persistence model?

Or will it just be easier to change my sensor data collection system to push data into openHAB2, instead of directly into InfluxDB?

Thanks anyone who can give me any tips on this. I’m pretty new to openHAB still!

I don’t think the persistence model would support this. To make it work “natively” inside OH it would require a separate binding.

This would probably be easiest. You could write a small script or program to get new data from InfluxDB and publishes them to OH using MQTT or HTTP REST.

Thanks Rich for the advice, I think you’re entirely correct - good to have it confirmed. :slight_smile:

For anyone who finds this later on, in the end I discovered that InfluxDB’s pubsub API is not documented yet, so rather than try to use that I changed the sensor acquisition program to push a subset of the readings in parallel - both directly to Influx and simultaneously to OpenHAB via the REST API.

This results in some duplication (metric values going to OpenHAB are persisted in Influx, so the same sensor value ends up in two Influx databases). However when writing directly to Influx I can leverage the extra metadata on measurements (keys, etc.).