Xiaomi Human Presence Sensor integrated into Home Assistant

I’ve been using the new Xiaomi battery-powered PIR+mmWave Occupancy Sensor for the past three months, and I wanted to share my experience and some tips for integrating it with Home Assistant.

Product links:

My Take: I’ve found it to be a pretty reliable sensor for my setup. Here are a few things that stood out to me (image 1/2/3 in the gallery):

  • Three-year battery life on a single CR2450 battery (no need for a power cord).
  • It supports motion detection up to 6 meters, stationary body detection at 4 meters, and light intensity reporting with a 130-degree field of view.
  • The smart algorithm leverages PIR for detecting motion (as PIR is better at this), while the low-energy mmWave radar maintains detection for stationary bodies.

    osb-2


It only supports BLE broadcast for data reporting, so there is no easy way to make it work in Home Assistant with Local Automation (before 2024.10.0 release).


:gift:I submitted a modification to HA (which is already included in the 2024.10.0 stable release), adding support for a local BLE solution. This method directly listens to the sensor’s BLE broadcasts, without relying on the cloud, allowing for local automation.

(A friend of mine also uses ‘Xiaomi Gateway 3 for Home Assistant’ integration to read the sensor’s data, but I haven’t tried it myself because it requires downgrading Xiaomi Multimode Gateway’s firmware, which I prefer not to do. However, if you have an old gateway firmware and haven’t upgraded it, you could give it a try.)


:tada: :tada: :tada: [update@2024-10-04] The change is already included in the 2024.10.0 stable release!

How to Enable “Xiaomi BLE” Integration:

Feel free to ask if you need further details on the setup.

Enjoy~

1 Like

Thank you for your work to integrate these sensors into HA.
I just ordered them since I need presence detection in areas without an outlet.

Do I need a Xiaomi gateway for initial setup? The documentation from the Xiaomi BLE integration states that you need one to get the encryption keys. Though I used an Xiaomi scale and didnt need one. Just the Mii fit app for initial setup. Would be a showstopper to be honest.

Do I need a Xiaomi gateway for initial setup?

[Dian] I don’t think so. The initial setup can be done on your phone. The initial encryption key is sync-ed between the cloud and the sensor by Mi Home app on your phone. After that, the encryption key can be extracted from the cloud and Xiaomi Gateway should not be required…

Just have a try and let me if I misunderstand it.

Is it possible to add it to HomeKit via HA with the HomeKit integration?

Yes. I tried and it worked.

1 Like

good news: beta release (2024.10.0b0 for now) w/ the change was just released.

1 Like

Thank you for the feedback. I’m going to buy one to test in a bathroom

1 Like

3 years battery life? Wow!

1 Like

:tada: :tada: :tada: [update@2024-10-04] The change is already included in the 2024.10.0 stable release!

2 Likes

Thanks for the great work! Was following your changes on GitHub and finally included in 2024.10.0 release.

To anyone who doesn’t have occupancy sensors (occupancy, detection detected/cleared etc) in HA after setting up, make sure your battery cover is firmly locked (dots match each other). Spent lot of time debugging this :sweat_smile:

1 Like

Hi, this sensor and integration looks great, I made local integration. It is connected to HA but I cannot see sensors(I can se just signal). What am I doing wrong:).
Thanks for help

1 Like

can you tell what you did ? did you add bluetooth proxy device in the HA before trying to discover the new occupancy sensor ?

I’m trying to add the sensor to the Mi Home app without the gateway, but it seems to not recognise the QR code on the back of the device, and it doesn’t seem to find it when I use the nearby devices feature either.

The earlier comments suggested that I might be able to do it without the gateway - am I missing something?

I’m using them for some days now, they’re pretty reliable and fast. Using them in combination with esphome bluetooth proxys.

I don’t have a gateway and just used the nearby device feature. Have you pushed the button on the sensor for a few seconds till it blinks, prior searching for devices?
The QR Code didn’t work for me either.

Don’t know if its related: I have set the country to china in the Xiaomi Home app

Yeah, I held the button on the top and it blinked 6 times. I have the nearby devices permission enabled for the app as well :thinking:

Try setting the country inside the app to china, that might help.

Switching the region (which seemed to switch server) didn’t seem to help - thanks for the suggestion, though!

I’m using an Android, and this is the Mi Home app that I’m trying to use.

Are you using an iOS device or an Android device to initially set it up?

Android device (Pixel 7 Pro) and the same app. Strange that it doesn’t work for you.
I’m out of ideas.
Maybe try another phone. You really only need to have the devices in your account so you can extract the bind key.

Switching the region to “Chinese Mainland” (which also switch server) is required to discover the sensor in Mi Home app.
Also, please enable the phone’s bluetooth connection.
Then, the device should be discovered in “Add Device” nearby list.

I discovered the device using the Mi Home app and put it into pairing mode, but the device was detected without its sensors.