Aqara Motion Sensor Hack for 5 sec

[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.

6 Likes