Last active
December 12, 2024 07:56
-
-
Save oidebrett/c83185ee47d1d355e2dc9f1e035ef921 to your computer and use it in GitHub Desktop.
Accessing Matter Attributes using Python and the Matter SDK
This file contains hidden or 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
| # Import the core chip libraries of Attribute and Clusters | |
| from chip.clusters import Attribute, Objects as Clusters | |
| # Import the required clusters | |
| from chip.clusters.Objects import Binding, BasicInformation | |
| # Fetch attributes | |
| allAttributes = await devCtrl.ReadAttribute(1, [('*')]) | |
| firstResult = allAttributes[0] | |
| # Access specific class entries | |
| binding_data = firstResult.get(Binding, "No Binding data available") | |
| basic_info = firstResult.get(BasicInformation, "No Basic Information available") | |
| # Print and explore the data | |
| print("Binding Data:", binding_data) | |
| print("Basic Information Data:", basic_info) | |
| # Iterating over all keys and values | |
| for cls_key, value in firstResult.items(): | |
| print(f"Class: {cls_key}, Value: {value}") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment