Persistence - persist item to a time in the past

Hello all,
I was wondering if anyone knew of a way to persist an item value to a time in the past.

What I am thinking is that I want to attach an esp32 wifi microcontroller to my cars obd2 port to capture trip milage, gas tank level, speed , etc…

basically the esp32 would log the data while out driving and then when home later that evening it would post each data point to an item. When this item changes it would trigger a rule that would parse the value and time from a string item and would persist this data to a previous time of day i.e. gas tank level 40% at 10:00am.

From looking at the persistence docs I dont think this is possible, but has anyone come up with a solution to this type of problem?

The only way is trough the REST API. You wouldn’t post the values to an Item. Instead you would post them using a specific JSON format to the persistence REST API endpoint.

Though you will need to have an Item that represents each different piece of information.

Once you go through all that, you will need to decide whether it might not just be easier to post the data to the database directly instead of going through openHAB to do it.

You will also have to figure out how you will track the current time on the ESP32. Usually, without a separate board with a battery attached, the only time the microcontrol knows is “x milliseconds since I turned on”.

super cool idea, please post if you get it going, maybe a simple tutorial or how to

Thank you for your input, I will look into interfacing to influxdb directly. My plan for time syncronization was to either use a ds1307 or similar real time clock and use ntp everytime the device connected to the network or to integrate a gps receiver into the device, not sure yet.

Yes I will post updates when/if they happen, like most, I have many projects in the fire and far less time available.

1 Like

I will be possible to create the items you want in OH and post the ‘historical’ data to your persistence db. I did it once (so manually imported the data) with some data I logged on a laptop. I used a SQL database on my NAS, so it’s more post to db issue than a true OH issue.

I do understand you want all your data on one platform though.

1 Like