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 #
####################################################
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.
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.