Do not shutdown device upon errors #587
Merged
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.
This PR removes the calls to
shutdown
(Gen1) andself._disconnect_websocket()
(same asshutdown
, 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)aioshelly/aioshelly/block_device/device.py
Lines 168 to 170 in e8058a5
However it would be better not to call shutdown at all and let the caller/user decide when to shutdown the device.