Friday, July 25, 2014

Retrieving Data Balance using Tasker

If you are a Mobile Prepaid user (in India), you usually get post Call/SMS/Data session informative messages containing amount consumed, charged and balance remaining. Using Tasker, one can pull the necessary info from such messages and display it as a more useful home screen widget. Here I am explaining how to pull remaining data balance from the Post data session message displayed by BSNL


Since the formatting of message vary from carrier to carrier, this particular task will not work on any other carrier. However, one can create similar tasks to pull the data using 'Variable Split' and 'Variable Section' actions.

[Pre-requisites] Tasker and Minimalistic Text
[Profile Name] Post Data Session Msg Dismiss //You can change this
[Trigger Event] New Window (Label:*DATA session* Window Type:Dialog) //New Window containing the phrase 'DATA session'. This Query is used to isolate the flash message received after terminating a mobile data session.
[Execute Task when Event Occurs] Data Session
[Example of Flash Message received] "DATA session duration XXmin XXsec and data used is XXX.XXX KB and deducted from free DATA account. DATA Day Acc Bal remaining is XXXX.XX MB" (Carrier is BSNL - India)

[Task] Data Session
A1: Wait [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ]
A2: Variable Set [ Name:%NEWDATABAL To:%WIN]  //Sets variable 'DATADET' to contents of flash message received after disconnecting data. 'WIN' is a system variable that stores the contents of last flash message received.
A3: Button [ Button:Back ] //Simulates 'Back' Button Action to Close the Flash message dialog.
A4: Variable Split [ Name:%NEWDATABAL Splitter:is Delete Base:Off ] //Split the message on the basis of splitter 'is'. If you analyse the message given above, You will see that the remaining data balance is mentioned in the end and is preceeded by 'is'. So to retrieve just the balance, we have to split the message using the Variable Split action in Tasker. The splitter chosen is 'is'. After splitting following new variables are created by Tasker: NEWDATABAL1, NEWDATABAL2 and NEWDATABAL3. Of the three, one we need is NEWDATABAL3 as it contains the balance remaining. The last step is pushing the data to Minimalistic text widget for displaying it in the home screen.
A5: Minimalistic Text [ Configuration:Databalance = %NEWDATABAL3] //Push the variable to Minimalistic Text Widget

Dependent on Flash message. Sometimes, due to network issues, such messages may not be received and hence the data balance will not be updated.

No comments:

Post a Comment