Automations with a motion timed trigger not working

Hello,

I have an issue that driving me crazy. I have automations that are configured to do something if a trigger happened a few mins ago, but some are working and some are not working. For example, the following automation is configured to send a message if a motion sensor stops detecting motion for 5 mins.

  alias: motion test 5
  description: ''
  trigger:
  - type: no_motion
    platform: device
    device_id: 433da9b76c1c5ea6a49e314488bbc69d
    entity_id: binary_sensor.motion_test
    domain: binary_sensor
    for:
      hours: 0
      minutes: 5
      seconds: 0
  condition: []
  action:
  - service: notify.aldur80_bot
    data:
      message: '10'
  mode: single

After 5 mins, or more, of the motion sensor reporting that there is no motion, the automation isn’t triggered. Checking the automation section shows that it didn’t trigger. If I change the time from 5 mins to 3 mins, then it works just fine. I have replicated this issue with multiple different automations.

I’m running core-2021.12.2, supervisor-2021.12.2.

Of note is that I have a fairly large HA deployment, probably around 200 zigbee devices split up between two conbee II devices. Plus other devices such as my unifi protect cameras (around 10) and alexa echos (around 12). Everything works great except the timed automations issues I’ve described here. I also have around 40 automations configured.

Try it with a state trigger:

  trigger:
  - platform: state
    to: 'off'
    entity_id: binary_sensor.motion_test
    for:
      minutes: 5

If that works then there is something wrong with the device trigger and you should report it here:

I’d also advice you to avoid device automations as much as possible and use state / numeric state triggers and conditions and use service calls instead of device actions.

It is a lot easier to change a new entity id to match an old one if you replace a device. It can be done in one location, Configuration / Entities. Changing device ids is more complicated and must be done everywhere you have used it.

You’ve got a typo in your copy/paste:

trigger:
  - platform: state
    to: 'off'
    entity_id: binary_sensor.motion_test
    for:
      minutes: 5
1 Like

You should be aware (I was not until the last few weeks). That if you are editing other automations while you are waiting, that every time you edit and save ANY automation, Home Assistant reloads ALL automations, not just the one that has changed - and ALL automations are reset, in this case your automation will only trigger AFTER a reload, when the sensor has started detected motion again and then gone back no motion for 5 minutes.

Fixed. Thanks.

1 Like

So I did this, and it worked, but only for motion sensors that are directly connected with the coordinator. The other motion sensors, that are exhibiting the automation problem, are connected through IKEA Tradfri plugs. Could this possible be the problem?

All the Tradfri plugs are connected to the coordinator without a problem, and I can control them without a problem. Also, the motion states are being reported accurately in HA, but HA just doesn’t act upon them.

wow, that’s a huge change that I missed. Thanks for pointing that out. Unfortunately, that doesn’t appear to be my problem.

That’s not a recent change. It’s been like that forever.

I was able to find a workaround for this problem and I thought I’d update this thread if anyone else runs into the same problem.

I ended up putting each motion sensor into it’s own group.

After doing that, I reference the group as a trigger in the automation and I’m able to give it a timer of 5, 10, 15, 20, 30, or more minutes. The automation fires every time.