SOLVED - Timeout when Provisioning Preferred Thread Credentials for Nanoleaf Light

Edit: I found the solution. I added it to the bottom.

Hey,
I have the Secretlab x Nanoleaf MagRGB Strip which afaik, is categorized under nanoleaf essentials. It supports Thread and Bluetooth.
Over the last couple days I was reading into Thread and Matter, and find the entire topic very interesting. Since I had a thread compatible product and was annoyed by the very bad Bluetooth connection between the strip and HASS, I decided to get a Google Nest Hub 2nd Gen as my Thread Border Router.

I removed the device (previously connected with the HomeKit Device Integration & Bluetooth) from HASS and connected it to Apple Home/Nanoleaf App. The Strip was immediately connected to the Thread network of the nest hub and was already way more responsive then with Bluetooth. Good stuff.

I then used the Iphone HASS Companion App to set the nest hub thread network as my preferred network in the thread integration. This worked totally fine as well.

Then I just followed the instructions here.

I put the magstrip into pairing mode, added it to HASS in the web UI on my PC through bluetooth, and verified it was working. Which it was. Then I wanted to use the “Provision Preferred Thread Credentials” Button. After clicking it, nothing happened for 5-10 seconds, after which the Thread Status changed from Disabled to Detached and a couple seconds after, back to Disabled. At that point, I also got this error message:

Failed to call service button/press. Could not migrate device to Thread

Checking the logs, This is what I could find:

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:238
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 12:51:53 AM (1 occurrences)
Last logged: 12:51:53 AM
[140166134511168] Could not migrate device to Thread

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohomekit/zeroconf.py", line 326, in async_find
    if discovery := await waiter:
                    ^^^^^^^^^^^^
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohomekit/zeroconf.py", line 325, in async_find
    async with asyncio_timeout(timeout):
  File "/usr/local/lib/python3.11/asyncio/timeouts.py", line 111, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/homekit_controller/connection.py", line 924, in async_thread_provision
    await self.hass.data[CONTROLLER]
  File "/usr/local/lib/python3.11/site-packages/aiohomekit/zeroconf.py", line 329, in async_find
    raise AccessoryNotFoundError(
aiohomekit.exceptions.AccessoryNotFoundError: Accessory with device id a7:00:18:47:b5:76 not found

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 238, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2149, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2186, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 272, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 882, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 952, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/button/__init__.py", line 132, in _async_press_action
    await self.async_press()
  File "/usr/src/homeassistant/homeassistant/components/homekit_controller/button.py", line 176, in async_press
    await self._accessory.async_thread_provision()
  File "/usr/src/homeassistant/homeassistant/components/homekit_controller/connection.py", line 947, in async_thread_provision
    raise HomeAssistantError("Could not migrate device to Thread") from exc
homeassistant.exceptions.HomeAssistantError: Could not migrate device to Thread

Based on the logs, it looks like the light cant be found while trying to add it to the thread network, which is weird, since controlling it right before trying to provision the thread credentials works totally fine.

After the error, the device is completely unresponsive through HASS until I delete and pair it again.

After the initial attempt, I tried several other ways. Ie, connecting the Strip through Apple Home instead of the Nanoleaf app, then removing it and adding it to HASS again. Same result. I tried pairing it to Nanoleaf with my Android phone, then removing it and adding it to HASS through the Andoid Companion App and trying to provision the thread credentials through the android app as well. Same result.

I couldnt find any topics with a similar issue, which I guess is because Threads is pretty new.

Im running HAOS in a VM on a Truenas Scale server. never had any issues with HASS yet, this seems to be the first big hurdle.

Any help is greatly appreciated!

SOLUTION:

So the misstake was between the steps of pairing the Light to the nanoleaf app and afterwards pairing it to HASS.
Once paired to nanoleaf and checking that thread was working fine, I put the light into pairing mode again and added it via Bluetooth to HASS. Here is the misstake. The pairing mode is also a hard reset of the light. So to make it work, I disabled my bluetooth device in HASS (just to make sure), removed the device from the nanoleaf app/Apple Home and restarted HASS. Again, just to make sure the devices that showed up in HASS wasnt using Bluetooth.
After the reboot, the device still showed up and I was able to add it. The light was super responsive and my bl device was off, so the only other option for it was Thread. I wasnt 100% sure though, because the light config page didnt show the usual thread info, but only the Provision Preferred Thread Credentials Button. After another HASS reboot, everything showed up as expected though. Finally its working!

2 Likes

Thank you very much! It’s exactly what was happening to me with the Nanoleaf Essential bulbs in HomeKit and Home Assistant!