Skip to content

Use hass config retry instead of native reconnect logic, improve error handling#50

Merged
rabits merged 2 commits into
rabits:mainfrom
GnoX:improve-connection-retries
Jun 30, 2025
Merged

Use hass config retry instead of native reconnect logic, improve error handling#50
rabits merged 2 commits into
rabits:mainfrom
GnoX:improve-connection-retries

Conversation

@GnoX
Copy link
Copy Markdown
Collaborator

@GnoX GnoX commented Jun 30, 2025

This PR adds multiple changes:

  • Reworked reconnection logic - instead of handling reconnections ourselves, this PR switches control to home assistant config reloads. This is better because it displays errors and retries in integration UI so user does not need to look at logs to see if something failed.
  • Reconnect can now only create one task at a time - there was possibility that disconnected was called more than once which caused multiple reconnect tasks to be spawned at once. If this repeats several times, requests would overlap and device received messages in wrong order causing it to immediately disconnect. This spawned yet more reconnect tasks and existing messages would still be received on the same characteristic but client would not be connected. This would explain what was was happening in [Bug]: Error Logging Loop / Disk Space Usage #36.
  • Added issues in case of connection failures - if the device can not connect more than 10 times in succession, setup fails until it is manually reloaded and creates HA issue that persists until the device is connected successfully
  • Changed update period default to 10 seconds - it makes more sense to have it a bit higher by default as most of the users don't need it.
  • Added observable states to connection for better error reporting
  • Added connection timeout option

@GnoX GnoX marked this pull request as ready for review June 30, 2025 00:02
@rabits rabits self-requested a review June 30, 2025 15:11
@rabits rabits added bug Something isn't working enhancement New feature or request labels Jun 30, 2025
@rabits
Copy link
Copy Markdown
Owner

rabits commented Jun 30, 2025

Thank you! Will quickly check how it's working on my setup and will approve.

Copy link
Copy Markdown
Owner

@rabits rabits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Works for me and defaulting to update per 10 sec is necessary. Geeks will find out how to get immediate updates, but for regular user once per 10 sec sounds reasonable.

@rabits rabits merged commit f61b1f3 into rabits:main Jun 30, 2025
3 checks passed
@GnoX GnoX deleted the improve-connection-retries branch December 14, 2025 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants