Xiaomi Human / Body / Motion Sensor - Timeout

How do you reset the sensor state? Mind sharing your automation please?

- id: '1578279316231'
  alias: Reset Sensor state
  description: ''
  trigger:
  - entity_id: binary_sensor.stairs
    for: 00:00:05
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data_template:
      entity_id: binary_sensor.stairs
      state: 'off'
    service: python_script.set_state

The Set State script can be found here
https://github.com/rodpayne/home-assistant/blob/77293b434ca30acff1b43d6ec81374061950e34b/.homeassistant/python_scripts/set_state.py

8 Likes

So Home Assistant thinks that it was only on for 5 sec.
Thanks!
This fixes half the issues.
But does the sensor trigger again in less than 3min? (or what’s it’s default value?)

1 Like

No, unless you do the hardware mod to the sensors, which you can find here on the forum and requires literally 1 minute per sensor. Then you’re able to trigger the sensor as many times as you wish.

1 Like

Hey critical2104,

I just got my first four Aqara Sensors in the mail and immediately modded one of them (the option of doing so was the main reason i got them), added it to Raspbee/Phoscon in HA and only then realized that the hardware-mod alone dose not make HA recognise the 5sec reset. So i went online and found your Post. I’m very new to HA and still struggle with the coding part of it. Could you maybe take me through the steps on how exactly to make this work? Where and how do i place that automation-script and where the Python-Script ? It seems one has to create an automation for each sensor? Is there any way of having all registered sensors resetting after 5sec? (I plan on adding quite a few more, all of them modded)

Thank you in advance!

Hey, if you’re using deConz you can use the following automation (put this in your automations.yaml file) to make the sensor states reset after 5 seconds. This uses a service deconz exposes to HA so it’s much simpler. You can copy the service part for as many sensors as you have.

- alias: 'Xiaomi Aqara Motion Sensors duration fix'
  trigger:
    - platform: homeassistant
      event: start
  action:
    - service: deconz.configure
      data:
        entity: binary_sensor.motion_sensor_name
        field: "/config"
        data: {"duration": 5}
33 Likes

This. Just. Works. The knowledge of this forum never seizes to amaze me! You are the King, marcelod!

1 Like

there are any update to use the modding with the gateway xiaomi?

actually, i use the mod with the zigbee2mqtt

@Aiace88 do you use the decent.configure with zigbee2mqtt?

i use a old configuration of zigbee2mqtt but it’s work.

i request is possibile use the modding without the zigbee2mqtt, use only the gateway.

This is great, thank you so much! Thanks to the hardware hack and your solution I can do miracles now with the Aquara sensors :slight_smile:

1 Like

Thanks a million for this :smiley:

Works perfectly!!!

So much better than me trying to solder little bits & breaking things!

Wow, this is cool, but isn’t a one-time configure not enough? Is it not persistent?

I have not tested it yet, so it actually means that also the state in phoscon is changing every 5 sec? Or is it still there in motion detected state? So there is just another event coming in?

Because I saw a hack earlier, to just set the state to OFF on a binary sensor after 5 sec, but that didn’t work either

I changed over to it this morning, and can confirm that it works & is persistent.

I have been walking back & forth and it spots me every time.

It’s not simply resetting the state, the sensor ‘cools down’ after 5 seconds - and is ready to detect again.

(With deConz, Conbee 2, Hassio on a Pi 4)

1 Like

cool, so we can delete that automation after the first restart of HA, its not needed anymore, only if you want to go back to the 90 sec default setiing
so in other words, you see the “motion deteced” / “not detected” state in phoscon changing every 5 sec?
so also, the binary sensor in HA actually changing every 5 sec?

Yes in Phoscon, and Yes in binary sensor :slight_smile:

I’ve left the automation in, so it’s easy to change the duration.

Plus, if anyone is looking in the windows they probably think I’ve gone crazy walking back and forth the past few hours!

cool, gonna try out , thnx for feedback

And btw, there is no impact on battery with this duration change?

Too early to say I imagine, there should be some hit I guess.

ok, tested it out, indeed the “motion not detected” state is indeed trigger after 5 sec in phoscon
however, after the 5 sec , i dont see any new “motion detected” anymore
so i can dance for 60 seconds, before i see the new motion detected message
so set the duration for 60 seconds instead of 90 , is indeed better, i dont have the 30 sec ghost then
using conbee 1 here