OpenVPN 3.0.X - Connect and Disconnect with Tasker (Solution)

Search This thread

user9082390

Member
Oct 26, 2018
40
5
Could you share your profile? I cannot get it to work with OpenVPN Connect.

Oh gosh yeah I would love to, is there an easy way to export it out of Tasker and paste it into here? I'm still a noob. Otherwise I will type out my solution like this:
I have three profiles, as below, with 4 different tasks.
-------------------------------------------------------------------
Wifi Connected > VPN Connect Intent
VPN Disconnect Intent

Wifi Connected + Not VPN Connected > VPN Connect (note this is not my intent task)

Not Wifi Connected > VPN Disconnect (not this is not my intent task either)
-----------------------------------------------------------------------
Tasks:
VPN Connect = OpenVPN Configuration Connect and connect to my VPN

VPN Disconnect = OpenVPN Configuration Disconnect

VPN Connect Intent=
1. Send Intent
Action net.openvpn.openvpn.connect
2. Wait
4 seconds
3. Go Home
Page 0
4. Go Home
Page 0

VPN Disconnect Intent=
VPN Connect Intent=
1. Send Intent
Action net.openvpn.openvpn.disconnect
2. Wait
4 seconds
3. Go Home
Page 0
4. Go Home
Page 0
------------------------------------------------------------------------------

My apologies that I can't really explain at all how this works, it was all trial and error to put together. It does work 99% of the time though for me, which has made me happy. If you know of an easier way for me to share these let me know and I'll try that too.
 

beatschubser

Senior Member
Feb 7, 2014
140
51
Munich
My apologies that I can't really explain at all how this works, it was all trial and error to put together. It does work 99% of the time though for me, which has made me happy. If you know of an easier way for me to share these let me know and I'll try that too.

No worries, thanks for your reply? I figured it out now, had a typo in one the intent parameters. Here's the intent, it works with the current version of OpenVPNConnect:

Code:
<Str sr="arg0" ve="3">net.openvpn.openvpn.CONNECT</Str>
<Int sr="arg1" val="0"/>
<Str sr="arg2" ve="3"/>
<Str sr="arg3" ve="3"/>
<Str sr="arg4" ve="3">net.openvpn.openvpn.AUTOSTART_PROFILE_NAME: PC openvpnprofilename</Str>
<Str sr="arg5" ve="3">net.openvpn.openvpn.AUTOCONNECT: true</Str>
<Str sr="arg6" ve="3"/>
<Str sr="arg7" ve="3">net.openvpn.openvpn</Str>
<Str sr="arg8" ve="3">net.openvpn.unified.MainActivity</Str>
<Int sr="arg9" val="1"/>
 

epicurean

Senior Member
Nov 6, 2005
279
19
OnePlus 10 Pro
No worries, thanks for your reply? I figured it out now, had a typo in one the intent parameters. Here's the intent, it works with the current version of OpenVPNConnect:

Code:
<Str sr="arg0" ve="3">net.openvpn.openvpn.CONNECT</Str>
<Int sr="arg1" val="0"/>
<Str sr="arg2" ve="3"/>
<Str sr="arg3" ve="3"/>
<Str sr="arg4" ve="3">net.openvpn.openvpn.AUTOSTART_PROFILE_NAME: PC openvpnprofilename</Str>
<Str sr="arg5" ve="3">net.openvpn.openvpn.AUTOCONNECT: true</Str>
<Str sr="arg6" ve="3"/>
<Str sr="arg7" ve="3">net.openvpn.openvpn</Str>
<Str sr="arg8" ve="3">net.openvpn.unified.MainActivity</Str>
<Int sr="arg9" val="1"/>

Sorry, noob question but how exactly do you put the above input into Tasker?
 

ktmom

Retired Forum Moderator
Apr 22, 2015
5,176
3,387
Deep Space Station K7
Oh gosh yeah I would love to, is there an easy way to export it out of Tasker and paste it into here? I'm still a noob. Otherwise I will type out my solution like this:
I have three profiles, as below, with 4 different tasks.
-------------------------------------------------------------------
Wifi Connected > VPN Connect Intent
VPN Disconnect Intent

Wifi Connected + Not VPN Connected > VPN Connect (note this is not my intent task)

Not Wifi Connected > VPN Disconnect (not this is not my intent task either)
-----------------------------------------------------------------------
Tasks:
VPN Connect = OpenVPN Configuration Connect and connect to my VPN

VPN Disconnect = OpenVPN Configuration Disconnect

VPN Connect Intent=
1. Send Intent
Action net.openvpn.openvpn.connect
2. Wait
4 seconds
3. Go Home
Page 0
4. Go Home
Page 0

VPN Disconnect Intent=
VPN Connect Intent=
1. Send Intent
Action net.openvpn.openvpn.disconnect
2. Wait
4 seconds
3. Go Home
Page 0
4. Go Home
Page 0
------------------------------------------------------------------------------

My apologies that I can't really explain at all how this works, it was all trial and error to put together. It does work 99% of the time though for me, which has made me happy. If you know of an easier way for me to share these let me know and I'll try that too.
In order of easiest to import;

You can use taskernet to export a shareable link. Make sure the task (profile/project) is named, long press the name to select it, in the 3-dot menu select export -> as link. Then late the link here.

Else, export as a XML to storage, then attach that file here.

Finally, export description to clipboard and paste here.
 

Mbadr3

Member
Apr 5, 2018
26
4
Guys that's how it works:

Action :
net.openvpn.openvpn
Extra : net.openvpn.openvpn.AUTOCONNECT_PROFILE_NAME:
Extra :
net.openvpn.openvpn.AUTOCONNECT:true
Class :
net.openvpn.unified.MainActivity
Target :
Activity

Openvpn Connect Version 3.1.1
 
  • Like
Reactions: Note4Addict

epicurean

Senior Member
Nov 6, 2005
279
19
OnePlus 10 Pro
Forgive my noobieness.
I want to be able to enable an OpenVpn connection everytime I open a certain app (eg IPcamviewer), and disconnect the OpenVpn 1 min after I stop using the app.
How do I enable that in tasker?
Using the latest openvpn app
 

harmtemolder

Member
Nov 5, 2018
6
2
The way to set this up has changed again. This works:

Code:
Send Intent
Action:android.intent.action.MAIN
Cat:None
Extra:de.blinkt.openvpn.shortcutProfileName:PROFILENAME
Package:de.blinkt.openvpn
Class:de.blinkt.openvpn.LaunchVPN
Target:Activity

(from “How to use Tasker with the new OpenVPN version?” on Android Enthusiasts on StackExchange)
 

Top Liked Posts

  • There are no posts matching your filters.
  • 10
    Hi All,

    It would appear that the interface / code changed rather a lot in the most recent update and the previous intents are no longer working.

    I have figured out how to fix this. Please follow the directions below.

    Important Note: Your profile name is now prefixed with PC. E.g. My profile of test.co.uk/example [user] would now be PC test.co.uk/example [user]

    So, here are the settings (don't include the curly brackets):

    Connect

    Action: net.openvpn.openvpn.CONNECT
    Extra: net.openvpn.openvpn.AUTOSTART_PROFILE_NAME: PC {Your profile name}
    Extra: net.openvpn.openvpn.AUTOCONNECT: true
    Package: net.openvpn.openvpn
    Class: net.openvpn.unified.MainActivity
    Target: Activity

    Disconnect

    Action: net.openvpn.openvpn.DISCONNECT
    Extra: net.openvpn.openvpn.STOP: true
    Package: net.openvpn.openvpn
    Class: net.openvpn.unified.MainActivity
    Target: Activity

    Edit: As of the current version (3.0.4), OpenVPN no longer remains in the foreground on disconnect.
    2
    Go Home tasker task

    As another workaround for OpenVPN Connect staying in the foreground on Disconnect I added this tasks to my disconnect profile
    Wait 5 seconds
    Go Home

    Tasker has a Go Home task built in that effectively works for this use case!
    1
    Could you explain in tasker how to do it?

    Thanks

    You will need the AutoInput Tasker plugin for this to work. You can get it from here:
    https://play.google.com/store/apps/details?id=com.joaomgcd.autoinput

    1. Follow the above steps for the Disconnect task
    2. Hit the + to add a new action
    In the list that pops up, select Task -> Wait and change it to 1 second
    3. Hit the + button to add a new action
    In the list select Plugin -> AutoInput -> Global Action
    Hit the pencil icon next to Configuration
    Hit Action -> Select Back from the list
    Hit the check mark on the top right, then hit the back button to return to the Actions list
    4. Repeat #3

    Your Actions list should look like the attached image.

    I had to add the AutoInput 'Back' action twice since OpenVpn Connect backs out of the VPN Profile screen into the main app screen. The second Back action takes you to back into your last app/activity.

    It's a lazy workaround so I'm sure someone will come up with something better in time.
    1
    Thanks for sharing, i was quite annoyed by that update.
    Made my day
    1
    First of all, thank you for this post.
    Currently I'm using "go home" to "close" open vpn after disconnect.

    Latest change log says "* added minimize app on disconnect shortcut feature"
    Do you think we can use it in Tasker somehow to natively minimize the app after disconnect?
    I was using: wait 1 second and go home.

    After updating, it actually closes itself automatically now. It happens very quickly - I don't even see the OpenVPN UI.