Xiaomi Human / Body / Motion Sensor - Timeout

This is what I did, just didn’t test it yet, gonna have to wait till I get home from work to test this out.

https://pastebin.com/3KFSLzs3

Basicly added condition to turn off lights if xiaomi motion is off.

@INTEL, did you manage to change the motion sensor setup to 5s in xiaomi.py file on HASSIO?
We may need to download xiaomi.py from the source and then edit and use it as a custom component.

Nope, hassio is running under ResinOS, and couldn’t find an option to edit xiaomi.py, so I’m looking oin workaround described above.

But where in the file we need to copy the code?

Try this:

https://github.com/NidalM/home-assistant/blob/master/homeassistant/components/binary_sensor/xiaomi_aqara.py#L22

1 Like

Is doesn’t makes sense to reduce the scan interval as the sensor has approximately 60 second resolution.

The intervals for Home Assistant and the sensor aren’t necessarily in sync.

Say the sensor updates the gateway once per min. And Home Assistant polls the gateway once every 30s. That means it could take anywhere between 0s to 30s before Home Assistant reflects the new state. i.e. it could take up to 1min 30s before the new state is reflected.

If you reduce the SCAN_INTERVAL to 10s, it shortens the max time Home Assistant polls the gateway to figure out the new state to 1min 10s. Its not much of an improvement but I think its a reasonable trade-off in terms of performance.

The scan interval already is 10 seconds, reducing it to 5 doesn’t make any improvement.

I believe its currently 30s in the master branch though I may be looking in the wrong place:

https://github.com/home-assistant/home-assistant/blob/master/homeassistant/components/binary_sensor/init.py#L19

I managed to create a custom component in hass.io using this code

from datetime import timedelta

SCAN_INTERVAL = timedelta(seconds=10)

and stored it in /config/custom_components/binary_sensor/xiaomi_aqara.py

I’m certain it loaded correctly but I don’t get any improvement in my turn off response time. Strangely, I don’t experience the 60 to 90 seconds you guys are seeing. My motion sensors don’t flip back to ‘off’ until exactly 120 seconds, with or without the custom component.

Were there some changes to the component since this thread was started? Any ideas why this isn’t working?

I have the second generation model with the luminance sensor.

I’m running into the same issue.

I really dont understand what the problem is. In the MiHome.app is see all motions instantly and other Sensors, like my xiaomi window sensors, works too without any issues and all motions are instantly shown in HA.

I think a motion sensor with a 2 minute blindtime is nearly useless.

4 Likes

Especially with all the false reports I get from the body sensor. Anyone else has this? No one was in my room (I know that for a fact), and I even had it pointed at a wall, but I still get multiple motion detections per day.

@Gerben321 Do you get that with all of them? Maybe you got a faulty one. I got three this week and haven’t noticed any false positives

For motion sensor even MiHome.app and their automation triggers only one time per minute.

I don’t support your complain. Motion is detected and reported instantly. Just the transition to “no_motion” has a maximum delay of 2 minutes.

1 Like

Thats true. But in these 2 minutes you see no motion in HA. But you see it in the protocoll in the mihome.app.
Its nearly impossible so relize a usefull motion detection like this.

For example.
I go into my kitchen -> motion detection -> lights on.
I grap a glass of water and leave and switch manually off the light.
The next motion only triggers in 2 minutes, so in this time my wife can only go in with no light or have to switch manually in.
That suxx

Just don’t turn off the light within the 2 minutes. It turns off by automation. If your wife enters the kitchen the light remains on. Do you try to safe the power of two minutes?

I have been told off by my partner for exactly the same problem :smile:! The delay in detecting no motion is less of a problem, the problem is the delay is re-detecting motion.

Thats it.
Sure I can wait this 2 minutes, because I know how its working. But my kids and my wife dont want to think about this. It just must work with no issues!

I‘m using a zwave motion detection device. This have a blind time of 8 seconds and works perfect. But its far more expensive.

Hmm… I understand the significance now. Lets hope the gateway firmware gets an update some day. For now it’s a firmware issue and cannot be improved.

1 Like