Zigbee DH Development

I am trying to work on the Xiaomi Door/Contact Switch handler.

The problem I have is that the sensor stops reporting battery after a while and I am not able to get it back no matter what I do (drop the device and rejoin it) so I though maybe the DH could request some data. When I try I do not get any response.

So am I doing my Zigbee commands correctly??
Here is my refresh:

def refresh() {
def linkText = getLinkText(device)

def configCmds = zigbee.readAttribute(0x0000, 0x05) + zigbee.configureReporting(0x0001, 0x0021, 0x20, 300, 600, 0x01)

log.debug "${linkText}: refreshing: ${configCmds}"

return configCmds

In my log I get:
Front Door: refreshing: [st rattr 0x8F3D 0x01 0x0000 0x0005, delay 2000, zdo bind 0x8F3D 0x01 0x01 0x0001 {00158D0001583EB3} {}, delay 2000, st cr 0x8F3D 0x01 0x0001 0x0021 0x20 0x012C 0x0258 {01}, delay 2000]

But I never see any response.

First thing in my parse function:

def parse(String description) 
  def linkText = getLinkText(device)
  log.debug "${linkText}: Parsing '${description}'"

I know that the sensor sends data for cluster “0000” and attrId == “0005” if I press the button on it. And I am able to parse it.

In my experience the Xiaomi sensors do not do a very good job of responding to any commands we send to it. Whether that’s because they are extremely sleepy and just don’t hear the commands, or because they only sort of follow the Zigbee spec (in other cases they don’t do what they are supposed to), I’m not sure. It’s been several months since I was getting them setup in my house, but I’m not sure they really allow for configuration, or reading attributes. They seem to sort of do their own thing. One thing I haven’t done (or seen a writeup of someone who has), is set some up with a Xiaomi hub and sniff the Zigbee traffic which could give some clues to how their hub handles it, but unless you have the equipment to do that you’re probably out of luck.

For the time being though, what you have here would be correct for a normal device, but the fact that it is not responding further enforces my experience that Xiaomi devices don’t typically respond to commands.

You can take a look at Xiaomi Zigbee Door/Window Sensor, Motion Sensor, & Smart Button Device Type [beta] for existing DTHs the community has written and discussion on them as well.

Thanks for the response.

Ok am ijn the US so the Xiaomi gateway would require an adaptor to plug in and I am not opposed to that.

I don’t have a zigbee sniffer either, but if they are reasonably priced I would be willing to get these two items to further develop the DH.

The sensors are very well built, small and cost effective.

If you haven’t seen this already: Zigbee Sniffer Recommendations

or this? https://www.arrow.com/en/products/2267/adafruit-industries