Skip to content

Instantly share code, notes, and snippets.

@x86-39
Last active October 2, 2021 23:33
Show Gist options
  • Save x86-39/8c2d717d80eaebe382df39517f3201ae to your computer and use it in GitHub Desktop.
Save x86-39/8c2d717d80eaebe382df39517f3201ae to your computer and use it in GitHub Desktop.
Home Assistant Morning Alarm

Home Assistant Card & Automation for a script at a specified time, the time can be configured through a card and be disbabled. A different automation can automatically re-enable it if it would have ran but was disabled.

configuration.yaml

input_boolean:
  alarm_enabled:
    name: "Enable Alarm Tomorrow"
    initial: on
    icon: mdi:theme-light-dark

input_datetime:
  alarm_monday:
    name: "Alarm on Monday"
    has_time: true
    has_date: false
    initial: "08:00"
  alarm_tuesday:
    name: "Alarm on Tuesday"
    has_time: true
    has_date: false
    initial: "08:00"
  alarm_wednesday:
    name: "Alarm on Wednesday"
    has_time: true
    has_date: false
    initial: "06:00"
  alarm_thursday:
    name: "Alarm on Thursday"
    has_time: true
    has_date: false
    initial: "06:00"
  alarm_friday:
    name: "Alarm on Friday"
    has_time: true
    has_date: false
    initial: "08:00"
  alarm_saturday:
    name: "Alarm on Saturday"
    has_time: true
    has_date: false
    initial: "10:00"
  alarm_sunday:
    name: "Alarm on Sunday"
    has_time: true
    has_date: false
    initial: "11:00"

Entities Card

type: entities
entities:
  - entity: input_boolean.alarm_enabled
  - entity: input_datetime.alarm_monday
  - entity: input_datetime.alarm_tuesday
  - entity: input_datetime.alarm_wednesday
  - entity: input_datetime.alarm_thursday
  - entity: input_datetime.alarm_friday
  - entity: input_datetime.alarm_saturday
  - entity: input_datetime.alarm_sunday
title: Alarms

automations.yaml

# Alarm Automation
- id: '1632921598103'
  alias: Alarm
  description: Morning Alarm
  trigger:
  - platform: time
    at: input_datetime.alarm_monday
    id: alarm_monday
  - platform: time
    at: input_datetime.alarm_tuesday
    id: alarm_tuesday
  - platform: time
    at: input_datetime.alarm_wednesday
    id: alarm_wednesday
  - platform: time
    at: input_datetime.alarm_thursday
    id: alarm_thursday
  - platform: time
    at: input_datetime.alarm_friday
    id: alarm_friday
  - platform: time
    at: input_datetime.alarm_saturday
    id: alarm_saturday
  - platform: time
    at: input_datetime.alarm_sunday
    id: alarm_sunday
  condition:
  - condition: or
    conditions:
    - condition: and
      conditions:
      - condition: trigger
        id: alarm_monday
      - condition: time
        weekday:
        - mon
    - condition: and
      conditions:
      - condition: trigger
        id: alarm_tuesday
      - condition: time
        weekday:
        - tue
    - condition: and
      conditions:
      - condition: trigger
        id: alarm_wednesday
      - condition: time
        weekday:
        - wed
    - condition: and
      conditions:
      - condition: trigger
        id: alarm_thursday
      - condition: time
        weekday:
        - thu
    - condition: and
      conditions:
      - condition: trigger
        id: alarm_friday
      - condition: time
        weekday:
        - fri
    - condition: and
      conditions:
      - condition: trigger
        id: alarm_saturday
      - condition: time
        weekday:
        - sat
    - condition: and
      conditions:
      - condition: trigger
        id: alarm_sunday
      - condition: time
        weekday:
        - sun
  action:
  - service: script.bulbs_wake_up_sequence # Replace with your service!
  mode: single
# This re-enables the alarm automatically if it was disabled and would have ran
- id: '1632947224475'
  alias: Alarm Re-enable
  description: Re-enables Morning Alarm
  trigger:
  - platform: time
    at: input_datetime.alarm_monday
    id: alarm_monday
  - platform: time
    at: input_datetime.alarm_tuesday
    id: alarm_tuesday
  - platform: time
    at: input_datetime.alarm_wednesday
    id: alarm_wednesday
  - platform: time
    at: input_datetime.alarm_thursday
    id: alarm_thursday
  - platform: time
    at: input_datetime.alarm_friday
    id: alarm_friday
  - platform: time
    at: input_datetime.alarm_saturday
    id: alarm_saturday
  - platform: time
    at: input_datetime.alarm_sunday
    id: alarm_sunday
  condition:
  - condition: or
    conditions:
    - condition: and
      conditions:
      - condition: trigger
        id: alarm_monday
      - condition: time
        weekday:
        - mon
    - condition: and
      conditions:
      - condition: trigger
        id: alarm_tuesday
      - condition: time
        weekday:
        - tue
    - condition: and
      conditions:
      - condition: trigger
        id: alarm_wednesday
      - condition: time
        weekday:
        - wed
    - condition: and
      conditions:
      - condition: trigger
        id: alarm_thursday
      - condition: time
        weekday:
        - thu
    - condition: and
      conditions:
      - condition: trigger
        id: alarm_friday
      - condition: time
        weekday:
        - fri
    - condition: and
      conditions:
      - condition: trigger
        id: alarm_saturday
      - condition: time
        weekday:
        - sat
    - condition: and
      conditions:
      - condition: trigger
        id: alarm_sunday
      - condition: time
        weekday:
        - sun
  action:
  - service: input_boolean.turn_on
    target:
      entity_id: input_boolean.alarm_enabled
  mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment