Tweak speech. Add a separate music function

This commit is contained in:
2020-03-08 12:31:24 +02:00
parent d68107166e
commit 4c30687ee9
6 changed files with 38 additions and 27 deletions

View File

@@ -0,0 +1,14 @@
script:
music_play:
alias: "Music - Play"
sequence:
- service: media_player.volume_set
entity_id: media_player.master_bedroom
data:
volume_level: 0.3
- service: media_player.select_source
entity_id: media_player.master_bedroom
data:
source: "Evening Chill"
- service: fan.turn_off
entity_id: fan.philips_airpurifier

View File

@@ -7,9 +7,11 @@ script:
say:
alias: Speech - Say
sequence:
# Don't talk while in sleep mode.
- condition: state
entity_id: input_boolean.sleep_mode
state: "off"
# Combine partials for speech message.
- service: script.say_discretely
data_template:
message: >-
@@ -24,6 +26,7 @@ script:
say_discretely:
alias: Speech - Say discretely
sequence:
# Figure out whether to talk or send a text.
- service_template: >
{% if is_state('media_player.master_bedroom', 'playing')
or is_state('input_boolean.speech_notifications', 'off')
@@ -47,8 +50,13 @@ script:
sequence:
- service: media_player.volume_set
entity_id: media_player.master_bedroom
data:
volume_level: 0.5
data_template:
volume_level: >-
{% if now().strftime('%H')|int < 6 and now().strftime('%H')|int > 1 %}
0.2
{% else %}
0.5
{% endif %}
- service: tts.amazon_polly_say
data_template:
entity_id: media_player.master_bedroom

View File

@@ -11,6 +11,7 @@ automation:
platform: homeassistant
event: start
action:
- delay: 00:00:06
- service: script.say
data:
message: "Hey! I was out for a bit, but I'm back online!"

View File

@@ -8,25 +8,22 @@ script:
routine_coming_home:
alias: Routine - Coming home
sequence:
# Enter home mode.
- service: script.security_camera_off
- service: light.turn_on
entity_id: light.living_room_all_lights
# Check if welcome home is enabled, proceed with welcome routine.
- condition: state
entity_id: input_boolean.routine_welcome_home
state: "on"
- delay: 00:00:03
- service: script.coming_home_say_welcome
# TODO: Add condition for time - don't blast music late at night :)
- delay: 00:00:03
- service: media_player.shuffle_set
entity_id: media_player.master_bedroom
data:
shuffle: true
- service: media_player.select_source
entity_id: media_player.master_bedroom
data:
source: Evening Chill
# Wait a while for me to enter before welcoming.
- delay: 00:00:02
- service: script.coming_home_say_welcome
- delay: 00:00:13
- service: script.music_play
coming_home_say_welcome:
alias: Routine - Coming home - Say welcome

View File

@@ -3,17 +3,12 @@ script:
alias: Routine - Waking up
sequence:
- service: script.routine_morning_briefing
- delay: 00:00:25
- delay: 00:00:35
- service: script.say
data:
message: "Here's some music to start the day!"
- delay: 00:00:02
- service: media_player.select_source
entity_id: media_player.master_bedroom
data:
source: "Evening Chill"
- service: fan.turn_off
entity_id: fan.philips_airpurifier
- service: script.music_play
routine_morning_briefing:
alias: Routine - Morning Briefing

View File

@@ -1,12 +1,8 @@
>-
{%- if is_state('group.all_windows', 'on') -%}
{%- if is_state('binary_sensor.living_room_right_window_on_off', 'on') -%}
The living room window is opened.
{%- endif -%}
{%- if is_state('binary_sensor.bedroom_right_window_on_off', 'on') -%}
The master bedroom window is opened.
{%- endif -%}
{%- if is_state('binary_sensor.living_room_right_window_on_off', 'on') -%} The living room window is opened. {% endif %}
{%- if is_state('binary_sensor.bedroom_right_window_on_off', 'on') -%} The master bedroom window is opened. {%- endif -%}
{%- else -%}
All windows are closed.
{%- endif -%}