File tree 2 files changed +11
-11
lines changed
2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -445,24 +445,26 @@ async def read_attribute(
445
445
self ,
446
446
node_id : int ,
447
447
attribute_path : str ,
448
- ) -> Any :
449
- """Read attribute(s) on a node."""
450
- return await self .send_command (
448
+ ) -> dict [ str , Any ] :
449
+ """Read one or more attribute(s) on a node by specifying an attributepath ."""
450
+ updated_values = await self .send_command (
451
451
APICommand .READ_ATTRIBUTE ,
452
452
require_schema = 4 ,
453
453
node_id = node_id ,
454
454
attribute_path = attribute_path ,
455
455
)
456
+ if not isinstance (updated_values , dict ):
457
+ # can happen is the server is running schema < 8
458
+ return {attribute_path : updated_values }
459
+ return cast (dict [str , Any ], updated_values )
456
460
457
461
async def refresh_attribute (
458
462
self ,
459
463
node_id : int ,
460
464
attribute_path : str ,
461
- ) -> Any :
465
+ ) -> None :
462
466
"""Read attribute(s) on a node and store the updated value(s)."""
463
467
updated_values = await self .read_attribute (node_id , attribute_path )
464
- if not isinstance (updated_values , dict ):
465
- updated_values = {attribute_path : updated_values }
466
468
for attr_path , value in updated_values .items ():
467
469
self ._nodes [node_id ].update_attribute (attr_path , value )
468
470
Original file line number Diff line number Diff line change @@ -545,8 +545,8 @@ async def send_device_command(
545
545
@api_command (APICommand .READ_ATTRIBUTE )
546
546
async def read_attribute (
547
547
self , node_id : int , attribute_path : str , fabric_filtered : bool = False
548
- ) -> Any :
549
- """Read a single attribute (or Cluster ) on a node."""
548
+ ) -> dict [ str , Any ] :
549
+ """Read one or more attribute(s ) on a node by specifying an attributepath ."""
550
550
if self .chip_controller is None :
551
551
raise RuntimeError ("Device Controller not initialized." )
552
552
if (node := self ._nodes .get (node_id )) is None or not node .available :
@@ -576,9 +576,7 @@ async def read_attribute(
576
576
# update cached info in node attributes
577
577
self ._nodes [node_id ].attributes .update (read_atributes )
578
578
self ._write_node_state (node_id )
579
- if len (read_atributes ) > 1 :
580
- return read_atributes
581
- return read_atributes .get (attribute_path , None )
579
+ return read_atributes
582
580
583
581
@api_command (APICommand .WRITE_ATTRIBUTE )
584
582
async def write_attribute (
You can’t perform that action at this time.
0 commit comments