From a9c6708a7b8ef4cc1f694355940d0f2af223d6d9 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Sat, 29 Jun 2024 14:47:10 +0200 Subject: [PATCH] Use GetConnectedDevice directly to get device proxy (#723) --- matter_server/server/sdk.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/matter_server/server/sdk.py b/matter_server/server/sdk.py index afedbd3c..d81ba37c 100644 --- a/matter_server/server/sdk.py +++ b/matter_server/server/sdk.py @@ -319,8 +319,16 @@ async def read( # This is basically a re-implementation of the chip controller's Read function # but one that allows us to send/request custom attributes. future = self.server.loop.create_future() - device = await self.find_or_establish_case_session(node_id) async with self._get_node_lock(node_id): + # GetConnectedDevice is guaranteed to return a deviceProxy + # otherwise it will raise a ChipStackError exception. A caller to + # this function should handle the exception in any case, as the Read + # below might raise such exceptions too. + device = await self._chip_controller.GetConnectedDevice( + nodeid=node_id, + allowPASE=False, + timeoutMs=None, + ) Attribute.Read( future=future, eventLoop=self.server.loop,