Posts Tagged ‘Tasker’


Making a Scene over a Power Cut

December 26, 2012

Vista busy cursor  Last Sunday we woke early to find the power was out, and clearly had been for hours. It wasn’t just the house circuit-breaker which had tripped; the whole street was dark. I used my phone to check the Scottish Power website and found that the problem was known about and a fix expected by around 10am. In the event the power came back on a little earlier than that.

There was no harm done; the outage was not long enough for food in the freezers to start thawing.  All the same, I wondered if there might have been some way I could have been alerted earlier. It is not as if we get power cuts every other week, but this happens two or three times a year and an outage just after we had gone to bed might go unnoticed until the morning, easily long enough to risk problems with the food in the freezers.

A thought had come to me as I picked up my phone to check the power company’s website. My phone was plugged in to the charger, as it is every night. At the hardware level, the circuitry would have detected that the battery was no longer charging when the power cut out. Could this not have been intercepted programmatically and made to trigger an audible alert?


I searched the Google Play Store for apps that could be used to detect power cuts. I only found two of note. One was a paid app designed to detect outages on key circuits, e.g. the circuit that powers the freezers, at a holiday home or business – in any event somewhere remote. It would send a text to a chosen mobile number to warn of an outage. But I did not want to be alerted by text; I just wanted a simple audible alarm to warn of a local residential area power cut. This app could not do that.

There was another app which did have the audible alert functionality I was after. Except that it was very poorly written. Once the alarm had started sounding, there was no way to stop it without rebooting the phone! Both apps were uninstalled in double quick time.

For a short period I seriously thought of writing my own app to do the job properly, maybe marketing it.  I have been dabbling in Android app development and am well up to the task. Then I had my second lightbulb moment. I could probably program the Tasker app to provide the functionality I wanted. Tasker is a wonderful app which can be used to customise the behaviour of Android phones in any number of creative ways. I’ve written posts about Tasker before, for example the profile I created to ensure notification sounds were muted at night time. To use Tasker you specify “what” should happen and “when”. The “what” will be some specific action you wish to happen automatically, such as a change in notification volume, turning on the wi-fi or the sounding of an audible alarm. Determining the “when” consists of creating “profiles”, descriptions of particular statuses, such as proximity to a particular geographical location, the period between specified hours of the day, etc. One of the options for profile is “on AC power”, so Tasker can be programmed to trigger actions when the phone is plugged in to the mains and when it is disconnected. Note that from Tasker’s perspective there is no difference between unplugging the charger and a power cut. Either way, the hardware detects that the supply of AC power has stopped.

It is very easy to create a Tasker profile which detects when AC power is disconnected and sounds an alarm. Unfortunately, that would cause the alarm to sound every time I disconnected the charger in the morning. I needed something a bit cleverer – maybe arrange for the sounding of the alarm to be deferred for a minute or so and meantime display a dialog box which the user would press to cancel the alarm. That way, each morning when I took the phone off the charger I would see the dialog box and tap to prevent the alarm going off. If, on the other hand, there was a power cut during the night I would sleep through the display of the dialog box and be awakened by the power cut warning alarm a minute later. The question is whether Tasker was clever enough to make such a solution possible.

The answer is yes. At one time it would not have been. What has made the difference is the introduction of “Scenes” into its functionality around a year or so ago. When Scenes were first announced, I was not sure what to do with them. I had a brief play but did not really “get” them so left them be. It was only when I started thinking about Tasker and power cuts that I realised I could use a Scene to add the dialog box functionality that would make the whole idea workable. The Scene I created is a dialog box occupied in its entirety by a button. When the phone exits the “on AC power” profile, it kicks off a series of actions.  The first is to display the dialog box with its button, labelled “Cancel Disconnection Alarm”. The second is to set a “user variable” named %POWERCUTALARM to status ON. It then performs a 60 second “wait” operation and the third is to play an mp3 file (the power cut alarm) but only if  %POWERCUTALARM is still set to ON.

Should the user have tapped on the button in the dialog box before the 60 second wait had run its course, this would have triggered the execution of Tasker commands to set %POWERCUTALARM to OFF with the result that the alarm mp3 would not play. 

I have tested all this with a simulated power cut, the simulation taking the form of switching the mains off at the socket where the charger is plugged in. It may be a while before we get a real power cut to test with, but I’m happy if that does not happen for months and months.

There is a postscript. Another idea, but less of a lightbulb and more a slap on the head.  This is to do with the Tasker profile which mutes notifications at night. I had this originally set so the profile would be active at specific times of the day, e.g. coming on at midnight and off at 8am. Those times proved to be too rigid, so I later moved on to switching the profile on and off manually by linking the profile to a button on my phone’s desktop. But the best solution is to have notifications muted when the phone is on AC power, because that corresponds exactly to when I am in bed asleep. But until the power cut incident I had never thought to check whether Tasker could respond to changes in mains power connection status. I have now adapted the Tasker Power Cut profile to also control muting of notification sounds.  All obvious in hindsight.



Android Upgrade Process: Galaxy S to Note

February 15, 2012

Vista busy cursor  Yesterday I ordered a new Samsung Galaxy Note as an upgrade, to replace my Galaxy S.  It should arrive sometime today and I need to prepare. I want my new phone to be set up with everything I need as quickly as possible and as painlessly as possible: my apps, my email, my contacts, my calendar, my various customisations. This should not be a major planning exercise but does need a little bit of thinking ahead and a few preparatory steps.

Contacts, Email & Calendar

Trivial. My contacts, email, calendar are all tied to my Google ID. I use gmail and other Google services for everything. Once I have logged into Google on my new phone all these things will just be there. No help from Yoda do I need.

SMS/MMS history, call log, browser bookmarks, alarms

Do I actually need this? I have kept my texts from when I first had the phone, but rarely had occasion to look at old texts. I can think of one occasion – my son had texted me the postcode for his flat in London. I wanted to mail him something and had no other record. So there is little harm done if I start with a blank SMS history but as an experiment I am going to try to transition it to the Note.  I’m using  myBackup Pro to back up various items to the cloud: Call Log, Bookmarks, SMS, MMS, Alarms.  I will attempt to restore these into the Note.  Could be interesting. The bookmarks won’t be complete as I have taken to using the Dolphin browser which has a separate bookmark system.

Done it. Backup uploaded.  The app helpfully has a facility so you can email yourself the access details for later retrieval of the backup from the cloud.


Also easy. I installed AppBrain and used it to create an on-line record of all my apps. I should be able to rely on the Android Market to recover all my paid apps but possibly it won’t have the free apps.  I currently have around 80 apps in total, most of them free ones. That’s where AppBrain comes in; I should be able to install them one by one from there. Time to do an AppBrain sync.  Done.

I installed Google Currents from the apk as it has not officially been released in the UK.  I still have the file as an email attachment.  It is out of date now but still works.  That one will have to be done manually.

Photos and other media

I’m just going to copy the entire accessible file system, both on-board and on micro SD card, to my PC.  I can copy as many of my media files as I want on to the new phone. Quite a lot of music.  Some photos. I will in any event take the opportunity to back my photos up the the cloud.


I use the Tasker app to customise the behaviour of my phone. This includes handy buttons to turn brightness up to max (handy if you are out in the street and can’t see your screen), auto switching of wifi on and off depending on whether I am at home, switching off notification sounds at night time, etc.

In practice the most reliable way is to have Tasker email the XML for each behaviour profile to my gmail. I can load the profiles back into Tasker later in the new phone.  Done.

Just realised that this approach does not save the individual task definitions that are used to power the icons for max brightness, silent, quiet, SMS reader on etc.  So I have turned on Tasker’s autobackup to create a file with the complete user data in XML.  This gets copied to the PC with the other files and will be available for restore in the Note.

GO Launcher Ex

Nearly forgot! I have a lot of customisation built into my launcher settings. But there is a backup option.  I have just run the backup and the file will be copied to my PC with all the other files.

I think I am good to go when the new phone shows up.



Putting the Galaxy to rights #10 – Silent Night Tasker Profile

June 16, 2011

Vista busy cursor A while back I wrote a post about the Tasker profile I use to ensure notification sounds on my Samsung Galaxy S are automatically muted at night, from midnight to 8am.

The same profile would work on any Android phone. For the record this is the Tasker “script”:

Profile: "Silent Night
 Time: From 00:00 Till 08:00 
 Enter: "Mute Notifications" 
  A1: Notification Volume [ Level:0 Display:Off Sound:Off ] 
  A2: Notify Cancel [ Title: Warn Not Exist:Off ] 
  A3: Variable Set [ Name:%SNIGHT To:ON Do Maths:Off 
      Append:Off ]
  A4: Variable Set [ Name:%VOLMODE To:L Do Maths:Off 
      Append:Off ]
  A5: Silent Mode [ To:OFF ] 
 Exit: "Reinstate Notifications" 
  A1: Notification Volume [ Level:5 Display:Off 
      Sound:Off ] 
  A2: Variable Set [ Name:%SNIGHT To:OFF Do Maths:Off 
      Append:Off ]

The two “Variable Set” instructions are not necessary to make the profile work. They just set the user defined Tasker variable %SNIGHT to “On” or “Off” as applicable so other Tasker profiles or tasks can modify their behaviour, where relevant, depending on whether the Silent Night profile is active. I could just have had those other profiles/tasks refer to the time, but that would have involved more work and, more importantly, not taken account of any manual disabling of Silent Night. Enter tasks A2, A4 and A5 are again not essential. I use them to cancel out the effects of other Tasker actions which I use.


Putting the Galaxy to rights #9 – The Benefits of a Mobile Meltdown

May 24, 2011

Vista busy cursor Normally a complete breakdown in the functioning of a phone would be thought of as a bad thing.  In my case at least it had a very positive result. My Samsung Galaxy S Android phone is now running far better than when it was new.

Right from when I bought it last September, the Galaxy S tended to be fairly sluggish.  Certainly not as snappy and responsive as my wife’s iPhone 4.  This may have been the so called “lag” problem which led to various “lag fix” solutions promoted on various websites, none of which I felt comfortable about trying.

I also put performance issues down to the fact that I tend to work my phone very hard – I have it playing back podcasts and audiobooks for hours during the day. For some reason, prolonged audio playback seemed to cause steady deterioration in performance.  The apps I use (ACast and the Audible app) tended to be very CPU and RAM hungry, and sometimes the phone would completely jam up, needing a reboot.  It was not uncommon to have to reboot the phone two or three times a day. That did not seem right.

There was another annoyance which caused even more reboots. This was the “stuck notifications pull-down” problem. With Android, if you see notification icons in the status bar at the top, you can look at the detailed notifications by touching the bar and dragging down, revealing the notifications screen.  Ever since the Froyo update, a bug appeared such that occasionally, seemingly at random, the notification screen would “stick”, i.e. refuse to open when dragged.  Only a reboot would fix it.

A few weeks ago there was a system update, from 2.2 to 2.2.1. I approached it with trepidation, much as I had before with the Froyo 2.2 upgrade, because of the risk of losing data.  I backed up everything I could think of, including use of MyBackup Pro from Rerware to back up phone logs, text messages and all sorts of other data up to the cloud. In the event, the update to 2.2.1 ran without a hitch and no data was lost.  It was just a matter of setting up all my app icons – I had made a list of the icons I had placed on the various desktops.

And the result of the update was a very noticeable improvement in performance. Version 2.2.1 is supposed to include an official version of the “lag fix” or at least something to make the phone run more snappily. The Quadrant Standard benchmark also showed a significant improvement.

All was wonderful … until the aforementioned meltdown.  I had just set off on a long journey in the car, driving home to Manchester from London, and was looking forward to 2 or 3 hours of my audiobook. The book was playing when my wife tried to call (she has a special ringtone) but I could not get the phone to complete the connection.  Possibly reception was bad.  I tried to return the call using Vlingo voice dialling but could not get it to recognise my voice command with all the surrounding traffic noise. Repeated attempts to use Vlingo seemed to squeeze the phone’s resources to breaking point. Every time I tried to restart the audiobook the playback deteriorated, becoming more halting or cylon-like.  Sometimes it recovers with time.  On this occasion the phone just gave up and died.  Total lock-up.

I was on the motorway approach at the time so kept on driving and later pulled into a service station so I could at least call my wife.  The battery was very low and I rang to warn her. But the phone had had to be rebooted and now was not booting cleanly. I was getting warning dialog after warning dialog about background apps failing to start up.  Many apps could not be launched at all.  I could make calls but no chance of any podcasts or audiobooks.  I completed my long journey in silence or listening to the least awful dross I could find on the radio.

Back home it was obvious the phone had suffered a terminal meltdown.  No way would it recover from the messed up state it was in. My guess is that, when stressed by my attempts to run Vlingo voice commands alternating with audiobook playback, some key configuration data had been overwritten or corrupted. There was only one way out and that was to try a factory reset. On the plus side, I had all the backups and other preparation from my upgrade to Froyo 2.2.1, so took the plunge.

It worked. The phone was returned to a stable state and I was able to get all my data back from the cloud and other locations.  Only my old Kik conversations were lost.  And the phone was flying!  It had never performed better.  No lag of any kind.  No stuck notification screen.  No gradual deterioration in performance over the course of the day.  Battery lasting far better.  And no more reboots!

I did have to reinstall my apps of course.  Part way through that process I obtained a Quadrant benchmark of 1260 which is pretty amazing for a Samsung Galaxy S.  I did notice that the benchmark was reducing as I added apps incrementally. So I left out some of the apps I had been using before, such as Watchdog and NetSentry, which I no longer felt I needed and which had been sapping phone resources continuously in the background.

The Quadrant benchmark came down to around 1050 with all the apps I felt I really needed, but that is still very good and the phone continues to be a revelation.  Frustrating lag and slow-downs have been banished, and the phone mostly gets through the day now without needing a middle of the day battery boost.




Putting the Galaxy to rights #8 – Tasker for a Silent Night

April 27, 2011

Vista busy cursor It was only by chance that I came across the single most powerful and useful app available for Android, namely Tasker by Lee Wilmot.  I was Googling for information about the to-do list app Taskos but the search results were littered with articles about Tasker.  No doubt Google thought Taskos was a typo.

Tasker allows you to automate your phone in a far more sophisticated, powerful and flexible way than you might have thought remotely feasible. You automate your phone’s behaviour by creating profiles.  Each profile has one or more contexts and actions, the “when” and “what” respectively of the customised behaviour. The context could be based on time or date (e.g. do something at 8am every morning), location (do something when phone comes within a given distance of a geographical location), or an event such as an incoming text message or the user waving the phone about in a particular way, etc.  The actions cover everything from changing screen brightness to reading an SMS message out loud using the phone’s speech synthesiser.

My first very simple use of Tasker was to improve on my existing solution for muting audible email, text and other notifications at night. I had been using Advanced Mode Scheduler (AMS) to mute notification sounds between midnight and eight in the morning but this had drawbacks.  AMS does not let you schedule changes to a single phone setting – you are forced to choose settings for everything and they are all applied at the scheduled times. This meant that any manual changes I might have made (e.g. turning wifi on or off) would be overridden every time the AMS scheduler was activated.

Tasker is a far more precise instrument. I created a profile called Silent Night. It has a single context defined as the time period from midnight to 8am every day.  It has two actions.  The first sets the notification sounds volume to zero and is triggered on commencement of the context, i.e. at midnight.  The second action restores the notification volume and is triggered at the termination of the context, that is at 8am. No other settings are affected.

That simple profile barely scratches the surface of what Tasker can do.  I have now created four further profiles, to be the subject of future posts. 

%d bloggers like this: