I will show you how to create a trigger that uses your phones next alarm. This can be a little tricky to setup, but works perfect when used correct.
I use this for my morning wake-up automation, that runs a sunrise in the bedroom, start the Bluesound music on the right radio channel, and slowly increases the volume. See how to control your Bluesound device from Home Assistant.
Requirements:
– You have installed the Home Assistant companion app on your phone.
Start by enabling the sensor in your Home Assistant companion app on your phone.
Go to “Manage sensors” – “Next alarm” and enable it.
It will show you when the next alarm is, and what package (app) on your phone that have the next alarm.
If you like me, uses the calendar and have notifications in the calendar, these will show up in next alarm. It’s by design, and you can’t get rid of it, but you can make Home Assistant ignore all the alarms not coming from apps on your allow list.
Under “Local Time” you can see the next alarm.
Under “Package” you can see the app with the next alarm.
At the button you have the “Allow list” where you can specify the apps you would like Home Assistant to respond to.
In my setup I only want alarms from my built-in alarm app on my phone, so I allow that app by clicking on “Allow list” and select it.
In my setup I only want alarms from my built-in alarm app on my phone, so I allow that app by clicking on “Allow list” and select it.
If we go to entities in Home Assistant and search for “Next Alarm” we will find a new sensor with the time for the next alarm.
Next step is to use this sensor in an automation.
Create a trigger by pressing “Add trigger” and choose “Template”. In “Value template” paste 1 of these examples.
The first example triggers at the next alarm time.
The next example triggers 15 min before the next alarm.
You can adjust the time by changing the value “900” to the number of seconds you like.
{{now().strftime('%a %h %d %H:%M %Z %Y') == (((state_attr('sensor.sm_a546b_next_alarm', 'Time in Milliseconds') | int / 1000 ) ) | timestamp_custom('%a %h %d %H:%M %Z %Y'))}}
{{now().strftime('%a %h %d %H:%M %Z %Y') == (((state_attr('sensor.sm_a546b_next_alarm', 'Time in Milliseconds') | int / 1000 | int - 900) ) | timestamp_custom('%a %h %d %H:%M %Z %Y'))}}
I use the 15 min before next alarm as trigger, so I can have a nice sunrise and start the music slowly before the alarm on my phone start.
I use this every morning, both on workdays and in the weekends, and it have never failed me. I really enjoy the ability to control the volume fade-in in Home Assistant and make it much more smooth than in the Bluesound app.
Now that Home Assistant know exactly when you wakeup everyday, only your fantasy limit your possibilities. Radio and sunrise is only the beginning, and you could turn on the coffee maker, and tons of other automations that make your life a little easier.
This was made and tested on Home Assistant version 2023.12.4.