IOS alarm clock.app trigger command for HA

Anyone who figured out how an the alarm clock.app on iPhone could be used to trigger a command towards HA (to launch automations for my morning routine)? Or any alternative alarm clock app for that matter.

So far, all I’ve seen was the Sleep Cycle App that has an integration with the HUE bridge. But I don’t want to buy a light bulb to put somewhere in a cupboard so that it doesn’t bother anyone when it gets turned on/off (through which I could then launch automations). And the emulated_hue approach doesn’t seem 100% yet neither, from what I can read in other posts.

I’ve also seen some alternatives through an alarm functionality configured within HA itself and myself I’m using an approach through Google Calendar entries now, but that’s all not exactly what I was hoping/looking for.

4 Likes

I just figured this out today using the IOS shortcuts app. Here’s what my actions looks like it’s just a URL and a get content from URL

But I don’t think a timer or alarm can trigger a shortcut, can it?

Edit: solved in iOS 13 https://www.macstories.net/news/the-full-list-of-automation-triggers-in-shortcuts-for-ios-13/

I dont know about others I’m on 13 beta However i don’t see the “ when alarm is triggered” option yet

In Shortcuts, click automations at the bottom and select personal. You’ll be able to do it from there.

Unless I am seeing less than others, I only have the option to trigger an action either when an alarm is either stopped or snoozed (see screenshot below). That still not 100% what I’m looking for as I would want to ge able to trigger automations also before the time the alarm goes off (or at the very least when it is triggered). For example:

  • turn on the lights when the alarm goes off
  • turn on the heating in the bathroom 30 minutes prior to the alarm

The simple fact that this tread gets picked up again 2.5 years after I started it tells me that I am not the only one who is looking for such functionality.

2 Likes

Wait, what? :slight_smile:

How does this works with URL actually?
Didn’t know you could just post any command via webhook without an automation on Hassio.

Could you explain like I’m 5? :smile:

PS: I do have Hass Cloud/Nabu Casa

You most definitely are not the only one looking for this. I actually gave up on this because I know the limitations of Apple, but seems iOS 13 might make we want to look into it again.

automation:
  trigger:
    platform: event
    event_type: ifttt_webhook_received
    event_data:
      action: call_service
  action:
    service_template: '{{ trigger.event.data.service }}'
    data_template:
      entity_id: '{{ trigger.event.data.entity_id }}'

The URL is just and address to send the JSON Post message. this is the automation i use for all of my webhooks. IFTTT and otherwise. basically the json data that we enter falls into the templates and tells it what to do.

:exploding_head:

Thanks mate! Will try it out!

Would y’all mind going into a little more detail about how you set this up? I’m new to webhooks/NabuCasa as well as shortcuts with the new iOS.

Also was there a way to trigger something at or before the alarm time? Or only when the alarm is stopped or snoozed?

Not trying to hijack this thread, but the problem I’ve been trying to find a solution is very similar:

Now I’m setting the alarm time in both HA and Iphone, let’s say 06:00. In HA I’ve got automation etc. that triggers certain things way before 06:00 (for example at 03:00). Iphone alarm at 06:00 is just to physically get me awake.
How could these 2 be combined, so that when I set my alarm to 06:00 in Iphone, that time would be passed to HA? Could be some other app that the default Iphone alarm.

2 Likes

I want a solution on this issue as well!

1 Like

I am still using the same solution which I set up as a workaround when I initially asked this question.
Basically it means that I am using the CALDAV calendar integration

My partner an I have a shared icloud calendar (could be Google too I guess) in which we, among the agenda stuff that is important for both of us, also have an automatically recurring entry. In fact, we have 2 of those, one is for weekdays, the other one for weekend days.

name of calendar-entry: #WAKE-UP !!-30
start time: 7am (weekdays) or 8 am (weekends)
end time: not relevant

Important is the !!-30 as that is how I can trigger an offset x minutes (in this case 30) before the start of the “appointment”. That’s when here at home the lights start to fade towards the state we want them in when we wake up, the heating in the bathroom gets turned on, etc… At the start-time, a whole morning routine starts as well, including latest news broadcoast, local traffic, etc…

As the CALDAV sensor is updated regularly, I can do the exeptions (e.g. when we have to get up earlier or later than usual) via the Calendar of my iPhone . A few moments later, all is updated. Only thing to remember in the Calendar app is to pay attention that changes are only done to the relevant entries. It is an easy mistake to - most of the time unaware - update all recurring future entries of a calendar item instead of only the relevant one.

Since I set it up, we obviously changed things too. For instance, I now also have the workday-sensor set up, next to the calendar entry. That means that I can now forget to remove the calendar entry on a bank holiday during the week if we don’t want to be woken up. There will be no wake up routine at all on that day. Of course, if we simply want to be awake at another time on that bank holiday, we would change the exisitng value.

As a backup, my partner still uses the alarm clock in the iphone as well.
It’s more a failsafe (we never needed it, HA didn’t let us down), but it feels safer.

I have been looking at Shortcuts & Automations and it seems that you can now trigger actions based on what is done with an alarm (Snoozed or Stopped) but not with the beginning of the time. Or better, x minutes before the beginning.

I can share code if needed, but nothing that I used for this was particularly exceptional.

This looks like it’s gotten a lot easier with iOS 13 with the latest version of the HA companion app installed. No webhooks or even JSON required… see here:

I too am puzzled by Apple’s choice to only include alarm clock triggers that occur after user intervention. Alarm clocks in HA seem to have always been a dilemma, as attested to by the fact that there’s not even an official alarm clock card. Using the settings on your phone is an elegant way around this… Apple will probably add it eventually but give it a boost if you want:

Adding my name to the pile of users who wish they could trigger Home Assistant service calls when an alarm goes off, or a few minutes before, rather than after user intervention.

1 Like

I’m pretty incompetent when it comes to JSON & YAML, but I just set this up and tested it with an iOS Shortcut and Node-RED. I chose to use an input_boolean as my trigger, but I’m sure an Automation would work, too.

In Shortcuts, tap “+” to set up a new Automation (mine is already in the list on screen):

Tap “Create Personal Automation,” then “Alarm,” and set your parameters on the next screen. Tap “Next,” then “Add Action.” From here, you’ll search for and/or select “Dictionary.” “Add new item,” and select “Text.” In the Key field, you’ll enter entity_id. In the Text field, you’ll enter the full entity_id of your input_boolean, in my case, input_boolean.my_alarm_active.

After that, click the “+” button, and search for and/or select “Home Assistant.” Select “Call Service,” and on the next screen, tap the blue “Service” link to add the service you want to call. In my case, it’s input_boolean.turn_on. Like I said, you could use an Automation here, too.

This is what mine looks like when it’s done:

Then, I just used a Node-RED flow to 1) call some services to turn on lights, etc., and then 2) turn off my input_boolean.

I hope this helps. I’ve gotten a lot out of this community, and it’s nice to be able to finally answer a question…

1 Like

That is absolutely amazing and even 2 years later, your assistance here has allowed me to do exactly what i wanted! :smiley:

I had previously been using the “focus” feature that is passed through the companion app, but it is no way near as good as this!

Thank you so much :slight_smile:

1 Like