Help needed with ingesting historical data in HA

Hello,

I hope I am posting in the correct category. I am struggling a bit with Home Assistant and I would really appreciate if you could point me in the right direction.

I want to run a combined temperature / humidity sensor (Sensirion SHT45) from an ESP-01S, bare ESP-12F or an ESP32-C3 Super Mini (the board doesn’t really matter) and I want it to run as long as possible on batteries. I am already experimenting with deep sleep with the ESP-01S for another project and I am pretty happy with the autonomy.

To maximize battery life of my tiny weather station, I wanted the ESP to deep sleep most of the time, wake up every 5 minutes, take measurements and store them in the RTC memory. Every hour (every 12 cycles), the ESP would connect to WiFi and send the data to Home Assistant through MQTT.

This approach saves a lot of battery because the most energy consuming operation, WiFi networking, is only performed every hour instead of every 5 minutes.

However, my problem is I haven’t been able to get Home Assistant to ingest historical data. I send a payload that looks like this:

{“temperature”:23.96,“humidity”:58.92,“timestamp”:“2026-02-27T10:12:48Z”}

But Home Assistant ignores the timestamp and inserts all records at the time it consumes them from MQTT, and I haven’t been able to find out how to configure it to tell it to use the timestamp of the record.

I checked online, people were suggesting using InfluxDB or Spook, but that really feels like it’s overkill to just be able to process backdated data points. It also didn’t reassure me that some people apparently corrupted their whole HA instance when messing with Spook.

It seems like such a common use case, to be able to send a bunch of stored measurements from a device to HA, that I can’t believe there’s no native solution for that.

Am I missing something obvious? Is there a simpler approach that would work in my case?

Thanks!

As far as I know, outside of manipulating the database directly, Home Assistant doesn’t allow for historical data to be handled.

When storing data in HA you send the data and HA then adds the current time to it, so you can not as such store historical data.
There is an integration that can store data in the Long Term Statistic database, but that is agregated data for one hour slots, so you might as well make the agregation directly on the device and store that value in the traditional way.

You can do it by writing an automation that generates state events. See this post

1 Like

Thank you everyone for your answers. It seems like such an obvious use case, after all not every IoT device is expected to be network reachable all the time, but I suppose that if it wasn’t considered at the beginning when building Home Assistant, that would explain why it’s still not supported today. It pains me to deploy a separate database just to be able to handle backdated data, but it might be the cleanest way available with Home Assistant unfortunately.

Assuming I install InfluxDB, it should then be possible to use that integration as the datasource for some custom entities and display them like normal in dashboard and the History tab, right? I’ve never used it before, so I’m not sure how HA integrates with timeseries stored by InfluxDB.

Have you glanced at this?

That is a post about storing historical data in the LTS database.
The LTS database store data in hour step intervals on the hour, so as I stated before there is no idea in trying to circumvent the HA interface, because the resolution will be 1 hour anyway.