I was using this shortcut, which was working great until this morning when we switched into GMT out of BST.
Now, Home Assistant is reading the time sent (ISO 8691) seemingly ignoring the +01:00 timezone.
Any ideas how to solve this without a manual check for a time with an hour offset?
I’m using a function in node red to fire my lighting scene 2 minutes before the alarm is scheduled if you haven’t found a way yet I can dig out the code
So, I ended up going a slightly different route to achieve the same result. Since I couldn’t figure out the previously mentioned issue, I set up a shortcut that will send the time of my next sleep alarm (without any date info) to a time only helper I set up in HA. I then made a script (with some back and forth assistance from ChatGPT) that will combine the time info from that helper and tomorrows date and add it to another helper I created in HA. I then set up an automation to automatically run the script any time the time info from the first helper is updated. It may be a more complicated way of doing it, but it seems to be working. Below is the script I’m using in case anyone else wants to give it a try.
Wondering if anyone else has faced the same problem or bug in Shortcuts app? When running the shortcut, toggle sleep alarm does not turn the alarm on (or back on), if it is off by default in the schedule. Figured this out by this simple shortcut, when running it with the schedule not having alarm on by default for tomorrow. Works perfectly, if alarm is on by deault.
Tried to have two schedules with alarm on for the weekdays and off on the weekend by default, but could not make it work due to this bug. Wether having one or two schedules does not affect to the outcome.
Great, it seems to work great on my iPhone and my HA. In the next few days I will see the behaviors in the field.
I set the automation trigger when the iPhone is charged, so every night before going to sleep. Using the MagSafe, if I had to change the alarm time, I would have to detach it from the magnet, and so when I reconnect it it will update the alarm time to HA again.
Exactly what I was looking for.
Thanks!
I used to check my wakeup time in the clock app.
So now I have an automation that is triggered when I close my clock app to fire the shortcut you mentioned.
I adjusted the helper name so it is recognized for me and HA.
Now I can automate my light (ledstrip) to act as a wakeup light starting X time before the wakeup time!
Got it to work but it took longer to implement than expected.
I am in the US and I believe that the ISO formatting is not working for me. I had to change all the adjusted date from ISO to Custom: yyyy-MM-dd HH:mm:ss.
After the change, I no longer have the issue mentioned before with multiple dates showing. I believe that time format in the iPhone is most likely the issue.
Aha! After some poking around, I figured out what’s going on and why people are getting more than one time entry.
For some reason, iOS is operating on the “Adjusted Date” variable differently when ISO8601 encoding is enabled. It appears to be concatenating the different time operations instead of operating on the variable like you’d expect. The solution is to configure the first two instances of “Adjusted Date” using Date Format = Medium and Time Format = Short.
Hey all! Thanks a lot for the shortcut and fixing the issues I got it working after adjusting the date to medium and also after syncing the date/time.
I am however, having one issue and that’s when I create the alarm after midnight, or in the same day I will be waking up. In this case, the shortcut creates a date one day after. Any idea how to add an IF value in there? Thanks a lot!
I am facing this also. It seems this automation will disable any health alarm that is not a part of the schedule. Rather dangerous and I almost found this bug the hard way! lol
I’ll play around and see if I can find a solution.
ETA I can’t find a solution. Seems like a bug in the “toggle” function.
Somewhat hilarious that Apple didn’t write a function to just get the current alarm status.
@M20Lucas thank you very much for creating this post and the automation; the Shortcut and HA work very well together. I’d like to expand to the following use case: I have a dimmer light that I want to gradually start a certain amount of minutes before the actual alarm is set.
Basically to subtract a number (20) of minutes from the Adjusted Date:
I’ve checked that the value as calculated in this step is an ISO 8601 Date/Time Format. Unfortunately this adjustment does not propagate to the Date/Time Helper in HA. Does anyone know what goes wrong here? I prefer to do the adjustment already on the iOS side preferably and have an advanced date/time in HA.
For reference, this is the successive config I’ve set up for gradual increase of the brightness: