Closed Sticklyman1936 closed 2 years ago
Ideally there would be some sort of call back from pyunifiprotect to alart when the websocket is disconnected, but I couldn't find one. Would avoid the cronjob.
Merging #13 (c9634ba) into main (e3fbb1b) will not change coverage. The diff coverage is
0.00%
.
@@ Coverage Diff @@
## main #13 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 3 3
Lines 242 270 +28
=====================================
- Misses 242 270 +28
Impacted Files | Coverage Δ | |
---|---|---|
unifi_protect_backup/unifi_protect_backup.py | 0.00% <0.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 e3fbb1b...c9634ba. Read the comment docs.
Thanks for the PR!
Fixes #12
Both network issues and restarts of Unifi Protect can cause the websocket to disconnect. Once this happens, no more events are recieved, and hence no events are stored via rclone.
We add a task which checks that the websocket is connected every minute. If the websocket is not connected, the connection is totally reset. For a simple network issue, is should be sufficient to just call pyunifiprotect's update(), but this doesn't work when protect has been restarted. Given that this is a tool that should always be running, we opt for the most extreme option of totally resetting the connection, and re-establishing it from scratch.