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
74.15k stars 31.13k forks source link

Homekit device #124387

Closed aburhinox closed 3 months ago

aburhinox commented 3 months ago

The problem

I'm unable to add a Nanoleaf Essentials (non Matter) lightbulb connected through Thread and the HomeKit Device integration. I am not using Homekit, but just a google home as a thread boarder router. I was able to add one of three lights successfully, but continue to have problems with the others.

My steps to add are factory reset bulb. Use nanoleaf app on phone to configure bulb and add to thread network. See bulb pop up in home assistant and try to configure.

I'm getting a popup stating

This accessory is already paired to another device. Please reset the accessory and try again.

I pulled the logs and found an error


2024-08-21 21:44:55.267 WARNING (MainThread) [aiohomekit.controller.coap.pdu] Transaction 0 failed with error 6 (Invalid request
2024-08-21 21:45:13.335 WARNING (MainThread) [aiohomekit.controller.coap.pdu] Transaction 0 failed with error 6 (Invalid request
2024-08-21 21:45:13.543 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 454, in async_step_pair
    return await self._entry_from_accessory(pairing)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/homekit_controller/config_flow.py", line 582, in _entry_from_accessory
    name = await pairing.get_primary_name()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/abstract.py", line 264, in get_primary_name
    accessories = await self.list_accessories_and_characteristics()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/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.12/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.12/site-packages/aiohomekit/controller/coap/connection.py", line 194, in post
    res_pdu = await self.post_bytes(req_pdu)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/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.12/site-packages/aiocoap/protocol.py", line 758, in _run_outer
    await cls._run(app_request, response, weak_observation, protocol, log)
  File "/usr/local/lib/python3.12/site-packages/aiocoap/protocol.py", line 833, in _run
    blockresponse = await blockrequest.response
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
aiocoap.error.LibraryShutdown
2024-08-21 21:45:13.546 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-08-21 21:45:13.548 ERROR (MainThread) [aiohomekit.utils] Failure running background task: Task-1195
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohomekit/utils.py", line 40, in _handle_task_result
    task.result()
  File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/coap/pairing.py", line 169, in _process_config_changed
    await self.list_accessories_and_characteristics()
  File "/usr/local/lib/python3.12/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.12/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.12/site-packages/aiohomekit/controller/coap/connection.py", line 194, in post
    res_pdu = await self.post_bytes(req_pdu)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/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.12/site-packages/aiocoap/protocol.py", line 758, in _run_outer
    await cls._run(app_request, response, weak_observation, protocol, log)
  File "/usr/local/lib/python3.12/site-packages/aiocoap/protocol.py", line 833, in _run
    blockresponse = await blockrequest.response
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiocoap/protocol.py", line 473, in send
    request_interface.request(pipe)
  File "/usr/local/lib/python3.12/site-packages/aiocoap/tokenmanager.py", line 246, in request
    self.outgoing_requests[key] = request
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^
TypeError: 'NoneType' object does not support item assignment

What version of Home Assistant Core has the issue?

core-2024.8.2

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

homekit_controller

Link to integration documentation on our website

No response

Diagnostics information

homekit_controller-01J5VTA0MRQMW4KV16H79WZWMJ-Nanoleaf A19 48FC-1ff84d6f4c83ad26366a8f6730d85d3d(1).json

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 3 months ago

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

Code owner commands Code owners of `homekit_controller` 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 homekit_controller` 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)


homekit_controller documentation homekit_controller source (message by IssueLinks)

Jc2k commented 3 months ago

Are you using iOS for the nanoleaf app?

aburhinox commented 3 months ago

No, I'm using an android device to control the nanoleaf bulbs directly. I'm trying to do this without any apple devices since I don't own any.

Jc2k commented 3 months ago

Thats fine. Just the error isn't lying, something is already paired to it, so trying to figure out what. Android can't cause that state, and you don't have iOS. So it's probably a failed HA pairing attempt that will need a factory reset. There was someone else on discord doing basically the same thing the other day. I think their bulb had completed the crypto exchange, but the last value returned by the Nanoleaf was broken. So the Nanoleaf thought the pairing was complete (hence the popup you now see) but HA didn't have enough information to complete.

In the end after a few tries, it just worked.

I suspect given one worked, there might be some interference or similar at play. The nanoleaf app isn't a reliable indicator here as it will fallback to bluetooth at the slightest hint of thread trouble, or not even use thread even if its working. I'd try physically swapping it with the one that worked, and seeing if the 2nd one works better there.

Someone else told me they had a google home as a thread border router, but didn't mention they actually had a couple of such devices. And actually they had partitioned as they werent in thread range of one another, and HA was using the wrong one. Turning off the problematic out of range ones fixed it.

aburhinox commented 3 months ago

Thanks for the tips @Jc2k but I couldnt get anything to work. They're all in the same light fixture so I did try to swap them around but that didnt help. I tried as many different combinations of factory reset on the bulbs, rebooting the google home, and rebooting home assistant and kept coming back up with that same error. I even tried to restore a home assistant backup from before I tried adding the lights and that didnt help. If the python errors in the log arent an issue, then I guess it's just my bulbs and not the code. I'll close this out and give up for now trying to figure it out.