@@ -551,8 +551,7 @@ async def send_device_command(
551
551
cluster_cls : Cluster = ALL_CLUSTERS [cluster_id ]
552
552
command_cls = getattr (cluster_cls .Commands , command_name )
553
553
command = dataclass_from_dict (command_cls , payload , allow_sdk_types = True )
554
- node_lock = self ._get_node_lock (node_id )
555
- async with node_lock :
554
+ async with self ._get_node_lock (node_id ):
556
555
return await self .chip_controller .SendCommand (
557
556
nodeid = node_id ,
558
557
endpoint = endpoint_id ,
@@ -573,10 +572,9 @@ async def read_attribute(
573
572
raise NodeNotReady (f"Node { node_id } is not (yet) available." )
574
573
endpoint_id , cluster_id , attribute_id = parse_attribute_path (attribute_path )
575
574
assert self .server .loop is not None
576
- future = self .server .loop .create_future ()
577
- device = await self ._resolve_node (node_id )
578
- node_lock = self ._get_node_lock (node_id )
579
- async with node_lock :
575
+ async with self ._get_node_lock (node_id ):
576
+ future = self .server .loop .create_future ()
577
+ device = await self ._resolve_node (node_id )
580
578
Attribute .Read (
581
579
future = future ,
582
580
eventLoop = self .server .loop ,
@@ -621,10 +619,11 @@ async def write_attribute(
621
619
value_type = attribute .attribute_type .Type ,
622
620
allow_sdk_types = True ,
623
621
)
624
- return await self .chip_controller .WriteAttribute (
625
- nodeid = node_id ,
626
- attributes = [(endpoint_id , attribute )],
627
- )
622
+ async with self ._get_node_lock (node_id ):
623
+ return await self .chip_controller .WriteAttribute (
624
+ nodeid = node_id ,
625
+ attributes = [(endpoint_id , attribute )],
626
+ )
628
627
629
628
@api_command (APICommand .REMOVE_NODE )
630
629
async def remove_node (self , node_id : int ) -> None :
@@ -1084,8 +1083,7 @@ async def _resolve_node(
1084
1083
self , node_id : int , retries : int = 2 , attempt : int = 1
1085
1084
) -> DeviceProxyWrapper :
1086
1085
"""Resolve a Node on the network."""
1087
- # log_level = logging.DEBUG if attempt == 1 else logging.INFO
1088
- log_level = logging .INFO # TEMP !
1086
+ log_level = logging .DEBUG if attempt == 1 else logging .INFO
1089
1087
if self .chip_controller is None :
1090
1088
raise RuntimeError ("Device Controller not initialized." )
1091
1089
try :
0 commit comments