[RELEASE] v0.5 of unified Xiaomi Door/Window contact sensor Device Driver
Works with both the Xiaomi “original” and Aqara models
For convenience please copy the D/W sensor device driver code from this direct link.
This is a unified Hubitat Device Driver for both the Xiaomi “original” and Aqara Door/Window contact sensor models. Basic use is the same, with the only difference being the battery reporting, which is handled in the code.
- The Hubitat hub should correctly select this custom device driver for both contact sensor models when paired.
- The date/time of the most recent opening of the contact is stored as
lastopen(human readable) and
- The date/time of the most recent report of any kind is stored as
lastCheckin(human readable) and
lastCheckinDate(java format). This may be useful in determining whether the sensor is still connected, since a status report including battery voltage is sent every 50-60 minutes.
- Battery replacement date tracking, stored in
- Commands / Preferences include:
• A Reset Battery Replaced Date command to track battery life
• Reset To Closed & Reset to Open commands to manually override an open / closed event
• Date / 24-hour clock settings for display of
• Min/Max voltage values used to calculate the battery percentage
- This device driver is not final, and some features or preferences may be added / removed
- The Aqara Door/Window sensor is special in that you do not have to wait 50 minutes for the first battery report. After it is paired, just short-press the reset button, and the battery level will be reported. However, a couple times I did this, the sensor immediately dropped its connection (see the next note for details on how to reconnect).
- I have four of each kind of these sensors, and in most cases, they dropped their connection around an hour after pairing, either just before reporting battery level (for the “original” model) or just after (for the Aqara model.) A few times, they stopped reporting open/close events within a few minutes. To reconnect them without deleting them from the devices list, I have to put my Hubitat in “Discover Devices” mode, and then start with a LONG-press of the reset button, watch for 3 quick LED flashes, and if not, keep short-pressing the reset button until the LED does flash 3 times. It won’t show up as a device to rename because it’s already in the device list.