-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Log extensively during commissioning (#462)
- Loading branch information
Showing
2 changed files
with
42 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"""Helpers to manage Cluster attributes.""" | ||
|
||
from typing import Any | ||
|
||
from ...common.helpers.util import create_attribute_path | ||
|
||
|
||
def parse_attributes_from_read_result( | ||
raw_tlv_attributes: dict[int, dict[int, dict[int, Any]]], | ||
) -> dict[str, Any]: | ||
"""Parse attributes from ReadResult's TLV Attributes.""" | ||
result = {} | ||
# prefer raw tlv attributes as it requires less parsing back and forth | ||
for endpoint_id, clusters in raw_tlv_attributes.items(): | ||
for cluster_id, attribute in clusters.items(): | ||
for attribute_id, attr_value in attribute.items(): | ||
# we are only interested in the raw values and let the client | ||
# match back from the id's to the correct cluster/attribute classes | ||
# attributes are stored in form of AttributePath: | ||
# ENDPOINT/CLUSTER_ID/ATTRIBUTE_ID | ||
attribute_path = create_attribute_path( | ||
endpoint_id, cluster_id, attribute_id | ||
) | ||
result[attribute_path] = attr_value | ||
return result |