From 38b12d0f116c1b0706703ffa41d50921ccd3c2ef Mon Sep 17 00:00:00 2001 From: Georgi Gardev Date: Sat, 28 Mar 2020 02:24:43 +0200 Subject: [PATCH] Initial version of alarm clock --- config/lovelace/00_home.yaml | 5 +++ config/packages/modes/sleep_mode.yaml | 54 +++++++++++++++++++++++++ config/packages/modules/music.yaml | 2 +- config/packages/routines/waking_up.yaml | 3 ++ 4 files changed, 63 insertions(+), 1 deletion(-) diff --git a/config/lovelace/00_home.yaml b/config/lovelace/00_home.yaml index 57f21d9..91237e9 100644 --- a/config/lovelace/00_home.yaml +++ b/config/lovelace/00_home.yaml @@ -125,6 +125,11 @@ cards: # Column 3: Misc - type: vertical-stack cards: + - type: entities + title: Alarm + entities: + - input_boolean.alarm_enabled + - input_datetime.alarm_time - type: "custom:weather-card" current: true details: true diff --git a/config/packages/modes/sleep_mode.yaml b/config/packages/modes/sleep_mode.yaml index 1320e4c..0fd65d4 100644 --- a/config/packages/modes/sleep_mode.yaml +++ b/config/packages/modes/sleep_mode.yaml @@ -1,8 +1,17 @@ +input_datetime: + alarm_time: + name: Wake up Time + has_date: false + has_time: true + input_boolean: sleep_mode: name: Sleep mode initial: off icon: mdi:sleep + alarm_enabled: + name: Enable alarm + icon: mdi:alarm automation: - alias: Sleep mode · Enable @@ -38,3 +47,48 @@ automation: input_boolean.turn_off {% endif %} entity_id: input_boolean.sleep_mode + + - alias: Alarm · Wake up + trigger: + platform: template + value_template: "{{ states('sensor.time') == states('input_datetime.alarm_time')[0:5] }}" + condition: + condition: and + conditions: + - condition: state + entity_id: input_boolean.alarm_enabled + state: "on" + - condition: state + entity_id: input_boolean.sleep_mode + state: "on" + action: + - service: script.music_play + data: + volume_level: 0.05 + - delay: 00:01:00 + - service: script.sonos_say + data: + message: "Hey! It's time to wake up!" + - delay: 00:00:10 + - service: media_player.volume_set + entity_id: media_player.master_bedroom + data: + volume_level: 0.1 + - delay: 00:02:00 + - service: script.sonos_say + data: + message: "Good morning! Time to get out of bed!" + - delay: 00:00:10 + - service: media_player.volume_set + entity_id: media_player.master_bedroom + data: + volume_level: 0.2 + - delay: 00:05:00 + - service: script.sonos_say + data: + message: "Hey! It's time to wake up!" + - delay: 00:00:10 + - service: media_player.volume_set + entity_id: media_player.master_bedroom + data: + volume_level: 0.3 diff --git a/config/packages/modules/music.yaml b/config/packages/modules/music.yaml index 3e78b02..b8dcc71 100644 --- a/config/packages/modules/music.yaml +++ b/config/packages/modules/music.yaml @@ -45,7 +45,7 @@ script: - service: media_player.volume_set entity_id: group.all_sonos data_template: - volume_level: "{{ volume | default(0.3) }}" + volume_level: "{{ volume_level | default(0.3) }}" - service: media_player.shuffle_set data_template: entity_id: "{{ states('input_select.sonos_leader') }}" diff --git a/config/packages/routines/waking_up.yaml b/config/packages/routines/waking_up.yaml index 81c020c..ec5ae60 100644 --- a/config/packages/routines/waking_up.yaml +++ b/config/packages/routines/waking_up.yaml @@ -5,6 +5,9 @@ script: - service: fan.turn_off entity_id: fan.philips_airpurifier + - service: media_player.media_stop + entity_id: media_player.master_bedroom + - service: script.routine_morning_briefing - wait_template: "{{ is_state('input_boolean.sarah_talking', 'off') }}" timeout: 00:02:00