Variables
General
A variable is a named value which changes over time e.g. the level of the battery, the time of day.
When Tasker encounters a variable name in a text, it replaces the name with
the current value of the relevant variable before carrying out the action.
The main purposes of variables are:
- 'dynamic binding': doing something with an action with data which
is unknown when the task is created e.g. respond to an SMS; the sender
is not known until the SMS is received.
- allow flow control within and
between tasks
- record data for some future use e.g. passing data between tasks
Variable Lifetime
Variable values should persist while Tasker is installed, even over a reboot of the device.
Built-In Variables
The values of Built-In variables are updated by Tasker.
- Airplane Mode Status
(dynamic)
%AIR
Whether Airplane Mode is on or off
- Battery Level
%BATT
Current device battery level from 0-100.
- Bluetooth Status
(dynamic)
%BLUE
Whether Bluetooth is on or off.
- Clipboard Contents
%CLIP
The current contents of the system clipboard.
- Date
%DATE
Current human-readable date.
- Day of the Month
%DAYM
Current Day of the Month, starting at 1.
- Day of the Week
%DAYW
Current Day of the Week starting with Sunday.
- Call Number/Date/Time
%CNUM / %CDATE / %CTIME
The number, date and time of the last call received.
- Email From/Cc/Subject/Date/Time
%EFROM / %ECC / %ESUBJ / %EDATE / %ETIME
The From, Cc, Subject, Received Date and Received Time of the last email received
by the K9 email agent.
- Free Memory
%MEMF
System free memory remaining in MB.
- GPS Status
%GPS
Whether the system GPS receiver is on or off.
- HTTP Response Code / Data / Content Length
%HTTPR / %HTTPD / %HTTPL
Values from the last HTTP POST/GET action.
- Keyguard Status
%KEYG
Whether the Keyguard is on or off
- Last Application
%LAPP
The name of the application that was in the foreground before the current one e.g. Maps.
- Last Photo
%FOTO
The filesystem path to the last photo taken by Tasker or the
standard system camera application.
- Location
%LOC
The latitude and longitude of the most accurate last position fix (GPS etc.)
- Location Accuracy
%LOA
The accuracy in metres of the most accurate last position fix.
- Location Provider
%LOP
The location provider for the most accurate last position fix.
- Screen
(dynamic)
%SCREEN
Whether the screen is on (value on) or off (value off).
- Silent Mode
(dynamic)
%SILENT
The current state of silent mode: off, vibrate or on.
- SMS From/Date/Time
%SMSRF / %SMSRB / %SMSRD / %SMSRT
The sender, body, date and time of the last SMS received.
These variables will be empty until the first time an SMS is received after
they have been referenced because Tasker does not monitor SMSs unless it's needed.
- Task Queue Seconds
%QTIME
The number of seconds since the current task first started executing.
Note that tasks can be interrupted by higher priority tasks, so this number
is not necessarily the total run-time of the task.
- Time
%TIME
Current human-readable time.
- Time Seconds
%TIMES
The current time in seconds.
- Uptime Seconds
%UPS
The number of seconds since the device last booted.
- Volume - Alarm/Call/Media/Notification/Ringer/System
(dynamic)
%VOLA / %VOLC / %VOLD / %VOLM / %VOLN / %VOLR / %VOLS
Current audio channel volume level.
- WiFi Info
%WIFII
When connected to an Access Point (AP), shows human-readable data about the AP. When not connected,
show details of the most recent Wifi scan results for nearby APs.
- WiFi Status
(dynamic)
%WIFI
Whether WiFi is on or off.
Note: if WiFi is enabling or disabled, in fact anything but enabled, it's classed as off.
Variables marked dynamic in the list above trigger changes in Variable Value states
and Variable Set events whenever their value changes.
User Variables
The actions Variable Set can be used to create new variables. Variable names must start with the % character and have
at least a further 3 alphanumeric characters.
Uninitialized Variables
User-variables which have not had a value assigned do not have replacements carried out e.g. in the expression I love %FRUIT, if
%FRUIT is uninitialized, the expression remains as it is, otherwise %FRUIT is replaced with the value.
Exception: uninitialized variables used in mathematical expressions are replaced with 0.
Variable Actions
There are several actions dedicated to direct manipulation of variable values. They're all
in the Variables category.
In addition, you can read lines or paragraphs from a text file into a variable with the
actions Read Line and Read Paragraph in the File category.