Just don't play TTS on anywhere on second floor while anyone is sleeping

Critical notifications will of course still ignore all restrictions
This commit is contained in:
2023-04-22 21:56:48 -04:00
parent 4ff38f76f6
commit a75dc0faa7
2 changed files with 27 additions and 21 deletions

View File

@ -1176,7 +1176,7 @@ script:
{{ message }}
</speak>
# Called wheh notification needs to play on echos
# Notifications that play on the Alexa devices
alexa_voice:
alias: 'Alexa Voice'
sequence:
@ -1194,6 +1194,11 @@ script:
volume_level: 1.0
- delay:
seconds: 3
- if:
- condition: template
value_template: "{{ is_state('binary_sensor.people_sleeping','on') and who in ['master_bedroom','master_bedroom_echo_dot','all_bedrooms'] and type not in ['critical','Critical'] }}"
then:
- stop: People are sleeping and this message is not important
- service: notify.alexa_media
data:
message: >
@ -1227,28 +1232,31 @@ script:
data:
type: tts
# Default audible notifications. Notifcations play on the google devices.
# Notifications that play on the Google devices.
jarvis_voice:
alias: 'Jarvis Voice'
sequence:
- if:
- condition: template
value_template: "{{ who in ['emma_bedroom','Emma Bedroom','media_player.emma_bedroom_speaker'] and is_state('input_boolean.emma_sleeping','on') }}"
then:
- stop: 'Emma is sleeping'
- if:
- condition: template
value_template: "{{ who in ['kallen_bedroom','media_player.kallen_bedroom_speaker','Kallen Bedroom'] and is_state('input_boolean.kallen_sleeping','on') }}"
then:
- stop: 'Kallen is sleeping'
- if:
- condition: template
value_template: >
{% if who in ['kids_bedrooms','all_bedrooms','everywhere','Everywhere','Kids Bedrooms','All Bedrooms'] %}
{{ is_state('input_boolean.kallen_sleeping','on') and is_state('input_boolean.emma_sleeping','on') }}
{% from 'time.jinja' import ct %}
{% set ct = ct() | int %}
{% set kallen_wakeup = state_attr('input_datetime.kallen_wakeup_time','timestamp') %}
{% if type in ['critical','Critical'] %}
false
{% elif who in ['emma_bedroom','Emma Bedroom','media_player.emma_bedroom_speaker'] %}
{{ is_state('binary_sensor.people_sleeping','on') }}
{% elif who in ['kallen_bedroom','media_player.kallen_bedroom_speaker','Kallen Bedroom'] %}
{% if (kallen_wakeup - 3600) < ct < (kallen_wakeup + 3600) %}
false
{% else %}
{{ is_state('binary_sensor.people_sleeping','on') }}
{% endif %}
{% elif who in ['kids_bedrooms','all_bedrooms','everywhere','Everywhere','Kids Bedrooms','All Bedrooms'] %}
{{ is_state('binary_sensor.people_sleeping','on') }}
{% endif %}
then:
- stop: 'Kids are sleeping'
- stop: 'People are sleeping'
- service: media_player.turn_on
data:
entity_id: >-
@ -1266,12 +1274,6 @@ script:
media_player.emma_bedroom_speaker
{% elif who in ['Basement Google','basement_google'] %}
media_player.basement_google_speaker
{% else %}
{% if states.input_boolean.audible_notifications.state == 'on' %}
media_player.living_room_tv
{% else %}
media_player.living_room_tv
{% endif %}
{% endif %}
- service: media_player.volume_set
data:

View File

@ -258,6 +258,10 @@ template:
- name: "Upstairs Bathroom Occupied"
unique_id: 7ec69a26-1013-4b0d-8662-a91ab9f040ca
state: "{{ is_state('timer.upstairs_bathroom_motion_timer','active') or is_state('binary_sensor.upstairs_bathroom_motion','on') or is_state('input_boolean.shower_mode','on') }}"
- name: "People Sleeping"
unique_id: 3f0a1504-fd01-4967-a6fb-0309813d31e3
state: "{{ is_state('input_boolean.emma_sleeping','on') or is_state('input_boolean.kallen_sleeping','on') or is_state('input_boolean.master_bedroom_sleeping','on') }}"
icon: mdi:sleep
mqtt:
sensor: