Automation where the trigger was activated 30 seconds after

Yes. If a condition “fails,” the automation just stops dead. You should add a not condition for both device tracker a and device tracker b (assuming you want the automation only to fire if no one is in zona_alarme). If you want it to fire when both of you are in zona_alarme, and just one leaves, you would use a “not” condition with an “or” condition.

Edit: I don’t think the script does anything for you. Scripts are just the action portion of an automation. I typically use them if I want to use the same sequence with multiple automations, or want a button to fire the automation manually as I see fit.

i want the action to activate when the two are out for 30 seconds (zone.zona_alarme). if the time does not reach 30 seconds, the action is not activated.

this is automation:


alias: Alarme auto-on
description: ''
trigger:
  - platform: zone
    entity_id: device_tracker.iphone1
    zone: zone.zona_alarme
    event: leave
  - platform: zone
    entity_id: device_tracker.iphone2
    zone: zone.zona_alarme
    event: leave
condition:
  - condition: state
    entity_id: device_tracker.iphone1
    state: not_home
  - condition: state
    entity_id: device_tracker.iphone2
    state: not_home
action:
  - service: switch.turn_on
    target:
      entity_id: switch.alarme_418
mode: single

can you paste what your complete example looks like for me to try it out, please?

alias: Alarme auto-on
description: ''
trigger:
  - platform: zone
    entity_id: device_tracker.iphone_11_tr
    zone: zone.zona_alarme
    event: leave
  - platform: zone
    entity_id: device_tracker.iphone_ana
    zone: zone.zona_alarme
    event: leave
condition:
  - condition: state
    entity_id: device_tracker.iphone_11_tr
    state: not_home
  - condition: state
    entity_id: device_tracker.iphone_ana
    state: not_home
action:
  - delay:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
  - condition: not
    conditions:
      - condition: or
        conditions:
          - condition: zone
            entity_id: device_tracker.a
            zone: zone.zona_alarme
          - condition: zone
            entity_id: device_tracker.b
            zone: zone.zona_alarme
  - service: switch.turn_on
    target:
      entity_id: switch.alarme_418
mode: single

This will “cancel out” if either one of you is still in zona_alarme.

EDIT: You have to change out the dummy device trackers a and b for the real ones in my example of course.

When either of the two are out or when both are out (for 30 seconds)?

1 Like

when both are out for 30 seconds

thank you… I’ll try it soon

it works perfectly!
I’m going to study this automation…. i’m more used to the reactor plugin from my vera home.… that I like a lot.
thank you all!

1 Like

Finally! That one was way harder than I expected. :joy:
I’m glad that it worked out. Some automations with much more complex logic than that are easier to figure out.