Door or Window Status

My kids are constantly opening and closing the doors and windows when it is over 90 degrees out.
I have written the automation to notify me if a door or window is open. I have a total of 16 doors and windows. I do not want to write an automation for each.
How can I combine them in one automation.
Here is what I have.

####################################################
#         DOOR WINDOW STATUS       2021Apr07       #
####################################################
- id: "1552497003983"
  alias: Office Window Opened
  trigger:
    - entity_id: binary_sensor.alarm_14_office_window
      from: "off"
      platform: state
      to: "on"
  action:
    - service: notify.telegram_carlton
      data:
        title: Alert
        message: The Office Window was opened

- id: "1552497003984"
  alias: Office Window Closed
  trigger:
    - entity_id: binary_sensor.alarm_14_office_window
      from: "on"
      platform: state
      to: "off"
  action:
    - service: notify.telegram_carlton
      data:
        title: Alert
        message: The Office Window was closed
    ####################################################
    #            END OF CONFIGURATION FILE             #
    ####################################################

Thanks for the help

You could just add each window/door as a trigger.
I do something similar but I use a light as a trigger and all my windows and doors as conditions with β€œor” statements. When my master bedroom light is turned off then if any windows or doors are open I get a TTS over the speaker in the master bedroom.
This is not exactly what you were asking but the ideas should work for you.

alias: Notification Bedtime Door and Window Report
description: TTS to Speaker when any door or window are open
trigger:
  - platform: state
    entity_id: light.leviton_masterbed
    to: 'off'
    for: '00:00:30'
condition:
  - condition: or
    conditions:
      - condition: state
        entity_id: binary_sensor.kitchen_window
        state: 'on'
      - condition: state
        entity_id: binary_sensor.front_door
        state: 'on'
      - condition: state
        entity_id: binary_sensor.deep_freezer_door
        state: 'on'
      - condition: state
        entity_id: cover.garage_door_big
        state: open
      - condition: state
        entity_id: cover.garage_door_small
        state: open
      - condition: state
        entity_id: binary_sensor.sliding_glass_door
        state: 'on'
action:
  - service: tts.marytts_say
    entity_id: media_player.rpispeaker1
    data_template:
      message: ...Some doors and windows are open
mode: single

Well, I just noticed that I need to add a few sensors to my automation. I have added a few since I wrote this.

This monitors multiple binary_sensors and reports the ones that have changed state.

- alias: Door and Window Monitor
  mode: queued
  trigger:
    - platform: state
      entity_id:
        - binary_sensor.alarm_14_office_window
        - binary_sensor.another_window
        - binary_sensor.some_other_window
        - binary_sensor.front_door
        - binary_sensor.another_door
  action:
    - service: notify.telegram_carlton
      data:
        title: Alert
        message: The {{ trigger.to_state.name }} was {{ 'opened' if trigger.to_state.state == 'on' else 'closed' }}
1 Like

Just a tip building on @123 You can start by creating a group with all the window and door sensors. This group can be used as a trigger.

group:
  door_window_group:
    name: Door & Window Sensor
    entities:
      - sensor.door_1
      - sensor.window_1
      - sensor.door_2
      - sensor.window_2

I have a group called
group.windows and group.doors
How would I use that in the automation.
Thanks

I think it would be best if you go with @123 suggestion as it will give you optimized option for actions. Grouping would lead to complicated and long action sequence.

Thanks will try it in a few hours.