Is it possible to collect ESPHome data "offline" and then later batch enter into HA Recorder

Suppose I have a portable ESPHome device that is often but not always connected to HA -- for example, if I take it out of my home or otherwise loses WiFi connectivity.

Is there any way to still collect state info and store internally in memory or to SD card and then have it automatically dump back to HA Recorder dataase with the appropriate timestamp.

I know I could hack something ugly using sqlite to insert into the relevant states and attributes tables while also updating the short and long term statistics tables but that would be klugey and likely not very robust.

This functionality would seem to be very useful -- whether for devices that may move out of range or potentially for very low power devices where you don't want to continually reconnect WiFi every time you get a new sample.

Said another way, this would allow ESPHome + HA to be a standard backend for a broad variety of mobile data collection devices beyond those that are always tethered and connected to your HA instance.

Any thoughts?

Pretty sure that is outside the thinking of what is "right" for HA.

What problem are you trying to solve?
Perhaps HA is not the right solution.

I use InfluxDB directly with Grafana queries, since I started well before HA was created. With that it is possible to put old data in. I have two devices that do that, but all others don't bother.

Most of the data is incredibly boring so missing some is no great loss.

I do have battery operated BT temp sensors and they report occasionally. I also have a plan for some devices that will be remote and could benefit from what you are saying, but I am not sure how interesting the data from them would really be.

I have seen this type of question before and the general response is there isn't an easy supported way to do this. Only a few people have ever expressed an interest in it.

I don't have the details handy but there is a github repo import_statistics which exports & imports csv data for HA. There is also a thread on this in the community.

I agree it's beyond "traditional" HA scope.
However, I have started to use HA as my one-size-fits all data collection center, including for things like biometrics.
While not perfect and perhaps beyond original design, I can leverage all the many HA tools and extensions for all these other datastreams.

Plus there are a number of hybrid use cases for sensors that are mostly at home or home-related but not always connected. Sow would be cool if these hybrid and adjacent use cases could be supported...

Yeah that is what I meant by various kluges. I also wrote my own code that does this...

I've seen a few similar threads on this. Eg

Since there are some people who think this is a good idea, why not share what you have done. It could help others and if enough people think it is good it might even get official support at some point.

I had to fix some long term data and my sql skills are lacking. So i used this to export, tidy up, and then import. It would work also for just importing new data.

1 Like