From 56576021fafbb5c6a6fb302d4c163faa772868fe Mon Sep 17 00:00:00 2001 From: TheThomaas Date: Wed, 14 Jan 2026 19:09:28 +0100 Subject: [PATCH] Add alarm clock blueprint --- alarm_clock.yaml | 115 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 alarm_clock.yaml diff --git a/alarm_clock.yaml b/alarm_clock.yaml new file mode 100644 index 0000000..af49a59 --- /dev/null +++ b/alarm_clock.yaml @@ -0,0 +1,115 @@ +blueprint: + name: Alarm Clock + description: Alarm Clock with wake up light + domain: automation + source_url: https://git.thethomaas.net/TheThomaas/home-assistant-blueprints/src/branch/main/alarm_clock.yaml + input: + alarm_time: + name: Alarm Time + description: Input containing the time of the alarm + selector: + entity: + domain: input_datetime + time_offset: + name: Time Offset + description: Offset to turn on the lights before the alarm + default: 5 + selector: + number: + min: 0 + max: 30 + binary_condition: + name: Alarm today + description: Trigger the alarm today ? + selector: + entity: + domain: binary_sensor + presence_condition: + name: Presence Conditions + description: Everything that can have a state 'home' + selector: + entity: + domain: + - input_select + - person + target_light: + name: Target Light + description: Light that will be turned on + selector: + entity: + domain: light + alarmed_turned_off: + name: Alarm Turned Off + description: Everything that can have a state on/off + selector: + entity: + domain: binary_sensor + # has_woken_up: + # name: Person has woken up + # description: Everything that can have a state on/off + # selector: + # entity: + # domain: binary_sensor + sleep_mode: + name: Sleep Mode + description: Switch to turn off before the alarm + selector: + entity: + domain: switch + +trigger_variables: + alarm_time: !input alarm_time + time_offset: !input time_offset + +variables: + binary_condition: !input binary_condition + presence_condition: !input presence_condition + target_light: !input target_light + # has_woken_up: !input has_woken_up + sleep_mode: !input sleep_mode + +trigger: + - platform: template + value_template: > + {% set Hour, Minute = states("sensor.time").split(":") %} + {% set seconds = Hour | int * 3600 + Minute | int * 60 %} + {% set offset = time_offset * 60 %} + + {% set time2 = state_attr(alarm_time, 'timestamp') | timestamp_custom('%H:%M') %} + {% set Hour2, Minute2 = time2.split(":") %} + {% set seconds2 = Hour2 | int * 3600 + Minute2 | int * 60 %} + + {{ seconds2 - offset == seconds }} + +condition: + - condition: state + entity_id: !input binary_condition + state: 'on' + - condition: template + value_template: > + {{ states(presence_condition) in ['Home', 'home'] }} + # - condition: state + # entity_id: !input has_woken_up + # state: 'off' + # for: + # hours: 8 + +action: + - service: switch.turn_off + entity_id: !input 'sleep_mode' + - service: light.turn_on + entity_id: !input 'target_light' + data: + brightness_pct: 100 + transition: "{{ time_offset * 60 }}" + - wait_for_trigger: + - platform: state + entity_id: !input alarmed_turned_off + to: "on" + - wait_template: "{{ is_state(has_woken_up, 'on') }}" + - delay: + minutes: 10 + - service: light.turn_off + entity_id: !input 'target_light' + data: + transition: 60 \ No newline at end of file