FORUMS
Remove All Ads from XDA

[GUIDE][Difficulty: Intermediate] Monitor Monthly Call/Data Usage

833 posts
Thanks Meter: 1,866
 
Post Reply Email Thread
If you're not using an unlimited minutes/data plan, then you might be finding yourself monitoring your usage so you can stop yourself from incurring significant overages on your account. You can use a third-party widget or get notified from your carrier's app (if such a feature exists) but the disadvantages of these are a) the theming abilities of these widgets are limited or b) your carrier's app isn't all that great.

Using Tasker, AutoInput, and USSD codes you can easily grab this data and manipulate it however you want. In my tutorial, I will be grabbing the minutes/data used from T-Mobile USA and incorporate it into a Zooper Widget.

Prerequisites
  1. AutoInput to query the text on the toast input.
  2. USSD codes you can run that will provide you with the remaining minutes/data left in your account. You will have to look these up for your carrier.
  3. OPTIONAL: Zooper Widget, for displaying the minutes/data in the form of a progress bar.

I'm not defining any contexts here for you, but you can set these tasks up to run on whatever trigger you want. For instance, for me I have these two tasks run every night at 1am to update my Zooper Widgets.

Instructions
  • Run the USSD code you want to automatically grab at least one time manually in the phone app. Take a screenshot or write down the text used for reference. It's less than 160 chars since it's an SMS, so don't complain about having to write (You could use Flash action to show what the output is, that's up to you though)
  • Create a task and call it "Call Usage."
  • Phone --> Call. Set the Number to the USSD code that will return how many minutes you have left. For me on T-Mobile USA this is #646#. Check "Auto Dial."
  • Plugin --> AutoInput UI Query. Check "Only Visible" and go down to "Text" and put in some unique, recurring text from the USSD code pop-up that AutoInput will wait to see before querying the screen. For me, I used "Addl minutes are charged" because I'm on a pre-paid plan.
  • Plugin --> AutoInput Action. This one is a bit wonky to set up, but basically you'll want to have AutoInput ready to record your tap input while the USSD is already on screen. To do this I would recommend setting a wait function before running the USSD code, then quickly going to AutoInput and starting the record input function. Once the USSD code is on screen, you can record the input. Optionally, you can use an input tap to have it tap anywhere on the screen to dismiss it.
  • Variables --> Variable Split. Split %aitext(1) in an attempt to isolate the amount of remaining minutes you have. For me, I set the Splitter to "You have"
  • Variables --> Variable Split. Split %aitext12 to fully isolate the number value of the remaining minutes. Here, I did "included minutes" as the Splitter.
  • Variables --> Variable Set. Set Name to %calltotal and set it To your total minutes minur %aitext121. Check "Do Math". This will determine how many minutes you have actually used.
  • (OPTIONAL): Plugin --> Zooper Widget Pro Variable. Set #TCALLUSAGE# (which should be written as CALLUSAGE within the ZW configuration, but is presented to ZW as variable #TCALLUSAGE#) to %calltotal. Now you can display this variable as a part of any Zooper Widget you like!

  1. Create a new task called "Data Usage."
  2. Phone --> Call. Number is the USSD code that tells you the data remaining in your plan. For me on T-Mobile USA it's #932#. Again, set it to "Auto Dial."
  3. Plugin --> AutoInput UI Query. Again, like before, click on "Only Visible" and for Text set something unique from the USSD code pop-up that will make AutoInput query the screen when the text pops up.
  4. Plugin --> AutoInput Action. Do the same as before, hell, you can even copy/paste the same action from the previous task to dismiss the pop-up!
  5. Variables --> Variable Split. Split %aitext(1) to isolate the amount of data used. For me, I put "You have used" as the splitter.
  6. Variables --> Variable Split. Split %aitext12 using the splitter to separate the number and its data unit. For me, I set it to "MB"
  7. Variables --> Variable Set. Set Name to %datamb and set it to ceil(%aitext121). This will round-up the data usage to the nearest whole number, so it will display properly in Zooper Widget.
  8. (OPTIONAL): Plugin --> Zooper Widget Pro Variable. Set #TDATAUSAGE# to %datamb. Same idea as before.



Finally, here's what my Zooper Widget looks like (along with my config). My usage had just reset recently so you can't really see much of the progress, though:



Attached Files
File Type: xml Call_Usage.tsk.xml - [Click for QR Code] (8.3 KB, 440 views)
File Type: xml Data_Usage.tsk.xml - [Click for QR Code] (9.1 KB, 574 views)
The Following 6 Users Say Thank You to MishaalRahman For This Useful Post: [ View ] Gift MishaalRahman Ad-Free
 
 
8th March 2016, 09:53 AM |#2  
Senior Member
Flag Washington, DC
Thanks Meter: 37
 
More
Great work, any chance to posting the script?

Sent from my Nexus 6P using Tapatalk
8th March 2016, 05:12 PM |#3  
MishaalRahman's Avatar
OP Editor in Chief
Thanks Meter: 1,866
 
More
Quote:
Originally Posted by djide

Great work, any chance to posting the script?

Sent from my Nexus 6P using Tapatalk

I've placed the XML files as attachments to the thread. Cheers!
9th March 2016, 03:04 AM |#4  
TeriusPR's Avatar
Senior Member
Flag San Juan
Thanks Meter: 4
 
More
When I run the task it shows me this error and how or where do you make the or find the widget?
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20160308-230230.jpg
Views:	492
Size:	237.5 KB
ID:	3675766  
9th March 2016, 03:11 AM |#5  
MishaalRahman's Avatar
OP Editor in Chief
Thanks Meter: 1,866
 
More
Quote:
Originally Posted by TeriusPR

When I run the task it shows me this error and how or where do you make the or find the widget?

Can you provide a screenshot of the pop-up that shows up when you enter the USSD code? As for the widget, you would have to download Zooper Widget from the Play Store, then create a "Progress Bar" widget and for the number put in the variable that Tasker is setting, as shown in my screenshot. For the min put 0 and for the max put your data limit (for me, it's 5000MB)
9th March 2016, 03:21 AM |#6  
TeriusPR's Avatar
Senior Member
Flag San Juan
Thanks Meter: 4
 
More
This is the only popup, and then I receive a text message with all the data usage's numbers.
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20160308-231942.png
Views:	448
Size:	244.0 KB
ID:	3675774  
9th March 2016, 03:28 AM |#7  
MishaalRahman's Avatar
OP Editor in Chief
Thanks Meter: 1,866
 
More
Quote:
Originally Posted by TeriusPR

This is the only popup, and then I receive a text message with all the data usage's numbers.

Since your carrier is sending you text messages, you will have to intercept the text message content in order to get the data you want. My profile won't work for that, but luckily intercepting text message content is rather simple.

Simply create an Event, go to Phone --> Received Text. For the Sender, set it to the carrier's number that they text you from. You can leave the content part blank, or you can input a unique phrase from the text message that always stays the same so Tasker will only trigger off of these texts and not any other texts your carrier might send you. Then in the task, all the data you need to process will be stored in %SMSRB, which holds the SMS text content. Simply split until you get the data you've used each month and then you're golden.
The Following User Says Thank You to MishaalRahman For This Useful Post: [ View ] Gift MishaalRahman Ad-Free
9th March 2016, 03:44 AM |#8  
foxsprout's Avatar
Senior Member
Thanks Meter: 176
 
More
Great tutorial! How do you create the widget? Sorry, noob here...

also, what if I want to use different source (other than USSD), like SMS. Since my data usage in USSD only shows unlimited (I'm using unlimited plan with FUP), but when I use SMS, it's showing my left data usage.

Thanks before
9th March 2016, 03:51 AM |#9  
TeriusPR's Avatar
Senior Member
Flag San Juan
Thanks Meter: 4
 
More
The event part was pretty simple but setting the task gave me a little of problem because I'm not sure how to split those variables and what name exactly put in. Do I need something more?
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20160308-234927.png
Views:	238
Size:	185.9 KB
ID:	3675808  
14th April 2016, 05:52 PM |#10  
Junior Member
Thanks Meter: 0
 
More
not works for me
it getting error at variable split
11th May 2016, 03:11 AM |#11  
Junior Member
Thanks Meter: 0
 
More
Variable split error
To those of you getting an error when trying to split the variable, see this attached screenshot. It works!

Thanks OP. Good idea.
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2016-05-10-19-07-33.png
Views:	300
Size:	131.1 KB
ID:	3747029  
Post Reply Subscribe to Thread

Tags
data plan, minutes, tasker, ussd, zooper widget

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes