I noticed that there was already code which retried the connection to the heatpump when it was disconnected, but it had a bug where it never reset the number of tries, so if it tried twice on Tuesday, then successfully reconnected, tried twice on Thursday, and successfully reconnected, and tried once on Friday, with the default count of 5 it would then give up until restarted.
Now it resets the number of tries after each successful connection. It also never completely gives up trying to connect.
I also updated the logic which delays the retries to use exponential backoff instead of a constant retry rate. Exponential backoff is a common retry strategy that seemed easy enough to apply here.
Fixes #159
I noticed that there was already code which retried the connection to the heatpump when it was disconnected, but it had a bug where it never reset the number of tries, so if it tried twice on Tuesday, then successfully reconnected, tried twice on Thursday, and successfully reconnected, and tried once on Friday, with the default count of 5 it would then give up until restarted.
Now it resets the number of tries after each successful connection. It also never completely gives up trying to connect.
I also updated the logic which delays the retries to use exponential backoff instead of a constant retry rate. Exponential backoff is a common retry strategy that seemed easy enough to apply here.