Skip to content

Add appropriate guards to websocket actions#292

Merged
bachya merged 1 commit intodevfrom
cleanup-websocket
Nov 15, 2021
Merged

Add appropriate guards to websocket actions#292
bachya merged 1 commit intodevfrom
cleanup-websocket

Conversation

@bachya
Copy link
Copy Markdown
Owner

@bachya bachya commented Nov 15, 2021

Describe what the PR does:

From looking at Home Assistant logs, it's apparent that the SimpliSafe websocket, like the REST API, is a little flaky. This leads the current websocket implementation to connect/disconnect too many times, trigger the watchdog spuriously, etc. So, this PR adds some guards:

  1. async_connect only attempts to connect if we aren't already connected.
  2. Same with async_disconnect.
  3. We only trigger the watchdog if its underlying task hasn't already been cancelled.

Does this fix a specific issue?

Fixes https://github.com/bachya/python-simplisafe/issues/

Checklist:

  • Confirm that one or more new tests are written for the new functionality.
  • Run tests and ensure everything passes (with 100% test coverage).
  • Update README.md and docs/ with any new documentation.
  • Add yourself to AUTHORS.md.

@bachya bachya added the bug Bugs or issues which will cause a problem for users label Nov 15, 2021
@bachya bachya self-assigned this Nov 15, 2021
@qlty-cloud-legacy
Copy link
Copy Markdown

Code Climate has analyzed commit e48e8e3 and detected 0 issues on this pull request.

View more on Code Climate.

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 15, 2021

Codecov Report

Merging #292 (e48e8e3) into dev (2f92156) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev     #292   +/-   ##
=======================================
  Coverage   99.77%   99.77%           
=======================================
  Files          13       13           
  Lines         900      903    +3     
=======================================
+ Hits          898      901    +3     
  Misses          2        2           
Impacted Files Coverage Δ
simplipy/websocket.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2f92156...e48e8e3. Read the comment docs.

@bachya bachya merged commit 833be42 into dev Nov 15, 2021
@bachya bachya deleted the cleanup-websocket branch November 15, 2021 00:14
@github-actions github-actions bot locked and limited conversation to collaborators Nov 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Bugs or issues which will cause a problem for users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant