Variable Types
MacroDroid supports different variable types.
Choosing the right type for each variable helps keep your macros clean, efficient, and easy to maintain.
Understanding these types will allow you to store and manipulate data more effectively in your automations.
String
Stores text — any combination of letters, numbers, symbols or spaces.
Examples:
"Hello world""Current temperature: 25°C""https://api.example.com/login""User123"
Common uses:
- Notifications and Text to Speech (TTS)
- Building dynamic messages
- Storing HTTP responses, file paths or user input
Example with Magic Text: The current time is {hour}:{minute}
Integer
Stores whole numbers (positive or negative, without decimals).
Examples:
0,42,-15,2026
Common uses:
- Counters (e.g. how many times a macro has run)
- Loop control (repeat X times)
- Numeric comparisons (
if battery > 30)
Practical example:
- Action: Set Variable →
wifiCount = wifiCount + 1
Decimal
Stores numbers with a decimal point for more precise calculations.
Examples:
3.14,25.75,-0.5,12.345
Common uses:
- Mathematical operations
- Temperature, distance, percentages, averages
- Results of Calculate Mathematical Expression
Practical example:
- Action: Set Variable →
average = (value1 + value2) / 2
Boolean
Stores a simple logical value:
true / false.
Examples:
truefalse
Common uses:
- Flags and states (
isNightMode,isCharging,hasNotified) - Controlling macro flow with If conditions
- Avoiding repeated executions
Practical example:
- If
{v=nightMode}istrue, activate dark mode and lower brightness.
Array
Stores an ordered list of values. Each element can be accessed by its position (index).
Examples:
[1, 2, 3, 4]["Monday", "Tuesday", "Wednesday"]["Apple", "Banana", "Orange"]
Common uses:
- Lists of items (messages, URLs, names, settings)
- Random selection
- Iterating through elements with the Iterate Dictionary/Array action
Practical example:
messages = ["Good morning!", "Have a great day!", "Hello!"]- Use Iterate Dictionary/Array to show a random message in a notification.
Dictionary
Stores key-value pairs (structured data, similar to a JSON object).
Examples:
{"name": "Josue", "age": 28}{"city": "Mexico City", "country": "Mexico"}{"user": {"name": "Josue", "premium": true}}
Common uses:
- Storing API responses
- Settings
- Organized user or device data
Access example: After saving a dictionary in {v=user}, you can access its values with:
{v=user[name]}{v=user[age]}
Practical example:
- After an HTTP request, save user data:
user = {"name": "Josue", "level": 4, "premium": true}- Then use
{v=user[premium]}in conditions.
Quick Comparison
| Type | Stores | Best use | Example |
|---|---|---|---|
| String | Text | Messages, URLs, responses | "Hello world" |
| Integer | Whole numbers | Counters, loops, comparisons | 42 |
| Decimal | Numbers with decimals | Mathematics, measurements, averages | 25.75 |
| Boolean | True / False | States and flags | true |
| Array | Ordered list | Lists, random selection | ["Mon", "Tue", "Wed"] |
| Dictionary | Key-value | Structured data, APIs | {"name": "Josue"} |
