Aqara Motion Sensor Hack for 5 sec

I think I found the solution to the ghost switches and posted here: https://github.com/zigpy/zha-device-handlers/issues/523#issuecomment-744746599

Basically the solution is to reset the state in ZHA, not in HA. This is the yaml to change the state (replace IEEE with the sensor address):

service: zha.set_zigbee_cluster_attribute
data:
  ieee: '00:15:8d...'
  endpoint_id: 1
  cluster_id: 1280
  cluster_type: in
  attribute: 2
  value: 0
3 Likes

Just used this code in my sensor reset routine in node red and it works flawlessly (at least for the last 30 minutes I’ve been testing it). No more ghost triggers even using a 5s reset delay! Thanks!!!

nice that was the number 1 reason i choose deconz over ZHA
but now fixed. going to test this in the future

Is there anyway to do this without the hardware hack? Just not confident in solder such a small board :frowning: I use Deconz and Conbee

The hardware hack is needed. You can use a 4B pencil, but soldering is more reliable.

Also a feedback from my side:

I did the hardware mod and use ZHA (with a zigbee dongle).
I also use Node Red and this simple json post with state off did the the job.
No appdaemon needed, no flickling of code.
Thanks for sharing!

And when I understand it correct the “ghost false positive” are also now fixed:

TL;DR new sensors seem to have a 1 min reset period but still requires HA+ZHA state resets.

I’m unsure if Aqara has new hardware or firmware but 4 new sensors I recently received from Aliexpress seem to have a 1 min reset, as opposed to 2 min or 5 min reported earlier.

I applied both the service: python_script.set_state and service: zha.set_zigbee_cluster_attribute in automations as described in the thread above to reset the sensor state in HA and in ZHA after 5s.

All sensors are clearing in HA in 5s, as expected, but surprisingly the sensors are able to retrigger in just 1 min without the hardware hack. I’ve confirmed these are not false-triggers due to hardware still being in the “on” state by using a box to control true/false triggers.

At least for my use cases, 1 min is an acceptable reset period and I’m happy to not have to attempt hardware hacks.

1 Like

[New revision without requiring python_script.set_state installed and used]

For newcomers, summing up what has been just discussed here, this is the solution I’m using.

Tested on Home Assistant Core 2021.1.0 and ZHA integration

Requirements:

  • Aqara motion sensor hardware hack

  • an automation to turn on the light (can use a switch or light HA entity):

alias: Turn on light if Aqara motion sensor is activated
description: ''
trigger:
  - entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_ias_zone
    platform: state
    from: 'off'
    to: 'on'
condition: []
action:
  - service: switch.turn_on # (or light.turn_on)
    data: {}
    entity_id: switch.xxxxxxxxxxx # (or light.xxxxxxxxx)
mode: single
initial_state: true
  • an automation to turn off the light (can use a switch or light HA entity), but with checking after some seconds if the motion sensor is still clear, otherwise the light might be turned off even if somebody is still moving inside the room:
alias: Turn off light if Aqara motion sensor is clear
description: ''
trigger:
  - entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_ias_zone
    platform: state
    from: 'on'
    to: 'off'
    for: '00:00:20'
condition:
  - condition: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_ias_zone
    state: 'off'
action:
  - service: switch.turn_off # (or light.turn_off)
    data: {}
    entity_id: switch.xxxxxxxxxxxx # (or light.xxxxxxxxx)
initial_state: true
mode: single
  • finally, an automation to reset the Aqara ZHA zigbee cluster:
alias: Aqara motion sensor - reset ZHA cluster
description: ''
trigger:
  - entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_ias_zone
    platform: state
    from: 'off'
    to: 'on'
condition:
  - condition: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_ias_zone
    state: 'on'
action:
  - service: zha.set_zigbee_cluster_attribute
    data:
      ieee: '00:15:8d:00:xxxxxxxx'  # your Aqara IEEE
      endpoint_id: 1
      cluster_id: 1280
      cluster_type: in
      attribute: 2
      value: 0
mode: single

Delays are important to avoid ghost switching but can be adjusted or added to better suite your needs.
In this solution the light is turned off after 20 seconds the motion sensor is off.

5 Likes

Excellent wrap up!
ANy idea how to automate occupancy sensor in order to reset toghether with motion sensor?
Or even illuminance…

Actually, to update myself: illuminance works fine, every time motion is updated (5sec), illuminance is updated too.
But reset time for occupancy is still an challenge…

I found that the Aqara motion sensor for the cluster
MotionCluster (Endpoint id: 1, Id: 0x0500, Type: in)
has this cluster command:
init_test_mode (id: 0x0002)
which hopefully might be used to continuously reactivate the 5-second reset working mode that is normally temporarily activated after pairing, so without requiring the hardware hack.

I tried but this command fails as it requires 2 parameters that unfortunately are unknown to me.

Hi,

How do you open up the sensor so you can access the PCB? I have removed the battery, and don’t want to break the casing or interior by forcing it open.

Has anybody that have tried the pencil mod, any reliability issues? I’m considering if I should go with soldering (very inexperienced in soldering) or just use a pencil.
Thanks,
Br,
Tim

You can use a flat spudger between the casing and the piece that holds the battery. The latter is clipped into the casing, by gently making some room between the two and lifting the battery piece you should be able to get it out without much damage (the one shown in the photos below is damaged, the casing broke at its weakest point, below the sensor window; but that’s nothing a drop of super glue can’t fix).

I’m using the pencil hack on all my sensors (about 8 of them), and it has worked reliably for 18+ months.

1 Like

Hi,

Much thanks for the images.
I got this working together with @andrus example.

Having some issues with the sensor not being sensitive enough when sitting down (and moving laterally) might need to tweak some parameters to take into account the amount of time I sit still.

Thanks!
Br,
Tim

Hey it’s still working for you? I have also a aqara sensor and ZHA… but i don’t where to start to change the hardware to let it work every 5 seconds…

See:

1 Like

Has anyone experienced the motion sensor turning on (detecting motion) randomly after applying this hack? My sensor in the mud room keeps going on without anyone around.

To avoid ghost switching you should use an automation to turn off the light not before 20 seconds have passed from the initial sensor activation, like this:

alias: Turn off light if Aqara motion sensor is clear
description: ''
trigger:
  - entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_ias_zone
    platform: state
    from: 'on'
    to: 'off'
    for: '00:00:20'  # avoid ghost switching on
condition:
  - condition: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_ias_zone
    state: 'off'
action:
  - service: switch.turn_off # (or light.turn_off)
    data: {}
    entity_id: switch.xxxxxxxxxxxx # (or light.xxxxxxxxx)
initial_state: true
mode: single
1 Like

Not me. The only places I occasionally get random triggers are my garage (which isn’t very windtight) and outside (where sometimes the sensor gets a hit of sunlight on one part of the lens causing it to trigger).

Thanks. I’ll give this a shot.

I purchased mine at the end of Dec 2020, and they reset after 1 min 30 sec.