Notification when some enters zone and is there for 2 min

How can i have an automation that only flags once someone is in a zone for 2 minutes?

I think you were on the right track with the yaml you deleted. Which bit didn’t work?

For the time condition, it might be easier to use a schedule helper, which would simply be on or off.

Here is the code I was trying, never seems to trigger, so I’m doing something wrong.

alias: Andy leaves Shop
description: ""
trigger:
  - platform: state
    entity_id:
      - person.andy
    for:
      hours: 0
      minutes: 0
      seconds: 0
    from: zone.aldi
condition:
  - condition: state
    entity_id: person.andy
    state: zone:shop
    for:
      hours: 0
      minutes: 3
      seconds: 0
action:
  - service: notify.notify
    data:
      message: Andy has left shop
  - if:
      - condition: time
        after: "08:00:00"
        before: "21:00:00"
        weekday:
          - sun
          - mon
          - tue
          - wed
          - fri
          - thu
          - sat
    then:
      - service: notify.alexa_media
        data:
          data:
            type: announce
          target:
            - media_player.downstairs
          message: Andy has left  the shops
      - service: notify.alexa_media
        data:
          data:
            type: announce
          target:
            - media_player.office
            - media_player.bedroom
          message: Andy has left the shops
mode: single

You need to use the state of the person which should be the zone name, check the state in developer tools, most likely Aldi & Shop

perhaps try something like this… i notice that you use zone. and also zone: make sure you have the exact right name of the zone.

note that i only paid attention to the trigger since that’s what you’re asking about.
i nuked your condition. i’m not sure why you chose what you did for the trigger vs what you chose for the condition. as written it will only trigger if you move from zone.aldi to zone:shop. is that what you want? i’ve made it closer to your original post where it triggers when someone is in the zone (no matter where they came from) for 3 minutes (you said 2 but your code says 3, so i kept 3).

alias: Andy leaves Shop
description: ""
trigger:
  - platform: state
    entity_id:
      - person.andy
    for:
      hours: 0
      minutes: 3
      seconds: 0
    to: zone:shop
condition: []
action:
  - service: notify.notify
    data:
      message: Andy has left shop
  - if:
      - condition: time
        after: "08:00:00"
        before: "21:00:00"
        weekday:
          - sun
          - mon
          - tue
          - wed
          - fri
          - thu
          - sat
    then:
      - service: notify.alexa_media
        data:
          data:
            type: announce
          target:
            - media_player.downstairs
          message: Andy has left  the shops
      - service: notify.alexa_media
        data:
          data:
            type: announce
          target:
            - media_player.office
            - media_player.bedroom
          message: Andy has left the shops
mode: single

by the way, your code and your request seems to ask to trigger when someone is in zone:shop for 3 (or 2) minutes. but your notify message says it’s notifying when “andy has left shop” …

so do you want to notify on leaving? or entering? or 2? or 3?

Thanks for the help. In my ongoing search, I actually found a Blueprint that does what I need. It contains the option to delay the notification by x minutes on arrive/depart and even add conditions to the notifications.

I’ve implemented this, now and it’s working. I then added addtional code so my Alexa speaks the notifications too.

Here’s the custom code for the Alexa notifications (in case anyone else wants to add it in)

    custom_action_leaving:
      - service: notify.alexa_media
        data:
          data:
            type: announce
          target:
            - media_player.office
          message: "{{ person }} has left {{ zone }}."