Set alarm clock in iOS and in Indigo

Share your macOS, iOS, and iPadOS shortcuts here. Post your shortcut in a new topic and be sure to describe thoroughly (screenshots, full text of any scripts, apps used, etc).
MarcoGT
Posts: 1106
Joined: Thu Sep 11, 2014 1:06 pm
Location: Germany

Set alarm clock in iOS and in Indigo

Post by MarcoGT »

Hi,

I created a small iOS Shortcut and a related Python script which make following:

- ask you (by voice) to set up an alarm clock
- this alarm will be set in iOS and using SSH server also in Indigo

In my Indigo setup I have an "alarm clock" schedule which does some basic stuffs, and then a "good morning" action which makes other things; the second one is called manually (by voice), the first one is a schedule configured which takes the "alarm clock" variable as schedule time

iOS Shortcut: https://www.icloud.com/shortcuts/e2342c ... ce7a130369

Python Script:

Code: Select all

alarm_clock = indigo.variables[469044268].value # "sveglia"
alarm_cleaned = "0" + alarm_clock.split()[0]
indigo.variable.updateValue(469044268, value=alarm_cleaned)
Quick explanation: if I say to Siri "set an alarm at 6" (in Europe we usually do not use AM/PM, but 6 or 18), Siri will set the alarm in iOS at 18, I do not know why.
Therefore I have to say "set an alarm an 6 in the morning"; then of course the variable will not contain only the time, but also some other words; the small script will take just the number and will insert a leading zero for Indigo so that it recognizes as time for the schedule.

Marco
Londonmark
Posts: 510
Joined: Wed Feb 29, 2012 12:57 pm

Re: Set alarm clock in iOS and in Indigo

Post by Londonmark »

Great thinking. Like this a lot.
SofterEasy77
Posts: 1
Joined: Mon Apr 25, 2022 9:44 am

Re: Set alarm clock in iOS and in Indigo

Post by SofterEasy77 »

so nice function and code preview. if this work correctly can you share all of code? or it's open source?
MarcoGT
Posts: 1106
Joined: Thu Sep 11, 2014 1:06 pm
Location: Germany

Re: Set alarm clock in iOS and in Indigo

Post by MarcoGT »

There is no more code required in Indigo, just the shortcut posted above which will update the variable in Indigo
ryanbuckner
Posts: 1086
Joined: Sat Oct 08, 2011 12:33 pm
Location: Northern Virginia
Contact:

Re: Set alarm clock in iOS and in Indigo

Post by ryanbuckner »

I'm trying to implement something similar and maybe you can help me.

1) Based on an event or trigger in indigo (variable changed)
2) Fire shortcut to disable or enable an existing alarm on my iPhone

Here's the real use case. I have a process that sets a variable in Indigo when the kids' school is closed for the day (Holidays, Snow Closure, etc..). I also have an alarm on my iPhone to tell me to wake the kids for school. I would like to have Indigo disable that alarm on days that school is closed.

Where I'm getting hung up is how to target the alarm on my phone from the Indigo server. I can launch a shortcut but how does it target the alarm on my iPhone?
User avatar
DaveL17
Posts: 6828
Joined: Tue Aug 20, 2013 11:02 am
Location: Chicago, IL, USA
Contact:

Re: Set alarm clock in iOS and in Indigo

Post by DaveL17 »

@ryanbuckner - Sorry, I started to respond to this yesterday, but then realized it's trickier than I thought.

It would seem that alarms can't be synced between Apple devices via iCloud and, as far as I can see, there's no way to target a specific device with a Shortcut when it's run externally so this isn't directly possible: Indigo Trigger --> Indigo Action --> Shortcuts --> Disable alarm on your phone.

But I think it's possible with the following steps on your iPhone (there may be other ways to do it). You'll need some way to create persistent synced data across devices--I've been checking out a freeware package called "Data Jar". Data Jar would need to be installed on your Mac and your iPhone.

Set the criteria variable in Data Jar to reflect whether you want an alarm that day or not. You'll set the value of this variable using Indigo automation, so you'll need a Shortcut on your mac to set the Data Jar variable to True or False.

You'll need to set up a "Time of Day" Automation Shortcut on your phone with a "Toggle Alarm" action. Then do an "If/Else" based on the Data Jar variable value. Each day:

If Data Jar Value is False:
-> Toggle School Alarm Off
Else:
-> Toggle School Alarm On

You might also want a catch all to set the alarm to On just in case something didn't work right (default state is On).

Let me know if that makes any sense whatsoever. :D
I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]
ryanbuckner
Posts: 1086
Joined: Sat Oct 08, 2011 12:33 pm
Location: Northern Virginia
Contact:

Re: Set alarm clock in iOS and in Indigo

Post by ryanbuckner »

Yep, makes sense to me. Thanks for that suggestion. I'll let you know if I implement it or something like it.

Is there a way for the shortcut on the phone to reach out and check the variable in indigo at midnight, rather than firing the shortcut from Indigo.?
ryanbuckner
Posts: 1086
Joined: Sat Oct 08, 2011 12:33 pm
Location: Northern Virginia
Contact:

Re: Set alarm clock in iOS and in Indigo

Post by ryanbuckner »

I think I may have answered my own question
User avatar
jay (support)
Site Admin
Posts: 18310
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: Set alarm clock in iOS and in Indigo

Post by jay (support) »

ryanbuckner wrote:I think I may have answered my own question
And the answer is? Share with the class... :wink:
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
User avatar
DaveL17
Posts: 6828
Joined: Tue Aug 20, 2013 11:02 am
Location: Chicago, IL, USA
Contact:

Re: Set alarm clock in iOS and in Indigo

Post by DaveL17 »

Yes, you can have a shortcut reach out to Indigo for the variable value; what's less clear to me is whether you can do that in an Automation. There are restrictions on what Automations can do without human intervention. I know that Geofencing always relies on human intervention (as a personal security measure).
Apple wrote: The following automations can be run automatically:
Time of Day
Alarm
Sleep
CarPlay
Apple Watch Workout
NFC
App
Airplane Mode
Do Not Disturb
Low Power Mode
Battery Level
Charger
So if you can use a "Get Contents from URL" in conjunction with an Automation (and without human intervention), that would be far superior to the mumbo jumbo I wrote above. :lol:
I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]
ryanbuckner
Posts: 1086
Joined: Sat Oct 08, 2011 12:33 pm
Location: Northern Virginia
Contact:

Re: Set alarm clock in iOS and in Indigo

Post by ryanbuckner »

So I created a shortcut that looks like this: And then I have an automation that runs from my phone every morning at 4:00AM to run the shortcut
set alarm.png
set alarm.png (428.66 KiB) Viewed 3187 times
IMG_796732FDDF81-1.jpeg
IMG_796732FDDF81-1.jpeg (189.77 KiB) Viewed 3185 times
User avatar
DaveL17
Posts: 6828
Joined: Tue Aug 20, 2013 11:02 am
Location: Chicago, IL, USA
Contact:

Re: Set alarm clock in iOS and in Indigo

Post by DaveL17 »

Nice! Glad you were able to do it that way.

Much simpler.
I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]
User avatar
jay (support)
Site Admin
Posts: 18310
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: Set alarm clock in iOS and in Indigo

Post by jay (support) »

Nice! Per Dave's post above, please let us know if it runs unattended tomorrow morning.
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
ryanbuckner
Posts: 1086
Joined: Sat Oct 08, 2011 12:33 pm
Location: Northern Virginia
Contact:

Re: Set alarm clock in iOS and in Indigo

Post by ryanbuckner »

jay (support) wrote:Nice! Per Dave's post above, please let us know if it runs unattended tomorrow morning.
I moved the time up and ran a few tests with the Indigo variable = False and then = True . I locked the phone and both times the shortcut ran unattended and produced the desired outcome.

The "Notify When Run" option is really handy to see when steps fire. All looks good.
User avatar
jay (support)
Site Admin
Posts: 18310
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: Set alarm clock in iOS and in Indigo

Post by jay (support) »

Nice!
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
Post Reply

Return to “Apple Shortcuts”