Howto integrate a device returning a history of measurements

Hello,

I want to develop a binding to connect BluetoothLE devices to my openHAB2 installation.

I’m using SensorPush devices (http://www.sensorpush.com/) to measure temperature and humidity.
These devices do internally measurements every minute.
On connection you receive a large list of measurements and their timestamps.

I’m new to the openHub system. As far as I understood the current architecture and implementation,
such a usecase is not covered at all. Am I right?

To me it looks like openHAB wants to collect each single measurement on it’s own and taking care of persistence.

Is it possible, to receive such a datalog and bring it directly into the persistence layer?

For OH1, that is correct.

For OH2, I added methods to the persistence interface to allow time to be set in order to facilitate this sort of use case. So, these interfaces now exist within the persistence API for OH2 persistence services. Currently no persistence services currently support this at this time since they all only support the OH1 interface. I wrote an implementation of H2 for testing and this is under review in ESH…

Why not just pull the measurements with openhab as needed. Rather than do a data pull. Especially as you may be able to pull the data without needing a connection to the device.

I’ve done very similar with a Blue Maestro Tempo Disc. It has methods for logging and pulling data, but I found it used a lot less battery on the device to just let the device send out its advertising data, and interrogate that as it comes out to push values into openhab (1). I use mqtt as a transport, but I’m pulling with a remote raspberry pi to a central openhab instance.

I blogged about the process/data structure if you’re interested.

I’m also interested in storing historic Thing (channel) state from within the Plugwise Binding. I took a look at the code and discussion in the related PR #1872. So it seems there is currently no persistence service implementing ModifiablePersistenceService. Except for the H2 WIP which was closed for unknown reasons.

Now even if there was a ModifiablePersistenceService, how would a binding store the historic state? I don’t see a way to update historic state using the ThingHandlerCallback, BaseThingHandler or as some State subclass. The only way I see for currently using a ModifiablePersistenceService is by using the PersistenceResource REST resource.

My typical use case would be that I stop openHAB and after a restart, the binding persists any missed historic energy, temperature and humidity measurements that are obtained from the devices.

I would also need to implement InfluxDB persistence using ESH APIs. That may be straight forward and only take time when the right ESH APIs are there. :slight_smile:

There’s a GitHub issue (with a bounty) for implementing an API that bindings can use to report historic state updates: