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
AutoInput to query the text on the toast input.
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.
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)
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
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!
Create a new task called "Data Usage."
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."
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.
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!
Variables --> Variable Split. Split %aitext(1) to isolate the amount of data used. For me, I put "You have used" as the splitter.
Variables --> Variable Split. Split %aitext12 using the splitter to separate the number and its data unit. For me, I set it to "MB"
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.
(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:
Great work, any chance to posting the script?
Sent from my Nexus 6P using Tapatalk
djide said:
Great work, any chance to posting the script?
Sent from my Nexus 6P using Tapatalk
Click to expand...
Click to collapse
I've placed the XML files as attachments to the thread. Cheers!
When I run the task it shows me this error and how or where do you make the or find the widget?
TeriusPR said:
When I run the task it shows me this error and how or where do you make the or find the widget?
Click to expand...
Click to collapse
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)
This is the only popup, and then I receive a text message with all the data usage's numbers.
TeriusPR said:
This is the only popup, and then I receive a text message with all the data usage's numbers.
Click to expand...
Click to collapse
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.
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
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?
not works for me
it getting error at variable split
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.
Hey , didnt manage to understand whats the the USSD code you mention at the firsts steps of the guide.
Is it the code before the number of a phone?Of my phone or what? :/
vasilis_ said:
Hey , didnt manage to understand whats the the USSD code you mention at the firsts steps of the guide.
Is it the code before the number of a phone?Of my phone or what? :/
Click to expand...
Click to collapse
It's a "number" you can call. It's different for every carrier but it usually involves a * and a #.
When you call that "number" you get a pup up dialog with some I formation about your sms/phonecalls/data etc.
MishaalRahman said:
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
AutoInput to query the text on the toast input.
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.
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!
Create a new task called "Data Usage."
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."
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.
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!
Variables --> Variable Split. Split %aitext(1) to isolate the amount of data used. For me, I put "You have used" as the splitter.
Variables --> Variable Split. Split %aitext12 using the splitter to separate the number and its data unit. For me, I set it to "MB"
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.
(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:
Click to expand...
Click to collapse
I found out an app which does the same thing and has a well defined widget too
https://play.google.com/store/apps/details?id=fahrbot.apps.ussd.widget.lite
Hello, i just found out this thread. i am sorry for bringing up a year old thread, but I have had no luck finding something like this a little fresher.
I have been trying to get this to work in my phone(GS6) and my carrier(Claro Dominicana).
By the time my task reaches the variable split step i get an error. I cannot post the image because I am new to the forums. But basically it says the following: "Variable split: can't split unset value to set %aitext12"
I hope some of you can point me in the right direction.
Regards
Hello all XDA users! I created a project that automatically switches the clock format on your WM watchface whenever you switch between the formats on your phone via system settings.
===Prerequisites===
First and foremost, you need to install the Tasker (I used this on full version but it may work on the trial version) and have Allow External Access enabled, you can do this by doing the following:
Press the 3 dot menu
Click Preferences
Swipe over to Misc and find Allow External Access, then tap it to enable it
Done!
Then you need AutoTools by joaomgcd, you can download it here
Have USB Debugging enabled for ADB configuration for AutoTools
To Enable this, do the following:
Go to Settings
Go to About Device
Find your build number and click it several times until the phone says that you have enabled developer mode
Go into Developer Settings
Click on the tab that sets USB Debugging to enable it
Done!
Have ADB Drivers/Fastbook installed, here are two places that you can download these from but you don't have to download from these: Skipsoft, XDA
Have Installed WatchMaker Premium or Free Version
===About this Project===
What this project does is check if you have booted up your device and if so, it records the current time format your clock is set to. Then it checks if you have changed the format of your clock via broadcast intent, then it compares the previously recorded setting and the new setting, if they do not match, the task sends the new setting to WatchMaker and it changes the format on the watch to the new setting.
===Building the Project===
The first and foremost you MUST do is ensure that you have downloaded and got everything from the prerequisites. Once you have everything, follow the instructions for enabling access to system settings for AutoTools (you HAVE to do this in order for the profile to function correctly, as it needs to read the configuration for the 24hr format switch in the system settings, the profile will ONLY be looking at this setting). Once you have done these, you can move on to making the actual profiles
For the first profile, it will record the current clock format soon after the device boots up
So we must create an Event profile that will trigger soon after the phone finishes booting on, leave Invert unchecked
Now here's what you need for the actions:
Plugins -> AutoTools -> Secure Settings. Then click custom settings and do the following:
Setting Type: System
Name: time_12_24
Input Type: String
Leave Value Blank
Read Setting: Enabled
Variables -> Variable Set. Set %TIME_FORMAT to %time_12_24 (its the variable that AutoTools passes for the custom setting). This records the value we got from AutoTools and stores it in a global variable for us to use later on
OPTIONAL: Alert -> Notify Vibrate. For Title: put 'Logged Format Time' without quotes, and for text, added 'Log Format: %TIME_FORMAT' without quotes. This will notify that you have logged the format and will tell what the format is.
OPTIONAL: Task -> Wait. Set it for 10 seconds. This will make Tasker wait 10 seconds to move on to the next action
OPTIONAL: Alert -> Notify Cancel. For Title: put 'Logged Format Time' without quotes, and have Warn Not Exist checked. This will dismiss that notification we just sent 10 seconds ago
For the second profile, it will do the actual process of sending the variables to the WatchMaker App
We're going to create a Intent Received profile that will check if the specified broadcast intent has been received. For action, put 'android.intent.action.TIME_SET' without quotes. This will check if the TIME_SET intent has been received
Now here's what you need for the actions:
Task -> If. Set the condition to %TIME_FORMAT is SET. This will check if the global variable we defined in the first profile has something in it (this is for in case that you didn't boot up your device to store the value to the global variable so Tasker does not return an error since there is no value in the variable)
Plugin -> AutoTools -> Secure Settings. Like the same as like time, we're going to be finding that system variable, time_12_24. Just do the exact same steps as listed for the last time we defined this action
Task -> If. This time, set the condition to %time_12_24 does not match (!~) to %TIME_FORMAT. This will make Tasker check if the system format variable we just grabbed in the previous action DOES NOT match the previously recorded variable from our first profile. This is necessary to check because if you have automatic update clock enabled in system settings, that TIME_SET intent gets called whenever the phone updates to the network time, and because of this, we do not want Tasker constantly nagging us that the format has been update, despite that the format is the same as before.
Plugin -> WatchMaker -> WM Send Variable. Set the variable to send to %time_12_24, which is the new format that we switched to and just checked for.
OPTIONAL: Alert -> Notify Vibrate. For Title: put 'Time Format Changed' without quotes, and for text, added 'Updated Format to %time_12_24' without quotes. This will notify that you have logged the format and will tell what the format is.
OPTIONAL: Task -> Wait. Set it for 10 seconds. This will make Tasker wait 10 seconds to move on to the next action
OPTIONAL: Alert -> Notify Cancel. For Title: put 'Time Format Changed' without quotes, and have Warn Not Exist checked. This will dismiss that notification we just sent 10 seconds ago
Task -> End If. Close that If stated that we have created so far
Variables -> Variable Set. Set %TIME_FORMAT to %time_12_24. This will override the previously recorded value and place the new one in its place in the variable, %TIME_FORMAT
Task -> Stop. Leave everything else blank. This will make Tasker end the task from here
Task -> Else. Leave everything else blank. This basically says that if that system format variable DOES have something in it. This is necessary to check because
OPTIONAL: Alert -> Notify Vibrate. For Title: put 'Logged Format Time' without quotes, and for text, added 'Log Format: %time_12_24' without quotes. This will notify that you have logged the format and will tell what the format is.
OPTIONAL: Task -> Wait. Set it for 10 seconds. This will make Tasker wait 10 seconds to move on to the next action
OPTIONAL: Alert -> Notify Cancel. For Title: put 'Logged Format Time' without quotes, and have Warn Not Exist checked. This will dismiss that notification we just sent 10 seconds ago
Variables -> Variable Set. Set %TIME_FORMAT to %time_12_24. This records the value we got from AutoTools and stores it in a global variable for us to use later on.
Task -> End If. Close up the main IF statement that surrounds everything.
One final thing! Make sure that your watchface in WM has this method or something similar (WITH the quotes): '{ttime_12_24}' == '24' and '{dh23z}:{dmz}' or '{dh}:{dmz} {da}'. This sets the clock format to 24hr if the tasker value is 24, and switches to 12hr if the value is 12.
Note: You DO NOT have to have items such as he notification and clock method text to display exactly as I have, as I have designed these for my convenience.
===Download===
The download files are attached below, you can import this by doing the following:
Long-press the little icon that looks like a house at the bottom of the main menu
Press Import
Locate the downloaded file
Tasker should do the rest and import the entire project and the profiles
===Final Notes===
If you have any questions or issues, please feel free to post them here! ^^
Hello everyone i have a huawei mate 20 non root with android 9 and i would like to cancel an alarm with tasker but impossible.
I can activate an alarm at a given time but in the opposite direction impossible. do you have an idea thanks again
cordially
There are several ways to do this. What have you tried that isn't working? Even better, post the profile or task that isn't doing what you want. If you post just the task to snooze/dismiss an alarm, what triggers the task to run?
Before exporting, if you have sensitive information such as logins, api keys or anything else, you might consider setting those values to a variable and use the variable in your tasks so they won't export with the task.
To export a task description for posting, press on the name to highlight the profile. Go to the 3-dot menu and select export -> Description to Clipboard.
Now you'll be able to paste it. Be aware, it easier to use something like pastebin.com / hastebin.com and link to a post here. If you paste in a post here, the forum software will convert semicolons with characters directly after, into emoticons making it very hard to read.
Hello everyone here is what I can do and what does not work.
* What works
Calendar Entry Profile -> Work
Then task -> Set ALARM AM 05 H 45
* What does not work is the reverse task if not working then disable alarm clock
Thanks
Flechg said:
Hello everyone here is what I can do and what does not work.
* What works
Calendar Entry Profile -> Work
Then task -> Set ALARM AM 05 H 45
* What does not work is the reverse task if not working then disable alarm clock
Thanks
Click to expand...
Click to collapse
Posting the profile and task (as described above) is always more illuminating. However, the inverse of that would just be not setting an alarm. If there's no calendar entry the alarm is not set. I'm still missing the problem. Is there a residual alarm that goes off without having been set through tasker?
Edit -
I've been pondering and the only thing I can come up with is that you set an alarm and then the next day you set an alarm... then end up with a clock app full of alarms. If that's the problem, and the goal is to have the alarm only go off on work days, then approaching this problem the other way might be better.
Set the alarm to go of every day at the right time in the clock app, then create a profile that checks if today it's a work day, then set a variable.
In a second profile, use the variable (not a work day) as a context plus an AutoNotification intercept, for the alarm notification. You'll be canceling the alarm on days you don't need it.
On newer Android, there is a pre-notification that shows up some period before the alarm is set to fire (an hour maybe?). That notification has a dismiss button. If you intercept that notification, then the entry task can click on the dismiss button again using an AutoNotification action.
I think the category id is "Upcoming Alarms". This field can be examined by grabbing it in the AutoNotification profile context configured to "get all fields". Then flash %ancategoryid.
There are also clock app intents that can dismiss alarms. I don't use that because it doesn't work on my device. The intent looks like the following:
Code:
Send Intent [
Action:android.intent.action.DISMISS_ALARM
Cat:Default
Mime Type:
Data:
Extra:android.intent.extra.alarm.SEARCH_MODE:android.all
Extra:
Extra:
Package:
Class:
Target:Activity
This intent should only cancel the current occurrence of a repeating alarm.
If this works for you, then you can explore the android developer documentation - alarm clock and discover a variety of intents.
For the sake of completeness, in case this thread is found by others in the future, there is an action system -> cancel alarm.
This can be used to cancel/snooze/disable an alarm. However, it's reliability is dependant on the device/OS and at least in my case doesn't work any better than the intent. Some devices will always get a pop-up menu to confirm which alarm to take action on.
Hello and thank you for your answers
i tried intent as well as other things like cancel alarm but with my huawei it does not work okay is this android 9
I give up thanks again for your help
:crying:
The autoNotification method should work. If you haven't gone through and made sure that all of Huawei's power saving "features" are disabled so the apps can wake up and do their job without being killed by the system.
Read these
https://dontkillmyapp.com/huawei
https://tasker.joaoapps.com/userguide/en/faqs/faq-problem.html#00
If you really want help, then post what isn't working. Instructions to do so were given in post 2.