Skip to content

Instantly share code, notes, and snippets.

@jceloria
Created February 25, 2019 17:52
Show Gist options
  • Save jceloria/c732348a204ff17415366c0c4a0fee38 to your computer and use it in GitHub Desktop.
Save jceloria/c732348a204ff17415366c0c4a0fee38 to your computer and use it in GitHub Desktop.
alarm clock package in HA
---
# ############################################################################ #
# ### ALARM CLOCK PACKAGE #################################################### #
group:
# -------------------------------------------------------------------------- #
alarm_clock:
name: Alarm Clock
entities:
- input_datetime.alarm_clock
- input_boolean.alarm_clock_status
input_boolean:
# -------------------------------------------------------------------------- #
alarm_clock_status:
name: Alarm Clock Status
icon: mdi:alarm-check
initial: 'on'
input_datetime:
# -------------------------------------------------------------------------- #
alarm_clock:
name: Alarm Time
icon: mdi:timer
has_date: false
has_time: true
initial: '06:00'
sensor:
# -------------------------------------------------------------------------- #
- platform: time_date
display_options:
- 'date'
- 'time'
- platform: template
sensors:
alarm_clock_offset:
value_template: >-
{% set alarm = strptime(states.sensor.date.state+' '+states.input_datetime.alarm_clock.state,'%Y-%m-%d %H:%M') %}
{{ (as_timestamp(alarm) | round(0) - 15 * 60) | timestamp_custom('%H:%M') }}
script:
# -------------------------------------------------------------------------- #
wake_up:
sequence:
- event: LOGBOOK_ENTRY
event_data:
message: 'Executing wake_up script'
- service: scene.turn_on
entity_id: scene.master_bed_sunrise
- delay: 00:15:00
- service: notify.all
data:
message: "Rise and shine, assholes!"
data:
priority: 1
sound: updown
- service: scene.turn_on
entity_id:
- scene.master_bed_on
- scene.master_bath_on
automation:
# -------------------------------------------------------------------------- #
- alias: Artificial Sunrise Alarm Clock
initial_state: true
trigger:
- platform: template
value_template: >
{{ states.sensor.time.state == states.sensor.alarm_clock_offset.state }}
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.alarm_clock_status
state: 'on'
action:
- service: script.wake_up
- alias: Disable Alarm
initial_state: true
trigger:
- platform: state
entity_id: input_boolean.alarm_clock_status
to: 'off'
action:
- service: scene.turn_on
entity_id: scene.master_bed_off
- service: script.turn_off
entity_id: script.wake_up
# ############################################################################ #
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment