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, but there are a couple of ways to make it work in Home Assistant (HA).

Option 1: Cloud-based Solution with “Xiaomi Miot Auto”

The easy way to add the sensor to HA is to use “miot-auto” integration (at GitHub - al-one/hass-xiaomi-miot: Automatic integrate all Xiaomi devices to HomeAssistant via miot-spec, support Wi-Fi, BLE, ZigBee devices. 小米米家智能家居设备接入Hass集成 ), but it only support poll-based sensor data reading from the xiaomi cloud, which is not only slow but also reduce reliability. There are a lot of public articles to tell how to use it, and I assume any HA user can figure it out.
And, to ensure its low latency for (sensor → switch/light automation), I set the polling interval to 1 second in configuration.yaml brutally and it does work most of the time.

Customize via device model
xiaomi_miot:
  # https://github.com/al-one/hass-xiaomi-miot/blob/96ae163cf2823c97561b5dabea25085d66ba7d32/custom_components/xiaomi_miot/core/device_customizes.py
  device_customizes:
    xiaomi.sensor_occupy.03:
      interval_seconds: 1 # Seconds between each update state (Requires reload config entry)

Option 2: Local BLE Solution (Highly Recommended)

I submitted a modification to HA (which will most likely be included in the 2024.10.0 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.)

Since HA 2024.10.0 release isn’t officially released yet, you can try it out by either using the nightly dev container or my custom branch. The custom branch is based on the stable 2024.8.3 build, with cherry-picked commits specifically for the sensor.

How to Enable “Xiaomi BLE” Integration:

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

Enjoy~

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.