How to read cluster attributes programmatically?

Right now, a Zigbee cluster attribute can be set programmatically from a Python script like so:

service_data1 = {
    "ieee": "some_ieee",
    "endpoint_id": 11,
    "cluster_id": 6,
    "cluster_type": "in",
    "attribute": 16387,
    "value": 255,
}

hass.services.call("zha", "set_zigbee_cluster_attribute", service_data1, False)

However, I couldn’t find a way to read an attribute programatically. Maybe it’s possible through issue_zigbee_cluster_command, but I don’t know the command for that, and I couldn’t find any documentation on this.

Anyone has an idea how can I do it?

This would be useful to verify certain actions, for example, that the above service call succeeded, or in general scripts where reading a cluster attribute is useful.

Concrete example: After configuring the Hue lights’ power-on behavior with set_zigbee_cluster_attribute, we want to verify that our operation was successful by reading that value after the change. Note that some ZHA commands fail silently (the set operation “works” but reading the value proves it didn’t actually succeed)

You can via WS API. Send this

    data: {
        ieee: msg.payload.ieee,
        endpoint_id: 1,
        cluster_id: 0,
        cluster_type: "in",
        attribute: 5
    }
``` to `zha/devices/clusters/attributes/value` endpoint

It was long time ago, but maybe you could show an example or explain it a little bit more?

I ended up moving to Z2M - I find it more reliable and much less restrictive than ZHA.