Difference between revisions of "Trigger: MacroDroid Variable Change"

 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
=== About ===
+
<pre class="header-style">The MacroDroid Variable Change trigger fires when a MacroDroid variable is set to a certain value. This trigger monitors both global and local variables, allowing you to create reactive macros that respond to changes in variable state. The trigger fires once when the condition is first met, not repeatedly while the condition persists.</pre>
  
 +
''' Options '''
  
==<p><b>Specific value</b></p>==
+
''' Variable Selection '''
  
===  =  ===
+
First, select which variable to monitor from the list of available global and local variables. Variables can be of the following types:
 +
* String
 +
* Integer
 +
* Decimal
 +
* Boolean
 +
* Dictionary (with key selection)
 +
* Array (with index selection)
  
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
+
''' Trigger Mode '''
Means that the whole content of the string variable has to be equal to the whole set of typed characters.
 
</pre>
 
'' Compatible with [https://macrodroidforum.com/wiki/index.php/Variables#Standard_Variable_Types Variables | String, Integer, Decimal, Boolean] (Boolean only in the compare values condition/constraints) ''
 
<br>
 
  
===  != ===
+
* '''Specific Value Change''' - Fire when the variable changes to a specific value matching certain criteria
 +
* '''Any Value Change''' - Fire whenever the variable value changes to any new value
  
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
+
''' Comparison Options by Variable Type '''
Means that the content of the string variable has to be unequal (i.e. different) to the set of typed characters.
 
</pre>
 
'' Compatible with [https://macrodroidforum.com/wiki/index.php/Variables#Standard_Variable_Types Variables | String, Integer, Decimal, Boolean] (Boolean only in the compare values condition/constraints) ''
 
  
=== Contains ===
+
''Boolean Variables:''
 +
* True
 +
* False
  
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
+
''Integer/Decimal Variables:''
Means that the content of the string variable has to contain the whole set of typed character. For instance, enter the word information to match with a string variable containing the text: Here are the informations you asked for...
+
* '''Equal to (=)''' - Fires when the value equals the specified number
</pre>
+
* '''Not equal to (!=)''' - Fires when the value does not equal the specified number
'' Compatible with [https://macrodroidforum.com/wiki/index.php/Variables#String Variables | String '']
+
* '''Greater than (>)''' - Fires when the value becomes greater than the specified number (fires once on transition)
 +
* '''Less than (<)''' - Fires when the value becomes less than the specified number (fires once on transition)
  
=== Excludes ===
+
For numeric comparisons, you can specify:
 +
* A fixed numeric value
 +
* Another variable's value
 +
* A mathematical expression
  
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
+
''String Variables:''
Means that the content of the string variable has not to contain the typed text.
+
* '''Equals (=)''' - Fires when the string exactly matches the specified text
</pre>
+
* '''Not equals (!=)''' - Fires when the string does not match the specified text
'' Compatible with [https://macrodroidforum.com/wiki/index.php/Variables#String Variables | String] ''
+
* '''Contains''' - Fires when the string contains the specified text as a substring
 +
* '''Excludes''' - Fires when the string does NOT contain the specified text
  
==<p><b>The wildcards '*' and '?'</b></p>==
+
''' Additional String Options '''
  
=== ''' *''' ===
+
* '''Enable regular expression matching''' - Use regex syntax for pattern matching
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
+
* '''Ignore case''' - Perform case-insensitive comparison (disabled when regex is enabled)
* stands for any number of character (from 0 to any, same as '.*' in Regex).
 
</pre>
 
  
=== ? ===
+
''' Wildcard Matching '''
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
 
? is for 1 and only 1 mandatory character (same as '.{1}' in Regex).
 
</pre>
 
  
* '''Tick the box '''Enter regular expression matching''' if the typed text follows Regex syntax, far more powerful than plain text with or without wildcards (for advanced users).'''
+
When not using regex, wildcards can be used in string matching:
 +
* '''Asterisk (*)''' - Matches zero or more characters
 +
* '''Question mark (?)''' - Matches exactly one character
 +
 
 +
''' Examples '''
 +
 
 +
''Example 1: Announce when counter reaches 100''
 +
 
 +
  <pre class="trigger-style">Triggers
 +
 
 +
MacroDroid Variable Change: counter = 100</pre>
 +
  <pre class="action-style">Actions
 +
 
 +
Speak Text: Counter has reached 100</pre>
 +
 
 +
''Example 2: React to status variable containing "error"''
 +
 
 +
  <pre class="trigger-style">Triggers
 +
 
 +
MacroDroid Variable Change: status contains error</pre>
 +
  <pre class="action-style">Actions
 +
 
 +
Notification: Error detected in status</pre>
 +
 
 +
''' Notes '''
 +
 
 +
* For greater than (>) and less than (<) comparisons, the trigger only fires once when the value transitions into this state, not on subsequent updates where the same condition is still met
 +
* Local variables are only monitored for the macro they belong to
 +
* Dictionary and array variables allow you to monitor specific keys or indices
 +
* Magic text can be used in string comparison values
 +
* Expression evaluation is supported for numeric comparisons (e.g., using mathematical formulas)
 +
 
 +
''' See Also '''
 +
 
 +
* [[Action: Set Variable]]
 +
* [[Constraint:_MacroDroid_Variable]]

Latest revision as of 20:45, 6 January 2026

The MacroDroid Variable Change trigger fires when a MacroDroid variable is set to a certain value. This trigger monitors both global and local variables, allowing you to create reactive macros that respond to changes in variable state. The trigger fires once when the condition is first met, not repeatedly while the condition persists.

Options

Variable Selection

First, select which variable to monitor from the list of available global and local variables. Variables can be of the following types:

  • String
  • Integer
  • Decimal
  • Boolean
  • Dictionary (with key selection)
  • Array (with index selection)

Trigger Mode

  • Specific Value Change - Fire when the variable changes to a specific value matching certain criteria
  • Any Value Change - Fire whenever the variable value changes to any new value

Comparison Options by Variable Type

Boolean Variables:

  • True
  • False

Integer/Decimal Variables:

  • Equal to (=) - Fires when the value equals the specified number
  • Not equal to (!=) - Fires when the value does not equal the specified number
  • Greater than (>) - Fires when the value becomes greater than the specified number (fires once on transition)
  • Less than (<) - Fires when the value becomes less than the specified number (fires once on transition)

For numeric comparisons, you can specify:

  • A fixed numeric value
  • Another variable's value
  • A mathematical expression

String Variables:

  • Equals (=) - Fires when the string exactly matches the specified text
  • Not equals (!=) - Fires when the string does not match the specified text
  • Contains - Fires when the string contains the specified text as a substring
  • Excludes - Fires when the string does NOT contain the specified text

Additional String Options

  • Enable regular expression matching - Use regex syntax for pattern matching
  • Ignore case - Perform case-insensitive comparison (disabled when regex is enabled)

Wildcard Matching

When not using regex, wildcards can be used in string matching:

  • Asterisk (*) - Matches zero or more characters
  • Question mark (?) - Matches exactly one character

Examples

Example 1: Announce when counter reaches 100

Triggers

MacroDroid Variable Change: counter = 100
Actions

Speak Text: Counter has reached 100

Example 2: React to status variable containing "error"

Triggers

MacroDroid Variable Change: status contains error
Actions

Notification: Error detected in status

Notes

  • For greater than (>) and less than (<) comparisons, the trigger only fires once when the value transitions into this state, not on subsequent updates where the same condition is still met
  • Local variables are only monitored for the macro they belong to
  • Dictionary and array variables allow you to monitor specific keys or indices
  • Magic text can be used in string comparison values
  • Expression evaluation is supported for numeric comparisons (e.g., using mathematical formulas)

See Also