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.61k stars 30.37k forks source link

Unifi protect G4 Doorbell Pro Doorbell pressed events not working since upgrade to protect 2.10.11 #106102

Closed digitalbanana closed 9 months ago

digitalbanana commented 10 months ago

The problem

have had HA running in docker with G4 doorbell pro integration working for about 6 months, an automation plays a sound on a sonos device on doorbell pressed.

since update to protect 2.10.11, HA is no longer seeing doorbell pressed events

2023-12-20 09:38:56.724 DEBUG (MainThread) [pyunifiprotect.api] Skipping update since websocket is active
2023-12-20 09:39:01.725 DEBUG (MainThread) [pyunifiprotect.api] Skipping update since websocket is active
2023-12-20 09:39:06.725 DEBUG (MainThread) [pyunifiprotect.api] Skipping update since websocket is active
2023-12-20 09:39:11.726 DEBUG (MainThread) [pyunifiprotect.api] Skipping update since websocket is active
2023-12-20 09:39:12.558 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G4 Doorbell Pro (E438830C38CD)
2023-12-20 09:39:12.561 DEBUG (MainThread) [homeassistant.components.unifiprotect.select] Updating dynamic select options for Doorbell Text
2023-12-20 09:39:12.633 DEBUG (MainThread) [pyunifiprotect.data.bootstrap] last_ring for 643e2e7a01aee103e4005fb7 (True)
2023-12-20 09:39:12.633 DEBUG (MainThread) [pyunifiprotect.data.base] Event ping timer started for 643e2e7a01aee103e4005fb7
2023-12-20 09:39:12.633 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G4 Doorbell Pro (E438830C38CD) 
2023-12-20 09:39:12.634 DEBUG (MainThread) [homeassistant.components.unifiprotect.select] Updating dynamic select options for Doorbell Text
2023-12-20 09:39:13.826 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G4 Doorbell Pro (E438830C38CD)
2023-12-20 09:39:13.826 DEBUG (MainThread) [homeassistant.components.unifiprotect.select] Updating dynamic select options for Doorbell Text
2023-12-20 09:39:15.634 DEBUG (MainThread) [pyunifiprotect.data.base] Event ping callback started for 643e2e7a01aee103e4005fb7
2023-12-20 09:39:16.727 DEBUG (MainThread) [pyunifiprotect.api] Skipping update since websocket is active
2023-12-20 09:39:17.411 DEBUG (MainThread) [pyunifiprotect.websocket] WS Timeout loop sleep 29.99984071799554
2023-12-20 09:39:21.727 DEBUG (MainThread) [pyunifiprotect.api] Skipping update since websocket is active
2023-12-20 09:39:26.729 DEBUG (MainThread) [pyunifiprotect.api] Skipping update since websocket is active

weirdly last ring time is updated so am trying to make that work but wondering if anyone else has seen this or has any idea. my guess is that the unifi firmware update broke it

What version of Home Assistant Core has the issue?

2023.12.0

What was the last working version of Home Assistant Core?

2023.12.0

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Unifi Protect

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2023-12-20 09:38:56.724 DEBUG (MainThread) [pyunifiprotect.api] Skipping update since websocket is active
2023-12-20 09:39:01.725 DEBUG (MainThread) [pyunifiprotect.api] Skipping update since websocket is active
2023-12-20 09:39:06.725 DEBUG (MainThread) [pyunifiprotect.api] Skipping update since websocket is active
2023-12-20 09:39:11.726 DEBUG (MainThread) [pyunifiprotect.api] Skipping update since websocket is active
2023-12-20 09:39:12.558 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G4 Doorbell Pro (E438830C38CD)
2023-12-20 09:39:12.561 DEBUG (MainThread) [homeassistant.components.unifiprotect.select] Updating dynamic select options for Doorbell Text
2023-12-20 09:39:12.633 DEBUG (MainThread) [pyunifiprotect.data.bootstrap] last_ring for 643e2e7a01aee103e4005fb7 (True)
2023-12-20 09:39:12.633 DEBUG (MainThread) [pyunifiprotect.data.base] Event ping timer started for 643e2e7a01aee103e4005fb7
2023-12-20 09:39:12.633 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G4 Doorbell Pro (E438830C38CD) 
2023-12-20 09:39:12.634 DEBUG (MainThread) [homeassistant.components.unifiprotect.select] Updating dynamic select options for Doorbell Text
2023-12-20 09:39:13.826 DEBUG (MainThread) [homeassistant.components.unifiprotect.data] Updating device: G4 Doorbell Pro (E438830C38CD)
2023-12-20 09:39:13.826 DEBUG (MainThread) [homeassistant.components.unifiprotect.select] Updating dynamic select options for Doorbell Text
2023-12-20 09:39:15.634 DEBUG (MainThread) [pyunifiprotect.data.base] Event ping callback started for 643e2e7a01aee103e4005fb7
2023-12-20 09:39:16.727 DEBUG (MainThread) [pyunifiprotect.api] Skipping update since websocket is active
2023-12-20 09:39:17.411 DEBUG (MainThread) [pyunifiprotect.websocket] WS Timeout loop sleep 29.99984071799554
2023-12-20 09:39:21.727 DEBUG (MainThread) [pyunifiprotect.api] Skipping update since websocket is active
2023-12-20 09:39:26.729 DEBUG (MainThread) [pyunifiprotect.api] Skipping update since websocket is active


### Additional information

_No response_
home-assistant[bot] commented 10 months ago

Hey there @angellusmortis, @bdraco, mind taking a look at this issue as it has been labeled with an integration (unifiprotect) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `unifiprotect` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign unifiprotect` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


unifiprotect documentation unifiprotect source (message by IssueLinks)

AngellusMortis commented 10 months ago

@home-assistant add-label needs-more-information

AngellusMortis commented 10 months ago

Your logs say that it is still working fine.

digitalbanana commented 10 months ago

hi @AngellusMortis - okay im not sure exactly which events the logs relate to but the HA installation shows nothing for the (previously working) doorbell pressed event... i set up some text saying doorbell broken and i thought thats what these logs relate to...

either way i managed to get around the problem - i changed my automation to trigger on "G4 Doorbell Pro Last Doorbell Ring" changes and its working ok - very strange though - my hunch is that the doorbell is behaving slightly differently after the protect update

AngellusMortis commented 10 months ago

okay im not sure exactly which events the logs relate to but the HA installation shows nothing for the (previously working) doorbell pressed event

Exactly. You do not. That is why the issue template tells you how to generate logs and diagnostics. When you do not follow those instructions, you end up being wrong about what is important because you do not know how the code works. If you still want to disagree there is something wrong, then you need to follow the instructions correctly this time.

digitalbanana commented 10 months ago

okay i tried to follow the guidelines for log submission as best i could but sincere apologies if i have done this incorrectly. My initial post was that something has changed somewhere (either in HA core or Unifi) but to be honest I dont know which. Am happy to close this as i found a workaround but i would suspect there might be future similar reports if anyone is relying on the Doorbell pressed event. Thanks for your input

vju42 commented 9 months ago

I believe i have the same problem. Anything i can do to help? I do have a g4 doorbell (not pro) and do not see any events when pressing the button but also have no last pressed attribute.

marcoschwingel commented 9 months ago

I faced the same problem today and found a simple solution: The doorbell sensor was somehow missing in the integration (I updated to homeassistant 2023.12.4 yesterday), although it was present in the past and visible (without errors) in the log and history as well as in my automation. But it was not changed/triggered anymore when the doorbell button was pressed.

After I RELOADED the unifi protect integration, the sensor became visible again: doorbell_sensor

And my automation is working again: doorbell_history

MiraiSubject commented 9 months ago

I am using the G4 Doorbell not Pro

I readopted the doorbell, reloaded the integration and restarted the HA container as well but no dice.

Version | core-2023.12.4
Installation Type | Home Assistant Container
Development | false
Supervisor | false
Docker | true
User | root
Virtual Environment | false
Python Version | 3.11.6
Operating System Family | Linux
Operating System Version | 6.1.0-16-amd64
CPU Architecture | x86_64
Timezone | Europe/Amsterdam
Configuration Directory | /config

Here are my diagnostics with debug logging enabled (turned on debug logging, pressed doorbell, exported logs): home-assistant_unifiprotect_2023-12-31T15-36-32.602Z.log

Some things that stand out to me in the log:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pyunifiprotect/websocket.py", line 82, in _process_message
    sub(msg)
  File "/usr/local/lib/python3.11/site-packages/pyunifiprotect/api.py", line 694, in _process_ws_message
    processed_message = self.bootstrap.process_ws_packet(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyunifiprotect/data/bootstrap.py", line 578, in process_ws_packet
    return self._process_device_update(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyunifiprotect/data/bootstrap.py", line 489, in _process_device_update
    obj = obj.update_from_dict(deepcopy(data))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyunifiprotect/data/devices.py", line 1041, in update_from_dict
    return super().update_from_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyunifiprotect/data/base.py", line 546, in update_from_dict
    setattr(self, key, convert_unifi_data(data[key], self.__fields__[key]))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyunifiprotect/utils.py", line 238, in convert_unifi_data
    return type_(value)
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/uuid.py", line 175, in __init__
    hex = hex.replace('urn:', '').replace('uuid:', '')
          ^^^^^^^^^^^
AttributeError: 'UUID' object has no attribute 'replace'
2023-12-31 16:34:40.620 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 233, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 31, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 149, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/diagnostics/__init__.py", line 249, in get
    data = await info.config_entry_diagnostics(hass, config_entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/unifiprotect/diagnostics.py", line 21, in async_get_config_entry_diagnostics
    bootstrap = cast(dict[str, Any], anonymize_data(data.api.bootstrap.unifi_dict()))
                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyunifiprotect/data/bootstrap.py", line 232, in unifi_dict
    data = super().unifi_dict(data=data, exclude=exclude)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyunifiprotect/data/base.py", line 476, in unifi_dict
    data[key] = self._unifi_dict_protect_obj_dict(data, key, use_obj)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyunifiprotect/data/base.py", line 432, in _unifi_dict_protect_obj_dict
    obj = obj.unifi_dict()  # noqa: PLW2901
          ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyunifiprotect/data/devices.py", line 985, in unifi_dict
    data = super().unifi_dict(data=data, exclude=exclude)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyunifiprotect/data/base.py", line 1105, in unifi_dict
    data = super().unifi_dict(data=data, exclude=exclude)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyunifiprotect/data/base.py", line 976, in unifi_dict
    data = super().unifi_dict(data=data, exclude=exclude)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyunifiprotect/data/base.py", line 586, in unifi_dict
    data = super().unifi_dict(data=data, exclude=exclude)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyunifiprotect/data/base.py", line 468, in unifi_dict
    data[key] = self._unifi_dict_protect_obj(data, key, use_obj, klass)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyunifiprotect/data/base.py", line 386, in _unifi_dict_protect_obj
    value = getattr(self, key)
            ^^^^^^^^^^^^^^^^^^
AttributeError: 'Camera' object has no attribute 'event_stats'

Here are the access control settings for the local account I'm using for HA and Scrypted: image

Timeline view:

image

Before 16:23 I was factory resetting and readopting the doorbell hence the blank space.

AngellusMortis commented 9 months ago

OP never provided requested diagnostics data or additional data about how it was failing. If you are having this issue, make your own issue and provide the requested logs and diagnostics data.

AngellusMortis commented 9 months ago

@home-assistant close