home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.25k stars 30.24k forks source link

Do not have permission to read media for camera #127764

Open cholywell opened 1 day ago

cholywell commented 1 day ago

The problem

Running Protect 5.0.34

Multiple times per day Home Assistant will stop getting updates for the entities for all Unifi Protect and all video streams will stop working. If you try to reload the integration all entities will go unavailable. Sometimes if you wait a number of hours it starts working. To temporarily fix it I must keep restarting Unifi Protect and Home Assistant until it starts working.

When this happens there are errors in the Home Assistant logs:

uiprotect.exceptions.NotAuthorized: Do not have permission to read media for camera: 5d9294f800362703e70003ed

And errors in the /var/log/ui.log:

2024-10-06 13:43:16.465 WARNING UCore cloud: Endpoint check failed 2024-10-06 13:43:18.175 WARNING qt.network.http2: stream 1 finished with error: "Connection closed" 2024-10-06 13:43:18.218 WARNING qtprotobuflog: "ConsoleStatus" call "unifi.core.console.v1.ConsoleAPI" stream finished: "Connection closed"

What version of Home Assistant Core has the issue?

2024.10.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Unifi Protect

Link to integration documentation on our website

https://www.home-assistant.io/integrations/unifiprotect/

Diagnostics information

config_entry-unifiprotect-01J9C5GA8TF8XAH9W7CWYEVHW0.json

Example YAML snippet

No response

Anything in the logs that might be useful for us?

From the Home Assistant logs:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 477, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 559, in _handle
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 210, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 813, in get
    return await self.handle(request, camera)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 831, in handle
    image = await _async_get_image(
            ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 189, in _async_get_image
    else await camera.async_camera_image(width=width, height=height)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/unifiprotect/camera.py", line 251, in async_camera_image
    last_image = await self.device.get_snapshot(width, height)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/uiprotect/data/devices.py", line 1989, in get_snapshot
    raise NotAuthorized(
uiprotect.exceptions.NotAuthorized: Do not have permission to read media for camera: 5d9294f800362703e70003ed

From the /var/log/ui.log on the CloudKey:

2024-10-06 12:21:42.025 INFO LCM: user session active
2024-10-06 12:32:30.485 INFO LCM: user session inactive
2024-10-06 12:46:28.645 INFO LCM: user session active
2024-10-06 12:52:30.529 INFO LCM: user session inactive
2024-10-06 13:07:25.809 INFO LCM: user session active
2024-10-06 13:12:30.531 INFO LCM: user session inactive
2024-10-06 13:43:16.465 WARNING UCore cloud: Endpoint check failed
2024-10-06 13:43:18.175 WARNING qt.network.http2: stream 1 finished with error: "Connection closed"
2024-10-06 13:43:18.218 WARNING qtprotobuflog: "ConsoleStatus" call "unifi.core.console.v1.ConsoleAPI" stream finished:  "Connection closed"
2024-10-06 13:43:18.245 WARNING qtprotobuflog: "ConsoleStatus" call "unifi.core.console.v1.ConsoleAPI" stream finished:  "Connection refused"
2024-10-06 13:43:18.245 WARNING qtprotobuflog: "ConsoleStatus" call "unifi.core.console.v1.ConsoleAPI" stream error:  "unifi.core.console.v1.ConsoleAPI call ConsoleStatus stream failed: Connection refused"
2024-10-06 13:43:18.249 WARNING UCore grpc: Subscription error: QtProtobuf::QGrpcStatus::Unavailable "unifi.core.console.v1.ConsoleAPI call ConsoleStatus stream failed: Connection refused"
2024-10-06 13:43:21.363 WARNING UCore applications: Endpoint check failed
2024-10-06 13:43:21.363 WARNING UCore cloud: Endpoint check failed
2024-10-06 13:43:26.366 WARNING UCore applications: Endpoint check failed
2024-10-06 13:43:26.367 WARNING UCore cloud: Endpoint check failed
2024-10-06 13:43:28.374 WARNING qtprotobuflog: "ConsoleStatus" call "unifi.core.console.v1.ConsoleAPI" stream finished:  "Connection refused"
2024-10-06 13:43:28.374 WARNING qtprotobuflog: "ConsoleStatus" call "unifi.core.console.v1.ConsoleAPI" stream error:  "unifi.core.console.v1.ConsoleAPI call ConsoleStatus stream failed: Connection refused"
2024-10-06 13:43:28.374 WARNING UCore grpc: Subscription error: QtProtobuf::QGrpcStatus::Unavailable "unifi.core.console.v1.ConsoleAPI call ConsoleStatus stream failed: Connection refused"
2024-10-06 14:11:39.405 INFO LCM: user session active
2024-10-06 14:23:28.751 INFO LCM: user session inactive
2024-10-06 14:31:01.118 INFO LCM: user session active
2024-10-06 14:42:21.795 INFO LCM: user session inactive

Additional information

No response

home-assistant[bot] commented 1 day ago

unifiprotect documentation unifiprotect source

gionimi commented 14 hours ago

After the Protect update to versions 5.0.X, the integration became terrible. In version 4.0.33, it was quite stable. I'm experiencing many vehicle detection failures, the trigger that is activated but not deactivated, and car license plates that are no longer detected.