Aqara motion sensor does not work all the time

Hi,
You don’t mention what type of motion sensor you are using, nor the technology used - but let’s guess at Zigbee and a PIR:
https://www.aqara.com/en/products.html?cat_id=Sensor

The automation.yaml code you post (hint: add code fences to add formatting) logic looks fine, apart from perhaps minutes: 1 being a very short period, and type: no_motion possibly not matching the actual sensor output (but you say the issue is intermittent - so unlikely to be that). The only other thing is mode: restart.

My suggestion is to use the HASS History log to understand what the motion sensor is really doing. Intermittent issues are more likely to be real-world physical sensor issues than code race conditions.

Have a read of a recent thread discussing issues with false-triggering of an IKEA Zigbee PIR motion sensor to see an example log history, and the fix:

As an example to compare, here is one of my Zigbee PIRs (N.B. this sensor reports on and off)

- id: '123456'
  alias: Bedroom 20mins OFF
  description: Bedroom 20mins OFF
  trigger:
  - platform: state
    entity_id: binary_sensor.pir_ewelink_1234_ias_zone
    to: 'off'
    for:
      minutes: 20
  condition: []
  action:
  - service: light.turn_off
    data: {}
    target:
      device_id: 1234123412341234

If this helps, :heart: this post!

1 Like