Changes

no edit summary
Line 1: Line 1: −
<pre class="header-style">
+
<pre class="header-style">The Battery Level trigger fires when the battery level increases or decreases to a selected level, or on any battery level change. This is useful for automating power-saving features or notifications based on battery status.</pre>
This trigger fires when the device's Airplane mode setting is changed. You can configure it to trigger    when Airplane mode is enabled, or when it is disabled.
  −
</pre>
      
''' Options '''
 
''' Options '''
   −
When configuring this trigger, select one of the following:
+
* '''Increase/Decrease''' - Trigger fires when battery reaches a specific threshold
 +
** '''Increases to''' - Fires when battery level rises to or above the specified percentage
 +
** '''Decreases to''' - Fires when battery level falls to or below the specified percentage
 +
* '''Any Change''' - Trigger fires whenever the battery level changes
   −
* '''Airplane Mode Enabled''' - Fires when Airplane mode is turned ON
+
''' Configuration '''
* '''Airplane Mode Disabled''' - Fires when Airplane mode is turned OFF
     −
''' How It Works '''
+
When selecting "Increase/Decrease" mode, you can specify the threshold:
   −
The trigger listens for the system broadcast that Android sends whenever the Airplane mode state changes. This means the trigger fires immediately when the setting is toggled, regardless of how it was changed (Quick Settings tile, Settings app, or another automation).
+
* Use the slider to set a battery percentage from 0% to 100% (default is 50%)
 +
* Alternatively, select a variable to dynamically determine the threshold level
 +
* Choose whether to trigger on increases or decreases
   −
''' Example 1: Mute media when going to sleep '''
+
''' Variable Support '''
   −
When Airplane mode is enabled at night, automatically mute media volume.
+
You can use an integer variable to specify the battery threshold instead of a fixed value. This allows for dynamic thresholds that can be changed at runtime.
    +
''' Examples '''
 +
 +
''Example 1: Low Battery Warning''
 
   <pre class="trigger-style">Triggers
 
   <pre class="trigger-style">Triggers
   −
Airplane Mode Enabled</pre>
+
Battery <= 15%</pre>
 
   <pre class="action-style">Actions
 
   <pre class="action-style">Actions
   −
Volume Change - Media Volume = 0</pre>
+
Enable Power Saving Mode
  <pre class="constraint-style">Constraints
+
Notification: Battery is low - 15% remaining</pre>
 
  −
Time of Day (10:00 PM - 7:00 AM)</pre>
  −
 
  −
''' Example 2: Restore connectivity settings after flight '''
  −
 
  −
When Airplane mode is disabled, automatically enable Wi-Fi and Bluetooth.
      +
''Example 2: Resume Normal Mode When Charged''
 
   <pre class="trigger-style">Triggers
 
   <pre class="trigger-style">Triggers
   −
Airplane Mode Disabled</pre>
+
Battery >= 80%</pre>
 
   <pre class="action-style">Actions
 
   <pre class="action-style">Actions
   −
Set Wi-Fi State (Enable Wi-Fi)
+
Disable Power Saving Mode
Set Bluetooth State (Enable Bluetooth)</pre>
+
Enable Wi-Fi
 
+
Enable Sync</pre>
''' Example 3: Log flight times '''
+
   <pre class="constraint-style">Constraints
 
  −
Track when you enable Airplane mode (boarding a flight) by logging to a file.
  −
 
  −
  <pre class="trigger-style">Triggers
  −
 
  −
Airplane Mode Enabled</pre>
  −
   <pre class="action-style">Actions
     −
Write To File - Append "{hour}:{minute}:{second} - Flight mode started" to flight_log.txt</pre>
+
Power Connected</pre>
    
''' Notes '''
 
''' Notes '''
   −
* This trigger detects '''changes''' to Airplane mode. It does not fire based on the current state when a macro is enabled. To check the current Airplane mode state, use the [[Constraint:_Airplane_Mode|Airplane Mode Constraint]].
+
* The trigger only fires once when the level transitions to the new state, not on every subsequent level change where the condition remains true
* On some devices, enabling Airplane mode automatically disables Wi-Fi, Bluetooth, and mobile data. However, some devices allow Wi-Fi and Bluetooth to be re-enabled while Airplane mode remains active.
+
* For example, if you set "decreases to 20%", the trigger fires when battery drops to 20%, but not again at 19%, 18%, etc. until the battery first rises above 20% again
* No special permissions are required for this trigger.
+
* The trigger listens for the system broadcast ACTION_BATTERY_CHANGED
 +
* Some devices may not report every 1% change but may report in intervals such as 5% or 10%
 +
* The "Any Change" option is useful for logging or monitoring battery drain patterns
    
''' See Also '''
 
''' See Also '''
   −
* [[Constraint:_Airplane_Mode|Airplane Mode Constraint]] - Check if Airplane mode is currently enabled/disabled
+
* [[Constraint:_Battery_Level|Battery Level Constraint]]
* [[Action:_Airplane_Mode_On/Off|Airplane Mode On/Off Action]] - Enable or disable Airplane mode
+
* [[Trigger:_Battery_Temperature|Battery Temperature Trigger]]