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

What can we as users do to avoid that? Whether Thread or BLE it just shows up under the HomeKit Controller integration.

Right now I think all you can do is wait. I didn’t hit this for some reason - maybe I was just out of Bluetooth range when I did the thread pairing.

When the BLE backend migrates to using hkid instead of MAC it shouldn’t be possible to hit it any more. I’m not going to manage more than an hour in front of a computer before 2012 is released and it’s a big change so it won’t be till jan at best.

No worries! Just wanted to make sure I wasn’t missing something obvious. Your work is greatly appreciated and benefits a lot of people, myself included.

Merry Christmas and happy new year!

Are you going to try and fix the broken beta (2022.12.b01/2) pairing? When I updated everything it unlinked all my devices and I couldn’t repair them either.

Yes. Don’t try and do anything to fix it on your end. They aren’t unlinked, the code is just erroring before they come online. If I can’t fix it by Tuesday I’ll revert the Pr that broke it.

But as I said before, in future if you hit a trace back it’s best to post it on GitHub to make sure I see it in time. I nearly didn’t check here this weekend.

1 Like

Could someone hitting the _async_endpoint_changed exception (“AttributeError: ‘CoAPPairing’ object has no attribute ‘owner’”) try 2022.12.0b4. It doesn’t trigger an exception here, but I’m not 100% sure that I’m just not hitting it.

So far so good. Just updated and everything is working! Thanks!

I copied the provision function from https://github.com/Jc2k/aiohomekit/pull/148 and stuck it into homekit_controller (with a few modifications to make it work) to commission an airversa air purifer to the OpenTread Border Router addon for HA and it worked! The airversa air purifier joined the thread network as a child. After getting the airversa onto the thread network homekit kept the BLE connection for a bit then stopped and I couldn’t get homekit controller to see it over thread. My ipv6 knowledge is not great, can anyone point me in a direction to figure out if I’m getting data out of the thread network from the aiversa? If I have a ipv6 route to it, ect?

As a side note the same process doesn’t seem to work with the nanoleaf A19 it seems to try to join the thread network then jump back to ble.

2 Likes

@JuliusBlueTek thanks for the testing and feedback! You’ll have to do a few things by hand… first, stop HA. Next, get to the HA (OS) console & find the config directory. On my HA OS it is at /mnt/data/supervisor/homeassistant/. Then, edit .storage/core.config_entries. You’ll need to find the right entity; the “title” should match the name in the web interface, “domain” will be “homekit_controller”, and “data.Connection” will be “BLE”. Note that the dot notation I’m using is to drill into the JSON data object.

  • Change the “unique_id” from the current value (equal to the “data.AccessoryAddress”) to the lowercase “data.AccessoryPairingID” value.
  • Change the “data.Connection” value from “BLE” to “CoAP”.
  • Add a “data.AccessoryIP” key with the current IPv6 address of the accessory.
  • Add a “data.AccessoryPort” key with a numeric value of 5683 (no quotes!).

Finally, save the file, start HA, & let us know how it goes. Thanks again for testing!

1 Like

Ok so it seems like Openthread border router wants to use the wireless connection if it can. Disabling the wireless ipv4 & ipv6 seems to have gotten openthread to use the eth0 and the airversa shows up in mdns under _hap._udp. now! I’m not sure why it didn’t when it was using the wireless.

I didn’t mention before, but I also tossed in the reconfig code into config_flow.py from Comparing home-assistant:dev...roysjosh:hap-thread-provision · home-assistant/core · GitHub and the changes to the entity seem to happen automatically now that the airversa show up on the network.

Now I’m getting this error:


Logger: homeassistant.config_entries
Source: custom_components/homekit_controller/connection.py:238
Integration: HomeKit Controller
First occurred: 1:56:21 AM (1 occurrences)
Last logged: 1:56:21 AM

Error setting up entry Airversa AP2 1306 for homekit_controller
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/uuid.py", line 58, in normalize_uuid
    return str(UUID(value)).upper()
  File "/usr/local/lib/python3.10/uuid.py", line 177, in __init__
    raise ValueError('badly formed hexadecimal UUID string')
ValueError: badly formed hexadecimal UUID string

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 372, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/config/custom_components/homekit_controller/__init__.py", line 42, in async_setup_entry
    await conn.async_setup()
  File "/config/custom_components/homekit_controller/connection.py", line 238, in async_setup
    await self.pairing.async_populate_accessories_state(
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/coap/pairing.py", line 190, in async_populate_accessories_state
    await self.list_accessories_and_characteristics()
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/coap/pairing.py", line 156, in list_accessories_and_characteristics
    characteristic["type"] = normalize_uuid(characteristic["type"])
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/uuid.py", line 60, in normalize_uuid
    raise ValueError(f"{value} doesn't look like a valid UUID or short UUID")
ValueError: 45E5011ECB4000A80FF2603DE doesn't look like a valid UUID or short UUID

Sorry for potentially being a bit off-topic here, but I have a similar issue as was described in this thread. My current set-up is the following:

  • 2 HomePods, 1 ATV
  • 3 Nanoleaf Essential Bulbs
  • 1 Eve Door/Window
  • 2 Eve Thermo (paired directly into HomeKit so can be disregarded?)

I get ocassional dropouts in the Nanoleafs and the Eve Door/Window. A restart of HomeAssistant sometimes fixes it for a couple minutes before it occurs again. It often fixes itself after some time but then devices get unavailable again.

What troubleshooting steps should I try out? (And thank you all for your hard work on this!!)

@JuliusBlueTek interesting, can you get the debug logs from aiohomekit? You can PM them to me. I’m looking for a line starting with “Get accessory info:” which should have the full accessory characteristic database… it seems like your device has a non-compliant HAP characteristic UUID.

@haluapre can you please try the patch in this post and let me know if it helps? HomeKit Accessory Protocol (HAP) over CoAP/UDP (was: Nanoleaf Essentials bulb via Thread/CoAP) - #265 by lambdafunction Also, as mentioned in that post, maybe start with a smaller value than 10 like 2 or 3 (but no smaller). It won’t fix whatever is causing devices to become disconnected but it will help them recover. You’ll still see them go unavailable for a bit. Oh, one more question. Do you see any logs similar to: CoAP POST returned unexpected code <aiocoap.Message at 0x7fdf6f1ea350: Type.ACK 4.04 Not Found ?

1 Like

Thank you for the quick response, I will try out the patch and report back! I couldn’t find any logs similar to what you’ve posted. The only log entry I found that might be in relation to the issue is the following:

2022-12-16 14:35:43.889 WARNING (MainThread) [aiohomekit.controller.coap.connection] Pair verify failed
OSError: [Errno 113] received through errqueue
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/coap/connection.py", line 384, in connect
await self.do_pair_verify(pairing_data)
File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/coap/connection.py", line 344, in do_pair_verify
response = await coap_client.request(request).response
File "/usr/local/lib/python3.10/site-packages/aiocoap/protocol.py", line 612, in _run_outer
await cls._run(app_request, response, weak_observation, protocol, log)
File "/usr/local/lib/python3.10/site-packages/aiocoap/protocol.py", line 671, in _run
blockresponse = await blockrequest.response
aiocoap.error.NetworkError: [Errno 113] received through errqueue

It keeps disconnection with the following exception, but tends to reconnect now given the quick-fix you suggested (see image):
Logger: aiohomekit.controller.coap.pdu
Source: components/homekit_controller/connection.py:726
First occurred: 17:23:46 (4 occurrences)
Last logged: 17:35:46

Transaction 0 failed with error 6 (Invalid request

Is there any way to turn on more detailed logging?

@haluapre that particular error is innocuous. We are trying to read from a control characteristic. I need to add some code to skip reading from it during the “get all current accessory values” bit of a (re-)connect.

You can turn up debug logs for aiohomekit and possibly homeassistant.components.homekit_controller which might reveal more. There are instructions to turn on debug here: HomeKit Accessory Protocol (HAP) over CoAP/UDP (was: Nanoleaf Essentials bulb via Thread/CoAP) - #283 by lambdafunction

Logs are on now, the aforementioned error line of yours is not showing up anywhere. The same Bulb still disconnects roughly every 3 Minutes like clockwork (3 Minutes also being the time I used in the is_connected function). Should I send you the logs in case there is anything useful for you in there, or is some of the encrypted data from the debug better not shared?

I didn’t see how to pm on here. It’s all just a test environment so I’ll just post it here for now.

2022-12-16 13:31:46.515 DEBUG (MainThread) [aiohomekit.controller.coap.connection] Get accessory info: [{'aid': 1, 'services': [{'type': '3E', 'iid': 1, 'characteristics': [{'type': '14', 'iid': 2, 'perms': ['pw'], 'format': 'bool'}, {'type': '20', 'iid': 3, 'perms': ['pr'], 'format': 'string'}, {'type': '21', 'iid': 4, 'perms': ['pr'], 'format': 'string'}, {'type': '23', 'iid': 5, 'perms': ['pr'], 'format': 'string'}, {'type': '30', 'iid': 6, 'perms': ['pr'], 'format': 'string'}, {'type': '52', 'iid': 7, 'perms': ['pr'], 'format': 'string'}, {'type': '53', 'iid': 8, 'perms': ['pr'], 'format': 'string'}, {'type': '34AB8811AC7F4340BAC3FD6A85F9943B', 'iid': 9, 'perms': ['pr', 'hd'], 'format': 'string'}, {'type': '220', 'iid': 10, 'perms': ['pr'], 'format': 'data'}]}, {'type': 'A2', 'iid': 16, 'characteristics': [{'type': 'A5', 'iid': 17, 'perms': ['pr'], 'format': 'data'}, {'type': '37', 'iid': 18, 'perms': ['pr'], 'format': 'string'}]}, {'type': '55', 'iid': 32, 'characteristics': [{'type': '4C', 'iid': 34, 'perms': [], 'format': 'data'}, {'type': '4E', 'iid': 35, 'perms': [], 'format': 'data'}, {'type': '4F', 'iid': 36, 'perms': [], 'format': 'int'}, {'type': '50', 'iid': 37, 'perms': ['pr', 'pw'], 'format': 'data'}]}, {'type': 'BB', 'iid': 32832, 'characteristics': [{'type': 'A5', 'iid': 32833, 'perms': ['pr'], 'format': 'data'}, {'type': '23', 'iid': 32834, 'perms': ['pr'], 'format': 'string'}, {'type': 'B0', 'iid': 32835, 'perms': ['pr', 'pw', 'ev'], 'format': 'int', 'minValue': 0, 'maxValue': 1}, {'type': 'A9', 'iid': 32836, 'perms': ['pr', 'ev'], 'format': 'int', 'minValue': 0, 'maxValue': 2}, {'type': 'A8', 'iid': 32837, 'perms': ['pr', 'pw', 'ev'], 'format': 'int', 'minValue': 0, 'maxValue': 1}, {'type': '29', 'iid': 32838, 'perms': ['pr', 'pw', 'ev'], 'format': 'float', 'unit': 'percentage', 'minStep': 20.0, 'minValue': 0.0, 'maxValue': 100.0}, {'type': 'A7', 'iid': 32839, 'perms': ['pr', 'pw', 'ev'], 'format': 'int', 'minValue': 0, 'maxValue': 1}, {'type': '45E5011ECB4000A80FF2603DE', 'iid': 32840, 'perms': ['pr', 'pw', 'ev'], 'format': 'int', 'minValue': 1, 'maxValue': 255}, {'type': '55E5011ECB4000A80FF2603DE', 'iid': 32841, 'perms': ['pr', 'pw', 'ev'], 'format': 'int', 'minValue': 1, 'maxValue': 255}, {'type': '65E5011ECB4000A80FF2603DE', 'iid': 32842, 'perms': ['pr', 'pw', 'ev'], 'format': 'int', 'minValue': 0, 'maxValue': 1}, {'type': '11A', 'iid': 32843, 'perms': ['pr', 'pw', 'ev'], 'format': 'bool'}, {'type': '4015E5011ECB4000A80FF2603DE', 'iid': 32844, 'perms': ['pr', 'pw', 'ev', 'hd'], 'format': 'int', 'minValue': 0, 'maxValue': 2}, {'type': '5015E5011ECB4000A80FF2603DE', 'iid': 32845, 'perms': ['pr', 'pw'], 'format': 'data'}, {'type': '5025E5011ECB4000A80FF2603DE', 'iid': 32846, 'perms': ['pr', 'pw', 'ev'], 'format': 'data'}, {'type': '4025E5011ECB4000A80FF2603DE', 'iid': 32847, 'perms': ['pr'], 'format': 'string'}]}, {'type': '8D', 'iid': 2576, 'characteristics': [{'type': 'A5', 'iid': 2577, 'perms': ['pr'], 'format': 'data'}, {'type': '23', 'iid': 2578, 'perms': ['pr'], 'format': 'string'}, {'type': '95', 'iid': 2579, 'perms': ['pr', 'ev'], 'format': 'int', 'minValue': 0, 'maxValue': 5}, {'type': 'C6', 'iid': 2580, 'perms': ['pr', 'ev'], 'format': 'float', 'minStep': 1.0, 'minValue': 0.0, 'maxValue': 1000.0}, {'type': '6015E5011ECB4000A80FF2603DE', 'iid': 2581, 'perms': ['pr', 'ev'], 'format': 'data'}, {'type': '6025E5011ECB4000A80FF2603DE', 'iid': 2582, 'perms': ['pr', 'pw', 'ev'], 'format': 'int', 'minValue': 0, 'maxValue': 1}]}, {'type': 'BA', 'iid': 32896, 'characteristics': [{'type': 'A5', 'iid': 32897, 'perms': ['pr'], 'format': 'data'}, {'type': '23', 'iid': 32898, 'perms': ['pr'], 'format': 'string'}, {'type': 'AC', 'iid': 32899, 'perms': ['pr', 'ev'], 'format': 'int', 'minValue': 0, 'maxValue': 1}, {'type': 'AB', 'iid': 32900, 'perms': ['pr', 'ev'], 'format': 'float', 'minStep': 1.0, 'minValue': 0.0, 'maxValue': 100.0}]}, {'type': '701', 'iid': 112, 'characteristics': [{'type': 'A5', 'iid': 113, 'perms': ['pr'], 'format': 'data'}, {'type': '706', 'iid': 116, 'perms': ['pr'], 'format': 'string'}, {'type': '702', 'iid': 115, 'perms': ['pr'], 'format': 'int', 'minValue': 0, 'maxValue': 31}, {'type': '703', 'iid': 117, 'perms': ['pr', 'ev'], 'format': 'int', 'minValue': 0, 'maxValue': 127}, {'type': '22B', 'iid': 118, 'perms': ['pr'], 'format': 'bool'}, {'type': '704', 'iid': 119, 'perms': ['pr', 'pw'], 'format': 'data'}]}, {'type': '239', 'iid': 2560, 'characteristics': [{'type': 'A5', 'iid': 2564, 'perms': ['pr'], 'format': 'data'}, {'type': '23A', 'iid': 2561, 'perms': ['pr'], 'format': 'int', 'minValue': 0, 'maxValue': 67108863}, {'type': '23C', 'iid': 2562, 'perms': ['pr'], 'format': 'data'}, {'type': '24A', 'iid': 2565, 'perms': ['pr', 'ev'], 'format': 'int'}]}, {'type': '1005E5011ECB4000A80FF2603DE', 'iid': 32960, 'characteristics': [{'type': 'A5', 'iid': 32961, 'perms': ['pr'], 'format': 'data'}, {'type': '23', 'iid': 32962, 'perms': ['pr'], 'format': 'string'}, {'type': '1015E5011ECB4000A80FF2603DE', 'iid': 32963, 'perms': ['pr', 'pw', 'ev'], 'format': 'int', 'minValue': -1200, 'maxValue': 1400}, {'type': '1025E5011ECB4000A80FF2603DE', 'iid': 32964, 'perms': ['pr', 'pw'], 'format': 'int'}]}]}]

That is just the Get accessory info part there is a lot after that where it looks like it reads data like:

2022-12-16 13:31:50.048 DEBUG (MainThread) [aiohomekit.controller.coap.connection] ENCRYPT counter=11
2022-12-16 13:31:50.509 DEBUG (MainThread) [aiohomekit.controller.coap.connection] DECRYPT counter=11
2022-12-16 13:31:50.512 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x00, Status=Success, Len=24
2022-12-16 13:31:50.512 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x01, Status=Success, Len=5
2022-12-16 13:31:50.512 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x02, Status=Success, Len=19
2022-12-16 13:31:50.512 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x03, Status=Success, Len=16
2022-12-16 13:31:50.512 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x04, Status=Success, Len=8
2022-12-16 13:31:50.512 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x05, Status=Success, Len=5
2022-12-16 13:31:50.512 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x06, Status=Success, Len=16
2022-12-16 13:31:50.513 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x07, Status=Success, Len=10
2022-12-16 13:31:50.513 DEBUG (MainThread) [aiohomekit.protocol.tlv] receiving [
  1 (Identifier): (22 bytes/<class 'bytearray'>) 0x536c65656b706f696e7420496e6e6f766174696f6e73
]

2022-12-16 13:31:50.513 DEBUG (MainThread) [aiohomekit.controller.coap.connection] Read value for 3E.20 iid 3: value 'Sleekpoint Innovations'
2022-12-16 13:31:50.513 DEBUG (MainThread) [aiohomekit.protocol.tlv] receiving [
  1 (Identifier): (3 bytes/<class 'bytearray'>) 0x415032
]

2022-12-16 13:31:50.513 DEBUG (MainThread) [aiohomekit.controller.coap.connection] Read value for 3E.21 iid 4: value 'AP2'
2022-12-16 13:31:50.513 DEBUG (MainThread) [aiohomekit.protocol.tlv] receiving [
  1 (Identifier): (17 bytes/<class 'bytearray'>) 0x4169727665727361204150322031333036
]

2022-12-16 13:31:50.514 DEBUG (MainThread) [aiohomekit.controller.coap.connection] Read value for 3E.23 iid 5: value 'Airversa AP2 1306'
2022-12-16 13:31:50.515 DEBUG (MainThread) [aiohomekit.protocol.tlv] receiving [
  1 (Identifier): (14 bytes/<class 'bytearray'>) 0x5757303232323139303031333036
]

I’d post it all here but there is a limit to the length I can post ^.^

Here is the section where the value is being read from that casses the UUID error. The BB.45E5011ECB4000A80FF2603DE


2022-12-16 13:31:50.720 DEBUG (MainThread) [aiohomekit.controller.coap.connection] Read value for A2.37 iid 18: value '1.2.0'
2022-12-16 13:31:50.720 DEBUG (MainThread) [aiohomekit.controller.coap.connection] ENCRYPT counter=13
2022-12-16 13:31:50.875 DEBUG (MainThread) [aiohomekit.controller.coap.connection] DECRYPT counter=13
2022-12-16 13:31:50.878 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x00, Status=Invalid request, Len=0
2022-12-16 13:31:50.878 WARNING (MainThread) [aiohomekit.controller.coap.pdu] Transaction 0 failed with error 6 (Invalid request
2022-12-16 13:31:50.883 DEBUG (MainThread) [aiohomekit.controller.coap.connection] Failed to read 55.50 iid 37
2022-12-16 13:31:50.883 DEBUG (MainThread) [aiohomekit.controller.coap.connection] ENCRYPT counter=14
2022-12-16 13:31:51.653 DEBUG (MainThread) [aiohomekit.controller.coap.connection] DECRYPT counter=14
2022-12-16 13:31:51.654 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x00, Status=Success, Len=2
2022-12-16 13:31:51.654 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x01, Status=Success, Len=13
2022-12-16 13:31:51.655 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x02, Status=Success, Len=3
2022-12-16 13:31:51.655 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x03, Status=Success, Len=3
2022-12-16 13:31:51.655 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x04, Status=Success, Len=3
2022-12-16 13:31:51.655 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x05, Status=Success, Len=6
2022-12-16 13:31:51.656 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x06, Status=Success, Len=3
2022-12-16 13:31:51.656 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x07, Status=Success, Len=3
2022-12-16 13:31:51.656 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x08, Status=Success, Len=3
2022-12-16 13:31:51.656 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x09, Status=Success, Len=3
2022-12-16 13:31:51.657 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x0a, Status=Success, Len=3
2022-12-16 13:31:51.657 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x0b, Status=Success, Len=3
2022-12-16 13:31:51.657 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x0c, Status=Success, Len=22
2022-12-16 13:31:51.657 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x0d, Status=Success, Len=10
2022-12-16 13:31:51.658 DEBUG (MainThread) [aiohomekit.controller.coap.pdu] Got PDU Control=0x02, TID=0x0e, Status=Success, Len=19
2022-12-16 13:31:51.658 DEBUG (MainThread) [aiohomekit.protocol.tlv] receiving [
  1 (Identifier): (0 bytes/<class 'bytearray'>) 0x
]

2022-12-16 13:31:51.659 DEBUG (MainThread) [aiohomekit.controller.coap.connection] Read value for BB.A5 iid 32833: value None
2022-12-16 13:31:51.659 DEBUG (MainThread) [aiohomekit.protocol.tlv] receiving [
  1 (Identifier): (11 bytes/<class 'bytearray'>) 0x4169725075726966696572
]

2022-12-16 13:31:51.659 DEBUG (MainThread) [aiohomekit.controller.coap.connection] Read value for BB.23 iid 32834: value 'AirPurifier'
2022-12-16 13:31:51.663 DEBUG (MainThread) [aiohomekit.protocol.tlv] receiving [
  1 (Identifier): (1 bytes/<class 'bytearray'>) 0x01
]

2022-12-16 13:31:51.663 DEBUG (MainThread) [aiohomekit.controller.coap.connection] Read value for BB.B0 iid 32835: value 1
2022-12-16 13:31:51.663 DEBUG (MainThread) [aiohomekit.protocol.tlv] receiving [
  1 (Identifier): (1 bytes/<class 'bytearray'>) 0x02
]

2022-12-16 13:31:51.664 DEBUG (MainThread) [aiohomekit.controller.coap.connection] Read value for BB.A9 iid 32836: value 2
2022-12-16 13:31:51.664 DEBUG (MainThread) [aiohomekit.protocol.tlv] receiving [
  1 (Identifier): (1 bytes/<class 'bytearray'>) 0x01
]

2022-12-16 13:31:51.665 DEBUG (MainThread) [aiohomekit.controller.coap.connection] Read value for BB.A8 iid 32837: value 1
2022-12-16 13:31:51.665 DEBUG (MainThread) [aiohomekit.protocol.tlv] receiving [
  1 (Identifier): (4 bytes/<class 'bytearray'>) 0x0000a041
]

2022-12-16 13:31:51.666 DEBUG (MainThread) [aiohomekit.controller.coap.connection] Read value for BB.29 iid 32838: value 20.0
2022-12-16 13:31:51.666 DEBUG (MainThread) [aiohomekit.protocol.tlv] receiving [
  1 (Identifier): (1 bytes/<class 'bytearray'>) 0x00
]

2022-12-16 13:31:51.666 DEBUG (MainThread) [aiohomekit.controller.coap.connection] Read value for BB.A7 iid 32839: value 0
2022-12-16 13:31:51.667 DEBUG (MainThread) [aiohomekit.protocol.tlv] receiving [
  1 (Identifier): (1 bytes/<class 'bytearray'>) 0xff
]

2022-12-16 13:31:51.667 DEBUG (MainThread) [aiohomekit.controller.coap.connection] Read value for BB.45E5011ECB4000A80FF2603DE iid 32840: value 255
2022-12-16 13:31:51.668 DEBUG (MainThread) [aiohomekit.protocol.tlv] receiving [
  1 (Identifier): (1 bytes/<class 'bytearray'>) 0xff
]

@JuliusBlueTek okay, thanks for the logs. This might be a quirk of this particular vendor… @Jc2k aren’t UUIDs supposed to be either the Apple short style or a full UUID? Have you seen truncated vendor UUIDs before?

@haluapre yikes, it definitely shouldn’t be reconnecting that frequently. You can PM the logs, we don’t log secret key info.

Ohhh I got the neoleaf a19 to join the HA addon Openthread board router - thread network! I had to add pairing._ensure_connected(4) right before pairing._async_request(OpCode.CHAR_WRITE, thread_control, request_tlv)

This is my modified code but it’s pretty much the same.

    async def thread_provision(
        self,
        network_name: str,
        channel: int,
        pan_id: str,
        extended_pan_id: str,
        network_key: str,
        unknown: int,
    ) -> None:
        """Provision a device with Thread network credentials."""
        thread_service = self.service
        thread_control = thread_service[CharacteristicsTypes.THREAD_CONTROL_POINT]
        
        async with self._accessory.pairing._config_lock:
            inner_request_tlv = TLV.encode_list(
                [
                    (1, b"\x03"),
                ]
            )
            request_tlv = TLV.encode_list(
                [
                    (TLV.kTLVHAPParamParamReturnResponse, bytearray(b"\x01")),
                    (TLV.kTLVHAPParamValue, inner_request_tlv),
                ]
            )
            await self._accessory.pairing._ensure_connected(4)
            resp = await self._accessory.pairing._async_request(OpCode.CHAR_WRITE, thread_control, request_tlv)
            _LOGGER.warning("start pairing", resp)
    
            thread_tlv = TLV.encode_list(
                [
                    (1, bytes(network_name, encoding="ascii")),
                    (2, channel.to_bytes(1, byteorder="little")),
                    (3, int(pan_id, base=16).to_bytes(2, byteorder="little")),
                    (4, bytes.fromhex(extended_pan_id)),
                    (5, bytes.fromhex(network_key)),
                ]
            )
            inner_request_tlv = TLV.encode_list(
                [
                    # TLV 1 is some sort of write/provision OpCode
                    (1, b"\x01"),
                    # TLV 2 contains the Thread network details
                    (2, thread_tlv),
                    # TLV 3 seems to be a bitfield or identifier; iOS sends 0 & Android sends 1
                    (3, unknown.to_bytes(1, byteorder="little")),
                ]
            )
            request_tlv = TLV.encode_list(
                [
                    (TLV.kTLVHAPParamParamReturnResponse, bytearray(b"\x01")),
                    (TLV.kTLVHAPParamValue, inner_request_tlv),
                ]
            )
            
            _LOGGER.warning("Prepared network data")
    
            try:
                _LOGGER.warning("Sending Network Data")
                await self._accessory.pairing._ensure_connected(4)
                resp = await self._accessory.pairing._async_request(
                    OpCode.CHAR_WRITE, thread_control, request_tlv
                )
                # we shouldn't get a response
                _LOGGER.debug("should be paired", resp)
            except Exception as e:
                # this is the expected code flow
                _LOGGER.debug("error pairing", e)
                await self._accessory.pairing.close()

Never seen that, no. I’d assume there’s some encoding trick to make the data blob smaller - like they trimmed trailing or leading 0’s.

I’d expect the 13th digit to be 1-5.

We should be able to compare this to the Bluetooth version of the pairing data. Or alternatively, using a Bluetooth service browser.