I'm working on optimizing some zigbee drivers and have a few questions.
As I understand it, it should be possible to send a command to a Zigbee device to read mutliple attributes in a cluster at once. However, the example code I've seen all reads a single attribute at a time. For example, for reading color attributes, code like the following is common:
But that doesn't seem to work. Anybody know how this should be done?
Also, does anybody know what the brackets "{}" at the end of the he rattr string are for? Maybe there are options that go in there, but I can't find any documention of the he command.
Similarly, according to section 2.5.16 of the Zigbee cluster specification, I understand that it should be possible to write multiple attributes at once.
So, as a common example, if I wanted to set Hue, Saturation, Color Temp, and Color Mode attributes of the color cluster (0x0300), rather than 4 separate commands, I should be able to do that more efficiently with a single write to all the attributes. Anybody know how?
Would there be a way to set the "raw" format of the command and just have Hubitat send that. I.e., for some common commands like color, it might be simple enough to format it myself if the hubitat methods can't support this.
This is a sample code for reading multiple attributes in one command
cmds += zigbee.readAttribute(0x0000, [0x0004, 0x000, 0x0001, 0x0005, 0x0007, 0xfffe], [:], delay=200) // Cluster: Basic, attributes: Man.name, ZLC ver, App ver, Model Id, Power Source, attributeReportingStatus
Writing requires separate commands for each attribute, as the data may be of a different type.
Thank you. That's what I was looking for. Seems to work perfectly!
Another question: what's the "[:]" for? are there options that can be put in there or something?
Also, for the status 0xfffe, on a color bulb report, I get:
['status':'86', 'attrId':'FFFE', 'attrInt':65534]
I found an attributeReportingStatus attribute in 2.3.5.1.2 of the zigbee cluster specification, but it doesn't seem to match these values. Am I looking in the wrong place for the meaning of this?
And finally, the reading of attributes generally follows setting them - for example, after setting color or level to confirm what was set (at least that's how it is in public drivers on the Hubitat github). I also notice in the zigbee spec. section 2.5, you can configure reporting for attributes. Is it possible to simply configure a device to report anew attribute for things like on, setting levels, color, etc. immediately after it gets set, or is the manual polling necessary? If a device can be configured to automatically generate a report, it seems this would be much more efficient than querying it after each set.
This map can contain additional parameters, the only one that I am aware of and using in some of my drivers is the manufacturer code, where required:
if (isT1()) { // RTCGQ12LM Aqara T1 human body movement and illuminance sensor
cmds += zigbee.readAttribute(0x0001, 0x0020, [:], delay=200)
cmds += zigbee.readAttribute(0xFCC0, 0x0102, [mfgCode: 0x115F], delay=200)
}
Note, that the Aqara manufacturer code is required only for the Aqara custom cluster FCC0.
On the basic cluster 0xFFFE attribute - it's usage is specific for Tuya devices. Reading it is a part of the 'Tuya Magic' spell that unlocks some Tuya devices and they start to use the standard ZCL clusters, instead of the Tuya proprietary EF00 cluster and 'data points'. In your case, the status code returned 0x86 means 'not supported', and this is expected for non-Tuya devices.
Whether a specific attribute can be configured to be reported automatically by the devices depends solely on the device firmware. Typically, automatic reporting can be configured for attributes that are measured by the device itself - like battery percentage remaining, temperature, humidity, power, voltage, etc.... Attributes that are configured by the Zigbee coordinator (like level, color, etc..) are usually not reported back.
As @kkossev mentioned its completely up to the device how reporting is offered. Some devices don't even support timers to do the reporting on a frequency. Generally to test I try and configure reporting on a bunch of cluster/attributes and see what the response is. Often its UNSUPPORTED or another similar error.
I've had one device that only supports report configurations on non useful attributes. The SAGE doorbell sensor won't accept reporting on anything except the Basic/Manufacturer name (0x0004) attribute (returns "Echostar"). I ended up using it as a device-health checkin as all the other what-you'd-think-would-make-sense attributes rejected any requests for reporting.
If I wanted to read multiple attributes from a specific endpoint, how would that be done? I don't see where in the zigbee.readAttribute you specify an endpoint (I assume it might be an option in the [:] options list, but I can't find documentation.
I noticed there is also a "he raw" command which I assume I can use to do #1 in raw form, but I can't find any documentation on how it is formatted. Is there documentation for this anywhere? I tried looking in the forums and through old SmartThings documentation sites, but I didn't find anything clear on this.
I was able to figure it out (I got lucky and found a reference in an old SmartThings driver). To use an endpoint other than 1, you add a destEndpoint option to the option Map like this . . .