Unifi OS 4.x and pyunifiprotect breaking changes
Closed this issue · 23 comments
Unifi Protect Backup 0.10.7 works with Unifi Protect 4.0.7 and 4.0.19 work without changes, however Unifi OS 4.x and pyunifiprotect are introducing breaking changes.
Unifi OS 4.0.3 changes the cookie names: https://github.com/AngellusMortis/pyunifiprotect/issues/382
This PR resolves it: https://github.com/AngellusMortis/pyunifiprotect/pull/388
There is also a PR that refactors Unifi OS auth in a seemingly breaking change: https://github.com/AngellusMortis/pyunifiprotect/pull/391
Both PRs are merged but there isn't a new version yet.
If I produce a dev build with these changes included would you be able to test them?
Unfortunately I only have one unifi setup which I won't upgrade to EA because last time I tried it broke everything and I had to factory reset everything
If you can put it into a docker, and give me the tag name, I can.
If I produce a dev build with these changes included would you be able to test them?
Unfortunately I only have one unifi setup which I won't upgrade to EA because last time I tried it broke everything and I had to factory reset everything
Yes! It looks like punifiprotect has a release that includes these PRs now. I can test it out.
The dev container has been updated to the latest version of pyunifiprotect. Let me know if that works without any other changes
Sorry it took so long, but I finally got around to testing it. Predictably ended up with the same error in #151
I know you're low on time right now so I'll patiently wait. I can test whatever dev builds you push.
there should be a new build shortly that fixes #151 in the dev container, if you can confirm this works with 4.x.x I will push a new release. My UDM still hasn't gotten the update.
there should be a new build shortly that fixes #151 in the dev container, if you can confirm this works with 4.x.x I will push a new release. My UDM still hasn't gotten the update.
Working a lot better now. The previous error is gone, but now there's this:
2024-06-05 22:29:03 [ ERROR ] unifi_protect_backup.missing_event_checker : Unexpected exception occurred during missing event check:
Traceback (most recent call last):
File "/usr/lib/python3.12/site-packages/unifi_protect_backup/missing_event_checker.py", line 151, in start
async for event in self._get_missing_events():
File "/usr/lib/python3.12/site-packages/unifi_protect_backup/missing_event_checker.py", line 65, in _get_missing_events
events_chunk = await self._protect.get_events(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pyunifiprotect/api.py", line 786, in get_events
response = await self.get_events_raw(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pyunifiprotect/api.py", line 745, in get_events_raw
return await self.api_request_list("events", params=params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pyunifiprotect/api.py", line 316, in api_request_list
data = await self.api_request(
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pyunifiprotect/api.py", line 274, in api_request
data = await self.api_request_raw(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pyunifiprotect/api.py", line 249, in api_request_raw
await self._os.verify_response(url, response)
File "/usr/lib/python3.12/site-packages/pyunifiprotect/session.py", line 332, in verify_response
raise NotAuthorized(msg % (url, response.status, reason))
pyunifiprotect.exceptions.NotAuthorized: Request failed: /proxy/protect/api/events - Status: 401 - Reason: {'code': 401, 'message': 'Unauthorized'}
I just saw that is being discussed in #150
My UDM still hasn't gotten the update so I am unable to test this to figure out why this is happening. I saw people on the home assistant forums saying creating a new local only user fixed issues, so maybe try that?
My UDM still hasn't gotten the update so I am unable to test this to figure out why this is happening. I saw people on the home assistant forums saying creating a new local only user fixed issues, so maybe try that?
I recreated the local user for UPB and it made no difference. I even tested setting it as a super admin which had no difference. I switched it back to the custom role denying console OS settings access.
I have tracked down the issue, it is caused by Unifi Protect returning invalid cookies, which means pyunifiprotect is then not re-using the session token, triggering a rate-limit on authentication:
https://github.com/AngellusMortis/pyunifiprotect/issues/401
It would appear that the pyunifiprotect
repository is no more.
Maybe it is time to move to the fork?
https://github.com/uilibs/uiprotect
@ronytomen thanks for the heads up. I will make the switch. I suspected this might happen so already forked pyunifiprotect for this projects use incase something happened to it
Wow. Wtf? I’m glad I just moved my pull request changes from there yesterday.
Looks like it's been pulled off PyPI too which is an issue. I will be switching to the new fork as soon as the new downloader is merged, I'll have everything prepped to go
It would appear bdraco was the original dev of the library to begin with, so no major issue here with it having been moved to a new location. They seem super chill and am hoping I can sign on as a maintainer with them, once I learn how he would like certain things done on that repo. :p
Actually a user named briis was, then forked to bdraco, then forked to AngellusMortis. briis has archived their repository. Just a fun fact.
If you check the bottom of the readme I think it still lists briis, because I've been too lazy to update it 😅
Can folks confirm if the latest release has addressed this now? Locally for me it seems to work now with 4.x.x
I upgraded to Protect 4.0.33
today and pulled the latest docker image. Everything is working for me but I have a mix of G3/G4/G5 cameras, nothing fancy.
Still working for me on experimental.
I upgraded to Protect
4.0.33
today and pulled the latest docker image. Everything is working for me but I have a mix of G3/G4/G5 cameras, nothing fancy.
The issues are with Unifi OS 4.x, not Protect 4.x
I upgraded to Protect
4.0.33
today and pulled the latest docker image. Everything is working for me but I have a mix of G3/G4/G5 cameras, nothing fancy.The issues are with Unifi OS 4.x, not Protect 4.x
My bad, I misunderstood.
Can folks confirm if the latest release has addressed this now? Locally for me it seems to work now with 4.x.x
It has been working fine for me since June 5th on the latest release.