Frigate, automation using mqtt to alert when a person's in a zone

I’m struggling to get my head around using Frigate/MQTT in HA automations.

I’ve got Frigate running, and notifications being sent to my mobile using the common blueprint.
I’d like to have HA push the video stream form my cameras to kodi on my TV too.

I’ve got it working except on thing. For one of my cameras I have a zone named Front_grass. I’d like to only have the stream pushed to kodi when a person enters this zone. At the moment I’ve got it working but whenever a person is detected anywhere.
How can I make use of the zone in either a condition or (preferably) IF action?
(In an IF would be best, cos I’ve got other cameras without zones in the same automation, that I’ve removed for clarity)

My current automation:

alias: Camera to kodi test
description: ""
triggers:
  - trigger: mqtt
    topic: frigate/reviews
    payload: new
    value_template: "{{value_json['type']}}"
conditions:
  - condition: state
    entity_id: input_boolean.tv_power
    state: "on"
  - condition: template
    value_template: "{{ trigger.payload_json['after']['severity'] == 'alert' }}"
actions:
  - action: media_player.media_pause
    metadata: {}
    data: {}
    target:
      entity_id: media_player.kodi
  - alias: Front
    if:
      - condition: template
        value_template: "{{ trigger.payload_json['after']['camera'] == 'Front' }}"
        enabled: true
    then:
      - action: media_player.play_media
        metadata: {}
        data:
          media:
            media_content_id: media-source://camera/camera.espcamfront_front
            media_content_type: image/jpeg
            metadata:
              title: CamFront Front
              thumbnail: /api/camera_proxy/camera.espcamfront_front
              media_class: video
              children_media_class: null
              navigateIds:
                - {}
                - media_content_type: app
                  media_content_id: media-source://camera
              browse_entity_id: media_player.kodi
        target:
          entity_id: media_player.kodi
      - data:
          media:
            media_content_id: http://192.168.5.11:1984/api/frame.jpeg?src=Front
            media_content_type: video
            metadata: {}
        entity_id: media_player.kodi
        action: media_player.play_media
        enabled: false
      - action: script.normal_notification
        metadata: {}
        data:
          icon: mdi:cctv
          title: Front Camera>Kodi
          message: Front Camera>Kodi
    enabled: true
mode: single

I’ve done a lot of guessing and brute-forcing it so far, maybe there’s just a better approach entirely?

Thanks a lot

Interesting! I am sitting with the same challenge for the trigger. Did you find a way to trigger in a specific zone?

There are probably better ways, but this ended up working OK for me:

alias: Camera to Kodi livingroom
description: ""
triggers:
  - trigger: mqtt
    topic: frigate/events
conditions:
  - condition: state
    entity_id: input_boolean.tv_power
    state: "on"
  - condition: template
    value_template: "{{ trigger.payload_json['after']['label'] == 'person' }}"
  - condition: template
    value_template: "{{ trigger.payload_json['before']['end_time'] == 'null' }}"
    enabled: false
  - condition: state
    entity_id: media_player.kodi_livingroom
    state: playing
    enabled: false
actions:
  - if:
      - condition: template
        value_template: "{{ trigger.payload_json['after']['camera'] == 'Garden' }}"
    then:
      - action: media_player.media_pause
        metadata: {}
        data: {}
        target:
          entity_id: media_player.kodi_livingroom
      - action: media_player.play_media
        metadata: {}
        data:
          media:
            media_content_id: media-source://camera/camera.espcamgarden_garden
            media_content_type: image/jpeg
            metadata:
              title: CamGarden Garden
              thumbnail: /api/camera_proxy/camera.espcamgarden_garden
              media_class: video
              children_media_class: null
              navigateIds:
                - {}
                - media_content_type: app
                  media_content_id: media-source://camera
              browse_entity_id: media_player.kodi_livingroom
        target:
          entity_id: media_player.kodi_livingroom
    alias: Garden
  - alias: Front
    if:
      - condition: template
        value_template: "{{ trigger.payload_json['after']['camera'] == 'Front' }}"
      - condition: template
        value_template: "{{ 'Front_grass' in trigger.payload_json['after']['entered_zones'] }}"
    then:
      - action: media_player.media_pause
        metadata: {}
        data: {}
        target:
          entity_id: media_player.kodi_livingroom
      - action: media_player.play_media
        metadata: {}
        data:
          media:
            media_content_id: media-source://camera/camera.espcamfront_front
            media_content_type: image/jpeg
            metadata:
              title: CamFront Front
              thumbnail: /api/camera_proxy/camera.espcamfront_front
              media_class: video
              children_media_class: null
              navigateIds:
                - {}
                - media_content_type: app
                  media_content_id: media-source://camera
              browse_entity_id: media_player.kodi_livingroom
        target:
          entity_id: media_player.kodi_livingroom
      - data:
          media:
            media_content_id: http://192.168.5.11:1984/api/frame.jpeg?src=Front
            media_content_type: video
            metadata: {}
        entity_id: media_player.kodi_livingroom
        action: media_player.play_media
        enabled: false
  - alias: Spare
    if:
      - condition: template
        value_template: "{{ trigger.payload_json['after']['camera'] == 'Spare' }}"
    then:
      - action: media_player.media_pause
        metadata: {}
        data: {}
        target:
          entity_id: media_player.kodi_livingroom
        enabled: false
      - action: media_player.play_media
        metadata: {}
        data:
          media:
            media_content_id: media-source://camera/camera.espcamspare_spare
            media_content_type: image/jpeg
            metadata:
              title: CamSpare Spare
              thumbnail: /api/camera_proxy/camera.espcamspare_spare
              media_class: video
              children_media_class: null
              navigateIds:
                - {}
                - media_content_type: app
                  media_content_id: media-source://camera
              browse_entity_id: media_player.kodi_livingroom
        target:
          entity_id: media_player.kodi_livingroom
        enabled: false
  - alias: Test
    if:
      - condition: template
        value_template: "{{ trigger.payload_json['after']['camera'] == 'Test' }}"
    then:
      - action: media_player.media_pause
        metadata: {}
        data: {}
        target:
          entity_id: media_player.kodi_livingroom
      - action: media_player.play_media
        metadata: {}
        data:
          media:
            media_content_id: media-source://camera/camera.test
            media_content_type: image/jpeg
            metadata:
              title: Test
              thumbnail: /api/camera_proxy/camera.test
              media_class: video
              children_media_class: null
              navigateIds:
                - {}
                - media_content_type: app
                  media_content_id: media-source://camera
              browse_entity_id: media_player.kodi_livingroom
        target:
          entity_id: media_player.kodi_livingroom
mode: single

The Front camera has a zone named Front_grass, which are checked for using

    if:
      - condition: template
        value_template: "{{ trigger.payload_json['after']['camera'] == 'Front' }}"
      - condition: template
        value_template: "{{ 'Front_grass' in trigger.payload_json['after']['entered_zones'] }}"
    then:

It doesn’t feel like a great way to do it but it’s the best I could get working.