Difference between revisions of "Trigger: Wifi State Change"

(Created page with "This trigger will fire when the wifi state changes. You can configure it to fire when wifi is enabled or disabled, or when connected to/disconnected from a specific network....")
 
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This trigger will fire when the wifi state changes.
+
<pre class="header-style">This trigger will fire when the wifi state changes. You can configure it to fire when wifi is enabled or disabled, or when connected to/disconnected from a specific network.</pre>
  
You can configure it to fire
+
''' Options '''
  
when wifi is enabled or disabled, or when connected to/disconnected from a specific network.
+
''' Trigger States '''
  
Please note that since Android 8.1 this functionality requires location permission and location services enabled in order to detect connect/ disconnect events.
+
* '''Wifi Enabled''': Trigger when wifi is turned on
 +
* '''Wifi Disabled''': Trigger when wifi is turned off
 +
* '''Connected to Network''': Trigger when connected to a wifi network
 +
* '''Disconnected from Network''': Trigger when disconnected from a wifi network
 +
 
 +
''' Network Selection (for Connected/Disconnected) '''
 +
 
 +
When selecting "Connected to Network" or "Disconnected from Network":
 +
 
 +
* '''Any Network''': Trigger on connection/disconnection from any wifi network
 +
* '''Specific Networks''': Select one or more specific wifi networks by SSID
 +
* '''Add SSID''': Manually add an SSID that is not currently in range
 +
 
 +
The network selection dialog shows:
 +
* Networks detected during wifi scanning
 +
* Previously configured wifi networks on your device
 +
* Manually added SSIDs
 +
 
 +
Multiple networks can be selected, and the trigger will fire when connecting to or disconnecting from any of the selected networks.
 +
 
 +
''' Requirements '''
 +
 
 +
* '''Location Permission''': On Android 8.1 (Oreo MR1) and above, location permission is required for connect/disconnect detection
 +
* '''Location Services''': Location services must be enabled on Android 8.1+ for connect/disconnect events
 +
* '''Helper App''': On Android 10+ some features may require the MacroDroid Connectivity Helper or Universal Helper app
 +
 
 +
''' Examples '''
 +
 
 +
  <pre class="trigger-style">Triggers
 +
 
 +
Wifi State Change (Connected to Network: Home_Wifi)</pre>
 +
  <pre class="action-style">Actions
 +
 
 +
AutoSync On
 +
Set Variable: [location] = Home</pre>
 +
 
 +
''Configure device settings when connecting to home wifi.''
 +
 
 +
----
 +
 
 +
  <pre class="trigger-style">Triggers
 +
 
 +
Wifi State Change (Wifi Disabled)</pre>
 +
  <pre class="action-style">Actions
 +
 
 +
Enable Mobile Data
 +
Notification: Wifi disabled, mobile data enabled</pre>
 +
 
 +
''Automatically enable mobile data when wifi is turned off.''
 +
 
 +
----
 +
 
 +
  <pre class="trigger-style">Triggers
 +
 
 +
Wifi State Change (Disconnected from Network: Any Network)</pre>
 +
  <pre class="action-style">Actions
 +
 
 +
Wait 30 seconds
 +
If Wifi Connected = false
 +
    Set Wifi: Off
 +
    Set Wifi: On
 +
End If</pre>
 +
 
 +
''Auto-reconnect wifi after disconnection.''
 +
 
 +
''' Notes '''
 +
 
 +
* Since Android 8.1, location permission and enabled location services are required to detect connect/disconnect events.
 +
* The trigger listens for NETWORK_STATE_CHANGED_ACTION, WIFI_STATE_CHANGED_ACTION, and SUPPLICANT_CONNECTION_CHANGE_ACTION system broadcasts.
 +
* For "Connected to Network" and "Disconnected from Network" options, wifi must be enabled to configure the trigger (you will be prompted to enable it if disabled).
 +
* Multiple SSIDs can be selected for connect/disconnect triggers.
 +
* Use "Any Network" if you want to trigger on all wifi connection/disconnection events regardless of the network name.
 +
 
 +
''' See Also '''
 +
 
 +
* [[Trigger:_Wifi_SSID_Transition|Wifi SSID Transition Trigger]]
 +
* [[Constraint:_Wifi_State|Wifi State Constraint]]
 +
* [[Action:_Wifi_Configure|Wifi Configure Action]]

Latest revision as of 22:18, 7 January 2026

This trigger will fire when the wifi state changes. You can configure it to fire when wifi is enabled or disabled, or when connected to/disconnected from a specific network.

Options

Trigger States

  • Wifi Enabled: Trigger when wifi is turned on
  • Wifi Disabled: Trigger when wifi is turned off
  • Connected to Network: Trigger when connected to a wifi network
  • Disconnected from Network: Trigger when disconnected from a wifi network

Network Selection (for Connected/Disconnected)

When selecting "Connected to Network" or "Disconnected from Network":

  • Any Network: Trigger on connection/disconnection from any wifi network
  • Specific Networks: Select one or more specific wifi networks by SSID
  • Add SSID: Manually add an SSID that is not currently in range

The network selection dialog shows:

  • Networks detected during wifi scanning
  • Previously configured wifi networks on your device
  • Manually added SSIDs

Multiple networks can be selected, and the trigger will fire when connecting to or disconnecting from any of the selected networks.

Requirements

  • Location Permission: On Android 8.1 (Oreo MR1) and above, location permission is required for connect/disconnect detection
  • Location Services: Location services must be enabled on Android 8.1+ for connect/disconnect events
  • Helper App: On Android 10+ some features may require the MacroDroid Connectivity Helper or Universal Helper app

Examples

Triggers

Wifi State Change (Connected to Network: Home_Wifi)
Actions

AutoSync On
Set Variable: [location] = Home

Configure device settings when connecting to home wifi.


Triggers

Wifi State Change (Wifi Disabled)
Actions

Enable Mobile Data
Notification: Wifi disabled, mobile data enabled

Automatically enable mobile data when wifi is turned off.


Triggers

Wifi State Change (Disconnected from Network: Any Network)
Actions

Wait 30 seconds
If Wifi Connected = false
    Set Wifi: Off
    Set Wifi: On
End If

Auto-reconnect wifi after disconnection.

Notes

  • Since Android 8.1, location permission and enabled location services are required to detect connect/disconnect events.
  • The trigger listens for NETWORK_STATE_CHANGED_ACTION, WIFI_STATE_CHANGED_ACTION, and SUPPLICANT_CONNECTION_CHANGE_ACTION system broadcasts.
  • For "Connected to Network" and "Disconnected from Network" options, wifi must be enabled to configure the trigger (you will be prompted to enable it if disabled).
  • Multiple SSIDs can be selected for connect/disconnect triggers.
  • Use "Any Network" if you want to trigger on all wifi connection/disconnection events regardless of the network name.

See Also