Need logic help for alerting if door is left open after dark

I am not sure I have my logic correct yet, but my goal would be to send an alert if one of the kids leave a door or something open after dark. there’s been a few times that we have gotten up the next morning to find the garage door was left open all night.

so my logic is to set a condition that if after the sun had gone down and something is open to send the alert. my concern is I think this will send an alert every time something is opened after dark. I already have an alert for when something is left open for longer than 10 min but I also want something else if it’s dark.

also I ahve some sort of typo in this as I am getting an error…

####send notification if doors left open after Dark####
- alias: Doors/windows open after Dark
  initial_state: true
  trigger:
    - platform: state
      entity_id:
        - binary_sensor.garage_door
        - binary_sensor.front_door
        - binary_sensor.1st_floor_window
        - binary_sensor.basement_door
        - binary_sensor.basement_garage_door
        - binary_sensor.basement_windows
        - binary_sensor.breakfast_door
        - binary_sensor.sliding_glass_door
        - binary_sensor.sun_room_glass
      state: 'on'
  condition:
    condition: and
    conditions: 
      - condition: state
        entity_id: sun.sun
        state: below_horizon
      - condition: state
        entity_id: 
          - binary_sensor.garage_door
          - binary_sensor.front_door
          - binary_sensor.1st_floor_window
          - binary_sensor.basement_door
          - binary_sensor.basement_garage_door
          - binary_sensor.basement_windows
          - binary_sensor.breakfast_door
          - binary_sensor.sliding_glass_door
          - binary_sensor.sun_room_glass
        state: 'on'
  action:
    service: notify.simple    
    data_template:
      message : " {{ trigger.from_state.attributes.friendly_name }} has been left Open after dark " 
      title: "Don't forget to close doors"

here is the error:
Invalid config for [automation]: [state] is an invalid option for [automation]. Check: automation->trigger->0->state. (See /config/automations.yaml, line 232). Please check the docs at https://home-assistant.io/components/automation/

- alias: Doors/windows open after Dark
  initial_state: true
  trigger:
    - platform: sun
      state: below_horizon
  condition: 
    condition: or
    conditions:
      - condition: state
        entity_id: 
          - binary_sensor.garage_door
          - binary_sensor.front_door
          - binary_sensor.1st_floor_window
          - binary_sensor.basement_door
          - binary_sensor.basement_garage_door
          - binary_sensor.basement_windows
          - binary_sensor.breakfast_door
          - binary_sensor.sliding_glass_door
          - binary_sensor.sun_room_glass
        state: 'on'
  action:
    service: notify.simple    
    data_template:
      message : " {{ trigger.from_state.attributes.friendly_name }} has been left Open after dark " 
      title: "Don't forget to close doors"

conditions are already ‘and’ so you don’t need to add that in

EDIT: needed to make these all ‘or’

I am curious though because i was after the same some time back. Wouldn’t this automation send a notification if any of the entities is on (open) at the time of sunset ? But what about an hour later ? There does not seem to be a logic that checks that if all the doors have been closed after sunset and are closed at the time he wants to go to bed then “all checks out” ? I personally gave up on the automation and instead have all my relevant entities on an entity-filter card and they only show if they are open…which i can check easily before going to bed…my 2 cts…

  - entities:
      - light.red_lamp
      - light.blue_round_table
      - switch.kitchen_hall
      - switch.kitchen_main
      - switch.sonoff_basic_relay
      - switch.sonoff_basic_relay2
    show_empty: false
    state_filter:
      - 'on'
    type: entity-filter

Your automation will work only once, when sun goes down. But what if door was opened after sunset? Seems to me, there should be second automation, where doors would be a trigger and sun - condition

Sure there is. You just described it.

Trigger on sunset or bed time. Same conditions as in Dave’s example above.

@tom_l, i meant in the automation as written above. Only trigger is sun, not mention of bedtime. Like @Argo said, the automation will run once at sunset and that’s it.

that’s what was requested by the OP though

True. Re-read the post, my mistake, OP was only asking for sunset trigger.