Xiaomi Human / Body / Motion Sensor - Timeout

Thank you everybody! Now my five xiaomi motion sensors are faster, a 50% faster actually. I don’t have a gateway, I use a CC2531 with zigbee2mqtt and before I used to have a response every 90 seconds:

Now it is every 60 seconds:

All I did was to change one line for every device, in this file
…hassio\share\zigbee2mqtt\devices.yaml

IMG-20201224-WA0046

It works so good, and if one day I need a better motion detection, like the ‘5 seconds refreshing rate’, I’ll change the hardware like some of you guys have done.

Thank you guys!

1 Like

This works great :slight_smile: Thanks.

Does this update deconz to set timeout to this duration everytime HA restarts?

Am I understanding it right?

so, what is the real solution ? Need hardware AND software change ? Or only sofware is ok ?
If i change the duration with service or automation, "off become “on” for 5 seconds and come back to “off”, but i need to wait 60s to have a new movement detection.

I’ve just got it working with ZHA, ZZH! stick from NodeRed.
So my sensor is modded and send motion every 5 seconds.

No need for additional software packages, custom python scripts, changing source code or whatever.

[{"id":"41a07519.2c219c","type":"ha-api","z":"758f5e2e.1884d","name":"HA set state Off","server":"e71e8d0c.3aedc","debugenabled":false,"protocol":"http","method":"post","path":"states/binary_sensor.nameofsensor","data":"{\"state\":\"off\"}","dataType":"jsonata","location":"payload","locationType":"msg","responseType":"json","x":360,"y":660,"wires":[[]]},{"id":"51b9334d.6018fc","type":"server-state-changed","z":"758f5e2e.1884d","name":"Motion detected?","server":"e71e8d0c.3aedc","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.nameofsensor","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":100,"y":540,"wires":[["41a07519.2c219c","4b879245.55f91c","3cb50b6.b5377f4"],[]]},{"id":"4b879245.55f91c","type":"api-call-service","z":"758f5e2e.1884d","name":"ZHA set attributes","server":"e71e8d0c.3aedc","version":1,"debugenabled":false,"service_domain":"zha","service":"set_zigbee_cluster_attribute","entityId":"","data":"{\"ieee\": \"00:15:CHANGEME\",\"endpoint_id\": \"1\",\"cluster_id\": \"1280\", \"cluster_type\": \"in\", \"attribute\": \"2\", \"value\": \"0\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":370,"y":600,"wires":[[]]},{"id":"3cb50b6.b5377f4","type":"api-call-service","z":"758f5e2e.1884d","name":"Test toggle light","server":"e71e8d0c.3aedc","version":1,"debugenabled":false,"service_domain":"light","service":"toggle","entityId":"","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":560,"y":540,"wires":[[]]},{"id":"e71e8d0c.3aedc","type":"server","name":"Home Assistant","addon":true}]
1 Like

I’m a little late to this party - but I have several Xiaomi Mi motion sensors running through Deconz.

Will adding the automation below help with the timeout on these, or do you have to perform the hardware surgery detailed further up this page?:

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

So as my soldering skills aren’t up to much (and I didn’t have a fine tip), I thought I’d try out this conductive paint.

Works well. My sensor now responds again within seconds!

See the photo of my work. I used a cocktail stick to effectively paint the from one contact to the other.

Really pleased at how simple this is

1 Like

Just to add to my previous post…

Out of 5 sensors that I modded, only 3 came out alive. It’s probably my work that’s at fault though, not the mod.

One pretty much died completely and wouldn’t reconnect to the network, and the other is seeing motion every few seconds when there isn’t any.

To anyone running this mod for quite a while now, how’s does it impact the battery life?
Depends on the amount of movement it reports, I guess… But how is it in real life, does it drain actually noticeably faster?

I’ve been using a modded sensor since December sometime and my battery level currently reads 86%.

1 Like

So I changed the clusters via node red. The issue I have is that when motion is triggered, it changes from detected to off in half a second. How am I able to keep it showing “on”/“detected” for the entire time until it resets at the 15sec?

I am 2021.3.3 and I am not able to find that folder path to change the occupancy value. I am running HA on Hass OS on a VM on my NAS. Zigbee devices are connecting using the sonoff bridge. I only see a zigbee DB. What version of HA are you running?

I’m using the last one (2021.3.4)
How are you trying to find the files?

I see them through Samba Share in my windows PC… Not sure the way you are trying, but for example with the File Editor addon i can’t see it.
Let me show you a picture

Got it, I will try it through the samba share and you know. Yes, I was looking for it through the file editor. Thank you.

I connected to the samba share and still dont see the devices.yaml file. Below is what I have:

also, it looks like device tracker needs to be enabled - Device Tracker - Home Assistant

Below is my configuration.yaml, let me know if I have the device_tracker set correctly:

Appreciate your help.

Hey all,
I am using HA installed on Raspbian, a cc3xxx zigbee transceiver, Zigbee2Mqtt, as well as NodeRed. I just did this mod and used NodeRed to send the state:off command back to the device. After the 5 seconds, I put my hand in front of it, I get another motion-detected reply, so that seems to be working just fine.

The thing I noticed though, is that when I send the state:off command, that doesn’t actually change the occupancy setting. Do I also have to manually set that as well? Most all of my automations use that parameter currently, but it seems to stay in it’s usual state for the unmodified duration, not reflecting it’s newly change state of off as I was hoping.

Any suggestions?

Hi all,

Tried tonight this hack but without success, my sensor trigger only all 3 minutes, this is so long.

Tested on and with :
HA running on raspberry, with Conbee key last firmware, Zigbee2mqtt and node red
Sensor hardware modification done.

First Test :

Tested with this automation : GitHub - wernerhp/appdaemon_aqara_motion_sensors: An AppDaemon app to reset Xiaomi Aqara motion sensors after a given timeout.

With this config :

aqara:
  module: aqara
  class: Aqara
  timeout: 5
  motion_sensors:
    - binary_sensor.zig_sensor_stair
    - binary_sensor.zig_sensor_stair_occupancy

Second test :

modification of : hassio\share\zigbee2mqtt\devices.yaml

Nothing is working, can someone give me a hint ?

Thanks !

EDIT : WORKING !

With this node red flow :

I have installed this HACS automation and it created this folder structure:
\config\appdaemon\apps\appdaemon_aqara_motion_sensors
Here I am a bit lost and have these questions:

  • should I copy aqara.py to config\python_scripts by myself?
  • should I create apps folder (cannot find it)?
  • should i create apps.yaml and put it in apps folder afterwards (cannot find apps.yaml)?
  • is there any configuration in config.yaml neccesary?

Anyone found a solution already? A video of it would be awesome!

I just wanted to share my experience with the aqara motion sensors.
I got 4 of them a while back and perfomed the mod by soldering a small cable.
I’m using Deconz to integrate them into HA.

at first i was having issues with the 5 seconds but then i found about the config, since i’m using pyscript ( custom-components/pyscript: Pyscript adds rich Python scripting to HASS (github.com)) for control below is my code to configure deconz

it will perform the config at startup, every full hour, and manual when needed (connecting an extra sensor)
No need to manually add a list because it will just search for all sensors in the motion class. (i only have aqara motion sensors so no extra filtering needed)

@time_trigger
@service
@time_trigger("cron(0 * * * *)")
def Configure():
    log.info("Entry")

    sensors = state.names("binary_sensor")
    filtered = []
    for sensor in sensors:
        sensor_attr=state.getattr(sensor)
        if "device_class" in sensor_attr and sensor_attr["device_class"]=="motion":
            filtered.append(sensor)

    for sensor in filtered:
        log.info("Configuring "+sensor)
        deconz.configure(entity=sensor, field="/config", data={"duration":5})

The mod was working perfectly but my sensors would loose connection at random intervals ( a couple of days).
After updating deconz to the latest version and also updating the conbee 2 to the latest firmware i’ve been running the sensors stable now with a detection rate of 5 seconds.

Just to complete my setup. the following code is to capture the deconz events in pyscript

@state_trigger(f"{Constants.ENTITY_MOTION_VOORDEUR} == 'on'")
def Motion_Event_Voordeur_Detected():
    log.info("Entry")
    pyscript.Voordeur_Motion_Detected()

@state_trigger(f"{Constants.ENTITY_MOTION_VOORDEUR} == 'off'", state_hold=120)
def Motion_Event_Voordeur_Cleared():
    log.info("Entry")
    pyscript.Voordeur_Motion_Cleared()

Hope it helps someone :slight_smile: but thanks for sharing the mod over here. because i really like how the sensors work now.

2 Likes

Hi

You found any solution for this issue ?

After its going off its not trigger again but on xiaomi app its looks ok