#Missing Thread network name in Home Assistant db – how to fix?

1 messages · Page 1 of 1 (latest)

modest mountain
#

Hey all, I’m trying to solve an issue where the Thread network name in Home Assistant has gone missing. This leads to the error AttributeError: 'NoneType' object has no attribute 'encode' in the file "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/ble/pairing.py" when trying to pair HomeKit devices. I have around 30 paired Matter devices, and I’m using a HomePod Mini as my border router.

When using the iOS Companion app (which properly displays the network name) under Settings > Debugging > Thread Credentials, the “Transfer to Home Assistant” button switches to green when pressed, but nothing else happens. The credentials in HA are not updated with the network name.

Does anyone know how I can safely restore the missing Thread network name without having to re-pair all my Matter devices? Is there a way to pull the current Thread dataset through the WebSocket API, set the network name, and push it back into HA? I assume Python scripts can’t interact with the WebSocket API directly, but could AppDaemon, a custom integration, or something else handle this?

Any advice on solving this or what would happen if I deleted and re-added the Thread credentials would be greatly appreciated! Currently, my Nanoleaf light strip (Homekit), which used to act as a Thread router, won’t rejoin, and my Thread network is now unstable without it.

Thanks in advance!

modest mountain
#

As a followup: Using parse_tlv from python-otbr-api/main/python_otbr_api/tlv_parser.pyto decode my current thread.dataset I can see that the TLV contains the Channel, PAN ID, Extended PAN ID, Network Key and Active Timestamp. I don't know what it should contain, but there's no network name in the saved dataset.

thorny violet
#

there is a UI to import a TLV, but as something has already inserted a wrong TLV, i don't know if there is an API way to update it

#

you could potentially back up and delete .storage/thread.datasets, restart HA, then add the new TLV through the UI. OR, if you've got as far as you have just update thread.datasets directly.

#

note that the thread integration is only acting as a credential store here, even if you nuked thread.datasets you would still have a functional matter over thread network.

#

those credentials are already baked in to your BR and your matter devices, and your homepod is bridging all that to wifi, so nothing in HA actually needs the thread integration when you aren't adding a new device.

modest mountain
#

@thorny violet Thanks a lot (also for the gist)! I will try to figure out if I can replace the thread.datasets file while HA is running, as I currently only access it via SMB and only made a copy of the file to analyze it. SSHing into the device might be an option too. I’ll check if there’s a way to boot HAOS just enough to allow SSH access for editing the file.

I’m running HA on a Pi 4 with an external SSD, but since macOS can’t read ext4, directly modifying the file on the SSD would be much easier. Otherwise, I’d have to install Parallels, set up a Linux VM, and mount the SSD just to edit the file. I was therefor aiming for a solution with AppDaemon or a custom integration until now.

PS: There’s some urgency since my thread network stability depends on a HomeKit Nanoleaf Lightstrip acting as an additional router, which I have not been able to join to the Thread network over the past few days. Therefor many of my TRVs have been intermittently inaccessible, causing less-than-ideal heating in the apartment.

thorny violet
#

I’d have thought you’d be able to edit it over smb, but I don’t use smb for my ha box so no clue there

#

Make the TLV with my script and test adding it via the UI

#

There’s a chance it’ll do something and if not you’ll at least know the string passes any validation

#

reading the code, adding a TLV that already exists will work and update stuff but only if it’s newer

#

(Based on ACTIVETIMESTAMP)

neon halo
modest mountain
#

Thanks. I managed to create a new TLV. I then used "Add dataset from TLV" at /config/thread and entered the new TLV. Nothing changed, I still have no network name. I will need to investigate further tomorrow and will get back to you with an update. Maybe I need to alter the timestamp? It's at 3 seconds just like it was previously. Not sure what these 3 seconds are about exactly, will need to look into the code. Unfortunately I am not familiar with Python. 🙂

thorny violet
#

The timestamp is used to coordinate TLV changes

#

You can do this thing in the thread protocol where you create a pending dataset and set a time when it becomes active

#

Potentially you can get every single device to all switch to a different network name, channel, etc. all at the same time without having to recommission a thing

#

As long as the timestamp is bigger than the one already in thread.datasets will it should work

#

So 4 should work

modest mountain
#

Woohoo, @thorny violet thanks so much for your help. Your advice how to create a new TLV and to add it in the Thread integration Web UI as new dataset was very helpful. While I have no idea when, how and why HA lost the Thread network name, I'm glad it's now working again.

thorny violet
#

Yay

#

Can you mark this thread as resolved?

modest mountain
#

Sure, will do, once I find where to do so. 🙂

#

I also udpated the issue with a description how to solve the issue. I assume you will close it once you've seen my suggestion at the end of the comment. Thanks again for your assistance. https://github.com/home-assistant/core/issues/125925#issuecomment-2360442476

GitHub

The problem I cannot provision the preferred thread credentials to a Nanoleaf Essentials Homekit Lightstrip (NL55). Steps to reproduce: delete device, restart HA, run "Recorder: Purge entities...