Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not shutdown device upon errors #587

Merged
merged 2 commits into from
Jul 1, 2024
Merged

Do not shutdown device upon errors #587

merged 2 commits into from
Jul 1, 2024

Conversation

thecode
Copy link
Contributor

@thecode thecode commented Jun 30, 2024

This PR removes the calls to shutdown (Gen1) and self._disconnect_websocket() (same as shutdown, Gen2+) upon failures.
The shutdown process removes subscription to device async updates (updates which are pushed from the device by IP/MAC), this method is not reversible so after calling shutdown the only way to resubscribe to updates is to create a new device object.
However for sleeping devices we need the updates to continue flowing even if there is a failure since they trigger event to connect to the device.

Currently, If a sleeping device has an error on first time that we try to connect to it and it fails subsequent events from the device will be stopped so there won't be anything to try to trigger a new connection to the device on the next wakeup.
This logic was existing up to aioshelly 8.2.0 and removed by mistake (only the raise was supposed to move out of the condition)

if not async_init:
self.shutdown()
raise self._last_error from err

However it would be better not to call shutdown at all and let the caller/user decide when to shutdown the device.

Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
Copy link
Collaborator

@bieniu bieniu 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, tested with a real device.

@thecode thecode added the breaking-change Breaking changes label Jul 1, 2024
@thecode thecode merged commit d24f962 into main Jul 1, 2024
2 checks passed
@thecode thecode deleted the fix-shutdown branch July 1, 2024 14:22
@thecode thecode mentioned this pull request Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants