Door Status Indicator and warning

My goal is to have an indicator show the status of all the doors. I have a RGB led as an indicator. When all doors are closed, the indicator will show green. When any door is opened, indicator will change to red. If after 5 minutes the door is still open, the indicator will flash red until all doors are closed.

I have tried to write an automation but I get hung up on checking the status. I am able to see the LED green when all doors are closed. When door is opened, LED turns Red. How do I get the LED to flash red after the door has been open 5 minutes?

Here is my code so far.

alias: Test New automation
description: ""
trigger:
  - type: opened
    platform: device
    device_id: 10a1a49bbf38654038c170b5258370da
    entity_id: ac0e300fea0e65b23c7f72ebaf1b2eec
    domain: binary_sensor
condition: []
action:
  - type: turn_on
    device_id: 91906ffcb7146914207ee6f85ad77810
    entity_id: 9285189849ae3ca6e4234e3f7765812b
    domain: switch
  - type: turn_off
    device_id: 91906ffcb7146914207ee6f85ad77810
    entity_id: 1757a487d193c096d96f95026d89a881
    domain: switch
  - wait_for_trigger:
      - type: not_opened
        platform: device
        device_id: 10a1a49bbf38654038c170b5258370da
        entity_id: ac0e300fea0e65b23c7f72ebaf1b2eec
        domain: binary_sensor
  - type: turn_on
    device_id: 91906ffcb7146914207ee6f85ad77810
    entity_id: 1757a487d193c096d96f95026d89a881
    domain: switch
  - type: turn_off
    device_id: 91906ffcb7146914207ee6f85ad77810
    entity_id: 9285189849ae3ca6e4234e3f7765812b
    domain: switch
mode: single

Thanks Bob