feature-requests icon indicating copy to clipboard operation
feature-requests copied to clipboard

Local buffering of periodic sensor measurements during communication outages

Open heathkh opened this issue 5 years ago • 8 comments

Describe the problem you have/What new integration you would like

Currently, when the wifi network or the home assistant server is down, sensor measurements are lost. I'd like if the ESP device could buffer periodic sensor measurements locally and submit them when it next has the ability to reach the home assistant server.

Please describe your use case for this integration and alternatives you've tried:

I'm logging measurements of temperature from 10 devices once a minute for a long-term study of thermal properties of my home over the course of the year. When there is a power outage at home or my server crashes, I lose important measurements and have gaps in my data.

Additional context

heathkh avatar May 16 '20 00:05 heathkh

I'd like this too

dougle03 avatar May 16 '20 14:05 dougle03

Another use case for this feature is to allow sensors to collect data while saving power by not connecting to wifi then periodically connect to wifi and update HA

ali-essam avatar Nov 11 '24 21:11 ali-essam

I would love to have it. WiFi is always unreliable and having a buffer for saving data, it will help to fill the gaps.

Emmegiemme avatar Nov 29 '24 10:11 Emmegiemme

I would like this too. For sensors in industrial edge computing this is standard under the name of 'buffering' when communication to the main storage is interrupted. Looking at the definitions for esphome of 'queues' and 'buffers', this kind of covers both. There is an order for time series data(queue) and a buffer to temporarily edge store the data, when communication is down. Of course you must be able to set a max amount of storage (available on the esp for this). Maybe it is possible to make use of what is already worked out in/for FreeRTOS?

Floriszz avatar Oct 26 '25 10:10 Floriszz

So the question is; is anyone actually working on this? I don't see any related PR's...

dougle03 avatar Oct 26 '25 10:10 dougle03

It is quite an old issue. I do see this; max_send_queue on esphome: https://esphome.io/components/api/ But I'm not sure if this covers it. Also I have read somewhere there is a parameter in esphome yaml config for it, but can not find it back.

Floriszz avatar Oct 26 '25 10:10 Floriszz

I think the bigger problem is HA records data based on time/date it got the data rather than any timestamp in the sensor data, so holding the data at the ESP and send when connected would result in collection of the sensor data, but not the time it was created, only the time it arrived into HA... This could be solved, but would require changes to HA also which are a lot less likely to happen as it's deep within HA's event handling system... Also, ESP's don't generally have an RTC to it would be difficult to validate the timestamp as being accurate...

dougle03 avatar Oct 26 '25 10:10 dougle03

OK. Clear. That makes sense. Best way forward would be that the esp does record time stamps and use ntp to keep clock in sync. But in one case I use an esp for water meter and it just needs to register/count pulses. So it could easily buffer the counts and send them through when connection is back. Good enough for a totalizer. OK, you will miss some real time flow during the network disconnect time. But the total will be good and averages can be calculated from it.

Floriszz avatar Oct 30 '25 21:10 Floriszz