Set alarm clock in iOS and in Indigo

Posted on
Wed Dec 12, 2018 11:36 pm
MarcoGT offline
Posts: 1090
Joined: Sep 11, 2014
Location: Germany

Set alarm clock in iOS and in Indigo

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

Posted on
Thu Dec 13, 2018 3:25 pm
Londonmark offline
Posts: 509
Joined: Feb 29, 2012

Re: Set alarm clock in iOS and in Indigo

Great thinking. Like this a lot.

Posted on
Tue Apr 26, 2022 12:23 pm
SofterEasy77 offline
Posts: 1
Joined: Apr 25, 2022

Re: Set alarm clock in iOS and in Indigo

so nice function and code preview. if this work correctly can you share all of code? or it's open source?

Posted on
Wed Apr 27, 2022 1:10 am
MarcoGT offline
Posts: 1090
Joined: Sep 11, 2014
Location: Germany

Re: Set alarm clock in iOS and in Indigo

There is no more code required in Indigo, just the shortcut posted above which will update the variable in Indigo

Posted on
Tue Apr 25, 2023 9:45 am
ryanbuckner offline
Posts: 1072
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Set alarm clock in iOS and in Indigo

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?

Posted on
Wed Apr 26, 2023 7:46 am
DaveL17 offline
User avatar
Posts: 6739
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Set alarm clock in iOS and in Indigo

@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]

Posted on
Wed Apr 26, 2023 8:11 am
ryanbuckner offline
Posts: 1072
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Set alarm clock in iOS and in Indigo

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.?

Posted on
Wed Apr 26, 2023 8:17 am
ryanbuckner offline
Posts: 1072
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Set alarm clock in iOS and in Indigo

I think I may have answered my own question

Posted on
Wed Apr 26, 2023 8:34 am
jay (support) offline
Site Admin
User avatar
Posts: 18185
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Set alarm clock in iOS and in Indigo

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

Posted on
Wed Apr 26, 2023 11:07 am
DaveL17 offline
User avatar
Posts: 6739
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Set alarm clock in iOS and in Indigo

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]

Posted on
Wed Apr 26, 2023 11:53 am
ryanbuckner offline
Posts: 1072
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Set alarm clock in iOS and in Indigo

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 2088 times


IMG_796732FDDF81-1.jpeg
IMG_796732FDDF81-1.jpeg (189.77 KiB) Viewed 2086 times

Posted on
Wed Apr 26, 2023 12:32 pm
DaveL17 offline
User avatar
Posts: 6739
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Set alarm clock in iOS and in Indigo

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]

Posted on
Wed Apr 26, 2023 3:09 pm
jay (support) offline
Site Admin
User avatar
Posts: 18185
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Set alarm clock in iOS and in Indigo

Nice! Per Dave's post above, please let us know if it runs unattended tomorrow morning.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Apr 26, 2023 4:01 pm
ryanbuckner offline
Posts: 1072
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Set alarm clock in iOS and in Indigo

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.

Posted on
Thu Apr 27, 2023 12:12 pm
jay (support) offline
Site Admin
User avatar
Posts: 18185
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Set alarm clock in iOS and in Indigo

Nice!

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Who is online

Users browsing this forum: No registered users and 1 guest