HomeKit Accessory Protocol (HAP) over CoAP/UDP (was: Nanoleaf Essentials bulb via Thread/CoAP)

Turn on debug level logs for homeassistant.components.bluetooth first then and lets see what you get.

So I see a bunch of stuff like this, which makes me think it should work:

2022-07-27 18:42:21.020 DEBUG (MainThread) [homeassistant.components.bluetooth] Device detected: xx:xx:xx:xx:xx with advertisement_data: AdvertisementData(local_name=‘Eve Door 15C9’, manufacturer_data={76: b’\x061\x00X4UW\x04\xdc\n\x00\xa4\x0c\x02\x02/\xb1\n\xb9’}) matched domains: {‘homekit_controller’}

Fair point, I guess I meant more that I’m still trying to figure out how to do all that, I’m fairly new to tinkering with BLE, I appreciate the info nonetheless.
I’m a bit too busy lately to dig into it, and thankfully everything works using essentials as a border router, but if I find anything I’ll be sure to post it here.

As far as I understand, Essentials won’t support matter over thread directly, but will still be able to link to matter through a bridge device of some kind, their PR has just been terrible at actually explaining anything properly.

I’m guessing there’s not enough resources on their hardware to support both matter and homekit via thread, along with their own proprietary stuff, my speculation is they originally thought they could add a toggle (similar to the remote control/thread router toggle on the Shapes I have), but along the way realized that wasn’t going to be feasible, and having two different firmwares or hardware versions was going to cause a lot of issues and confusion with customers.

I also wonder if maybe Matter’s implementation of thread started to require more overhead as the project grew, which is part of why you don’t really see anyone doing what nanoleaf did and putting out thread devices promising support for later since the project has been evolving over time as more companies sign on, and nobody wants to develop their own thread communication protocol when homekit exists and matter is on the way.

That said @madisonjar, I still wouldn’t recommend buying more Essentials unless your system is already committed to homekit, or you’re comfortable tinkering. The integration here still needs a compatible homekit over thread bridge, I bought a cheap Shapes kit to do this, you can see their current list here https://helpdesk.nanoleaf.me/en-US/essentials-thread-and-border-routers-15563

Hopefully there’ll eventually be a solution implemented to provision onto thread via BLE, it seems feasible but it just need some work to figure out, assuming nanoleaf hasn’t put some kind of restrictions in place for provisioning.

2 Likes

Ok - then turn on debug logs for homeassistant.components.homekit_controller and maybe aiohomekit, it’ll hopefully say why the device was rejected. Finally got bluetooth working on my prod HA last night so going to move a few Eve devices over to it.

Hey Tofu,

I’m new to home assistant and have got caught up in the rabbit hole of tinkering. Love everyone’s work and dedication to helping others.

I’ve been on homebridge for a while and just moved over to HA this week. Since then, I’ve been watching this post religiously and saw where hopefully this project will be added to the official home assistant on the next update.

I already own a homepod mini that acts as a thread bridge/border router to my nanoleaf strips, bulbs, and Schlage smart lock. If i follow the instructions from up above, do i still need a nanoleaf kit? I saw where the mini triangles kit was dropped to $50 on amazon recently so that isn’t terrible.

Thanks for the info on the essentials line. You are dead-on about their PR department. I was pretty pissed that it wouldn’t support Matter directly, but I guess that is on me for diving deep into an ecosystem that is still being developed.

Apparently I’m just an idiot. I had tried to get it working the other day, had opened the brand new Eve Door and put the battery in - but then pulled the battery when I couldn’t get it working. When I was testing, I wasn’t near the machine and forgot that I had pulled the battery. Put it back in and it immediately found the device. Sorry about that…

Update: Added both an Eve Door and Eve Switch. All working great. Much faster than using it via the HomePods (my thread network with the HomePods stopped functioning completely some time in the past month)

That’s great news! I’m actually having a hard time getting bluez to be stable on my main home assistant so you are doing better than me so far!!

Hey Jc2k,

First off thanks for all the hard work you’ve put into this. I saw there was a major update to HA official today and read through the release notes, but didn’t see this listed as an updated feature.

I started to soak through the full release notes and there were hundred of listings and figured I’d check with the source directly.

Thanks again for all the help with this project. I know there aren’t that many of us trying to use the thread devices on HA but I’m speaking for the few here by showing some gratitude.

Edit- and if this was pushed to the official released what steps do I need to perform to test this out compared to the previous method.

Thanks!

If you scroll up Jc2k posted a pull request which is currently only merged to HA beta,

There is no august release yet, so you can either switch to Beta or wait a few days for a 2022.8 release to come along.

You don’t need anything else to get this integration to work, homepod mini should work fine as a thread border router, so long as it’s on the same network as HA itself. You should be able to check if your devices are using thread through the nanoleaf app, they updated it not too long ago to finally fix the thread side or if you have iOS you can also use the Eve app to look at the thread network.

If you want to get a little more technical you can get an mDNS browser (there’s a few different ones) and you should be able to find a _hap.udp service, which if you go into will list all the essentials devices.

1 Like

This is/was my understanding. If anyone testing this stuff has a different experience I would be very interested to hear.

  • 2022.8 will include bluetooth support for homekit - which should support bluetooth Nanoleaf devices.
  • The code for HomeKit CoAP/Thread support in HomeAssistant is all merged (save for this: Pass along IP updates from zeroconf by roysjosh · Pull Request #49 · Jc2k/home-assistant · GitHub). This includes updates to aiohomekit and Home Assistant.
  • The CoAP/Thread code is currently behind a feature flag. We needed more time to check that it still works before turning it on for every user (some of the cleanup we did to get here was extensive and it would be surprising if we hadn’t broken some things). You need to set (iirc) the environment variable AIOHOMEKIT_TRANSPORT_COAP=1 to turn it on.
  • Right now theres no supported by HA Core approach to set up a thread network and get HomeKit devices on it and in HA. All we have are the notes from @lambdafunction. I believe the most reliable method involves using an Android device to provision the thread network, and using a Nanoleaf device as the border router. When the devices are on the thread network and you set the environment variable as above, i’d expect you to be able to pair them with HomeAssistant.
  • AIUI, there isn’t a known way to use iOS to provision the thread network AND use it with HA. Setting up with iOS takes up the HomeKit “slot” on the device, so it becomes unpairable to HA. I believe (but haven’t been able to confirm) that removing the device from HomeKit will also remove it from the thread network.
  • @lambdafunction started researching the protocol used by Apple to provision thread networks. This is over HAP, and some initial findings are in https://github.com/Jc2k/aiohomekit/issues/81. If we can get that to work then I hope we can fully configure Thread for HomeKit within HomeAssistant.
1 Like

Agreed, Android + NL BR is the best combo currently. After that, the bulbs will show up over mDNS as HAP/Thread devices and HA can take over from there.

Concerning setting up a Thread network ourselves… on top of consuming the single HAP pairing slot, iOS doesn’t give away the Thread network info like Android does. On Android you can view the network creds in the NL app. If you want the iOS Thread network creds, you need to fool iOS into giving them to you. Only then could you use HA to provision NL bulbs in HAP/BLE mode to a Thread network set up by iOS, whether the BR is NL-based or a HomePod mini.

The other option is to run OpenThread’s BR on something like Nordic’s $10 USB stick though I haven’t tried pairing the NL bulbs with anything other than a NL BR or a HomePod mini. It might be a possibility though.

Interesting - hadn’t considered trying to reuse an existing network. Was planning to start a new one just for HA!

Has anyone tried to add non Nanoleaf devices to the Nanoleaf thread network? For instance, joining Eve’s line of products? Theoretically, given the credentials are exposed by Nanoleaf, we could do this (I think?) but I don’t have any clue even where to start. Specifically, how you try to pair the devices as the pairing codes on the devices seem specific to Homekit.

I’ve used the above Nordic dongle as a client into the NL Thread network. It was kind of fun watching my traffic during development. Edit to add: you don’t need the PIN to join the Thread network, just the 5 bits of info in the Android NL app. Really, IIRC you only need two of those: the network key and the network name.

Thank you for the explanation and the way you did it! I really appreciate it. I love my essentials (at least the colors etc.) and I am semi HomeKit committed (lets be honest home assistant has so much more going for it in the automation department!!) I have since bought a nano leaf shapes in hopes that it would allow me to connect to a smart things hub I have active (zwave smoke detectors and door lock) which feeds into home assistant and I was hoping to have that feed into home kit…but for some reason the shapes show up and the essentials don’t (I can see them in Smart things just cant control them it says unavailable). Anyways I will pop in here and keep checking as I see there was a big Bluetooth update to home assistant today and I don’t know if that will help. Again I really appreciate you and your explanation and effort on this project!!

Looks like 2022.8 just dropped today with the Homekit BLE changes.

I’ll have to pickup a cheap Amazon tablet over the weekend and hopefully finally get these nanoleaf bulbs integrated.

Thanks for the concise breakdown!

Well, I poked around and got Thread provisioning working via aiohomekitctl. I’ll work with @Jc2k to get this in HA, maybe as a service you can call or something. There are some bits I don’t understand yet and I was only able to get it to provision the bulb to my NL Elements BR; provisioning with the HomePod mini creds failed. I’ll keep poking at it but just FYI before you go and get too excited :slight_smile:

2 Likes

And here we go:

2022-08-03 22:54:49.517 WARNING (MainThread) [homeassistant.components.homekit_controller]
    Provisioning Thread credentials:
        hkid=8E:44:87:45:E6:10,
        network_name=NanoleafThread56,
        channel=15,
        pan_id=1996,
        extended_pan_id=406C81416665C6E5,
        network_key=REDACTED,
        flag=Android

And

_ltpdu._udp                                     PTR     Nanoleaf\032A19\03258L6._ltpdu._udp
Nanoleaf\032A19\03258L6._ltpdu._udp             SRV     0 0 5683 Nanoleaf-A19-58L6.local. ; Replace with unicast FQDN of target host
Nanoleaf\032A19\03258L6._ltpdu._udp             TXT     "id=8E:44:87:45:E6:10" "srcvers=1.6.35" "md=NL45" "eui64=REDACTED"

Hacktastic WIP branch: https://github.com/roysjosh/core/tree/hap-thread-provision

2 Likes

Does that mean you have it all integrated and full control over the bulb in Home Assistant? I am guessing that would work with the led strips too…Just cause I am new here, with this thread network that would also mean it creates its own network and can reach other bulbs correct so lets say you have your pi at one end of the house this will now extend the network all the way out to the other (in theory)? And one last question you arent using any special hardware are you? I have a Raspberry pi 3+ I am running, would what you did work? you got me excited in case you cant tell lol!