This post is to share my best practices setting up Aqara Vibration sensors with ZHA.
Integration goal
Goal of the setup is to create a security system with a set of aqara sensors (motion, vibration & door sensors).
Challenges
sensitivity
Recently I purchased a set of Aqara Vibration sensors however when I set them up with ZHA I noticed it did not immediately comply with my expectations (regarding vibration based triggering). Instead it looked like it required an earthquake to trigger the devices. Although that the sensitivity of the device is adjustable, the vibration sensitivity never complies with my expectations. It looks like the device it`s core sensitivity is orientation based → trigger on tilting or moving (acceleration) the device.
However in order to adjust the sensitivity:
1. Goto the list of devices
2. Select the device to adjust
3. Open device settings and select “Manage clusters”
4. Open device settings and select “Manage clusters”
4.1. In the Cluster list, select “VibrationBasicCluster (Endpoint id: 1, Id: 0x0000, Type: in)”.
4.2. Select the Attribute value as shown in image.
4.3. Fill in the Value section with a numeric value 1-21. This indicates the sensitivity to be set from a scale 1 - 21. On the internet people mention the scale definition as 1 high sensitivity, 11 medium sensitivity, 21 low sensitivity.
4.4. Fill the “Manufacturer Code Override” as shown in image.
4.5. Grab your Vibration sensor and make sure you are able to press the reset button for 1 sec.
Then hit the “SET ZIGBEE ATTRIBUTE” link and quickly press the reset button. When the press on reset button immediately results into a green checkmark on the Set attribute link, you are successful. Else retry this step.
Warning: be aware that there is a timeout on the setting. When this timeout passes and the setting was not successfully transferred it will show a green checkmark anyway. So make sure you see a green checkmark before the timeout and as a response to your press on the reset button.
Hint: standing closer to your Zigbee dongle helps getting a successful result.
5. To check if the sensitivity value has changed to your prescribed value. Remove the Value to blank, hit the “GET ZIGBEE ATTRIBUTE” and again press the reset button of the device.
This time there is no green checkmark but you have to repeat the step until the Value field is filled with a number, the actual sensitivity value from the device.
“unavailable” state
When devices are not triggered for a certain period of time, they are given an “unavailable” state in Home Assistant. When, after the “unavailable” state was set, the device notices a trigger then Home Assistant is not reacting and the security system has a flaw. In order to fix this I found out that ZHA has a timeout configuration for this where I set the timeout to approx a month (in seconds):
Using the device`s metadata
I placed the vibration sensors on windows to check if there is being tampered with and if there is movement (opening/closing) of the window. Another goal is to check if a window is open or closed when the security system is armed. In order to do this the orientation values of the sensor are required to notice deviation between open/closed. Since this is not a binary sensor value but a data set, it was a little trickier to get and use it:
Zigbee channel optimization
Zigbee vs WiFi channel config: