[Feature request] Add 'next_alarm' as entity in Home Assistant

Hi,

Is it at all possible to add the ‘next alarm datetime’ as an entity in Home Assistant, similar to the Android companion app? This would be really convenient to start morning routines before the alarm goes off.

Thanks

Marvin

As far as I know, this information is not possible to retrieve on iOS.

If it’s not super important to do things before your alarm goes off, you can do this with the Shortcuts app that is included with iOS by default.

  1. Inside the Shortcuts app is a tab called “Automation”, tap that and then the + button
  2. Create a Personal Automation with the “Alarm” trigger. Select which alarm you want to trigger from (wake-up alarm, or a custom alarm) and how you want to trigger. It can be one of two things, alarm snoozed or stopped.
  3. After hitting next then you select your action. Press “Add Action”, type “Home Assistant” into the search bar, and then pick the “Call Service” action.
  4. Tap the Service text and it will show all available services to pick from. Select automation.trigger and then for the service data put in {"entity_id":"automation.morning_routine"} – or whatever yours is called. Make sure that “Show When Run” is toggled off.
  5. On the next screen make sure that Ask Before Running is toggled off. And hit Done/Save.

Now when your morning alarm goes off and you hit the snooze or stop button on your phone, it will trigger your Home Assistant morning routine.

1 Like

Thanks for your extensive reply. This is exactly what I am currently doing. However, I would like to perform some actions before the alarm goes off, for example:

  • Triggering my wake up light
  • Heat the bathroom so it’s nice and warm when I get up

Is there any way to achieve this with iOS, without manually syncing alarms to Home Assistant?

After switching from android to iOS, that’s the feature I miss the most!
With my current solution I have to delete the earlier (and therefore inactive) alarms, as shortcuts doesn’t differ between active and inactive alarms.

My shortcut looks as follows:

  1. clock > show all alarms
  2. scripts > first object of alarms (this can also be changed to ask which alarm you want to sync)
  3. dictionary >
    entity_id - input_datetime.youralarm (or whatever)
    time - object from list
  4. home assistant > call service input_datetime.set_datetime with data of dictionary

Trigger is closing the clock app.

Screenshots, but in German:

3 Likes

You’re a legend. I am gonna give this a try, thanks!

Thanks @M1ke for the direction! Personally I had to make some adjustments to get it to work; so posting here for the ones having comparable troubles:

  1. clock > show all alarms
  2. scripts > first object of alarms (this can also be changed to ask which alarm you want to sync)
  3. Format date > Format ‘Element from list’.
    3.1 Then click on this variable (within the format time block), and from the selection Menu, change ‘Alarm’ to ‘Time’. If you do not do this, it will use the name of the Alarm as a variable instead of the Time.
    3.2 Select Date notation: none.
    3.3 Select Time notation: short
  4. dictionary >
    entity_id - input_datetime.youralarm (or whatever)
    time - Formatted date
  5. home assistant > call service input_datetime.set_datetime with data of dictionary
  6. AUtomatically run the script to stay up to date. I run it when I open the Clock app, when I close the clock app, when I connect my phone to the charger, and every night at 21:00

Note that when you make an error somewhere and get a wrongly formatted time, the home assistant service call does not succeed. Apprantly it checks whether the field ‘time’ is correctly formatted. To test it out, I called the service with a manual time and added my variable under an extra dictionary entry (‘test’). That case, I could test and call the service until I had the right configuration.

Attached my setup in Dutch: