Migrate rain window warning to ui, support porch windows, #89 #154

This commit is contained in:
2023-10-05 22:07:26 -04:00
parent 98276febac
commit f5af8ac613
2 changed files with 108 additions and 79 deletions

View File

@ -2728,3 +2728,111 @@
alias: Run custom meds script if tracker is active alias: Run custom meds script if tracker is active
mode: parallel mode: parallel
max: 10 max: 10
- id: '1696556688808'
alias: Rain Window Warning
description: Warn when it starts raining and a window is open
trigger:
- platform: state
entity_id: binary_sensor.raining
from: 'off'
to: 'on'
alias: Rain starts
condition:
- condition: state
entity_id: binary_sensor.windows
state: 'on'
alias: Windows are open
action:
- variables:
porch: '{{ true if states(''sensor.windows_open'') == ''1'' and is_state(''binary_sensor.front_window_near'',''on'')
else false }}'
message: "{% if porch == true %}\n It is raining and a window by the porch
is open. This is generally acceptable, but please close it if the wind is
blowing in.\n{% else %}\n It is raining and there are windows open in the
house. Please close them!\n{% endif %}\n"
alias: Define variables
- service: script.text_notify
data:
type: alert
who: all
title: WINDOWS ARE OPEN!
message: '{{ message }}'
tag: rain-window-warning
alias: Send text notification
- service: script.living_room_lights_alert
data:
type: blue
duration: 10
alias: Light alert in living room
- if:
- condition: state
entity_id: binary_sensor.basement_occupied
state: 'on'
alias: Basement is occupied
then:
- service: script.basement_lights_alert
data:
type: blue
duration: 10
alias: Light alert in basement
alias: Light alert in basement, if occupied
- service: script.speech_engine
data:
who: everywhere
type: weather
message: '{{ message }}'
alias: TTS notification
- wait_template: '{{ is_state(''binary_sensor.windows'',''off'') or is_state(''binary_sensor.raining'',''off'')
}}'
timeout: 00:15:00
continue_on_timeout: true
alias: Wait until windows are shut, or it happens to stop raining
- choose:
- conditions:
- condition: template
value_template: '{{ is_state(''binary_sensor.windows'',''off'') and is_state(''binary_sensor.raining'',''on'')
}}'
alias: Windows closed and still raining
sequence:
- service: script.text_notify
data:
type: alert
who: all
message: clear_notification
tag: rain-window-warning
alias: Clear text notification
- service: script.speech_engine
data:
who: common
type: weather
message: Windows are now closed. Thank you, and enjoy your dry house.
alias: TTS notification
- conditions:
- condition: template
value_template: '{{ is_state(''binary_sensor.raining'',''off'') }}'
alias: Stopped raining
sequence:
- service: script.text_notify
data:
type: alert
who: all
message: clear_notification
tag: rain-window-warning
alias: Clear text notification
- service: script.speech_engine
data:
who: common
type: weather
message: Nevermind, it has stopped raining. Feel free to do whatever you'd
like with the windows.
alias: TTS notification
default:
- service: script.speech_engine
data:
who: common
type: weather
message: Well, I guess no one cares if the house floods. Suit yourself, but
do not say I didn't warn you.
alias: TTS notification
alias: After wait completed
mode: single

View File

@ -1589,85 +1589,6 @@ automation:
- service: input_boolean.turn_on - service: input_boolean.turn_on
entity_id: input_boolean.freeze_warning entity_id: input_boolean.freeze_warning
- id: 288de6e1-ec3d-43fa-9be8-1b2e27e4ad85
alias: Rain Window Warning
trigger:
- platform: state
entity_id: binary_sensor.raining
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: binary_sensor.windows
state: 'on'
action:
- service: script.text_notify
data:
type: alert
who: 'all'
title: "WINDOWS ARE OPEN!"
message: "It is raining and there are windows open in the house. Please close them!"
tag: rain-window-warning
- service: script.living_room_lights_alert
data:
type: blue
duration: 10
- if:
- condition: state
entity_id: binary_sensor.basement_occupied
state: 'on'
then:
- service: script.basement_lights_alert
data:
type: blue
duration: 10
- service: script.speech_engine
data:
who: everywhere
type: weather
message: "It is raining and there are windows open in the house. Please close them!"
- wait_template: "{{ is_state('binary_sensor.windows','off') or is_state('binary_sensor.raining','off') }}"
timeout: "00:15:00"
continue_on_timeout: true
- choose:
- conditions:
- condition: template
value_template: "{{ is_state('binary_sensor.windows','off') and is_state('binary_sensor.raining','on') }}"
sequence:
- service: script.text_notify
data:
type: alert
who: all
message: clear_notification
tag: rain-window-warning
- service: script.speech_engine
data:
who: common
type: weather
message: "Windows are now closed. Thank you, and enjoy your dry house."
- conditions:
- condition: template
value_template: "{{ is_state('binary_sensor.raining','off') }}"
sequence:
- service: script.text_notify
data:
type: alert
who: all
message: clear_notification
tag: rain-window-warning
- service: script.speech_engine
data:
who: common
type: weather
message: "Nevermind, it has stopped raining. Feel free to do whatever you'd like with the windows."
default:
- service: script.speech_engine
data:
who: common
type: weather
message: "Well, I guess no one cares if the house floods. Suit yourself, but do not say I didn't warn you."
################################################################################ ################################################################################
## script ## ## script ##