Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure running background task #372

Closed
PrzemyslawKlys opened this issue Dec 15, 2024 · 1 comment
Closed

Failure running background task #372

PrzemyslawKlys opened this issue Dec 15, 2024 · 1 comment

Comments

@PrzemyslawKlys
Copy link

I'm running Home Assistant 2024.12.3 and trying to pair Nanoleaf Led Stip which seems to work via Thread. It keeps on failing claiming the device is already added to another device. It asks to report it, so I did.

2024-12-15 09:45:35.679 WARNING (MainThread) [aiohomekit.controller.coap.pdu] Transaction 0 failed with error 6 (Invalid request
2024-12-15 09:45:35.948 WARNING (MainThread) [coap-server] An exception that is not an aiocoap Error was raised from a transport; please report this as a bug in aiocoap: TypeError("'NoneType' object does not support item assignment")
2024-12-15 09:45:35.948 ERROR (MainThread) [aiohomekit.utils] Failure running background task: Task-198725
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/aiohomekit/utils.py", line 40, in _handle_task_result
    task.result()
    ~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/aiohomekit/controller/coap/pairing.py", line 169, in _process_config_changed
    await self.list_accessories_and_characteristics()
  File "/usr/local/lib/python3.13/site-packages/aiohomekit/controller/coap/pairing.py", line 149, in list_accessories_and_characteristics
    accessories = await self.connection.get_accessory_info()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohomekit/controller/coap/connection.py", line 413, in get_accessory_info
    _, body = await self.enc_ctx.post(OpCode.UNK_09_READ_GATT, 0x0000, b"")
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohomekit/controller/coap/connection.py", line 194, in post
    res_pdu = await self.post_bytes(req_pdu)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohomekit/controller/coap/connection.py", line 171, in post_bytes
    response = await self.coap_ctx.request(request).response
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiocoap/protocol.py", line 760, in _run_outer
    await cls._run(app_request, response, weak_observation, protocol, log)
  File "/usr/local/lib/python3.13/site-packages/aiocoap/protocol.py", line 835, in _run
    blockresponse = await blockrequest.response
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiocoap/protocol.py", line 475, in send
    request_interface.request(pipe)
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiocoap/tokenmanager.py", line 246, in request
    self.outgoing_requests[key] = request
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^
TypeError: 'NoneType' object does not support item assignment
2024-12-15 09:45:35.950 WARNING (MainThread) [coap-server] An exception that is not an aiocoap Error was raised from a transport; please report this as a bug in aiocoap: TypeError("'NoneType' object does not support item assignment")
2024-12-15 09:45:35.951 ERROR (MainThread) [homeassistant.components.homekit_controller.config_flow] Pairing attempt failed with an unhandled exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/homekit_controller/config_flow.py", line 437, in async_step_pair
    return await self._entry_from_accessory(pairing)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/homekit_controller/config_flow.py", line 565, in _entry_from_accessory
    name = await pairing.get_primary_name()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohomekit/controller/abstract.py", line 264, in get_primary_name
    accessories = await self.list_accessories_and_characteristics()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohomekit/controller/coap/pairing.py", line 149, in list_accessories_and_characteristics
    accessories = await self.connection.get_accessory_info()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohomekit/controller/coap/connection.py", line 440, in get_accessory_info
    results = await self.enc_ctx.post_all(OpCode.CHAR_READ, iids, data)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohomekit/controller/coap/connection.py", line 201, in post_all
    res_pdu = await self.post_bytes(req_pdu)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohomekit/controller/coap/connection.py", line 171, in post_bytes
    response = await self.coap_ctx.request(request).response
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiocoap/protocol.py", line 760, in _run_outer
    await cls._run(app_request, response, weak_observation, protocol, log)
  File "/usr/local/lib/python3.13/site-packages/aiocoap/protocol.py", line 835, in _run
    blockresponse = await blockrequest.response
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiocoap/protocol.py", line 475, in send
    request_interface.request(pipe)
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiocoap/tokenmanager.py", line 246, in request
    self.outgoing_requests[key] = request
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^
TypeError: 'NoneType' object does not support item assignment
@chrysn
Copy link
Owner

chrysn commented Feb 10, 2025

Thanks for reporting this.

The main issue appears to be in aiohomekit where the transaction failed. Apparently, aiohomekit then shuts down its aiocoap context and still keeps sending requests; please take this up with the aiohomekit developers (and CC me in the issue, I'm curious how this came to be).

There is a secondary error that aiocoap does not properly raise a LibraryShutdown error instead of a TypeError; this is being fixed.

@chrysn chrysn closed this as completed in 7d4b44b Feb 11, 2025
chrysn added a commit that referenced this issue Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants