Integration development - Handling connectivity issues

Hi all,

I started my first custom integration development - it is really fun and I love HA.
It is a simple integration that uses the polling mechanism in order to fetch data.
What I could not find out - even with intense reading of the documentation and scanning other code - what to do with connectivity issues.
My integration is fetching data every 4 hours. But it can happen that the internet connection is lost at the very same time. HA marks the entities as unavailable. And I have have to restart the integration, when connectivity is back.

Of course, I could reduce the update interval in general (to let’s say 15 minutes), but it does not feel right. I would like to have some more robustness in case of connectivity issues.
I’d love to ask HA to poll more often in case of connectivity issues or even poll once internet connectivity is live again.
But I was not able to reduce the update interval in case I receive an exception from aiohttp (I tried to change self.update_intervall within the DataUpdateCoordinators async_update_data function, but no look ) . What is your strategy for your integration in case of connectivity issues?

KR
Nazze

I write the integration for the Drayton Wiser system. It is a wifi device and has a known issue that is drops off the wifi frequently.

As such, the api has a retry routine, and if that fails the data update coordinator handles the fail and returns false. This then does not try to update the entities and keeps them available. I also have an entity to show the update status and last update time to be able to monitor this. Feel free to look at the code on our repo.

Alternatively, post a link to your code and i will review and recommend how to adapt.

That was really helpful. While reviewing your code and comparing I realized, that I did a stupid mistake in exception handling. :see_no_evil: I was rasing unintentionally a timeout exception to HA, where I thought I would catch it.
Thank you so much! :slight_smile: