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

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.

I have also done this but in a slightly different way using the time and date sensor.

{{ states('sensor.time_date') == (state_attr('input_datetime.iosalarm', 'timestamp') -60 )| timestamp_custom('%H:%M, %Y-%m-%d', true) }}

I just posted an updated version here for iOS 17. Apple changed a few things (for the worse in this case) but it works. :grinning:
I’ve also made use of a different date-time formatting, so I hope all you Germans can use this version without problems as well!

Would this help? If an alarm is deactivated, it will send a datetime in the past to HA. And I’ve changed the date-time formatting to ISO 8601 so it’s let prone to errors.

You could use the new filter options (and label your alarms) if need be…

Hi Maarten, this version of the shortcut seems to work for me except for the Woordenboek part. Any idea what it should be in english? Thanks!