home-assistant-libs / python-matter-server

Python server to interact with Matter
Apache License 2.0
519 stars 80 forks source link

commissioning failed #190

Closed flatsiedatsie closed 1 year ago

flatsiedatsie commented 1 year ago

I'm trying to commission a device (Tapo P125M mini). This is not on Home Assistant, but using the library in another project.

The process gets very far, with a lot of success messages, but then seemingly stumbles at the finish line:

INFO:chip.DMG:Received Command Response Data, Endpoint=0 Cluster=0x0000_0030 Command=0x0000_0001
INFO:chip.CTL:Failsafe disarmed
INFO:chip.CTL:Successfully finished commissioning step 'Cleanup'
Failed to commission: ../src/controller/CHIPDeviceController.cpp:1075: CHIP Error 0x000000AC: Internal error
ERROR:matter_server.server.client_handler:[547674974240] Error handling message: CommandMessage(message_id='commission_with_code', command='commission_with_code', args={'code': 'MT:YZ7A0U.ETCETCETC'})
Traceback (most recent call last):
  File "/home/pi/.webthings/addons/matter-adapter/lib/matter_server/server/client_handler.py", line 185, in _run_handler
    result = await result
  File "/home/pi/.webthings/addons/matter-adapter/lib/matter_server/server/device_controller.py", line 125, in commission_with_code
    raise NodeCommissionFailed(
matter_server.common.models.error.NodeCommissionFailed: Commission with code failed for node 3
DEBUG:chip.IN:SecureSession[0x7f64027f10]: MarkForEviction Type:1 LSID:29204
INFO:chip.SC:SecureSession[0x7f64027f10]: Moving from state 'kActive' --> 'kPendingEviction'
++Rcv raw: b'\x81~\x00\xba{\n  "message_id": "commission_with_code",\n  "error_code": 99,\n  "details": "Commission with code failed for node 3",\n  "_type": "matter_server.common.models.message.ErrorResultMessage"\n}'
ERROR:chip.EM:Failed to send Solitary ack for MessageCounter:138851852 on exchange 31560i:../src/messaging/ExchangeContext.cpp:144: CHIP Error 0x00000002: Connection aborted
DEBUG:websocket:++Rcv raw: b'\x81~\x00\xba{\n  "message_id": "commission_with_code",\n  "error_code": 99,\n  "details": "Commission with code failed for node 3",\n  "_type": "matter_server.common.models.message.ErrorResultMessage"\n}'
++Rcv decoded: fin=1 opcode=1 data=b'{\n  "message_id": "commission_with_code",\n  "error_code": 99,\n  "details": "Commission with code failed for node 3",\n  "_type": "matter_server.common.models.message.ErrorResultMessage"\n}'
DEBUG:chip.DMG:ICR moving to [AwaitingDe]
DEBUG:websocket:++Rcv decoded: fin=1 opcode=1 data=b'{\n  "message_id": "commission_with_code",\n  "error_code": 99,\n  "details": "Commission with code failed for node 3",\n  "_type": "matter_server.common.models.message.ErrorResultMessage"\n}'

.
client: on_message: {
  "message_id": "commission_with_code",
  "error_code": 99,
  "details": "Commission with code failed for node 3",
  "_type": "matter_server.common.models.message.ErrorResultMessage"
}

Then there's a few more "does not look like a CHIP device." messages, and then a final error:

DEBUG:chip.BLE:Device REDACTED does not look like a CHIP device.
DEBUG:chip.BLE:Device REDACTED does not look like a CHIP device.
DEBUG:chip.BLE:Device REDACTED does not look like a CHIP device.
ERROR:chip.CTL:Commissioning discovery over BLE failed: ../src/platform/Linux/BLEManagerImpl.cpp:814: CHIP Error 0x00000032: Timeout
ERROR:chip.-:../src/platform/Linux/BLEManagerImpl.cpp:814: CHIP Error 0x00000032: Timeout at ../src/controller/SetUpCodePairer.cpp:299

To get to this point I had to use the Tapo Android app to connect the device to Wi-Fi first. It then temporarily becomes discoverable. Normally the discover process won't find it. Is that as expected?

balloob commented 1 year ago

do you have TP-Link certificates loaded?

flatsiedatsie commented 1 year ago

I don't know. :-D

Is it /data/credentials/development/paa-root-certs ?

flatsiedatsie commented 1 year ago

I've managed to pair it!

For anyone finding this: the credentials/development/paa-root-certs directory has to be relative to the PWD - the working locaation of your script. This might not be the same as the location of the script.

It also seems important to really factory reset the device before a connection. Perhaps the device starts ignoring requests if too many are made, and the factory reset ... resets that.

tvories commented 1 year ago

Sorry to comment on an old issue, but where should I be getting the TP-Link certificates from? I'm not seeing any info when I search for the ppa-root-certs

OK, I see the URL here: https://github.com/project-chip/connectedhomeip/raw/master/credentials/development/paa-root-certs

What PWD/script are you talking about?