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
+14
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
+10 -2
View File
@@ -7,9 +7,11 @@ script:
say: say:
alias: Speech - Say alias: Speech - Say
sequence: sequence:
# Don't talk while in sleep mode.
- condition: state - condition: state
entity_id: input_boolean.sleep_mode entity_id: input_boolean.sleep_mode
state: "off" state: "off"
# Combine partials for speech message.
- service: script.say_discretely - service: script.say_discretely
data_template: data_template:
message: >- message: >-
@@ -24,6 +26,7 @@ script:
say_discretely: say_discretely:
alias: Speech - Say discretely alias: Speech - Say discretely
sequence: sequence:
# Figure out whether to talk or send a text.
- service_template: > - service_template: >
{% if is_state('media_player.master_bedroom', 'playing') {% if is_state('media_player.master_bedroom', 'playing')
or is_state('input_boolean.speech_notifications', 'off') or is_state('input_boolean.speech_notifications', 'off')
@@ -47,8 +50,13 @@ script:
sequence: sequence:
- service: media_player.volume_set - service: media_player.volume_set
entity_id: media_player.master_bedroom entity_id: media_player.master_bedroom
data: data_template:
volume_level: 0.5 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 - service: tts.amazon_polly_say
data_template: data_template:
entity_id: media_player.master_bedroom entity_id: media_player.master_bedroom
+1
View File
@@ -11,6 +11,7 @@ automation:
platform: homeassistant platform: homeassistant
event: start event: start
action: action:
- delay: 00:00:06
- service: script.say - service: script.say
data: data:
message: "Hey! I was out for a bit, but I'm back online!" message: "Hey! I was out for a bit, but I'm back online!"
+9 -12
View File
@@ -8,25 +8,22 @@ script:
routine_coming_home: routine_coming_home:
alias: Routine - Coming home alias: Routine - Coming home
sequence: sequence:
# Enter home mode.
- service: script.security_camera_off - service: script.security_camera_off
- service: light.turn_on - service: light.turn_on
entity_id: light.living_room_all_lights entity_id: light.living_room_all_lights
# Check if welcome home is enabled, proceed with welcome routine.
- condition: state - condition: state
entity_id: input_boolean.routine_welcome_home entity_id: input_boolean.routine_welcome_home
state: "on" state: "on"
- delay: 00:00:03
- service: script.coming_home_say_welcome
# TODO: Add condition for time - don't blast music late at night :) # Wait a while for me to enter before welcoming.
- delay: 00:00:03 - delay: 00:00:02
- service: media_player.shuffle_set
entity_id: media_player.master_bedroom - service: script.coming_home_say_welcome
data: - delay: 00:00:13
shuffle: true - service: script.music_play
- service: media_player.select_source
entity_id: media_player.master_bedroom
data:
source: Evening Chill
coming_home_say_welcome: coming_home_say_welcome:
alias: Routine - Coming home - Say welcome alias: Routine - Coming home - Say welcome
+2 -7
View File
@@ -3,17 +3,12 @@ script:
alias: Routine - Waking up alias: Routine - Waking up
sequence: sequence:
- service: script.routine_morning_briefing - service: script.routine_morning_briefing
- delay: 00:00:25 - delay: 00:00:35
- service: script.say - service: script.say
data: data:
message: "Here's some music to start the day!" message: "Here's some music to start the day!"
- delay: 00:00:02 - delay: 00:00:02
- service: media_player.select_source - service: script.music_play
entity_id: media_player.master_bedroom
data:
source: "Evening Chill"
- service: fan.turn_off
entity_id: fan.philips_airpurifier
routine_morning_briefing: routine_morning_briefing:
alias: Routine - Morning Briefing alias: Routine - Morning Briefing
+2 -6
View File
@@ -1,12 +1,8 @@
>- >-
{%- if is_state('group.all_windows', 'on') -%} {%- if is_state('group.all_windows', 'on') -%}
{%- if is_state('binary_sensor.living_room_right_window_on_off', 'on') -%} {%- if is_state('binary_sensor.living_room_right_window_on_off', 'on') -%} The living room window is opened. {% endif %}
The living room window is opened. {%- if is_state('binary_sensor.bedroom_right_window_on_off', 'on') -%} The master bedroom window is opened. {%- endif -%}
{%- endif -%}
{%- if is_state('binary_sensor.bedroom_right_window_on_off', 'on') -%}
The master bedroom window is opened.
{%- endif -%}
{%- else -%} {%- else -%}
All windows are closed. All windows are closed.
{%- endif -%} {%- endif -%}