I’m paranoid when it comes to a lot of things. I never trust a single device or a single alarm to wake me, so I always set alarms on both my tablet and my phone, as well as alarms that are set sequentially. Snooze, you say? Don’t use it. I get up when it rings, but I do things in my sleep all the time, like turn off alarms. Point being, setting the alarms takes a bit more time than I thought it should, so I decided to automate it in Tasker.
(To understand what goes on in this article, you should have finished the entire Tasker guide)
The alarm set system is activated with a hidden home screen shortcut that runs a task. It starts off much like my nap mode, with a Variable Query for %Alarm, with the rest of the task inside an If group for %Alarm not matching *Alarm*. This pops up a dialog to input the alarm time in the format HH.MM (24h format), and the use of the If group makes sure that canceling that dialog stops the task.
The first thing the rest of the task does is to send off an AutoRemote message to my tablet. Upon receiving this message, the tablet splits the alarm by the period, and then uses Set Alarm with the two resulting variables (hours and minutes) to set the alarm at the exact time specified in the initial Variable Query. It then sends a message back to the phone, confirming that the alarm has been set. Tasker picks up this message using an AutoRemote context, and transfers the confirmation message into a Flash action – which is on a Wait delay to make it coincide with alarm confirmation messages from the phone’s own alarm
Back on the phone, the task splits %Alarm too. It then uses Perform Task to run a task called Alarm Plus Five. This task sets %Alarm2 (the minutes) to %Alarm2+5 using math, which adds 5 minutes to the minutes variable.
Next there is an If check to see if %Alarm2 is greater than 59. If it is, the task does Set Variable %Alarm1 to %Alarm1+1, using math, and sets %Alarm2 to %Alarm2-60, also using math. This is to prevent a case where adding 5 minutes creates a minute variable of 60 or above, which wouldn’t work, since you can’t have for instance tell your alarm clock to wake you at 08:64. By adding 1 to the hour variable and subtracting 60 from the minutes variable in cases where there are more than 59 (i.e 60 or more) minutes, a situation like 8:64 becomes 9:4. Luckily, Set Alarm doesn’t need useless zeros before single digit numbers, so we don’t need to turn 9:4 into 09:04.
The final part of Alarm Plus Five sets the alarm with the new variables, which are five minutes later than the variablas used on the tablet.
After this, it goes back to the main task, which then uses a Wait for three seconds. This is to allow the alarm to set and flash on the screen. After the Wait, it runs the exact same task as above once more, via Perform Task. Since it always overwrites the same %Alarm1 and %Alarm2 variables, running the same task again actually adds another five minutes to the alarm, and then sets it. Since I’m very paranoid, it does the same Wait/Perform Task thing one more time before it calls it a day. At that point it has run Alarm Plus Five three times, each time adding 5 minutes to an alarm that it sets. The tablet is alarm 0, with the phone having alarms 2-4, and each goes off five minutes after the other.
Finally, the task does Variable Clear on %Alarm to reset it. That way it’s blank the next time the Variable Query runs, so that if you cancel, the rest of the task doesn’t run with the last value of %Alarm.
All in all, the user interaction looks like this:
Two devices, four alarms, all in one go.
I should note that the Set Alarm action doesn’t work with all alarm clock apps. It works with Alarm Clock Plus, and probably a bunch of others, so you just have to try. It’s also worth noting that tweaking the alarm defaults in Alarm Clock Plus is a good idea if you want to set the alarm externally like this. Alarm Clock Plus has many options, which unfortunately makes it very slow for setting quick alarms. Not a problem if you have the same alarm every day, but if you set different alarms all the time, this method shaves a lot of time off that as well.
Finally, a reader created a validation check for an alarm system like this. You can find it in his comment here. It basically checks to see that the time you input is actually a valid time, not for instance 25.93.