Xiaomi aqara motion sensor, how to trigger automation?

Hello, I have a motion sensor that I would like to use for turning on two lights when it detects motion.
This is the device, as you can see it is working and have just been detecting motion recently:
image
I have tried to use it as trigger like this:
image
But without luck, it doesn’t seem to trigger even though it reports that it detected motion.

Any ideas how I can make it trigger?

Link to device: https://www.aqara.com/us/motion_sensor.html
Integration: through smartthings

Can you share the whole automation? Go to the 3 dots in the top right of the screen, click on ‘Edit with YAML’ and copy in and paste in. Remember to highlight the code and click on the ‘</>’ button to preserve the indentations.

Sure :slight_smile:

alias: Full brightness on garden light when motion detected
description: ''
trigger:
  - type: motion
    platform: device
    device_id: f1c50514f8a9624fbcb4a23029f71xxx
    entity_id: binary_sensor.xiaomi_aqara_motion_sensor_motion_2
    domain: binary_sensor
condition:
  - condition: sun
    before: sunrise
    after: sunset
action:
  - domain: light
    entity_id: light.rgb_front_wall_outdoor
    device_id: 0aced2a7171711eb822387a6dbdaexxx
    type: turn_on
    brightness_pct: 100
  - domain: light
    entity_id: light.rgb_front_stand_outdoor
    device_id: 0acfb0b6221711eba9da5f969f755xxx
    type: turn_on
    brightness_pct: 100

Things to check:

  1. Is the automation turned on?
  2. Are there any errors in the logs?
  3. Check when the automation was last triggered (it will be in the attributes)
  4. Remove the sun condition and see if it triggers then

Yea I already tried make a new one even more simple with no sun and just 1 light. But it doesn’t trigger, I can confirm that the light however does turn on when I press the “execute” button. If I change the device to my door contact sensor and opens the door, the light also turns on. So I’m left to think its a problem with the motion sensor, but since I can see in the HA entity history that it does in fact report motion, I’m thinking that my trigger configuration must be wrong for this type of device. I tried experimenting with state change, but that also did not work, maybe because I am doing it wrong.

This is what I tries:

alias: New Automation
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.xiaomi_aqara_motion_sensor_motion_2
    from: 'off'
    to: 'on'
condition: []
action:
  - scene: scene.all_lights_on
mode: single

But this also didn’t trigger when the sensor detects motion

That is strange. If the automation executes correctly when manually triggered then it must be the trigger. The config looks correct.

The entity is definitely correct? You checked in the Developer Tools > States?

1 Like

Your condition is wrong, it’s never before sunrise and after sunset. Check the docs, it’s explicitly mentioned that you need two conditions for this.

You need to change to this (example straight from the docs):

condition:
  condition: or
  conditions:
    - condition: sun
      after: sunset
    - condition: sun
      before: sunrise
1 Like

Double check the entity_id. Also confirm under Developer Tool -> States, that this entity_id shows ‘on’ ehen motion is detected.

Thanks, the Dev tool was a good idea.
I reloaded the integration and renamed the device, I that created the same automation from scratch and this time it is working :slight_smile:

Still confuses my why I could see history of motion detection when looking at the device before, and it even said “motion detected 2 seconds ago” when it still wouldn’t trigger the automation.

Glad you got it working :slightly_smiling_face:

1 Like