How to turn exterior ON and OFF with camera detection?

I have the following Turn-ON and Turn-OFF automations to turn lights ON when camera via Frigate or directly from Reolink camera to HaOS. It seems to sort of work in the backyard but in the front where cameras pass by the street, the light remains ON very long or all night maybe. How to fix this so it only turns ON if a boundry is crossed for example and does not turn ON for cars on the road?

Turn-ON automation:

> alias: Automated - Front - Turn exterior potlights & camera floodlight - ON
> description: ""
> triggers:
>   - trigger: state
>     entity_id:
>       - binary_sensor.front_right_zone_all_occupancy
> conditions:
>   - condition: sun
>     before: sunrise
>     after: sunset
> actions:
>   - type: turn_on
>     device_id: 4c50666e8baec8ecaa4aa3bd5bdb65d3
>     entity_id: ac6b4a6d273e0b968e70383260d5d058
>     domain: switch
>   - type: turn_on
>     device_id: ba32460af96e515df10585a2ee70b1fe
>     entity_id: 8b99db6aaa6e12ba90069c9c851c531d
>     domain: light
> mode: single

Turn-OFF automation:

> alias: Automated - Front - Turn exterior potlights & camera floodlight - OFF
> description: ""
> triggers:
>   - trigger: state
>     entity_id:
>       - binary_sensor.front_right_zone_all_occupancy
> conditions: []
> actions:
>   - action: automation.turn_off
>     metadata: {}
>     data:
>       stop_actions: true
>     target:
>       entity_id: automation.automated_turn_exterior_potlights_camera_floodlight_on
>   - delay:
>       hours: 0
>       minutes: 0
>       seconds: 10
>       milliseconds: 0
>   - device_id: 4c50666e8baec8ecaa4aa3bd5bdb65d3
>     domain: select
>     entity_id: 30751c72d897de8460056b390a357a70
>     type: select_first
>   - type: turn_off
>     device_id: ba32460af96e515df10585a2ee70b1fe
>     entity_id: 8b99db6aaa6e12ba90069c9c851c531d
>     domain: light
>   - delay:
>       hours: 0
>       minutes: 0
>       seconds: 25
>       milliseconds: 0
>   - action: automation.turn_on
>     metadata: {}
>     data: {}
>     target:
>       entity_id: automation.automated_turn_exterior_potlights_camera_floodlight_on
> mode: single

Please format your yaml correctly using the </> button, it can then be read easily.

But it sounds like you need to set up zones in frigate so the cars driving by do not trigger in certain zones.

this is my code which does the same and the cars do not trigger it.

alias: Outside lights
description: ""
mode: single
triggers:
  - entity_id:
      - binary_sensor.drive_drive_person_occupancy
    to: "on"
    trigger: state
  - entity_id:
      - binary_sensor.boot_drive_person_occupancy
    to: "on"
    trigger: state
  - entity_id:
      - binary_sensor.d_gardencam_person_occupancy
    to: "on"
    trigger: state
  - entity_id:
      - binary_sensor.front_door_contact
    to: "on"
    from: "off"
    enabled: true
    trigger: state
conditions:
  - condition: state
    entity_id: sun.sun
    state: below_horizon
actions:
  - metadata: {}
    data: {}
    target:
      entity_id: light.outside_lights
    action: light.turn_on
  - delay:
      hours: 0
      minutes: 5
      seconds: 0
      milliseconds: 0
  - metadata: {}
    data: {}
    target:
      entity_id: light.outside_lights
    action: light.turn_off

Thanks. Can I see your sample code for Frigate? The Frigate support tells me I can not record for one area of the picture for movement and not for the other area. I have Zone and Mask setup. I want all inside Zone to record and all inside Mask to not record. And by doing so I want HaOS to receive mqtt alerts from Frigate for Zone movements only to turn ON lights an not MASK area movements. It seems to be impossible doing this in Frigate they tell me. Very odd.

That is exactly what zones are there for.

Read the docs and it will give you all you need.

And use the intergration to get the alerts not mqtt as it’s far easier.

Yeah, I have read those. Somehow they are not using a Zone like a zone and a Mask like a mask…still working with them to figure out.

What do you mean by integration?

Have you read all the docs?

You use zones to restrict what frigate detects, if you don’t want to detect people in a zone you use something like this (taken from the docs i linked earlier.

    snapshots:
      enabled: true
      timestamp: false
      bounding_box: false
      crop: false
      #height: 175
      required_zones:
        - boot_drive
        - boot_road