Here is a guide to get your iPhone alarm clocks into Home Assistant. I followed some examples I found here and on Reddit and created my own iOS shortcut. This is my first shortcut so I hope I did everything right, but wanted to share anyway, because I haven’t found a working alternative for this. Any feedback is welcome :).
The shortcut will loop through all your alarms and will create a list of the alarms that are enabled. It will only grab the first and last alarm set. If no alarm is set it will turn the input boolean off.
For the first alarm, last alarm and the boolean I set up a helper in Home Assistant. Additionally I added this to my configuration.yaml:
To finalize: add this shortcut to a new automation on your iPhone so it runs every time you close the ‘clock app’ on your iPhone. It may be necessary to run the shortcut in the shortcuts app for the first time to allow all the prompts (make sure you have at least two active enabled alarms, so all the prompts show up).
Thanks
Curious though what helpers you created and how you named them, do they really have the name alarm_example?
Or doesn’t it Matter what name you use?
Figured out some things already .
the addition example is there in the workflow.
i edited the names for my own use.
important that if you use the workflow, rename the server to the name of your own HA instance.
another thing i noticed is that there was a difference in time set on my phone and the one in HA.
I managed to work around that one by adjusting the template and add local=True:
last thing to mention is that you have to create the automation on your phone to call the script or flow when you close the clock app.
see the last automation in the attached screenshots.
Last thing to mention : when you are using Health and the sleeping schedule to wake you id does not see it als an alarm although it is in the clock app.
Hello, nice thing. I have transferred everything 1:1, unfortunately only the last alarm and the boolean switch are transferred correctly. The first alarm remains at 0:00
What could be the reason for this? Unfortunately I’m not so familiar with the shortcuts and it’s not so great on the small phone displays either
@niemehrarbeiten
it could be that the first alarm is one of health (ie sleepcycle) that seems to be another kind of alarm. I haven’t figured out how to use that yet.
In my case I wanted my home to do some wild stuff to improve alarm effectiveness. I added an input_button to HA and created an automation in shortcuts with the following configuration:
When: When the alarm is activated
Action:
Dictionary: entity_id: input_button.alarm_clock
Home Assistant Call input_button.press with data dictionary.
I then trigger my HA automations when the input_button is pressed, and only stop the house madness when I manually turn on a light in the kitchen
maybe this helps to better understand how it works:
the iOS shortcut will put your alarm values via the Home Assistant app on your phone to 3 specific helpers. The template in the configuration.yaml is reading these helper values and converts it into sensor entities.
Now, how to configure the helper? This is being done in Settings - Devices and Services - and then at the top select Helpers. With the “+ create helpers” button on the lower right helpers can be added. You need to configure 3 helpers.
1x type Toggle, this is for the detection if an alarm has been set or not. The iOS shortcut will change the toggle state for you. To keep it simple, name the toggle “alarm_example” since this will exactly match the config in the iOS shortcut.
2x type Date and/or time. Here your iOS shortcut will publish the time value of your alarms to. Like above, convenient naming for these two would be first_alarm_example and last_alarm_example.
Now you can run your iOS shortcut. By clicking on your created helper you should be able to see the values coming in. Works like a charm for me! Thanks @Milofow for this
I am stuck at this place with this error message: “Set Dictionary Value failed because Shortcuts couldn’t convert Alarm to Date”
It seems that the issue is related to the fact that an Alarm object can’t go into the dictionary…
Anyone who has an idea for a solution?
Note: The Alarm set boolean works just fine and gets set in Home Assistant.
I have the exact same error at the same spot. All my settings are by your default names and the Dictonary just says entity_id and then the 2 items are:
input_datetime.first_alarm_example and input_boolean.alarm_example
Hello, I had the problem that the alarm data was not transferred correctly.
I have found the error but I am having problems implementing the solution.
My better half has several alarm clocks that are always activated. Due to different working hours, she has alarms that only ring on Tuesday or Friday or Saturday, for example. These are not transmitted to HA. She has now been ill and therefore had all of them off. She once set a “normal” alarm clock and the data was transferred correctly.
In my opinion, this means that the shortcut should include a query for the current day of the week and then transmit the alarm time for this day. The alarm time is transmitted daily at 2.00 am.
Could someone please help me solve this problem?
Hello,
the shortcut works great! Thank you very much!!
I just have the problem that when I set my alarm for 10 AM or 11 AM, the time in HA is set to 22 or 23 hours.
It seems to be related to the formatting of the date or time, but unfortunately, I can’t find the solution.
My location is Germany, maybe there is a different setting for Germany?