Aqara Vibration sensor setup with ZHA - best practises

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
image

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):
image

image

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:

14 Likes

@Culemsao

Many thanks for this guide. As you say, it really does only trigger if there is an earthquake.

I noticed that with setting up the sensitivity, on a succesfull change it triggered this event:
Attribute Updated event was fired

Hi Shaun, thanks for sharing.

Wanted to also say thank you got this post. I was worried that I had wasted my money and needed to toss this in the garbage. Now, it’s working exactly as I had hoped and I also learned about a new section of ZHA that I never knew existed.

Thank you!

1 Like

i am having the hardest time getting this sensor to trigger even after setting to the highest sensitivity for some reason. I was able to set the sensitivity, but I was unable to read the sensitivity. That kept failing no matter how many times I pressed the button on the sensor. I have this currently connected to my Home Assistant Yellow. No issues with my Aqara P1 Sensor which makes me believe this sensor may be faulty? I have removed and readded a few times which is always successful and I do get a few triggers for a few minutes, but after that no readings from the sensor anymore. Somehow I lost 23% battery just in the 1 hour of testing!

Hi b00st3d, hard to tell from a distance. I don`t value the battery status to much, does never seem to be accurate. You could try adding a different battery and see if it helps. Have you tried moving the sensor closer to your zigbee device, just for testing?. Just to be sure, you mention you have set the sensitivy to highest, that should mean value = 1.

In case you figure it out and it works, please note that in my experience value = 1 sometimes gives faulty sensor readings. In my case I kept raising the value until I did not get these ghost values anymore. Stable endresult for me was value = 6.

HI @Culemsao, I think I have a defective sensor. I have been testing only two feet away from my main zigbee hub. It pairs fine initially, but then after a few minutes I lose all connectivity completely. I have enough time to set the sensitivity to 1, but I am unable to read the sensitivity after a few minutes. If I reset the device, everything is working, but once again fails after just a few minutes. I have a new sensor coming today to try out. Hopefully I will have better luck! Thank you!

edit new sensor arrived and it works perfectly! I was able to set sensitivity as well as read sensitivity and it functions even after 20-30 minutes.

I just purchased the Aqara vibration sensor and it worked fine for about 30 minutes but then stops providing any updates. I’ve tried repairing it a few times to my ZigBee network, and each time, it will work fine for 30 minutes and then stops.

I see b00st3d also had this problem and a new sensor fixed it. I think I’ll just get the Aeotec multipurpose sensor instead.

I just wanted to share my experience here in case anyone else comes across this problem.

1 Like

Or if you were running zigbee2mqtt, you could just click the setting in the UI for the device:

When you hear people talk about how Z2M has better device support than ZHA, this is another example of that. And another reason why I always recommend HA users use Z2M instead of ZHA for zigbee support.

I agree with ignoring the battery values. I have some Aqara temp sensors that have been reporting back 1% battery remaining for almost a year now. Still going strong. I’ll replace the battery when I get the alert that it dropped off the network.

Back to the topic at hand. I thought the highest sensitivity setting would fix my issue, but I really have to give it a few physical taps to get it to start detecting vibration and then it continues detecting properly until it stops. It’s the initial detection that isn’t working. Very frustrating, not sure I’ll find a solution for this.

Along with @fresnoboy’s comment. I’m running ZHA. Curious if switching over to z2m would change the initial reporting sensitivity. I’m currently > 50 zigbee devices, so I’m not looking to switch just out of curiosity. :slight_smile:

To satisfy your curiosity, it’s worth the $20 dollars or so for an extra stick to run ZHA and Z2M side by side. They coexist quite happily. Long term it’s probably best to commit to one or the other, but you can test a sample of each device under z2m and get a real feel for it without moving everything all at once.

2 Likes

Hello to all, and thanks for the information… is there also a way to decrease the time the device shows detection after vibration has stopped? Thanks

1 Like

I’d like to push this question, as I’m also looking for a way to decrease the duration of the time the device shows detected.

I know this a bit older of a thread, but changing the sensitivity on that screen results in an error, and hasn’t worked for me for months.

Try this Publishing to zigbee2mqtt (Aqara vibration sensor) - #7 by Tuuvian

I cant get the green checkmark to show up. Any hints?