Can not send command to lock/unlock a door lock

I am using Matter Server Add on (v6.1.2) to interact with Switchbot Door Lock.

The Door Lock is added to Matter Server via Switchbot Hub 2. Every thing works fine. I can get and listen to attribute changed events.

However, when I send a command to Lock or Unlock it via websocket. I got following error
---- command----

  "message_id": "123",
  "command": "device_command",
  "args": {
    "endpoint_id": 4,
    "node_id": 9,
    "payload": {
      "PINCode": null
    "cluster_id": 257,
    "command_name": "LockDoor"

---- response ----

    "message_id": "123",
    "error_code": 0,
    "details": "InteractionModelError: NeedsTimedInteraction (0xc6)"

the log

2024-06-27 15:08:19.139 (MainThread) ERROR [matter_server.server] Error doing task: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/matter_server/server/", line 214, in _run_handler
    raise err
  File "/usr/local/lib/python3.11/site-packages/matter_server/server/", line 197, in _run_handler
    result = await result
  File "/usr/local/lib/python3.11/site-packages/matter_server/server/", line 575, in send_device_command
    return await self._chip_device_controller.send_command(
  File "/usr/local/lib/python3.11/site-packages/matter_server/server/", line 297, in send_command
    return await self._chip_controller.SendCommand(
  File "/usr/local/lib/python3.11/site-packages/chip/", line 994, in SendCommand
  File "/usr/local/lib/python3.11/site-packages/chip/clusters/", line 312, in SendCommand
    raise chip.interaction_model.InteractionModelError(chip.interaction_model.Status.NeedsTimedInteraction)
chip.interaction_model.InteractionModelError: InteractionModelError: NeedsTimedInteraction (0xc6)

Does anyone have this kind of error? Thank you

Locks need a timed request. Just pass timed_request_timeout_ms with 1000 or similar.

Timed interactions are an extra safety precaution which should prevent intercept, interfere and replay attacks (basically, where the unlock command would be recorded on RF, then replayed again later, when the user is not at home). With the timing mechanism, there is a two phase protocol which prevents this from being possible.

See also how Core interacts with locks: core/homeassistant/components/matter/ at 3e9b57cc07c81bec24530aab4dfc3792ddc9d289 · home-assistant/core · GitHub.

1 Like


Thank you so much. And yes, it works.

There is no document about it, so I did not know.

One more thing, I know that we can put response_type: null in the request . Are there any other value for the response_type. I am looking for response, like , command executed with response success or failed from device.

Currently, when I send a command, I can not know if it has been executed successfully or not. The only way to know is to wait for the attribute_changed “event”.

Why are you using the WS API directly actually? HA should nicely abstract this for you :smile:

Afaik you need to look into in the cluster library to see what response types commands have.

Thank you for pointing out the, hmm, it seems that I can only know whether the target attribute was adjusted accordingly by waiting for the event. Fair enough!

Wew, I am going to create another add-on to send those Matter device resources to my custom server.

Because you are asking, Can I ask this question?

Is there anyway that I can get all devices (and control them too) connected to HA via HA abstraction?
Right now I am able to get/set Matter devices via the ws provided by the Matter Server Addon. But for others, I do not have any idea.