diyhue / diyHue

Main diyHue software repo
https://diyhue.org/
Other
1.52k stars 274 forks source link

geofence_client missing id_v2 #897

Closed caribo closed 7 months ago

caribo commented 1 year ago

Describe the bug

I have diyHue (06/03/2023) added to HomeAssistant 2023.3.1

The diyHue log file shows error due to missing id_v2 attribute associated with the geofence_client object

Steps to Reproduce

Connect HomeAssistant to diyhue Observe diyhue logs

Expected behavior

No errors expected

Logs

2023-03-06 10:15:58,780 - werkzeug - INFO - 192.168.1.3 - - [06/Mar/2023 10:15:58] "GET /eventstream/clip/v2 HTTP/1.1" 200 -
[2023-03-06 10:16:58,802] ERROR in app: Exception on /clip/v2/resource/geofence_client [POST]
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/usr/local/lib/python3.9/dist-packages/flask_restful/__init__.py", line 467, in wrapper
    resp = resource(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/flask/views.py", line 84, in view
    return current_app.ensure_sync(self.dispatch_request)(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/flask_restful/__init__.py", line 582, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/opt/hue-emulator/flaskUI/v2restapi.py", line 465, in post
    "rid": newObject.id_v2,
AttributeError: 'NoneType' object has no attribute 'id_v2'

Docker Info (please complete the following information):

Checklist

Additional context

caribo commented 1 year ago

@mariusmotea I think I am seeing this issue due to aiohue component of Homeassistant implementing a hack to keep the eventstream alive. Basically they are creating a geofence_client and updating the name very minute to flush the event through the event stream and determine that the connection is still alive.. and I don't think diyhue handles the creation / update of the geofence_client..

https://github.com/home-assistant-libs/aiohue/blob/2f5e048fe0ec086684d7f2e4abb9ad8b8915ea91/aiohue/v2/controllers/events.py

async def __keepalive_workaround(self) -> NoReturn:
        """Send keepalive command to bridge, abusing geofence client."""
        # Oh yeah, this is a major hack and hopefully it will only be temporary ;-)
        # Signify forgot to implement some sort of periodic keep alive message on the EventBus
        # so we have no way to determine if the connection is still alive.
        # To workaround this, we create a geofence client (with status not at home)
        # on the bridge for aiohue which will have its name updated every minute
        # this will result in an event on the eventstream and thus a way to figure out
        # if its still alive. It's not very pretty but at least it works.
        # Now let's contact Signify if this can be solved.
        # Update 2022-12-12: Still no solution and apparently no real need for signify to fix this
        # https://developers.meethue.com/forum/t/several-issues-and-questions-about-the-v2-api/6586/35
        prefix = "aiohue_"

Their approach leads to the eventstream connecting / disconnecting continually as the "keepalive" does not work with Diyhue (works with physical bridge though).

GitHub
aiohue/events.py at 2f5e048fe0ec086684d7f2e4abb9ad8b8915ea91 · home-assistant-libs/aiohue
Python3 asyncio package to talk to Philips Hue. Contribute to home-assistant-libs/aiohue development by creating an account on GitHub.
Write commented 11 months ago

I have a slightly different error but certainly related too


2023-08-11 16:29:47,407 - flaskUI.v2restapi - DEBUG - {'is_at_home': False, 'name': 'aiohue_', 'type': 'geofence_client'}
[2023-08-11 16:29:47,409] ERROR in app: Exception on /clip/v2/resource/geofence_client [POST]
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask_restful/__init__.py", line 467, in wrapper
    resp = resource(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask/views.py", line 84, in view
    return current_app.ensure_sync(self.dispatch_request)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask_restful/__init__.py", line 582, in dispatch_request
    resp = meth(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hue-emulator/flaskUI/v2restapi.py", line 465, in post
    "rid": newObject.id_v2,
           ^^^^^^^^^^^^^^^