[Android Apps and Games] brandall:
Disclaimer

Should this alarm fail, not wake you up, you lose your job, followed by your house and wife, please note that compensation claims will only be payable by cheque and may take up to 400 years to process <- You know what I’m sayin ;)

Theory

Q) Do you honestly think I’m ever going to use this? You seriously need to get out more.

A) Well maybe? I do!

I did give some thought to what I’d like to wake up to every morning, but unfortunately Tasker can’t perform that… :eek: So, I decided to go a little OTT and make this alarm useful for plenty of Tasker Tips and Tricks.

I separated out all of the tasks so you can easily see what I’ve done. They are then available for you to use or amalgamate into other profiles you have or wish to create. How nice am I…? Let’s take a look at them:

Alarm

This task is first to kick off and controls the flow of what Tasker is going to do. It starts by performing the task AlarmSnoozeMaths (we’ll look at this below) and then encounters its first IF check on the created variable %ALARMCOUNT. Every time you snooze the alarm clock it increases %ALARMCOUNT by 1. When the count is greater than 10, the alarm will stop activating.

As the task continues, it encounters more IF statements for %ALARMCOUNT and performs the action if the IF is true. This way, I was able to create different alarms for different ‘snooze times’. There are four custom speaking alarms and after that, it just plays your selected alarm ringtone.

AlarmSnoozeMaths

This task calculates what the time will be (to display on the screen) when you snooze for 10 minutes. %TIME + 0.10 would have been just so easy wouldn’t it..? But unfortunately when the time is 07:52, telling you your alarm was going to go off at 07:62 was just too untidy. Following the task through, you’ll see how I’ve split the variable %TIME by the ‘.’ and therefore had two variables ‘07’ and ‘52’. From there I add 10 to ‘52’ getting ‘62’. I say that IF it’s greater than 60, minus 60 from it; leaving ‘2’. I then say IF that number is less than 10, join it to ‘:0’, so we end up with ‘:02’. Simples.

The ‘07’ was easier to deal with. IF the above minutes had gone over 60, we would need to add ‘1’ to this number. IF that number was greater than 23, we’d change it to ‘00’.

All the split variables were then joined together and ended up with a more intelligent %STIME.

AlarmSnooze

This is a simple menu task that will pop up on the screen. Pressing one of the two choices will perform the associated tasks. The text you wish to display is in the label field. One performs the task AlarmSnoozeTime which handles the ‘snooze’ and the other performs AlarmReset, which is run when the alarm is turned off. EDIT - Forgot to mention, that if neither button is pressed after 2 minutes, it defaults to 'snooze'.

AlarmSnoozeTime

This firstly ‘shuts-up’ the speech or stops the music. Cancels the notifications and then patiently waits for 10 minutes (or your chosen snooze length) before kicking off the initial Alarm task again.

AlarmReset

Again, this silences and kills notifications before resetting and clearing variables, the most important of which is %ALARMCOUNT to 1, ready for next time it’s to be used. It turns your keyguard back on and stops. EDIT - VariableClear is added to this task by default in V2

AlarmUPSMaths

There is an inbuilt variable %UPS which is the time in seconds since you booted the device (uptime). In the AlarmInfo task, this information is used (amongst many other things!), but having it quote thousands of seconds was just too ugly and really pretty uninformative unless you are a maths genius and even then, first thing in the morning? So, I wanted to change this into hours and minutes. Following the task, you’ll see it starts by dividing %UPS by 3600 to convert it to hours. The result for example of 3.5 does not of course mean 3 hours and 50 minutes; wouldn’t that be easy..? No, the 0.5 = half = 30 minutes. So, by splitting the variable %UPS (which we transferred the created variable %UPMA originally for good house keeping) at the ‘.’ we can deal with the numbers behind the decimal places and convert them to minutes. If it was so simple to be 0.5, then multiplying that number by 60 would give us 30; wouldn’t that be simple..? In the event that it’s actually 0.521331232132131 we need to do something about the getting rid of the 30.121200234423823 (eg) – we do this by again splitting the variable and keeping only what was before decimal point (the whole minutes). Finally we are left with two created variables %UPHR and %UPMIN which are used in the AlarmInfo task for all but a second and therefore was a complete waste of my life – But hey, someone, somewhere, someday will read this when trying to do the same and hit the thanks meter!

AlarmInfo

The first of the information pulling tasks we will run. It grabs the text from the chosen URL in action #1 using an HTTP GET and then starts to extract what it needs – which in this case, is today’s weather forecast. If you’d like to see what information it initially collects and then follow how it’s split, add a file weather.txt under the ‘output file’ field which will store it on your storage card. The task then goes on to speak the weather to you, along with just about everything else that I could find in the Tasker variables for it to tell you! Annoying? Yeah, but that girl’s voice seriously gives me the horn… You? No? Oh...

AlarmMQoTD

Yes, what better to wake up to than a motivational quote!? I’m starting to realise that this profile is really going to make a difference in some of your lives... Ok, so another HTTP GET, followed by a lot of splitting to leave us just the Author and quote itself. This is spoken to you again shortly after by my girlfriend, erm, I mean the speech engine you use...

AlarmDayHoro

How could you possibly consider starting the day without knowing exactly what is going to happen to you by hearing your horoscope!? I know I couldn’t... Again, an HTTP GET, a lot of splitting and that’s what you’re left with.

AlarmNewsHeadlines

This task reads out the recipe of the day for you! Or alternatively, the news headlines as the title would suggest. HTTP GET, splitting, more splitting and job done.

AlarmAPOTD

Alarms are so visual aren’t they? How about some soothing wallpaper from NASA’s astronomy picture of the day – you can admire it whilst you press snooze... Another HTTP GET, but this time we are searching for the image source only and once we’ve dissected it, another HTTP GET grabs the image and Tasker updates your wallpaper with it.

AlarmNPOTD

Same as above, but just NASA’s picture of the day. WHOOP!

AlarmNGPOTD

Same again, but this time National Geographic. %WHOOP2!

AlarmNakedHotGirlOfTheDay

You wish... but if the thanks meter increases sufficiently, I’ll consider it for the next release ;)

VariableClear

The above tasks import a lot of text from the HTTP GET commands. Splitting them increases the amount yet further. This task is

not

currently instructed to run within any of the other tasks, so either run it manually (open it and press test) or add a ‘perform task’ action into AlarmReset, so it sweeps up for you.

Note: This task is HUGE. Currently (and unfortunately) you cannot join all of the split data together and clear it in one action. I’ve been reliably informed that it will be in the next Tasker update (although that comes a little too late for the 1.5hrs it took me to enter it all manually!) Have you hit the thanks meter yet? Do it again... EDIT - Added to the AlarmReset task as standard in V2

AlarmHTTPCheck

(added in V2)

Should part of a triggering task fail, Tasker is currently set up to cease further actions. Having an alarm based on the reliability of your data connectivity is never a good plan, so I had to resolve how to confirm if the HTTPGET had failed and consequently, so had the alarm. There is a built in variable %HTTPR which is the response code, but unfortunately it's not so simple to 'variable check' this in the next action - if the HTTPGET failed, then it would not go to the next action... This needs to be changed within Tasker, but in the mean time the solution was to trigger a separate task.

AlarmHTTPCheck is triggered before the HTTPGET and runs with a lower priority than the calling task to ensure the HTTPGET action is not delayed. It waits 3 seconds, before checking %HTTPR is either a value of 200 or 400 denoting success. The task will cease if this is the case. If it isn't, it will increase the value of %ALARMCOUNT to 5 (+1 will be added in the task Alarm) so all further HTTPGET alarm calls are skipped and only the alarm music is triggered. The disadvantage of this is having less snoozes, but if you are not woken up to your expected informative speech tasks, I'm sure even your sleepy self will realise something is amiss. Sorted?

Credits

Unknown for weather

Unknown for APOD Wallpaper

Daweav for original wiki alarm with snooze

UncleMike for AM/PM variable splits