Xiaomi Human / Body / Motion Sensor - Timeout

You can actually change this behaviour in the device configuration through zigbee2mqtt:


Hi all,

Did anyone tried to see is the timout can be changed using zigbee2mqtt?

Thank you in advance

No it can’t as it is by sensor design. Read the many threads on this topic.

I have two of these sensors deployed in hallways. They turn on lights when I stumble to the bathroom or kitchen in the middle of the night. The 2 minute timeout is fine with me.

Sorry. I didn’t find what you mentioned when I searched in the topic.

Yes, it can.

You modify the configuration.yaml file under /share/zigbee2mqtt/ and add the following under the occupancy/motion device:

occupancy_timeout: 10

See here:


Don’t forget to restart the addon after making the change.

1 Like

It’s not the same, you can’t change the timeout of the sensor itself.

No, but it does tighten up the delay.

I’m using a 5sec timeout and it’s very apparent.

This is what is written:

Timeout (in seconds) after the occupancy: false message is sent

The total timeout isn’t 5 seconds. It’s the response time of the gateway to the no motion message from the sensor. Please provide full information, otherwise people get wrong expectations.

Ahh my mistake, I wasn’t aware this was how it was altering the behaviour. Thanks for the info!

I am using occupancy_timeout setting. I believe the wording in the documentation is probably not exactly correct. This setting specifies a timeout after which the

occupancy: false

mqtt message is sent. So the timer starts at the moment a sensor signals presence and then after the specified time the mqtt message is sent. If on the other hand zigbee2mqtt gets a new occupancy message from the sensor during the timeout then the timer is restarted.

Xiaomi sensors have 60 seconds hardware timeout and I set zigbee2mqtt occupancy_timeout to 61 seconds. This prevents getting occupancy: false and another occupancy: true immediately afterwards.

1 Like

I’ve (hardware) modified one of my motion sensors. The 5 seconds timeout is awesome. The HA assistant component needs some improvements because the sensor reports “motion” via MCAST very often now. “no_motion” isn’t reported (whenever). I’ve implemented/hardcoded a timeout of 5 seconds now.

1 Like

Please share how you’ve accomplished this! :slight_smile:

Are there JTAG headers you connect to on the device or something?

edit: just found this actually:

http://livebywant.tistory.com/13?category=703455 (translation required).

Correct. I tried this mod suggested by @tyjtyj here: Xiaomi Human / Body / Motion Sensor - Timeout

This code change is needed to use the modded motion sensor:

For example by downloading this file and copy it to config/custom_components/binary_sensnor/xiaomi_aqara.py. Restart HA and give it a try! :slight_smile:


What impact could this modified code have if I have mixed sensors (modified and unmodified)?

Has any one tested the mod with deconz?

How can I easily open the motion sensor?

The sensor can be opened easily. The bottom is a screw cap. Remove the battery and pull gently the grey holder. It’s clipped.

tried it with a pencil and didn’t seem to work, use ikea small pencil