Washing Machine Notification with a binary sensor

Hello
I wondering if someone could take a look at this yaml code and tell me if it’s okay. What I’d like to happen is when the washing machine is finished, a binary sensor will trigger a light that will flash on and off eight times before remaining on for 300 seconds (5 minutes). Ideally I would like the light to turn off when the washer lid is opened, but I don’t believe there is a sensor for that (unless someone can tell me how to do this). Thanks in advance for any help that can be provided.

- id: '1682694410171'
  alias: Washer Notification
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.washer_wash_complete
    from: 'on'
    to: 
  condition: []
  action:
  - service: light.turn_on
    data:
      brightness: 255
      rgb_color:
      - 0
      - 128
      - 255
    target:
      entity_id: light.washer_dryer_notification_bulb_mintransitionlight
  - delay:
      seconds: 1
  - service: light.turn_off
    entity_id: light.washer_dryer_notification_bulb_mintransitionlight
  - delay:
      seconds: 1
  - service: light.turn_on
    entity_id: light.washer_dryer_notification_bulb_mintransitionlight
    data:
      brightness: 255
      rgb_color:
      - 0
      - 128
      - 255
  - delay:
      seconds: 1
  - service: light.turn_off
    entity_id: light.washer_dryer_notification_bulb_mintransitionlight
  - delay:
      seconds: 1
  - service: light.turn_on
    entity_id: light.washer_dryer_notification_bulb_mintransitionlight
    data:
      brightness: 255
      rgb_color:
      - 0
      - 128
      - 255
  - delay:
      seconds: 1
  - service: light.turn_off
    entity_id: light.washer_dryer_notification_bulb_mintransitionlight
  - delay:
      seconds: 1
  - service: light.turn_on
    entity_id: light.washer_dryer_notification_bulb_mintransitionlight
    data:
      brightness: 255
      rgb_color:
      - 0
      - 128
      - 255
  - delay:
      seconds: 1
  - service: light.turn_off
    entity_id: light.washer_dryer_notification_bulb_mintransitionlight
  - delay:
      seconds: 1
  - service: light.turn_on
    entity_id: light.washer_dryer_notification_bulb_mintransitionlight
    data:
      brightness: 255
      rgb_color:
      - 0
      - 128
      - 255
  - delay:
      seconds: 1
  - service: light.turn_off
    entity_id: light.washer_dryer_notification_bulb_mintransitionlight
  - delay:
      seconds: 1
  - service: light.turn_on
    entity_id: light.washer_dryer_notification_bulb_mintransitionlight
    data:
      brightness: 255
      rgb_color:
      - 0
      - 128
      - 255
  - delay:
      seconds: 1
  - service: light.turn_off
    entity_id: light.washer_dryer_notification_bulb_mintransitionlight
  - delay:
      seconds: 1
  - service: light.turn_on
    entity_id: light.washer_dryer_notification_bulb_mintransitionlight
    data:
      brightness: 255
      rgb_color:
      - 0
      - 128
      - 255
  - delay:
      seconds: 1
  - service: light.turn_off
    entity_id: light.washer_dryer_notification_bulb_mintransitionlight
  - delay:
      seconds: 1
  - service: light.turn_on
    entity_id: light.washer_dryer_notification_bulb_mintransitionlight
    data:
      brightness: 255
      rgb_color:
      - 0
      - 128
      - 255
  - delay:
      seconds: 1
  - service: light.turn_off
    entity_id: light.washer_dryer_notification_bulb_mintransitionlight
  - delay:
      seconds: 1
  - service: light.turn_on
    entity_id: light.washer_dryer_notification_bulb_mintransitionlight
    data:
      brightness: 255
      rgb_color:
      - 0
      - 128
      - 255
    entity_id: light.washer_dryer_notification_bulb_mintransitionlight
  - delay:
      seconds: 300
  - service: light.turn_off