Automation help - zone duration

Hi, any help is appreciated.
I’ve got an automation which tracks how long I visit a certain zone, but how can I avoid triggering the automation when I enter the zone for 1 second? so when driving by for instance.

What I’ve got now:

alias: Zone
description: ""
trigger:
  - platform: zone
    entity_id: person.admin
    zone: zone.hrmfitness
    event: enter
    id: enter
  - platform: zone
    entity_id: person.admin
    zone: zone.hrmfitness
    event: leave
    id: leave
condition: []
action:
  - if:
      - condition: trigger
        id:
          - enter
    then:
      - service: input_datetime.set_datetime
        metadata: {}
        data:
          datetime: "{{ now() }}"
        target:
          entity_id: input_datetime.zone_start
  - if:
      - condition: trigger
        id:
          - leave
    then:
      - service: input_datetime.set_datetime
        metadata: {}
        data:
          datetime: "{{ now() }}"
        target:
          entity_id: input_datetime.zone_end
mode: single

this isn’t possible unfortunately

trigger:
  - platform: zone
    entity_id: person.admin
    zone: zone.hrmfitness
    event: enter
    id: enter
for:
  hours: 0
  minutes: 0
  seconds: 0

Your trigger is event based. To only trigger after a certain time you will need a state based trigger.
If you are the only person in your smart home the easiest way is to check the state of the zone and if the state goes from 0 to 1 the trigger fires.
If you have multiple persons it might get a bit more difficult. A suggestion would be to make a template binary sensor that checks if your person is listed in the persons attribute of the zone. Then you use this sensor as trigger.

1 Like