Logic and design question on automation

So i want to display frigate birdseye (shows overview of cameras) on my dining room tv at 20:00. I do that with webrtc and RTSP. I want it to be interrupted every time frigate sees a person occupancy somewhere, and then RTSP that camera instead for 2 minutes or so, and then go back to the previous RTSP stream.

So ideally i get a loop maybe? that does this:

while no sensor.porch.person.occupancy
or no sensor.driveway.person.occupancy
etc
display frigate on tv

display sensor.porch for 1min < person detected
after that i want frigate birdseye to show again

I also thought about having 1 automation that displays frigate birdseye, and separate automations that display once they detect a person. That seems simple but that means i need to somehow use a trigger that runs it.

I can’t just use a regular timer, because that will only go once. I can do every 10 minutes or so, bit crude but would work i suppose, and rerun if the chromecast is turned off maybe, but because it’s a trigger i can only check if it changes state, not what it is (as with a condition).

Any tips/code on how to approach this would be very much welcomed!

regards,

but because it’s a trigger i can only check if it changes state, not what it is (as with a condition).

That is not true, all automations have trigger. variable which contains the state of the trigger and the exact values as well as attributes attributed with that trigger.

Pseudo-code…

automation 1:

trigger: 
  - 20:00
  - person detection for 2 minutes if the sensor stays on that long (if not see alternate option below)
action:
  - play birdseye on tv

automation 2:

trigger:
  - person detection
action:
  - play that camera on tv

alternate automation 1:

trigger: 
  - 19:58
  - person detection for 2 minutes if the sensor stays on that long (if not see alternate option below)
action:
  - delay 2 minutes
  - play birdseye on tv

Thanks both. I think i have it almost figured out, easier then i presumed, but i haven’t tested it yet. I guess i might also run into running to many automations (concurrent) runs at once if i have lots of people passing by?

1 automation for running all camera overview (e.g. birdseye)

alias: Show Frigate BirdsEye overview at Night on Diningroom
description: Show all cameras at night on dining room tv
trigger:
  - platform: state
    entity_id:
      - binary_sensor.front_driveway_1_person_occupancy
    from: "on"
    to: "off"
  - platform: state
    entity_id:
      - binary_sensor.front_driveway_2_person_occupancy
    from: "on"
    to: "off"
  - platform: state
    entity_id:
      - binary_sensor.front_porch_person_occupancy
    from: "on"
    to: "off"
  - platform: state
    entity_id:
      - binary_sensor.back_porch_person_occupancy
    from: "on"
    to: "off"
  - platform: state
    entity_id:
      - binary_sensor.greenhouse_person_occupancy
    from: "on"
    to: "off"
  - platform: state
    entity_id:
      - binary_sensor.greenhouse_2_person_occupancy
    from: "on"
    to: "off"
  - platform: state
    entity_id:
      - binary_sensor.garage_person_occupancy
    from: "on"
    to: "off"
condition:
  - condition: time
    after: "20:00:00"
    before: "06:00:00"
action:
  - service: webrtc.dash_cast
    data:
      url: rtsp://192.168.50.41:8554/birdseye
      entity_id: media_player.dining_room_tv
  - service: media_player.turn_off
    data: {}
    target:
      entity_id: media_player.dining_room_tv
mode: single

And one for showing the person occupancy when it happens. The only thing i’m not sure of how to pass the triggerid to the camera to be displayed. Probably just give it an id of camera name and then something like passing this to the RTSP url rtsp://192.168.50.41:8554/{{ trigger.id }} ?

alias: Show Frigate BirdsEye Person overview at Night on Diningroom
description: Show all cameras at night with person occupancy on dining room tv
trigger:
  - platform: state
    entity_id:
      - binary_sensor.front_driveway_1_person_occupancy
    from: "off"
    to: "on"
  - platform: state
    entity_id:
      - binary_sensor.front_driveway_2_person_occupancy
    from: "off"
    to: "on"
  - platform: state
    entity_id:
      - binary_sensor.front_porch_person_occupancy
    from: "off"
    to: "on"
  - platform: state
    entity_id:
      - binary_sensor.back_porch_person_occupancy
    from: "off"
    to: "on"
  - platform: state
    entity_id:
      - binary_sensor.greenhouse_person_occupancy
    from: "off"
    to: "on"
  - platform: state
    entity_id:
      - binary_sensor.greenhouse_2_person_occupancy
    from: "off"
    to: "on"
  - platform: state
    entity_id:
      - binary_sensor.garage_person_occupancy
    from: "off"
    to: "on"
condition:
  - condition: time
    after: "20:00:00"
    before: "06:00:00"
action:
  - service: webrtc.dash_cast
    data:
      url: rtsp://192.168.50.41:8554/{{ trigger.id }}
      entity_id: media_player.dining_room_tv
  - service: media_player.turn_off
    data: {}
    target:
      entity_id: media_player.dining_room_tv
mode: single