Enable next alarm sensor on the HA Android App
HA App → Settings → Companion App → Manage Sensors → Next Alarm → enable
Import the Blueprint
Create an Automation based on the imported Blueprint Adjustable Wake-up to Android alarm
3.1 In the Alarm Helper section you need to create a new Date / Time Helper and select that.
Set an alarm on your phone
Features
Offset (how many seconds before the phone alarm goes off)
Select any action to run, e.g. turn on lights, play media, etc…
Select any condition, e.g. only run if person is home, only run if sun has not risen yet, etc…
Some Inspiratios: (at your own risk)
If the sun has not risen yet, turn on the bedroom lights 10 minutes before the phone alarm goes off
If person 1 is at home, switch on the TV and tune it to a news channel 30 minutes before the phone alarm rings
If person 2 is not at home, retrieve today’s calendar events and announce them on the bedroom speaker 2 minutes before the alarm is set to go off
If the temperature outside is below 0°C, start warming up the car 45 minutes before the alarm is set to go off
Wake up to an inspirational quote from a text-to-speech service, right before the alarm goes off
Requirements
Android phone with mobile app
Next alarm sensor activated
Date and time helper entity, can be created in UI
Home Assistant Version 2024.10.x or higher
Tips, Tricks and Gotchas
You can add the helper entity to your lovelace dashboard to see the time when the actions will run.
You can test the action in the automation editor (run). I’ll will even check the conditions you have configured.
Changelog
2024-11.22: V3, Action can be tested, bugfixes and better snooze Handling, thanks @martinelv for the help here
2023-10-15: Fix when disabling the phones alarm the automation was still running @Propboot
2023-08-06: Initial release
blueprint:
name: Adjustable Wake-up to Android alarm
description: >
# Adjustable Wake-up to Android alarm v3
When the specified __conditions__ are satisfied, it runs these specified __actions__ prior the phone's next alarm
## 🔧 Requirements:
- [Android app](https://play.google.com/store/apps/details?id=io.homeassistant.companion.android) installed on your phone
- Next alarm sensor activated in the app (HA App → Settings → Companion App → Manage Sensors → Next Alarm → enable)
- Date and time helper entity, can be created in UI
- Home Assistant version 2024.10.0 or higher
## 💡Some Inspiratios: **(at your own risk)**
- If the sun has not risen yet, turn on the bedroom lights 10 minutes before the phone alarm goes off
- If person 1 is at home, switch on the TV and tune it to a news channel 30 minutes before the phone alarm rings
- If person 2 is not at home, retrieve today's calendar events and announce them on the bedroom speaker 2 minutes before the alarm is set to go off
- If the temperature outside is below 0°C, start warming up the car 45 minutes before the alarm is set to go off
- Wake up to an inspirational quote from a text-to-speech service, right before the alarm goes off
domain: automation
author: op00
homeassistant:
min_version: 2024.10.0
source_url: https://community.home-assistant.io/t/adjustable-wake-up-to-android-alarm/599838/26
input:
offset:
name: Offset
description:
"Enter an offset in seconds for the next alarm. Specify when the action should run __before__ the alarm\n\n
_max: 3600s = 1 hour_"
selector:
number:
min: 0.0
max: 3600.0
mode: box
step: 1.0
unit_of_measurement: Seconds
alarm_source:
name: Alarm Source
description: "Select the alarm source\n\n
_your Android phone's next alarm sensor_"
selector:
entity:
filter:
integration: mobile_app
device_class: timestamp
multiple: false
alarm_helper:
name: Alarm Helper
description: "Select the date and time helper\n\n
_manually created helper_"
selector:
entity:
filter:
domain: input_datetime
multiple: false
conditions:
name: Conditions
description:
"Choose the circumstances under which the actions will or will not run\n\n
_can be multiple or none_"
default: []
selector:
condition: {}
actions:
name: Actions
description: "Actions to run before alarm goes off\n\n
_can be multiple_"
default: []
selector:
action: {}
variables:
offset: !input offset
trigger:
- platform: state
entity_id:
- !input alarm_source
id: helper_update
- platform: time
at: !input alarm_helper
id: wake_up
actions:
- alias: Check trigger update helper / alarm mode
choose:
- conditions:
- condition: trigger
id: helper_update
sequence:
- delay:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
- alias: Check alarm sensor
if:
- condition: template
value_template: "{{ trigger.to_state.state not in [\"unknown\",\"unavailable\"] }}"
alias: Check if sensor has a state
then:
- data:
timestamp: "{{ (as_timestamp(trigger.to_state.state) |int ) - (offset)}}"
target:
entity_id: !input alarm_helper
action: input_datetime.set_datetime
alias: Set helper to date time - offset
else:
- data:
datetime: "1970-01-01 00:00:00"
target:
entity_id: !input alarm_helper
action: input_datetime.set_datetime
alias: Set helper to 1970-01-01 00:00:00, disable alarm
alias: Update helper
- conditions:
- condition: trigger
id: wake_up
- condition: and
conditions: !input conditions
sequence: !input actions
alias: Alarm Actions
default:
- choose:
- conditions:
- condition: and
conditions: !input conditions
sequence: !input actions
alias: Alarm Actions (default)
mode: parallel
trace:
stored_traces: 21
ToDo
Spellcheck
Ability to only listen to a specific alarm from android (not sure if that’s possible)
Fix manual trigger for testing
Handle snooze, setting a new alarm when the alarm is still running.
🧑🏼🤝🧑🏻 Contributions
Very welcomed and please do, so far:
Thanks @Propboot for providing a fix, when the alarm gets disabled
@op00 I now see what you realized, that everything people have been requesting of your previous blueprint can all be implemented using conditions. Brilliant in it’s simplicity!
Hi @op00
Thank you for this great blueprint. I noted that deactivating the alarm does not deactivate the scheduled alarm sequence. So I added the following condition:
I want to make a “wake up light” where a light slowly increases in brightness from the “offset” time until the alarm goes off. I see this older blueprint has functionality for this: Wake up to lights at next alarm (android), but since that one is deprecated I’m guessing it should also be possible with this one. Could anyone point me in a direction on how to implement that?
@kwint That’s what I use it for. If your light supports transition. You can add a service call ligth.turn_on with transition time to the actions.
Add Action → Call Service → Light: turn on → Select your Target → Select Transition (set a time) → select Brightness (target brightness)
When I make a new automation the alarm which is already sets works. But when I change the alarm the steps in the automation change.
If I look at the trace timeline it says: “Triggered by the state of sensor.tel_ruben_next_alarm at December 22, 2023 at 15:42:42” and suddenly only chooses option 1 therefore not executing the sequence.
sorry, not sure if I understand your question/problem. Sorry. But the blueprint/automation has two triggers. One, when the alarm is being set/changed (changes the helper) and the time condition (actual alarm, with the configures actions)
Thank you for this blueprint, it is exactly what I was looking for.
But I still have a question of understanding:
If I create several automations with the blueprint, do I need a separate helper for each automation or can the automations share one helper?
It was working for a while, but since a few days ago I have an issue: the first alarm fails to trigger anything, and only the subsequent snoozes work.
But even weirder: it works fine when I use an alarm in the middle of the day; only the morning one fails
There should be something happening at 8:42(alarm at 8:45 with 180s offset) but there is nothing.
It is simply not triggering
NOTE: the logs contain a test around 15:48 to confirm it indeed works sometimes/in the middle of the day.
Also I originally thought there could be an issue with the fact that I use a “long running” script as action (Sunrise Simulator Manual) but that does not seem to be an issue (and it worked for a while anyway).
I have in fact the same problem. In my oppion there is a design failure at the blueprint.
My alarm is set automatically to the next event on the next day at the same time.
Actions are starting with an offset of -60 and if I turn off the alarm the automation is already running. Trigger for a new alarm is starting but cannot run while the automation is already running.
I’v set the automation in mode parallel. In this way it is working but it isn’t the best solution.
Would be awesome to have also an offset (+) for the new next_alarm trigger. Or something else.
Sorry, I don’t really understand the problem.
If you could maybe list a timeline (Setting the alarm, Snoozing, state of the helper, state of the automation). It may be that your alarm app is different and therefore behaves different than mine.
I usually have 3 alarm clocks set. 5 seconds before the alarm clock triggers actions - turning on the light or raising the blinds (depending on the sun level) and starting the alarm clock on the nest speaker with a one minute delay.
This one-minute delay means that when the phone alarm clock starts after 5 seconds and the automation wants to set the time of the next alarm clock it does not happen because the automation is already running.
I know that getting rid of the delay will solve the problem but I’m looking for a way to trigger some of the action also after the alarm clock, not just before. To be honest, raising the blinds/ turning on the light would also suit me better after the alarm clock than 5 seconds before.