python-matter-server icon indicating copy to clipboard operation
python-matter-server copied to clipboard

ICD Client Behavior

Open dmartauz opened this issue 10 months ago • 6 comments

Matter specification defines ICD client Behavior requirements:

Image

It is required for Long Idle Time ICDs to actually operate in LIT mode:

Image

Does python-matter-server support ICD Client Behavior?

dmartauz avatar Feb 28 '25 10:02 dmartauz

yes, it should as it is included in the SDK

marcelveldt avatar Feb 28 '25 16:02 marcelveldt

I did a small test to check:

  1. I've compiled this example lit-icd-app from the SDK.
  2. I've paired it in Home Assistant and I can see that the controller hasn't registered.
  3. RegisteredClients AttributeId: 3 (0x003) remains empty

It seems that a brick is missing to handle this.

Image

Diag file:

matter-01JFWSB36P58F3NV6WSBEB0CQ6-TEST_PRODUCT-bccd3c57227eadfb7796d60f2d0cc694.json

lboue avatar Feb 28 '25 16:02 lboue

Here's what the specifications say from 24-27349-006_Matter-1.4-Core-Specification.pdf page 653

Image

It works fine using chip-tool:

./chip-tool pairing code 10 34970112332 --icd-registration true
[1740761303.868] [16707:16709] [ICD] Store ICD entry successfully with peer nodeId <000000000000000A, 1> and checkin nodeId <000000000001B669, 1>
[1740761303.868] [16707:16709] [TOO] Saved ICD Symmetric key for 000000000000000A
[1740761303.868] [16707:16709] [TOO] ICD Registration Complete for device 000000000000000A / Check-In NodeID: 000000000001B669 / Monitored Subject: 000000000001B669 / Symmetric Key: 43929101bc0c4970be9661c27e5f7f6c / ICDCounter 948456568
[1740761303.868] [16707:16709] [CTL] Successfully finished commissioning step 'ICDRegistration'

./chip-tool icd list
  +------------------------------------------------------------------------------------------+
  | Known ICDs:                                                                              |
  +------------------------------------------------------------------------------------------+
  | Fabric Index:Peer Node ID | Fabric Index:CheckIn Node ID |   Start Counter |  Counter Offset | MonitoredSubject | ClientType |
  +------------------------------------------------------------------------------------------+
  |   1:000000000000000A |   1:000000000001B669 |       948456568 |               0 | 000000000001B669 |          0 |
  | aes key:                              43929101bc0c4970be9661c27e5f7f6c                   |
  | hmac key:                             43929101bc0c4970be9661c27e5f7f6c                   |
  +------------------------------------------------------------------------------------------+

./chip-tool icdmanagement read registered-clients 10 0 | grep TOO
[1740761469.676] [16729:16732] [TOO] Sending command to node 0xa
[1740761469.676] [16729:16732] [TOO] Peer is a registered LIT ICD.
[1740761469.895] [16729:16732] [TOO] Sending ReadAttribute to:
[1740761469.895] [16729:16732] [TOO]    cluster 0x0000_0046, attribute: 0x0000_0003, endpoint 0
[1740761469.900] [16729:16732] [TOO] Endpoint: 0 Cluster: 0x0000_0046 Attribute 0x0000_0003 DataVersion: 3592571304
[1740761469.900] [16729:16732] [TOO]   RegisteredClients: 1 entries
[1740761469.900] [16729:16732] [TOO]     [1]: {
[1740761469.900] [16729:16732] [TOO]       CheckInNodeID: 112233
[1740761469.900] [16729:16732] [TOO]       MonitoredSubject: 112233
[1740761469.900] [16729:16732] [TOO]       ClientType: 0
[1740761469.900] [16729:16732] [TOO]       FabricIndex: 1
[1740761469.900] [16729:16732] [TOO]      }

chip-tool-icd-registration.log

There is a Nordicsemi demo for that:

lboue avatar Feb 28 '25 16:02 lboue

I found a test script. It shows how to use Python CHIP for ICD: icd_device_test.py#L134

    devCtrl.EnableICDRegistration(devCtrl.GenerateICDRegistrationParameters())
  EnableICDRegistration = def EnableICDRegistration(parameters: 'ICDRegistrationParameters'):
                          Enables ICD registration for the following commissioning session.
                          
                          Args:
                              parameters: A ICDRegistrationParameters for the parameters used for ICD registration, or None for default arguments. 

lboue avatar Mar 03 '25 09:03 lboue

@marcelveldt can you please comment on how to solve missing functionality?

dmartauz avatar Mar 09 '25 18:03 dmartauz

Create a PR or wait until it gets implemented at some point. It is not a priority at this moment.

marcelveldt avatar Mar 09 '25 18:03 marcelveldt

Hi all!

I thought I should complicate things a bit since I've been chasing why certain matter devices were misbehaving in my Home Assistant setup but worked flawlessly in other fabrics (subscriptions not resubscribing if a timeout occurs is one symptom), and I found that it's because one of the other fabrics in this multi-admin setup is LIT capable. This will make a LIT capable matter device advertise itself as a LIT device, but the HA Matter server will still consider it a SIT device since it's not LIT capable. However, due to what I think is a bug (but I will run that by some more people in CSA) in the SDK something in ReadClient.cpp will act on the change (or just the value for initial subscription) in the IcdManagement->OperatingMode which is 1 (=LIT) and not attempt resubscriptions and wait for the next checkin packet which will never arrive because the HA matter server doesn't register a check-in client.

So the effect of this is that if a LIT device goes out of range and a liveliness timeout triggers for the subscription that the HA matter server has set up then no new events or reports will arrive until the matter server is restarted. So when considering the prio of this then that might be worth taking into consideration, that if any other fabric the device is commissioned to is LIT capable then HA will have experience issues with that device, until either LIT support is implemented or someone fixes that very strange behavior in the SDK.

hnrkp avatar May 08 '25 06:05 hnrkp

@hnrkp what devices are ICD LIT capable?

Interesting behavior you've uncovered. Since LIT is a new feature, ideally, a device should well behave even without controller LIT support (just consume more power). But this sounds really like a buggy device side implementation 😰

agners avatar May 09 '25 08:05 agners

@agners Well, not many I would guess. I have only seen it in a prototype device which will probably not be a LIT ICD in the end. And since LIT ICD didn't come out of provisional state in the matter spec until 1.4 as I understand it, LIT ICD devices will start to arrive in scale in a little while. So the issue is probably not very big right now but I guess they'll be coming in the coming months.

The behavior is not really a buggy device side implementation (the device actually behaves exactly according to the spec). But it looks like slightly buggy behavior in the SDK, and I'll try to get some attention from the ICD LIT people in CSA. My point was that this issue goes away for any controller that implements ICD LIT, which might be good to take into consideration when prioritizing ICD LIT support. :)

hnrkp avatar May 09 '25 08:05 hnrkp

Please support ICD LIT device

sangphan12 avatar Nov 02 '25 04:11 sangphan12

Yes, planned to add support when the rewrite with matter,js is ready

Apollon77 avatar Nov 02 '25 15:11 Apollon77