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.
- Call Name / Number/ Date / Time (In)
(dynamic, monitored)
%CNAME / %CNUM / %CDATE / %CTIME
The caller name, number, date and time of the last call received.
Caller number is 0 if it's unknown.
Caller name is ? if it's unknown (probably because the caller number was blocked)
and set to the caller number if the contact couldn't be looked up.
It's unavailable on Android versions prior to 2.0.
- Call Name / Number/ Date / Time / Duration (Out)
(dynamic, monitored)
%CONAME / %CONUM / %CODATE / %COTIME / %CODUR
The called name, number, date and time of the last outgoing call made.
Called Name is set to the called number if the contact couldn't be looked up.
It's unavailable on Android versions prior to 2.0.
- Cell ID
(dynamic,monitored)
%CELLID
The current cell tower ID if known.
If you are using a Cell Near state, note that sometimes the Cell Near state will stay active
even though %CELLID reports that the tower ID is unknown or invalid; that is because Cell Near only
responds to valid IDs to prevent the state becoming inactive e.g. due to a service interruption.
- Cell Signal Strength
(dynamic,monitored)
%CELLSIG
The current phone signal level from 0-8 inclusive on a rougly linear scale. On some CDMA phones, the level will rise in steps of 2 (0,2,4,6,8). The value is -1 if the value
is unknown or there is e.g. no service.
There is a bug with some Android versions that the reported signal strength is not updated until the
device is turned off and on.
- Cell Service State
(dynamic,monitored)
%CELLSRV
The current phone service state. One of unknown, service, noservice, emergency, nopower.
- 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.
- Display Brightness
%BRIGHT
Current screen brightness, 0-255. On some devices, if the Android setting Auto Brightness is enabled, the
value will always be 255.
- Display Timeout
%DTOUT
Current system screen timeout (seconds).
- Email From/Cc/Subject/Date/Time
(dynamic)
%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
(dynamic)
)
%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.
- Light Level
(dynamic,monitored)
%LIGHT
The last recorded light level in lux.
- Location
(dynamic)
%LOC
The latitude and longitude of the last GPS fix.
See note.
- Location Accuracy
(dynamic)
%LOCACC
The accuracy in metres of the last GPS fix.
See note.
- Location Altitude
(dynamic)
%LOCALT
The altitude in metres of the last GPS fix, or 0 if unavailable.
See note.
- Location Speed
(dynamic)
%LOCSPD
The speed in metres/second at the last GPS position fix or 0 if unavailable.
See note.
- Location Fix Time Seconds
(dynamic)
%LOCTMS
The time in seconds of the last GPS fix. To get age of fix, take this away from %TIMES.
This value is not set until an offset of the GPS time from the fixed time has
been calculated (should be after the first GPS fix) because the value is meaningless
until that point.
See note.
- Location (Net)
(dynamic)
%LOCN
The latitude and longitude of the last network location fix.
See note.
- Location Accuracy (Net)
(dynamic)
%LOCNACC
The accuracy in metres of the last network location fix.
See note.
- Location Fix Time (Net)
(dynamic)
%LOCNTMS
The time in seconds of the last net location fix. To get age of fix, take this away from %TIMES.
See note.
- Music Track
(dynamic)
)
%MTRACK
The current playing music track (for Tasker actions Music Play and Music Play Dir only)
- Muted
%MUTED
Whether the microphone is currently muted (on) or not (off).
- Notification Title (monitored, dynamic)
%NTITLE
The title of the last notification shown in the status bar. Requires Tasker's accessibility server
to be running (see Android Accessibility Settings). Notifications generated by Tasker are not shown.
Not available on Cupcake.
- Phone Number
%PNUM
The current phone number of the device, if it's in service.
On some phones it doesn't work (Android limitation), seems related to the type of SIM.
- Profiles Active
(dynamic)
%PACTIVE
A comma-separated list of the currently active, named profiles in activation order. Duplicate
names will appear on the list only once.
- Profiles Enabled
(dynamic)
%PENABLED
A comma-separated list of the currently enabled, named profiles in creation order. Duplicate
names will appear on the list only once.
- Roaming
%ROAM
on if device is roaming on the current telephone network, otherwise off.
- 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.
- Speakerphone
%SPHONE
Whether the speakerphone is on or off
- Speech
(dynamic)
)
%SPEECH
The current utterance as a result of a Say or Say File action, if applicable.
- Task Queue Seconds
(dynamic)
)
%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.
- Telephone Network
%TNET
The current telephony network operator the device is using.
May be unreliable on CDMA networks
- Text From/Date/Subject/Time
(monitored)
%SMSRF / %SMSRN / %SMSRB / %SMSRD / %MMSRS / %SMSRT
The sender address, name, body, date and time of the last text (SMS or MMS) received.
These variables will be empty until the first time a text is received after
they have been referenced because Tasker does not monitor SMSs unless it's needed.
Sender name is set to sender address of no contact could be looked up.
It's unavailable on Android versions prior to 2.0.
Subject will only be set if the last text was an MMS.
- Time
%TIME
Current human-readable time.
- Time Seconds
%TIMES
The current time in seconds.
(seconds since some time in January, 1970, if you must know).
- Uptime Seconds
%UPS
The number of seconds since the device last booted.
- Volume - Alarm/Call/DTMF/Media/Notification/Ringer/System
(dynamic)
%VOLA / %VOLC / %VOLD / %VOLM / %VOLN / %VOLR / %VOLS
Current audio channel volume level.
On some devices, volume changes are not picked up dynamically, on others not
when using the phone app.
- 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.
- Wimax Status
%WIMAX
Whether Wimax is on or off.
Note: if Wimax is enabling or disabled, in fact anything but enabled, it's classed as off.
- Window Label
(monitored)
%WIN
The label of the current window, which could be a full-screen activity or a dialog.
Not set if the label is unknown.
For some windows, the label might be that of the first item in the window e.g. a menu entry or even a button.
General Notes
Variables marked dynamic
in the list above trigger changes in Variable Value states
and Variable Set events whenever their value changes.
Variables marked monitored
will cause the relevant monitor to startup to track their state
when they are used in contexts or tasks which are used by widgets or enabled profiles.
For instance, %CELLS used in a Flash action will cause cell location to be tracked.
Limitation: monitored variables cannot be detected in anonymous shortcuts.
Note On Location Variables
When the relevant provider (Net or GPS) is active, these variables report the values from the provider,
which may be more recent than Tasker has seen if other applications are asking for location.
When the relevant provider is not active, these variables report the last values seen by Tasker,
which could be the result of a Get Location
action or of monitoring for a Location Context
.
That means the the reported fix times could go backwards, if you turn off the location provider
between two uses of the variables.
User Variables
The actions Variable Set can be used to create new variables. Variable names have the following restrictions:
- they must start with the % character
- they are case-sensitive
- then must at least a further 3 alphanumeric characters, of which the first can't be a number
- they can also contain the underscore character (_) but not start or end with it
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.
Variables In Plugins
From Tasker version 1.0.10, plugin developers can tell Tasker to replace variables
it finds in plugin strings with their current Tasker value. If you have a plugin
which doesn't support this, send the developer this URL
http://tasker.dinglisch.net/plugins.html
which has the relevant details.