Skip to content

Read attributes

Markus edited this page Jul 10, 2019 · 2 revisions

You can easily read attriibutes from a node by use it's endpoint clusters.

You just have to know the cluster id and attribute id. Or you use the built in methods to retrieve the attributes.

Here is an example to retrieve the manufacturer name from the basic cluster:

var cluster = endpoint.GetInputCluster(ZclBasicCluster.CLUSTER_ID);
if (cluster != null)
{
    var result = await ((ZclBasicCluster)cluster).GetManufacturerNameAsync();

    if (result.IsSuccess())
    {
        ReadAttributesResponse response = result.GetResponse<ReadAttributesResponse>();
        if (response.Records.Count == 0)
        {
            Console.WriteLine("No records returned");
            continue;
        }

        ZclStatus statusCode = response.Records[0].Status;
        if (statusCode == ZclStatus.SUCCESS)
        {
            Console.WriteLine("Cluster " + response + ", Attribute "
                    + response.Records[0].AttributeIdentifier + ", type "
                    + response.Records[0].AttributeDataType + ", value: "
                    + response.Records[0].AttributeValue);
        }
        else
        {
            Console.WriteLine("Attribute value read error: " + statusCode);
        }
    }
}
Clone this wiki locally