Motion Sensor Automation Not Working

When I put condition in, I tested it passed the conditions but it won’t trigger my lights to turn on. However, if i remove the condition. It works.
Anyone has encountered this?

alias: Testing Motion
description: ""
trigger:
  - type: motion
    platform: device
    device_id: 98cd311bead3041f9bd87bf7e48adeda
    entity_id: 9e87a1199cd115b22b0e07d0daa3de0a
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 0
condition:
  - type: is_illuminance
    condition: device
    device_id: 98cd311bead3041f9bd87bf7e48adeda
    entity_id: 26ecab86c6a9b6c9e223112f38490bf1
    domain: sensor
    above: 1000
  - type: is_motion
    condition: device
    device_id: 98cd311bead3041f9bd87bf7e48adeda
    entity_id: 9e87a1199cd115b22b0e07d0daa3de0a
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 2
action:
  - type: turn_on
    device_id: 5da926cf7c7ae435e83634dc4213eaa1
    entity_id: 822459e9c6414bbb8411cab9bcc80d4d
    domain: light
    flash: short
mode: single

1 Like

So if im reading your automation correctly… when he trigger happens. (just after motion, remember the trigger happens instantly… ) it then checks the condition.

And you have said motion must be active for at least two seconds…

But the trigger was instant right after motion started.

See the problem?

Hi @NathanCu, may I ask how does the trigger timer works? Should I set it to 2 seconds same as the condition?

I would put the time in the trigger and remove the time from the condition.

but TBH, I’m not sure what benefit the condition gives you. :man_shrugging:

you’re already testing the condition is true by the trigger firing.

1 Like

Hi finity, I tried putting the time in the trigger but it triggered straightaway. What I trying to do is to make the sensor not so “sensitive” so only when i trigger it more than 2 seconds it will trigger it. Also i tried removing the is_motion condition and leaving the is_illuminance condition to test if the condition works, but it also did not work. The condition tested “Passed” but it still does not run the action.

Show the trace. Please

I don’t use “device” triggers (or any others) for good reasons so I honestly don’t know but do device triggers accept the “for:” option?

Maybe that’s where the issue lies.

1 Like

@NathanCu Will get the trace soon. Will get the time to test again.
@finity Hmm may need to check the API…

1 Like

@yuejun I don’t think the 2s is going to help here. Most of these sensors stay “on” when motion is detected for at least 30 seconds. In general the only way to adjust their sensitivity is by adjusting the device itself. Some of them have this capability and some don’t. If you wait for 2s like this it will just make it take 2s longer before you automation runs. :frowning:

-David

1 Like

Another idea to test is the automation without flash:short parameter under turn_on action.

Automation trace, as advised above, for sure is helpful to debug automations, but if you’re newbie it may be difficult to read and understand.

What I would advise you to do instead is to open the logbook (http://<your_ha_url>/logbook) and filter for motion sensor and light entities that you’re trying to automate (probably in 2 separate browser tabs). Logbook can help you understand how entities state changes over time.

2 Likes