Tasker and BlueIris

JJD

n3wb
Joined
Mar 6, 2018
Messages
16
Reaction score
0
Has anyone got tasker to use openvpn when you launch blueiris and the disconnect when closing properly?

For me it goes into an endless loop of trying to connect.

I was using this for tasks:
Code:
b) OVPN Profile module
Action: net.openvpn.openvpn.CONNECT
OR
Action: android.intent.action.VIEW
Cat: None
Mime Type: {blank}
Data: {blank}
Extra: net.openvpn.openvpn.AUTOSTART_PROFILE_NAME:PC {your_profile_name}
Extra: net.openvpn.openvpn.AUTOCONNECT:true
Extra: net.openvpn.openvpn.APP_SECTION:PC
Package: net.openvpn.openvpn
Class: net.openvpn.unified.MainActivity
Target: Activity

2. DISCONNECT
Action: net.openvpn.openvpn.DISCONNECT
Cat: None
Mime Type: {blank}
Data: {blank}
Extra: net.openvpn.openvpn.STOP:true
Extra: {blank}
Extra: {blank}
Package: net.openvpn.openvpn
Class: net.openvpn.unified.MainActivity
Target: Activity
Then created an application profile to launch the connect when blueiris is launched.

I am able to use tasker to activate the openvpn connection when im not on home wifi but I prefer to not be connected to vpn all the time and just have it when i launch blue iris.
 

DognamedTank

Getting the hang of it
Joined
Feb 24, 2018
Messages
90
Reaction score
41
There is no need for the VPN to connect when you are on your home WiFi.
 

JJD

n3wb
Joined
Mar 6, 2018
Messages
16
Reaction score
0
There is no need for the VPN to connect when you are on your home WiFi.
Never said thats what I wanted. The only thing i could get to work was when I an NOT on my home wireless it automatically connected to openvpn. I rather not have all that traffic and load ran through my router 24/7 just to view my cameras. I rather have it just launch openvpn connection when anyone opens BI when not home.

It already works fine when i come in contact with my home wireless it disconnects.
 

DognamedTank

Getting the hang of it
Joined
Feb 24, 2018
Messages
90
Reaction score
41
Never said thats what I wanted. The only thing i could get to work was when I an NOT on my home wireless it automatically connected to openvpn. I rather not have all that traffic and load ran through my router 24/7 just to view my cameras. I rather have it just launch openvpn connection when anyone opens BI when not home.

It already works fine when i come in contact with my home wireless it disconnects.
Sorry, looks like I read the pre-edit wrong. I haven't used tasker much, so I'll defer to other experts. I ended up just putting a shortcut widget next to the BI Icon that connects to my VPN so I can then click on my BI app after the VPN connects. It takes about 3-5 seconds. With tasker, the connection failure in BI before the VPN was fully connected took more time to clear than using the shortcut. If I were to play with it again, I would setup the tasker profile to launch BI when I clicked the VPN icon.
 

JJD

n3wb
Joined
Mar 6, 2018
Messages
16
Reaction score
0
Sorry, looks like I read the pre-edit wrong. I haven't used tasker much, so I'll defer to other experts. I ended up just putting a shortcut widget next to the BI Icon that connects to my VPN so I can then click on my BI app after the VPN connects. It takes about 3-5 seconds. With tasker, the connection failure in BI before the VPN was fully connected took more time to clear than using the shortcut. If I were to play with it again, I would setup the tasker profile to launch BI when I clicked the VPN icon.
Thats how I used to do it also, but my wife complains as well as others in the family when there is an alert, you cant just click on it. You have to to go the home screen connect to vpn then launch BI. Would be nice to all do in one task.
 

Terk

Pulling my weight
Joined
Feb 14, 2018
Messages
247
Reaction score
106
I'd be interested to know if you get this working, also do you use Geofencing with those devices? If so how do you get that to work without the VPN active?
 

JJD

n3wb
Joined
Mar 6, 2018
Messages
16
Reaction score
0
I'd be interested to know if you get this working, also do you use Geofencing with those devices? If so how do you get that to work without the VPN active?
I could never get geofencing to work accurately enough through all phones in the house so I now use BI-Fusion add-on for Smart things and it works great. Although I dont think that would matter because its based off GPS-location right? Atleast smartthings must be because im connected to VPN and it still says im away.
 

Terk

Pulling my weight
Joined
Feb 14, 2018
Messages
247
Reaction score
106
Yes, it is based off GPS but the app cannot tell the server to switch to home or away without an active VPN connection or a port open. BI-Fusion would be a good option, I started to get that installed but haven't had time to complete all of the BI steps required yet so I'll have to spend some time on that this weekend or next.
 

JJD

n3wb
Joined
Mar 6, 2018
Messages
16
Reaction score
0
Yes, it is based off GPS but the app cannot tell the server to switch to home or away without an active VPN connection or a port open. BI-Fusion would be a good option, I started to get that installed but haven't had time to complete all of the BI steps required yet so I'll have to spend some time on that this weekend or next.
Ahh true never thought of that, glad i got that working then haha. It works pretty much 100% of the time for me where BI was like 75% between all the android and iphones in the house.
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
1,132
Reaction score
1,240
Location
SF Bay Area
I leave my OpenVPN connection running all the time when I leave home. I would encourage you to consider doing this as well.

The main reason is to avoid complexity. While Tasker reliably triggers events when an app is running in the foreground, things get very complicated when the app is minimized (running in the background). Plugins that used to work no longer do. Some users report success with shell commands, but I've had no luck with them.

The second reason is that I also use Tasker profiles and home screen widgets to send http commands to and run web scripts on my web server. So toggling OpenVPN based on the state of the Blue Iris app is unhelpful.

Here's how I make OpenVPN connect automatically when I leave home, and disconnect automatically when I return...

1. I use the OpenVPN Tasker Plugin (Play Store).
Once installed, click its icon to open and confirm it is set up correctly (leftmost image below). NOTE: If you have not yet installed OpenVPN for Android, do it now (Play Store) ... and install your profile.

upload_2018-4-9_12-5-54.png

You are now ready to implement this plugin into your Tasker profiles. Here's how I use it...

2. I created two new tasks that I can use in any Tasker profile or task...
OpenVPN Connect & OpenVPN Disconnect

Both have one action each...
  • Click '+' to add an action.
  • Select 'Plugin' as the 'Action Category'.
  • Select 'OpenVpn Tasker plugin'.
  • Touch the pencil icon on the 'Configuration' setting
At this point you should see the rightmost image above.
  • For task OpenVPN Connect... Select your profile, then click the check mark and save the task.
    NOTE: If you don't see your profile in place of 'client' in the rightmost image, you have not set up OpenVPN correctly.
  • For task OpenVPN Disconnect... Select 'Disconnect VPN'. NOTE: This action terminates all active connections
3. I added these new tasks to the Tasker Profile I use to determine when I am home.
I call mine "Whereami Home".***
  • To "Whereami Home" profile's entry task, I added a 'Perform Task' action for the OpenVPN Disconnect task.
  • To "Whereami Home" profile's exit task, I added a 'Perform Task' action for the OpenVPN Connect task.
That's it.

~~~~

*** If you are curious, I use 3 Tasker 'Whereami' Profiles on my device: "Whereami Home", "Whereami Car" and "Whereami Away". None of them are Geofence-based, as I've also experienced reliability issues with geofencing. "Whereami Home" turns "on" if I am near or connected to my Home Wifi, or inside my Home NET location zone (for those rare events where my home wifi is off for some reason). "Whereami Car" turns 'on' if my device is connected via bluetooth to any of our cars and I am not near my Home Wifi (this avoids triggering the profile in my garage or driveway). "Whereami Away" turns 'on' if the home and car Profiles are both 'off'... The entry tasks for all 3 Profiles includes an action to set value of a global Variable named %WHEREAMI that I can use in any other Tasker Profile or Task.
 

emersonvier

Getting the hang of it
Joined
Apr 29, 2017
Messages
116
Reaction score
38
Location
IL
I want to click on BI icon or BI notification connect to OpenVPN and when I exit BI disconnect OpenVpn, is it possible?
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
1,132
Reaction score
1,240
Location
SF Bay Area
Yes, this is possible.

The instructions below will create a Tasker profile that will:
a) attempt to connect to your chosen OpenVPN profile when the Blue Iris app is opened, and
b) disconnect your OpenVPN session when Blue Iris not in the foreground (either minimized or closed).

(These instruction have been verified with Tasker version 5.1m, on a Samsung S9 running Android 8.0.0 (Oreo) with OpenVPN for Android 0.7.5)

How to create a Blue Iris / OpenVPN Tasker Profile...
1. Install the OpenVPN Tasker Plugin (see post #10 above)
2. Open Tasker
3. If not already selected, click the 'PROFILES' tab
4. Click the big plus sign icon (bottom right of screen)
5. Click Application
6. Choose the Blue Iris app
7. Click the back arrow
8. Choose New Task
9. Click the check mark (leaving blank the optional task name)
(note - if you cannot see the dialog, close the keyboard)
10. Click the big plus sign icon
11. Choose 'Plugin'
12. Choose 'OpenVpn Tasker Plugin'
13. Click the 'Configuration' pencil icon
14. Choose your OpenVpn profile (if none, see post #10 above)
15. Click the check mark
16. Click the back arrow
17. Click the back arrow again
(you should be back the 'PROFILES' tab now)
18. Click the check mark at the top ... this saves your work so far
19. Long-press the 'OpenVpn Connect..' entry after the green arrow in your new "Blue Iris' profile
20. Choose 'Add Exit Task'
21. Repeat 8-13 above
22. Choose 'Disconnect VPN'
23. Repeat 15-18 above
24. Close Tasker.

Now try repeatedly opening and minimizing the Blue Iris app. If everything is working, you should see the Android VPN connection 'key' icon toggling on/off in the notification bar at the top of your screen.

Troubleshooting: If nothing is happening, I've sometimes found it necessary to do these things:
i) Toggle Tasker off/on. Click the 3-dots menu (top right) and choose 'Disable Tasker'. Then repeat choosing 'Enable Tasker'.
ii) In Tasker's 'PROFILES' tab, under the new Blue Iris profile, click once on the 'OpenVpn Connect..' entry task (by the green arrow). Click the 'run' icon at the lower left of the screen. This should show the 'key' icon in the notification bar. Now click the back arrow and repeat for the exit task (by the red arrow).
 
Last edited:

emersonvier

Getting the hang of it
Joined
Apr 29, 2017
Messages
116
Reaction score
38
Location
IL
Hi @jaydeel , Thank you very much, works on my tablet.

Now I have problem on my S7 I cant install the OpenVpn Tasker Plugin, "OpenVpn Tasker Plugin can't be installed. Try again, and if the problem continues, get help troubleshooting(error code: -505", I sent message to developer.
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
1,132
Reaction score
1,240
Location
SF Bay Area
Glad it worked.

Regarding your S7 experience, I hope you are not out of luck with the developer... On Google Play, I note the OpenVpn Tasker Plugin v 1.0.11 has not been updated since Nov 2014.

You may want to check out the plugin's debug and a crash logs; perhaps they will provide a hint as to the cause. To configure these, click the 3-dot menu after you've clicked the 'Configuration' pencil icon.

(My experience with the OpenVpn Tasker Plugin is limited to my current Samsung S9 running Android 8.0.0 (Oreo), Tasker 5.1m and OpenVPN for Android 0.7.5.)
 

Pirateghost

Young grasshopper
Joined
Jan 8, 2015
Messages
30
Reaction score
1
Yes, this is possible.

The instructions below will create a Tasker profile that will:
a) attempt to connect to your chosen OpenVPN profile when the Blue Iris app is opened, and
b) disconnect your OpenVPN session when Blue Iris not in the foreground (either minimized or closed).

(These instruction have been verified with Tasker version 5.1m, on a Samsung S9 running Android 8.0.0 (Oreo) with OpenVPN for Android 0.7.5)

How to create a Blue Iris / OpenVPN Tasker Profile...
1. Install the OpenVPN Tasker Plugin (see post #10 above)
2. Open Tasker
3. If not already selected, click the 'PROFILES' tab
4. Click the big plus sign icon (bottom right of screen)
5. Click Application
6. Choose the Blue Iris app
7. Click the back arrow
8. Choose New Task
9. Click the check mark (leaving blank the optional task name)
(note - if you cannot see the dialog, close the keyboard)
10. Click the big plus sign icon
11. Choose 'Plugin'
12. Choose 'OpenVpn Tasker Plugin'
13. Click the 'Configuration' pencil icon
14. Choose your OpenVpn profile (if none, see post #10 above)
15. Click the check mark
16. Click the back arrow
17. Click the back arrow again
(you should be back the 'PROFILES' tab now)
18. Click the check mark at the top ... this saves your work so far
19. Long-press the 'OpenVpn Connect..' entry after the green arrow in your new "Blue Iris' profile
20. Choose 'Add Exit Task'
21. Repeat 8-13 above
22. Choose 'Disconnect VPN'
23. Repeat 15-18 above
24. Close Tasker.

Now try repeatedly opening and minimizing the Blue Iris app. If everything is working, you should see the Android VPN connection 'key' icon toggling on/off in the notification bar at the top of your screen.

Troubleshooting: If nothing is happening, I've sometimes found it necessary to do these things:
i) Toggle Tasker off/on. Click the 3-dots menu (top right) and choose 'Disable Tasker'. Then repeat choosing 'Enable Tasker'.
ii) In Tasker's 'PROFILES' tab, under the new Blue Iris profile, click once on the 'OpenVpn Connect..' entry task (by the green arrow). Click the 'run' icon at the lower left of the screen. This should show the 'key' icon in the notification bar. Now click the back arrow and repeat for the exit task (by the red arrow).
I'm having a small issue with this. When I click the BI icon, the VPN starts fine but I get a can't connect error on BI. When I go back in and hit connect again it works. It seems like BI is connecting faster than it is really detecting the VPN as running. Any ideas?
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
1,132
Reaction score
1,240
Location
SF Bay Area
Any ideas?
Tasker has a very flexible 'wait' command. You could try adding a few seconds wait after the 'Perform Task, OpenVPN Connect' step in the entry task. If no joy, keep increasing the wait time to see if that helps.

Another, albeit more complex, option is to create a profile to detect when you have a vpn connection. You can then test this state via the %PACTIVE variable, then open the Blue Iris app.
 

Pirateghost

Young grasshopper
Joined
Jan 8, 2015
Messages
30
Reaction score
1
The way it was written to do above, the activation of BI start up VPN. So, BI finishes first. It's actually backwards. I tried to make it work by switching them around so VPN goes first and that activates BI. I'm very new at this so it's taking some time to work it all out. I may explore your second option but looks beyond my capabilities at this point. Thanks.
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
1,132
Reaction score
1,240
Location
SF Bay Area
You are correct. Another approach is needed. Try the following. It’s four steps (2 & 3 are optional):
  1. Create a ‘Blue Iris Open’ task. This starts OpenVPN, waits a few seconds (you can tweak this), then opens Blue Iris.
  2. Create a ‘Blue Iris App’ profile. This one is optional, but is handy for closing OpenVPN when you close Blue Iris. It has only an exit task. In addition to closing OpenVPN, it issues a nice flash notification.
  3. Create a ‘VPN Connected’ profile. This one is optional. It has entry and exit tasks that flash nice notifications about the vpn state. In addition, it toggles a Tasker variable that can be used by future profiles & tasks.
  4. Create shortcut to #1 on your Android Device home screen. Btw, this is harder than I remember as Oreo has apparently removed the ‘shortcuts’ selection from the context menu that pops up when you long-press on an open space on the home screen. Now you must change a setting in Tasker, then long-press Tasker and use its context menu to drag a shortcut to #1 to the home screen.
The following instructions and images should be enough to get you through.

Step #1. Touch the TASKS tab. Touch the big plus icon. Enter ‘Blue Iris Open’ for new task’s name. Add the three Actions shown below.
upload_2018-10-6_22-35-47.jpeg

Now assign a screen icon to the task. At the bottom of the same screen, touch the center ‘checkerboard’ icon, then select ‘Application icon’, then select the Blue Iris app.
upload_2018-10-6_23-2-28.jpeg

Step #2. Touch the PROFILES tab. Touch the big plus icon. Select ‘Application’ and choose Blue Iris, then touch the back arrow icon. Select ‘New Task +’, then touch the check mark icon. Add a 1 millisecond wait Action, then touch the back arrow icon. Long-press on green arrow icon, then select ‘Add Exit Task’. Select elect ‘New Task +’, then touch the check mark icon. Add the actions below, then touch the back arrow icon. It is not necessary, but you can now long-press the green arrow icon again and delete the entry task (unneeded). Finally, you can optionally rename the new profile by long-pressing the new profile’s name.
upload_2018-10-6_22-48-5.jpeg

Step#3. Repeat above for Step #2, adding the entry and exit task Actions shown below.
Entry task...
upload_2018-10-6_22-52-50.jpeg

Exit task...
upload_2018-10-6_22-53-8.jpeg

Step #4. Touch Tasker’s 3-dot menu, then select ‘Preferences’. Touch the ACTION tab. Make sure ‘App Shortcut Tasks’ is checked. Touch any of the magnifier glass icons. Select your newly created ‘Blue Iris Open’ task.
upload_2018-10-6_23-8-58.jpeg

Exit Tasker by touching the back arrow, then the check mark. Go to your home screen (or touch the Apps icon) and find, then long-press the Tasker icon. From the context menu, touch and drag the ‘Blue Iris Open’ task to your home screen.
upload_2018-10-6_23-14-24.jpeg

That’s it. You can now use this shortcut to start OpenVPN, pause a while, then open Blue Iris.
upload_2018-10-6_23-15-0.jpeg
 
Last edited:

Pirateghost

Young grasshopper
Joined
Jan 8, 2015
Messages
30
Reaction score
1
Now I'll pick your brain more. When you get a notification from BI, you can click on the notification and it will open BI. How can I make it engage the tasks you provided earlier? Possible or just too much? Ideas?
 
Top