
Smart Alarm Clock
What is the Smart Alarm Clock?
The Smart Alarm Clock is a Home Assistant automation that is my attempt to make the ultimate Alarm Clock. It links a Sonos speaker with Google Calendar and my Phone to provide flexibility and reliability to waking up on time.
Here are the problems I've found with other alarm clocks:
- Phone - Repetitive sounds
- Sonos - Unreliable. Sometimes the alarm radio doesn't play, so it alerts with a boring fallback beep
- Traditional - Both of the above!
Also when a bank holiday or real holiday comes around. You have to remember to turn off (and back again) the alarm!
Home Assistant Integrations
To make this work, we need to add some required integrations to Home Assistant:
- Sonos - To play radio on the Sonos speaker
- Workday Sensor - To prevent the alarm triggering on weekends and bank holidays. Add your locale and exclude weekends and holidays
- Google Calendar - To be able to schedule date and time for a bespoke alarm, or to prevent the alarm going off on a particular day or range of days. In Google Calendar, create a new calendar just for your alarm clock.
- Home Assistant Phone App - To let you set a secondary alarm on your phone
After these are added to Home Assistant, we can start creating the automations and scripts.
Alarm Automation
We need to create an automation to trigger the alarm at a certain time every day. The conditions for this restrict when the alarm will start, so we need to add a few:
- Workday sensor: On - This makes sure that it is a workday (not weekend or bank holiday)
- Calendar: Off - If the calendar has an event for now then we do not want the alarm to trigger.
- Person zone: Home - Make sure I am at home
- Alarms scheduled for today: Off - If another event is in the calendar, the alarm is scheduled for later, so don't start now
Here's my alarm automation yaml:
alias: Alarm for Paul
description: ""
triggers:
- at: "07:30:00"
trigger: time
conditions:
- condition: state
entity_id: binary_sensor.workday_sensor
state: "on"
- condition: state
entity_id: calendar.work
state: "off"
- condition: zone
entity_id: person.paul
zone: zone.home
- condition: state
entity_id: input_boolean.alarms_scheduled_today
state: "off"
enabled: true
actions:
- action: notify.mobile_app_honor_magic_v3
data:
data:
intent_package_name: com.google.android.deskclock
intent_action: android.intent.action.SET_ALARM
intent_extras: >-
android.intent.extra.alarm.HOUR:{{ (now() +
timedelta(minutes=15)).strftime('%H')
}},android.intent.extra.alarm.MINUTES:{{ (now() +
timedelta(minutes=15)).strftime('%M')
}},android.intent.extra.alarm.SKIP_UI:true
message: command_activity
- if:
- condition: numeric_state
entity_id: sensor.honor_magic_v3_battery_level
below: 10
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.honor_magic_v3_interactive
for:
hours: 0
minutes: 2
seconds: 0
state: "on"
enabled: true
- condition: not
conditions:
- condition: state
entity_id: binary_sensor.honor_magic_v3_interactive
for:
hours: 1
minutes: 0
seconds: 0
state: "on"
enabled: true
then:
- data:
message: "⏰️ "
title: Alarm
data:
channel: Alarm
action: notify.mobile_app_honor_magic_v3
- stop: Phone is unlocked.. abort alarm and send notification instead
else: []
enabled: true
- action: script.fade_in_radio
metadata: {}
data: {}
mode: restart