I am trying to figure out the best way to return a zigbee writeAttribute command that includes a specific manufacturer code when a certain message is parsed.
One way I know of is to use wattr, like this:
def cmd = "he wattr 0x${device.deviceNetworkId} 0x01 0x0000 0xFF0D 0x20 {${attrValue}}"
// some more code
return cmd
But I have no idea where to add the manufacturer code.
Another method on Hubitat, as I understand it could be to skip returning the command on parse() and instead use sendHubCommand, like this:
We'll get to documenting these shortly, left to right
Cluster, attribute, data type, value
You shouldn't need to use send hub command, but it depends on the context.
Seeing that the formatting of the passed parameters is different than with SmartThings (double-quotes around the value of mfgCode vs. no double-quotes) gives me the feeling that I shouldn't make any assumptions about the context that would require using sendHubCommand.
Here's an abridged oversimplified version of what I'm trying to do in a device driver:
Basically, the write attribute command needs to happen right after a button is pushed which sends a message on cluster 0x0000 attribute 0x0005. Is this the right method in this context?
I don't get any error on zigbee.writeAttribute, but there's no response from the device. Unfortunately I'm not certain if it is even supposed to send a response, and because it's an Aqara sensor, it doesn't respond to zigbee.readAttribute(0x0000, 0xFF0D, [mfgCode: "0x115F"]) which would normally be the way to make sure the write attribute command worked.
Another thing I should ask about is the length of the hex value for the payload. On SmartThings, apparently there's a rule that:
The length of the payload must be two times the length of the data type. For example, if the datatype is 16-bit, then the payload should be 4 hex digits.
Does this rule also apply to zigbee.writeAttribute on Hubitat?
mfgCode just needs to be a string, doesn't matter if its double quotes or single.
what I do for commands I want to run from parse is the following, then you don't need sendHubCommand.
parse has a built in response wrapper, and if the last return is a command, it will execute it.
so this is the form i use
def cmds = [] //at the top of parse
then where ever I wish to fire a command
cmds.add(zigbee.whatever), if there's more than one you can do cmds.addAll()
then the very last line in parse
return cmds, or the like