Wireguard | Toggle on for mobile data and off for home Wi-Fi

2,337 views
Skip to first unread message

random king

unread,
Aug 31, 2021, 5:33:09 PM8/31/21
to Automate
I have configured a Wireguard connection to my home router. 

I would like to toggle on the Wireguard tunnel whenever I switch to mobile data and then toggle off the Wireguard tunnel whenever I connect to my home Wi-Fi. 

Is that possible without Root? 

Henrik "The Developer" Lindqvist

unread,
Sep 1, 2021, 10:38:16 AM9/1/21
to Automate
Try Broadcast send block...
  • Package: com.wireguard.android

  • Receiver class: com.wireguard.android.model.TunnelManager$IntentReceiver

  • Action= "com.wireguard.android.action.SET_TUNNEL_UP"

  • Extras: { "tunnel": "<name of tunnel goes here" }

See: https://github.com/WireGuard/wireguard-android/blob/master/ui/src/main/java/com/wireguard/android/model/TunnelManager.kt

You also need to grant the "control WireGuard tunnels" privilege. The "Receiver class" is probably optional.

Chad Bowers

unread,
Sep 28, 2021, 2:22:38 AM9/28/21
to Automate
Something, I just discovered.  If I start the service in automate, then, after the error pops up, manually connect the Wireguard VPN, then turn on my wifi to connect to my named wifi network, the Automate service will turn off the Wireguard connection.  Then, as long as I don't manually manipulate anything else, if I lose Wifi on that network again, it WILL connect to Wireguard and not throw the error.  

I have no clue why this is, but it works.  So, basically it looks like for this to work, you need to manually connect to Wireguard the first time, then (assuming you'll have to do this after every reboot) after that it should continue to work.
Reply all
Reply to author
Forward
0 new messages