Open dankeder opened 1 year ago
Hi, and thanks for raising this issue.
First, you "should" only see this specific behavior when LTSS is being started while the database is not available, whereas reconnection attempts should happen automatically for the case where the database goes offline while LTSS is running and then comes online again (regardless of the time it was offline). Can you please confirm this? Please note that data will be dropped while the database is offline.
Please feel free to submit a PR that covers the case where LTSS (HA) is (re-)started at a time when the database is offline.
When the TimescaleDB is unavailable while ltss is running / being started, it's retrying to reconnect 10 times with 3s delay, as seen here: https://github.com/freol35241/ltss/blob/master/custom_components/ltss/__init__.py#L125
After 30s it gives up and won't start writing data even if the DB becomes healthy in the meantime. This means that I have to babysit LTSS when I'm doing some DB maintenance and if I don't notice that it's down it leaves me with big gaps in the data.
It would be better if LTSS was retrying to reconnect indefinitely (while logging the problem if it cannot connect), or at least if the number of retries was configurable (all the way to infinity).
I can help with the PR, just let me know if you are interested in this kind of change.
Thank you for your hard work.