[General] Add better timeout and error handling#121
Open
tchapi wants to merge 3 commits intogduteil:mainfrom
Open
[General] Add better timeout and error handling#121tchapi wants to merge 3 commits intogduteil:mainfrom
tchapi wants to merge 3 commits intogduteil:mainfrom
Conversation
tchapi
commented
Mar 28, 2026
Comment on lines
-263
to
-266
| headers = { | ||
| "Authorization": f"Bearer {self._access_token}", | ||
| "Content-Type": "application/json", | ||
| } |
Contributor
Author
There was a problem hiding this comment.
Please review with hide whitespace: on for clarity (most differences are indentation ones)
tchapi
commented
Mar 28, 2026
| self._config_uniq_id = config_uniq_id | ||
| self._last_value: str | None = None | ||
| self._device_uniq_id = config_uniq_id | ||
| self._attr_name = name |
Contributor
Author
There was a problem hiding this comment.
Missing attr set, while it is used below in the log (making the integration crash)
tchapi
commented
Mar 28, 2026
| await self.coordinator.set_away_mode_timestamps( | ||
| self._capability["capabilityId"], | ||
| self._value_pending, | ||
| self._value_on, |
Contributor
Author
There was a problem hiding this comment.
Setting value as pending was actually not setting the away mode to On all the time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello @gduteil 👋🏼
While using the integration in my HA installation (I have a Calypso boiler), I noticed that it was sometimes "losing" the connection, and then the data was not showing anymore (and I couldn't use the actions too). When reloading the integration, it was working again.
I identified a few things that I think could make the integration more robust.
No request timeouts
async with self._session.get(...)has no timeout.If the Atlantic API hangs (given the quality of their app and ecosystem, ... I'd say it could happen 😅 — but it can also be due to network conditions on the wifi the boiler is),
_async_update_datanever returns. SinceDataUpdateCoordinatorruns updates sequentially, the next scheduled poll never starts. The integration freezes silently, data goes stale, HA shows no error.Network errors don't trigger reconnects
The
try/except ContentTypeErroris inside theasync withresponse block. Any error that happens before the response body is read —aiohttp.ClientConnectorError, asyncio.TimeoutError, ServerDisconnectedError— is outside the try and propagates up.DataUpdateCoordinatorcatches it and logs it, butself.onlinestaysTrue. So the next poll goes down theif self.online: branchagain instead of callingconnect(). It never re-authenticates.401 / token expiry has no proactive handling
There's no
expires_intracking and no HTTP status check. Token expiry only self-heals if the API returns a non-list JSON body (triggeringself.online = False). If the session degrades silently, it never recovers.Setting away mode as "pending"
The Atlantic API seems to respond better to setting the away mode as ON rather than PENDING (in
CozytouchAwayModeSwitch)I've tried to fix these four things in the PR here. Hopefully it helps everyone using this integration to have a more robust integration!
I've tested the modified file on my installation for 2 days, no problem so far (and no disconnects + better away mode handling).
Note
I've used Claude to analyze the possible errors and get best practices, but the code is mostly mine.