| Line 1: |
Line 1: |
| − | <pre style="background-color: #EEEEEE; color: Black; border-radius: 10px; padding: 10px;"> | + | <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> |
| − | Will fire when a MacroDroid variable is set to a certain value.
| |
| | | | |
| − | Note that when comparing less than or greater than, the trigger will only fire once when the value transitions into this state (not on subsequent updates where that same condition is still met).
| + | ''' Options ''' |
| − | </pre>
| |
| − | <br>
| |
| − | '''Example Usage'''<br/> | |
| | | | |
| − | <pre style="background-color: #AC2424; color: white; border-radius: 10px; padding: 10px;">
| + | ''' Variable Selection ''' |
| − | Triggers
| |
| | | | |
| | + | 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><br>
| + | ''' Trigger Mode ''' |
| − | <pre style="background-color: #1665B0; color: white; border-radius: 10px; padding: 10px;">
| |
| − | Actions
| |
| | | | |
| | + | * '''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><br>
| + | ''' Comparison Options by Variable Type ''' |
| − | <pre style="background-color: green; color: white; border-radius: 10px; padding: 10px;">
| |
| − | Constraints
| |
| | | | |
| | + | ''Boolean Variables:'' |
| | + | * True |
| | + | * False |
| | | | |
| − | </pre><br>
| + | ''Integer/Decimal Variables:'' |
| − | <pre style="background-color: teal; color: white; border-radius: 10px; padding: 10px;">
| + | * '''Equal to (=)''' - Fires when the value equals the specified number |
| − | Local variables
| + | * '''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 |
| | | | |
| − | </pre><br> | + | ''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'' |
| | + | |
| | + | <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]] |