Set Phone Alarms with Your Voice Assistant
Want to set alarms on your Android phone just by talking to your Home Assistant-powered voice assistant? With the right script and ExtendedOpenAI function, you can say things like "Set an alarm for 7:30 on Alice's phone" and it will work - no tapping, no typing!
How This Works
The system combines:
- A Home Assistant script that sends an alarm command to your chosen Android phone (via the Home Assistant Companion App).
- An ExtendedOpenAI function so your voice assistant can trigger this script using natural language.
- Device "friendly names" mapped to unique device IDs, so you can just say "Bob's phone" and Home Assistant knows exactly which device to use.
Step 1: Mapping Device IDs to Friendly Names
Home Assistant identifies devices using a long string (device ID), not their visible names. You can find your Android phone's device ID like this:
- Go to Settings → Devices & Services → Devices.
-
Click on your phone; look at the browser URL. The last part is the device ID (e.g.,
23c5c2f12ed640b6c8e1007bdebc3003). - Make a list of device IDs and their friendly names:
- Bob's Phone:
23c5c2f12ed640b6c8e1007bdebc3003 - Alice's Phone:
6af3e434ca7c4a709bbff22ef455c055
- Bob's Phone:
Step 2: The Home Assistant Script
Here is a script you can use in Home Assistant to set an alarm on a specific Android device. It accepts the time and the device ID, making it voice-assistant friendly.
alias: Set Android Alarm
description: Set an alarm on the Android phone
fields:
alarm_time:
description: Time to set the alarm for
example: "08:00:00"
selector:
time: null
name: Alarm Time
required: true
phone:
selector:
device:
integration: mobile_app
name: Phone
description: >-
The phone to set the alarm on (Must be an android phone, with HA companion
app & Google clock installed, and correct permissions set)
sequence:
- variables:
hour: "{{ alarm_time.split(':')[0] | int }}"
minute: "{{ alarm_time.split(':')[1] | int }}"
- data:
message: command_activity
data:
ttl: 0
priority: high
intent_package_name: com.google.android.deskclock
intent_action: android.intent.action.SET_ALARM
intent_extras: "android.intent.extra.alarm.HOUR:{{ hour }},android.intent.extra.alarm.MINUTES:{{ minute }},android.intent.extra.alarm.SKIP_UI:true"
action: notify.mobile_app_{{ device_attr(phone, 'name') | slugify }}
mode: single
-
alarm_time: The time for the alarm in
HH:MM:SSformat. Only the hour and minute are used. - phone: The Android device you want to set the alarm on.
- intent_extras: MUST be a single line with no spaces after commas for the alarm to work correctly (hour and minute).
- notify.mobile_app_... Sends the command to the right phone using its device name (converted to the correct format).
Step 3: ExtendedOpenAI Function Spec (with Friendly Name Support)
Now, let's let your voice assistant understand friendly phone names. Here's how you define it in your OpenAI tool/function spec:
- spec:
name: set_alarm_on_android_phone
description: Set an alarm on a specific Android phone using its friendly name (e.g. "Bob's Phone") and the alarm time.
parameters:
type: object
properties:
phone:
type: string
description: The phone to set the alarm on.
enum:
- 23c5r2f12ed640b6c8k1657bdebc3103
- 6af3e434ca7c4a709bbff22ef455c055
enumNames:
- "Bob's Phone"
- "Alice's Phone"
alarm_time:
type: string
description: The time for the alarm in HH:MM format (24-hour clock).
required:
- phone
- alarm_time
function:
type: script
sequence:
- service: script.set_android_alarm
data:
phone: "{{ phone }}"
alarm_time: "{{ alarm_time }}"
response_variable: _function_result
- enum: List of device IDs (from Step 1).
- enumNames: The friendly names the assistant will show and accept in voice commands.
- When you say "Set an alarm on Bob's Phone," the function automatically uses the right device ID for Home Assistant.
Step 4: Using the Voice Assistant
- Make sure each phone is set up in Home Assistant and the Companion App is installed with notifications enabled and Google Clock installed.
- Add the script and OpenAI function definition as shown above.
-
Try a voice command like:
Set an alarm for 7:30 on Alice's phone - The phone will receive the alarm instantly - no extra steps!
Troubleshooting & Tips
-
If the alarm only sets for the hour and not the minute, make sure
intent_extrasis on a single line with no spaces after commas. - If you change a device name or re-add a phone, double-check the device ID and update your mapping.
- The Companion App needs to have notification and activity permissions. Also, ensure Google Clock is installed and set as default for alarms.
Summary
With just a small amount of setup, you can use friendly, natural language to set alarms on any Android phone in your house using Home Assistant and ExtendedOpenAI. This approach keeps things simple for everyone - no need to remember device IDs or tap through menus ever again!