Sync next iOS16+ alarm clock in HA (with Shortcuts and companion app)

Are you using iOS 17? What do you see at the privacy settings?

Yup I’m on latest iOS 17 beta.

EDIT: I think it may be language related on your shortcut, I’m english, but noticed you had “If Name Contains Wekker”, I presume Wekker needs changing to the english equivalent on my shortcut.

Yeah ‘Wekker’ is Dutch for Alarm (and that’s the Label I gave my alarm on the iPhone). BTW have you tried to start the shortcut once? I only noticed this, when I launched the shortcut and it showed a popup asking me for this premission. After this I found the Privacy screen where I could set it to Always.

Ah thats it, I’ve changed it over to Alarm, but your biggest clue is the name you gave your alarm. I was using the bedtime / sleep schedule alarm so looks like that part is still broken on ios17.

Yeah, that never seemed to work (at least I always used an ‘extra’ alarm which went off at the same time). Not sure the ‘Bed Time’ schedule alarm could be used.

Hi there, I issued this missing alarm to apple. Hope they will add the wake-up alarm to shortcuts shortly.

1 Like

Found a work around. Replace the Find Alarm block with two Edit Sleep Alarm blocks set to Toggle. The output of the Edit Sleep Alarm block lets you see if it is enabled and the time.

Good idea! Have you been able to store the output of the toggle to a variable / text item? I can see the output in the UI, but I’m not able to use it in my further shortcut flow…

For now I’ve create a little workaround for anyone on iOS 17 beta 8.
Sync sleep alarm 17 beta 8

  • it only works with sleep alarms.
  • it’ll toggle the the next sleep alarm twice, in order to fetch the alarm time. (Thanks @kadaan)
  • as I have a sleep alarm set for every morning, it assumes the alarm time is for the next morning. For now it can’t detect if a sleep alarm is skipped or not.

When iOS 17 is officially out, I’ll try to remake the original shortcut.

6 Likes

We’re back in business, thanks Maarten.

1 Like

Hi guys, is there a way to add a delay in the input_datetime? I would like to open my cover 5minutes before my alarm goes off.
Thanks in advance

I did that by using a template trigger like this:

platform: template
value_template: >-
  {{ (as_timestamp(as_timestamp(now()) | timestamp_custom('%Y-%m-%dT%H:%M:00'))
  | round(0) + (5 * 60)) ==
  (as_timestamp(states("input_datetime.[FILL THIS PART IN]")) | round(0)) }}

I had to jump through some hoops, since the now() includes the timezone, but the synchronized alarm datetime did not, so that’s why you see the conversion of the now() timestamp using timestamp_custom.

1 Like

Hi,

Does anyone else have problems with the sleep schedule?
I’ve set it up a couple of days ago and everything was working fine. But now the date returned is always 0001-01-01

I’d love to see the updated shortcut, if it needs changes for the final release of iOS 17

Mine has been fine since using the updated shortcut for iOS 17. I have it set to run when I close the clock app and at 23:59 every night.

I have set the trigger shorcut in my phone to 00:01. If the alarm is disable, it sends a random date to the past. e.g. 01.01.20 00:00


good evening everyone, I’m the absolute shortcut noob. I’ve been sitting down for the last few days because the sync of my normal alarm clocks no longer works for me since iOS 17. This is what came out for me. The shortcut works when an alarm clock is activated. Maybe it will be helpful for someone or maybe someone will have suggestions for improvement.

https://www.icloud.com/shortcuts/2d0e689260cb48618737f84dc740a5c7

1 Like

I am having trouble triggering an automation, maybe someone has an idea.

I used the Shortcut solution from M20Lucas.
This works perfectly.

As a helper I have created an entity with the name input_datetime.ios_sleep_alarm
If I check the entity, it shows me the correct date and time.

In the next step I created an automation, as trigger I use the template trigger from lencioni.

platform: template
value_template: >-
  {{ (as_timestamp(as_timestamp(now()) | timestamp_custom('%Y-%m-%dT%H:%M:00'))
  | round(0) + (5 * 60)) ==
  (as_timestamp(states("input_datetime.ios_sleep_alarm")) | round(0)) }}

because I use the German version and was not sure, I changed the date format as a test.

platform: template
value_template: >-
  {{ (as_timestamp(as_timestamp(now()) | timestamp_custom('%dT-%m-%Y%H:%M:00'))
  | round(0) + (5 * 60)) ==
  (as_timestamp(states("input_datetime.ios_sleep_alarm")) | round(0)) }}

Both templates do not trigger.

Is the input_datetime.ios_sleep_alarm entity correct? or would I need to specify input_datetime:ios_sleep_alarm?

Or is there another reason why the automation does not trigger?

Your best bet for understanding what your template is doing is by doing to Developer tools > Template. That will give you a REPL that you can use to debug your templates and see what each of the parts is evaluating to.

Thanks for the input!

With the tool I was able to create a template that works.

{% set alarm_time = as_timestamp(states('input_datetime.XYZ')) %}
{% set time_now = as_timestamp(now()) %}
{{ time_now >= alarm_time - 600 }}

for input_datetime.XYZ insert your helper.
alarm_time - 600 is the time before the alarm clock.
The number 600 is seconds. 600 seconds = 10 minutes.

For example, if you want your automation to go off 30 minutes before your iPhone alarm goes off, set the number from 600 to 1800.