Page 1 of 2

Set alarm clock in iOS and in Indigo

PostPosted: Wed Dec 12, 2018 11:36 pm
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

Re: Set alarm clock in iOS and in Indigo

PostPosted: Thu Dec 13, 2018 3:25 pm
by Londonmark
Great thinking. Like this a lot.

Re: Set alarm clock in iOS and in Indigo

PostPosted: Tue Apr 26, 2022 12:23 pm
by SofterEasy77
so nice function and code preview. if this work correctly can you share all of code? or it's open source?

Re: Set alarm clock in iOS and in Indigo

PostPosted: Wed Apr 27, 2022 1:10 am
by MarcoGT
There is no more code required in Indigo, just the shortcut posted above which will update the variable in Indigo

Re: Set alarm clock in iOS and in Indigo

PostPosted: Tue Apr 25, 2023 9:45 am
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?

Re: Set alarm clock in iOS and in Indigo

PostPosted: Wed Apr 26, 2023 7:46 am
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

Re: Set alarm clock in iOS and in Indigo

PostPosted: Wed Apr 26, 2023 8:11 am
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.?

Re: Set alarm clock in iOS and in Indigo

PostPosted: Wed Apr 26, 2023 8:17 am
by ryanbuckner
I think I may have answered my own question

Re: Set alarm clock in iOS and in Indigo

PostPosted: Wed Apr 26, 2023 8:34 am
by jay (support)
ryanbuckner wrote:
I think I may have answered my own question


And the answer is? Share with the class... :wink:

Re: Set alarm clock in iOS and in Indigo

PostPosted: Wed Apr 26, 2023 11:07 am
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:

Re: Set alarm clock in iOS and in Indigo

PostPosted: Wed Apr 26, 2023 11:53 am
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 2375 times


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

Re: Set alarm clock in iOS and in Indigo

PostPosted: Wed Apr 26, 2023 12:32 pm
by DaveL17
Nice! Glad you were able to do it that way.

Much simpler.

Re: Set alarm clock in iOS and in Indigo

PostPosted: Wed Apr 26, 2023 3:09 pm
by jay (support)
Nice! Per Dave's post above, please let us know if it runs unattended tomorrow morning.

Re: Set alarm clock in iOS and in Indigo

PostPosted: Wed Apr 26, 2023 4:01 pm
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.

Re: Set alarm clock in iOS and in Indigo

PostPosted: Thu Apr 27, 2023 12:12 pm
by jay (support)
Nice!