Motion group automatisation problem

Hello,

I’m trying to arm in away mode my house when there is no motion for 30 mins.

I create a motion group and an automatisation. If I use the field ‘for’ to add a 30 mins delay in the trigger, the automatisations will never run. If I’m not using the field for, the automatisation will kick in right away when there is no motion. I’m missing something?

alias: Security - Auto Arm
description: ''
trigger:
  - platform: state
    entity_id: group.motion
    to: 'off'
    for:
      hours: 00
      minutes: 30
      seconds: 00
condition:
  - condition: not
    conditions:
      - condition: zone
        entity_id: person.xxx
        zone: zone.home
  - condition: time
    before: '16:00:00'
    after: '08:00:00'
  - condition: device
    device_id: 365270f2ff76a2f21ac90d72dd7b5e7e
    domain: alarm_control_panel
    entity_id: alarm_control_panel.aqara_hub_m1s_597b
    type: is_disarmed
action:
  - device_id: 365270f2ff76a2f21ac90d72dd7b5e7e
    domain: alarm_control_panel
    entity_id: alarm_control_panel.aqara_hub_m1s_597b
    type: arm_away
  - service: notify.mobile_app_pixel_6
    data:
      title: Home Srcurity
      message: Alarm system arm in away mode (30 mins no motion)
mode: single

type or paste code here


It’s not a simple delay. It requires group.motion to remain off for at least 30 minutes in order to trigger. In other words, it doesn’t merely wait 30 minutes, like a delay would do, it requires the state value to remain unchanged for 30 minutes. Any motion detected during the 30-minute countdown will reset the countdown.

Your automation is designed to trigger when:

  • no motion is detected for 30 minutes

and the following conditions are met:

  • person.xxx is not home
  • current time is between the hours of 08:00 and 16:00
  • alarm panel is disarmed

Check the automation’s trace which should be created whenever the State Trigger occurs. Also check the history of group.motion and confirm its state remains off for at least 30 minutes.

Yes I’m sorry for my bad explication :slight_smile:

I can confirm that there is no motion for the last 30 mins, even the group is off for the last 32 mins.

There is no automatisation trace that is what I found strange!

If I remove the 30 mins and set the motion group to on/off, the automatisation will kick in. But not with the ‘for 30 mins to the off state’

If it works without the for but not with it then it really sounds like group.motion is never able to maintain a state of off for 30 minutes. As an experiment, set for to a shorter time period. Also, how are you testing this automation?

I assume you are aware that whenever you restart Home Assistant, execute Reload Automations, or save a new/modified automation in the Automation Editor, all automations are reloaded and any that use for are canceled and restarted (i.e. the 30-minute countdown is canceled and reset).

I try for 10 seconds and 5 mins and their both work. But not for 30 mins…

I test the automatisation with the developer tools to change the state of the group.

For sure I know that is no motion: image|403x186

And Yes I know. I didn’t touch the automatisation between the time!

I’m using the same king of automatisation with other device (state on for y mins) and it’s working very well.

Don’t know why it’s not working with the motion group.

Last time automatisation start, it’s when the off for was at 10 seconds:

image

The results of your experiments continue to show that the entity’s state is capable of remaining off for up to 5 minutes, just not for 30 minutes. It confirms the State Trigger can work correctly but that the entity’s state fails to remain unchanged for as long as 30 minutes. I realize you say it does remain off for that long but the trigger’s behavior disagrees.

Try progressively longer time periods (10, 15, 20, 25), maybe it will reveal the actual limit isn’t 30 but something else. That value might serve as a clue to what’s going on.

As an alternative, if you know how to compose SQL queries, you can use the SQLite Web Add-on to examine the entity’s detailed history in the database. If there’s even a sub-second change from off to on to off it will be visible in the database.