DarkFox-homeassistant/packages/automation/sleep.yaml

356 lines
10 KiB
YAML

group:
sleep_as_android:
name: 'Sleep as Android'
entities:
- sensor.sleep_tracker
- sensor.phone_alarm
- counter.snooze_counter
counter:
snooze_counter:
name: Snooze Counter
icon: mdi:alarm-snooze
script:
bedroom_sunrise:
alias: Bedroom Sunrise
sequence:
# Turn the lights to low brightness at a very warm temperature
- service: light.turn_on
data:
transition: 60
brightness: 51
kelvin: 2700
entity_id: light.bedside
# Wait 5 seconds
- delay: 00:00:05
# Over ten minutes, turn the lights a little brighter and to a
# cooler-than-soft-white color.
- service: light.turn_on
data:
transition: 600
brightness: 63
kelvin: 3600
entity_id: light.bedside
# Wait again
- delay: 00:00:05
# Finally, over fifteen minutes, shift the lights to a cool white at 90%.
- service: light.turn_on
data:
transition: 900
brightness: 230
kelvin: 4200
entity_id: light.bedside
morning_briefing:
alias: Morning Briefing
sequence:
- service: tts.google_say
data_template:
entity_id: "{{ device_entity_id }}"
message: >
{{ states.sensor.tts_greeting.state }}. Klokken er {{ states.sensor.time.state }}.
Vejrudsigt: {{ states.sensor.dmi_city_weather.state }}.
{{ states.sensor.dark_sky_temperature.state | replace('.', ',') }}˚
og {{ states.sensor.dark_sky_wind_speed_name.state }}.
{% if is_state('binary_sensor.workday_sensor', 'on') and now().hour < 12 -%}
S-Tog Linje B:
{%- if is_state('sensor.s_train_b_status', 'Til tiden') -%}
Kører normalt.
{%- else -%}
{{ states('sensor.s_train_b_status') }}. {{ states('sensor.s_train_message') }}
Estimeret rejsetid: {{ states('sensor.travel_time_to_work_public_transit') }} minutter.
{%- endif -%}
{%- endif -%}
language: 'da'
wakeup_playlist:
alias: Wakeup Playlist
sequence:
- service: tts.google_say
data_template:
entity_id: "{{ device_entity_id }}"
message: >
Hey Google. Shuffle {{ now().strftime("%A") }}, from Spotify, on {{ state_attr(device_entity_id, 'friendly_name') }}.
alexa_calendar:
alias: Alexa Calendar
sequence:
- service: tts.google_say
data_template:
entity_id: "{{ device_entity_id }}"
message: Alexa, what's today's schedule?
morning_lights:
alias: Turn lights to default and turn off the fan.
sequence:
- service: input_select.select_option
data_template:
option: 'Default'
entity_id: >
{% if is_state('input_boolean.guests', 'on') %}
input_select.bedroom_light_profile
{% else %}
input_select.light_profile
{% endif %}
- service: switch.turn_off
entity_id: switch.bedroom_fan
automation:
- alias: sleep_tracking_activity
initial_state: true
trigger:
platform: state
entity_id: sensor.sleep_tracker
to: 'tracking'
condition:
condition: and
conditions:
- condition: state
entity_id: binary_sensor.martin_presence_delayed
state: 'on'
- condition: template
value_template: "{{ not is_state('input_select.martin_activity', 'Sleeping') }}"
action:
service: input_select.select_option
data:
entity_id: input_select.martin_activity
option: Sleeping
- alias: sleep_paused_activity
initial_state: true
trigger:
platform: state
entity_id: sensor.sleep_tracker
to: 'paused'
condition:
condition: and
conditions:
- condition: state
entity_id: binary_sensor.martin_presence_delayed
state: 'on'
- condition: template
value_template: "{{ not is_state('input_select.martin_activity', 'Sleep Paused') }}"
action:
service: input_select.select_option
data:
entity_id: input_select.martin_activity
option: "Sleep Paused"
- alias: alarm_ringing_activity
initial_state: true
trigger:
platform: state
entity_id: sensor.phone_alarm
to: 'ringing'
condition:
condition: and
conditions:
- condition: state
entity_id: binary_sensor.martin_presence_delayed
state: 'on'
- condition: template
value_template: "{{ not is_state('input_select.martin_activity', 'Waking') }}"
action:
- service: input_select.select_option
data:
entity_id: input_select.martin_activity
option: Waking
- alias: alarm_dismissed_activity
initial_state: true
trigger:
platform: state
entity_id: sensor.phone_alarm
to: 'dismissed'
condition:
condition: and
conditions:
- condition: state
entity_id: binary_sensor.martin_presence_delayed
state: 'on'
- condition: template
value_template: "{{ not is_state('input_select.martin_activity', 'Awake') }}"
action:
- service: input_select.select_option
data:
entity_id: input_select.martin_activity
option: Awake
- alias: bedtime_action
initial_state: true
trigger:
platform: state
entity_id: sensor.phone_alarm
to: 'bedtime'
condition:
condition: state
entity_id: binary_sensor.martin_presence_delayed
state: 'on'
action:
- service: input_select.select_option
data_template:
option: 'Ambient'
entity_id: >
{% if is_state('input_boolean.guests', 'on') %}
input_select.bedroom_light_profile
{% else %}
input_select.light_profile
{% endif %}
- delay: 00:30:00
- service: input_select.select_option
data_template:
option: 'Night'
entity_id: >
{% if is_state('input_boolean.guests', 'on') %}
input_select.bedroom_light_profile
{% else %}
input_select.light_profile
{% endif %}
- alias: sleeping_action
initial_state: true
trigger:
platform: state
entity_id: input_select.martin_activity
to: 'Sleeping'
action:
- service: input_select.select_option
data_template:
option: 'Off'
entity_id: >
{% if is_state('input_boolean.guests', 'on') %}
input_select.bedroom_light_profile
{% else %}
input_select.light_profile
{% endif %}
- alias: sleep_paused_action
initial_state: true
trigger:
platform: state
entity_id: input_select.martin_activity
to: 'Sleep Paused'
condition:
condition: state
entity_id: binary_sensor.martin_presence_delayed
state: 'on'
action:
- service: input_select.select_option
data_template:
option: 'Night'
entity_id: >
{% if is_state('input_boolean.guests', 'on') %}
input_select.bedroom_light_profile
{% else %}
input_select.light_profile
{% endif %}
- alias: waking_action
initial_state: true
trigger:
platform: state
entity_id: input_select.martin_activity
to: 'Waking'
action:
- service: input_select.select_option
data_template:
option: 'Night'
entity_id: >
{% if is_state('input_boolean.guests', 'on') %}
input_select.bedroom_light_profile
{% else %}
input_select.light_profile
{% endif %}
- service: script.bedroom_sunrise
- service: script.wakeup_playlist
data:
device_entity_id: "media_player.east_side_speakers"
- alias: awake_action
initial_state: true
trigger:
platform: state
entity_id: input_select.martin_activity
to: 'Awake'
action:
- service: input_select.select_option
data_template:
option: 'Ambient'
entity_id: >
{% if is_state('input_boolean.guests', 'on') %}
input_select.bedroom_light_profile
{% else %}
input_select.light_profile
{% endif %}
- service: input_select.select_option
data:
entity_id: input_select.playlist_player
option: 'media_player.east_side_speakers'
- delay:
seconds: 1
- service: input_select.set_options
data_template:
entity_id: input_select.playlist
options:
- "==SCRIPT==morning_briefing"
- "{{ states.sensor.podcast_bbc_minute.state }}"
- "{{ states.sensor.podcast_24syv_nyheder.state }}"
- "==SCRIPT==wakeup_playlist"
- "==END=="
- delay:
seconds: 2
- service: media_player.volume_set
data_template:
entity_id: 'media_player.east_side_speakers'
volume_level: 0.5
- alias: up_and_walking_activity
initial_state: true
trigger:
platform: state
entity_id: binary_sensor.hallway_sensor
to: 'on'
condition:
condition: and
conditions:
- condition: state
entity_id: binary_sensor.martin_presence_delayed
state: 'on'
- condition: state
entity_id: input_select.martin_activity
state: 'Awake'
action:
- service: script.turn_on
data:
entity_id: script.morning_lights
- service: joaoapps_join.phone_send_tasker
data:
command: "sleep_tracking_stop"
- service: input_select.select_option
data:
entity_id: input_select.playlist_player
option: 'media_player.east_side_speakers'
- delay:
seconds: 1
- service: input_select.set_options
data_template:
entity_id: input_select.playlist
options:
- "==SCRIPT==morning_briefing"
- "{{ states.sensor.podcast_bbc_minute.state }}"
- "{{ states.sensor.podcast_daily_tech_news_show.state }}"
- "==END=="
- delay:
seconds: 2
- service: media_player.volume_set
data_template:
entity_id: 'media_player.east_side_speakers'
volume_level: 0.5