First, thank you for the reply.
Let’s see if I can point you in a direction that might give you a hint.
I use alarm.com for my hard wired alarm system. HA has some integrations and such so I took advantage of it.
I first created a binary sensor to look like this.
####################################################
alarm_14_office_window:
friendly_name: "14_Office Window"
device_class: window
value_template: "{{ state_attr('alarm_control_panel.alarm_com', 'sensor_status')|regex_search('14_Office Window is Open', ignorecase=TRUE) }}"
I then created some groups that look like this.
####################################################
# GROUP.WINDOWS #
####################################################
windows:
entities:
- binary_sensor.alarm_5_master_bedroom_window_1
- binary_sensor.alarm_6_master_bedroom_window_2
- binary_sensor.alarm_7_master_bathroom_window
- binary_sensor.alarm_9_greatroom_window_1
- binary_sensor.alarm_10_greatroom_window_2
- binary_sensor.alarm_12_kitchen_window
- binary_sensor.alarm_13_bedroom_window
- binary_sensor.alarm_14_office_window
####################################################
# GROUP.DOORS #
####################################################
doors:
entities:
- binary_sensor.alarm_1_frontdoor
- binary_sensor.alarm_4_garage_door_inside
- binary_sensor.alarm_11_greatroom_french_doors
####################################################
Lastly I create an automation that tells me when a door or window is opened/closed.
####################################################
# DOOR WINDOW STATUS 2020Apr07 #
####################################################
- alias: Door and Window Monitor
mode: queued
trigger:
- platform: state
entity_id:
- binary_sensor.alarm_5_master_bedroom_window_1
- binary_sensor.alarm_6_master_bedroom_window_2
- binary_sensor.alarm_7_master_bathroom_window
- binary_sensor.alarm_9_greatroom_window_1
- binary_sensor.alarm_10_greatroom_window_2
- binary_sensor.alarm_12_kitchen_window
- binary_sensor.alarm_13_bedroom_window
- binary_sensor.alarm_14_office_window
- binary_sensor.alarm_1_frontdoor
- binary_sensor.alarm_4_garage_door_inside
- binary_sensor.alarm_11_greatroom_french_doors
action:
- service: notify.telegram_carlton
data:
title: Alert
message: The {{ trigger.to_state.name }} was {{ 'opened' if trigger.to_state.state == 'on' else 'closed' }}
Lastly I made an automation that told me what door/windows were open at 8 pm.
####################################################
# DOORS OPEN STATUS 2020Apr02 #
####################################################
#https://community.home-assistant.io/t/automation-that-checks-for-is-doors-are-open-before-going-to-bed/59456/7
- id: "1793401787732"
alias: "8 pm Door Check"
description: Door Check
trigger:
- at: "19:59:00"
platform: time
condition:
condition: template
value_template: >
{{ states | selectattr('entity_id', 'in', state_attr('group.doors','entity_id')) | selectattr('state','in',['on','open']) | list | length >= 1 }}
action:
- service: media_player.volume_set
data:
volume_level: 0.7
entity_id: media_player.everywhere
- data:
entity_id: group.echo
media_content_id: amzn_sfx_trumpet_bugle_04
media_content_type: sound
service: media_player.play_media
- data:
data:
method: speak
type: announce
message: >
{% set open_doors = ( states | selectattr('entity_id', 'in', state_attr('group.doors','entity_id')) | selectattr('state','in',['on','open']) | list | map(attribute='name') | join(', ') ) %}
It is 8 pm and the following doors are open: {{ open_doors }}
service: notify.alexa_media_everywhere
- service: notify.telegram_carlton
data_template:
title: "It's 8 PM Doors Open!"
message: >
{% set open_doors = ( states | selectattr('entity_id', 'in', state_attr('group.doors','entity_id')) | selectattr('state','in',['on','open']) | list | map(attribute='name') | join(', ') ) %}
Its 8 PM and the following doors are open: {{ open_doors }}
mode: single
####################################################
# WINDOW OPEN STATUS 2020Apr02 #
####################################################
#https://community.home-assistant.io/t/automation-that-checks-for-is-doors-are-open-before-going-to-bed/59456/7
- id: "1893401787732"
alias: "8 pm Window Check"
description: Window Check
trigger:
- at: "19:58:00"
platform: time
condition:
condition: template
value_template: >
{{ states | selectattr('entity_id', 'in', state_attr('group.windows','entity_id')) | selectattr('state','in',['on','open']) | list | length >= 1 }}
action:
- service: media_player.volume_set
data:
volume_level: 0.8
entity_id: media_player.everywhere
- data:
entity_id: group.echo
media_content_id: amzn_sfx_trumpet_bugle_04
media_content_type: sound
service: media_player.play_media
- data:
data:
method: speak
type: announce
message: >
{% set open_windows = ( states | selectattr('entity_id', 'in', state_attr('group.windows','entity_id')) | selectattr('state','in',['on','open']) | list | map(attribute='name') | join(', ') ) %}
It is 8 pm and the following windows are open: {{ open_windows }}
service: notify.alexa_media_everywhere
- service: notify.telegram_carlton
data_template:
title: "It's 8 PM Windows Open!"
message: >
{% set open_windows = ( states | selectattr('entity_id', 'in', state_attr('group.windows','entity_id')) | selectattr('state','in',['on','open']) | list | map(attribute='name') | join(', ') ) %}
Its 8 PM and the following windows are open: {{ open_windows }}
mode: single
####################################################
# END OF CONFIGURATION FILE #
####################################################
All of the automations work well.
Last night I created your automation. I opened a window, then sprayed the weather station with some water. Within 30 seconds I got a notice informing me it was raining and my office window was open.
So for me it worked.
Maybe you can kludge something together from this information!