reorganized code

This commit is contained in:
Mahasri Kalavala
2022-12-04 12:38:48 -05:00
parent 20bdf8ed76
commit bb0cf6db6b
17 changed files with 407 additions and 1092 deletions

View File

@@ -79,7 +79,7 @@ script:
sequence:
- service: script.all_indoor_lights_off
- service: input_boolean.turn_on
entity_id: input_boolean.notify_camera_alerts
entity_id: input_boolean.camera_alerts
- service: alarm_control_panel.alarm_arm_away
data:
entity_id: alarm_control_panel.home
@@ -150,151 +150,20 @@ script:
rgb_color: [0, 255, 0]
###############################################################################
# A script that toggles Nest Thermostat between eco/away & non-eco/away modes
###############################################################################
toggle_climate:
sequence:
- service: climate.set_away_mode
data_template:
entity_id: climate.dining_room
away_mode: "{{ false if state_attr('climate.dining_room', 'away_mode') == 'on' else true }}"
###############################################################################
# _ _ _ _ __
# | \ | | | | (_)/ _|
# | \| | ___ | |_ _| |_ _ _
# | . ` |/ _ \| __| | _| | | |
# | |\ | (_) | |_| | | | |_| |
# |_| \_|\___/ \__|_|_| \__, |
# __/ |
# |___/
# Notify Related Scripts
###############################################################################
good_night_tts:
sequence:
- service: script.voice_notify
data_template:
message: !include ../templates/goodnight.yaml
###############################################################################
# Voice Notify
# Conditions:
# => Only Announce when people are home. Except in emergency mode!
# => Only Announce when Music is NOT being played
###############################################################################
voice_notify:
sequence:
- condition: template
value_template: "{{ states('input_boolean.voice_notifications') == 'on' }}"
- condition: template
value_template: "{{ states('input_boolean.do_not_disturb') | lower == 'off' }}"
- condition: template
value_template: "{{ message | trim != '' }}"
- condition: template
value_template: "{{ states('input_boolean.home_mode_away') == 'off' }}"
- condition: template
value_template: >
{% if only_at_night | default('no', true ) == "yes" %}
{% if states('sun.sun') == "above_horizon" %}
false
{% else %}
true
{% endif %}
{% else %}
true
{% endif %}
- service: media_player.volume_set
entity_id: media_player.living_room, media_player.upstairs
data_template:
volume_level: >
{% if states('input_boolean.emergency_mode') == "on" %}
{{ states('input_number.tts_volume_level_alert') }}
{% else %}
{% if now().hour | int < 12 and now().hour | int > 6 %}
{{ states('input_number.tts_volume_level_morning') }}
{% elif now().hour|int > 12 and now().hour|int < 20 %}
{{ states('input_number.tts_volume_level_afternoon') }}
{% else %}
{{ states('input_number.tts_volume_level_evening') }}
{% endif %}
{% endif %}
- service: tts.amazon_polly_say
entity_id: media_player.living_room, media_player.upstairs
data_template:
cache: true
message: >
{% set msg = "" %}
{% macro getGreeting() %}
{% if greeting | default('yes', true ) == "yes" %}
{% if now().hour|int < 12 %}
Good morning.
{% elif now().hour|int < 18 %}
Good afternoon.
{% else %}
Good evening.
{% endif %}
{% endif %}
{% endmacro %}
{%- macro getEndGreeting() -%}
{%- if greeting |default('yes', true ) == "yes" -%}
Thank you!
{%- endif -%}
{%- endmacro -%}
{% set msg = msg + "<speak> " %}
{% set msg = msg + getGreeting() %}
{% set msg = msg + ". " + message %}
{% set msg = msg.replace(".", " <break time='0.5s'/> ") %}
{% set msg = msg + " " + getEndGreeting() %}
{% set msg = msg + " </speak>" %}
{{ msg }}
###############################################################################
# Greeting
###############################################################################
voice_greeting:
sequence:
- service: tts.amazon_polly_say
entity_id: media_player.living_room, media_player.upstairs
data_template:
cache: true
message: >
{% set msg = "" %}
{% macro getGreeting() %}
{% if greeting | default('yes', true ) == "yes" %}
{% if now().hour|int < 12 %}
Good morning.
{% elif now().hour|int < 18 %}
Good afternoon.
{% else %}
Good evening.
{% endif %}
{% endif %}
{% endmacro %}
{% set msg = msg + "<speak> " %}
{% set msg = msg + " " + getGreeting() %}
{% set msg = msg.replace(".", " <break time='0.5s'/> ") %}
{% set msg = msg + " </speak>" %}
{{ msg }}
###############################################################################
# Status around the house
# Status of the house
###############################################################################
home_status:
sequence:
- service: script.voice_notify
- service: script.notify_family
data_template:
message: !include ../templates/home_status.yaml
notify_options:
- voice
###############################################################################
# Display message on LED Matrix Screen
###############################################################################
led_message:
good_night_tts:
sequence:
- condition: state
entity_id: input_boolean.led_alerts
state: "on"
- service: mqtt.publish
- service: script.notify_family
data_template:
topic: messageboard/messages
payload: "{{ message }}"
message: !include ../templates/goodnight.yaml
notify_options:
- voice