Android. Just installed blue iris app. How can I make.my VPN turn on and off automatically

speedway1213

Young grasshopper
Joined
Sep 18, 2022
Messages
30
Reaction score
5
Location
Los angeles
How can I make my VPN turn on and off automatically when I open the blue iris app ? I am using zero tier for now but will use OpenVPN soon.

Don't want to leave it on all day cause of battery issues.
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
1,236
Reaction score
1,294
Location
SF Bay Area
^^+1
For an example with specific instructions, see this post
 

The Automation Guy

Known around here
Joined
Feb 7, 2019
Messages
1,443
Reaction score
2,877
Location
USA
I use the app "Tasker" to accomplish this and it works great. This is how I do it....

I've created a "Task" in Tasker that does these things.... If I am at home or my parents home, the task immediately starts the BI app, otherwise it starts a VPN with my home network and then waits 3 seconds before starting BI (to allow the VPN time to make the connection. This keeps BI from timing out initially). To start this task, I have created a shortcut on my phone's desktop that starts this "connection" task. I use the icon for the BI app as the label for this task so it looks like you are starting the BI app, but instead you run this task. I also have it set up so that anytime you stop using the BI app (either by closing it out, "backing" out of the app, or by opening another app), Tasker will automatically close the VPN connection.

Here is the steps I take to do all of this:
1. Create a "Task" in Tasker (labeled it "View Cameras" ) with these commands:
A. Test Net command (stores the current SSID of whatever WiFi network you are connected to into a variable - if any).​
B1. Created an If Statement that if the variable above does NOT equal my home network SSID and does NOT equal my parent's home network SSID (I have a permanent VPN connection between the two locations and therefore don't need to use the VPN when I am at their house)​
B2 THEN I autoconnect to my Home VPN connection using OpenVPN that is also installed on my phone.​
The commands for that are:​
Code:
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
B3 - Wait 3 seconds​
B4 - End IF​
C. I launch the app Blue Iris (I am using the paid mobile app on my phone).​
2. Created athe desktop shortcut by longpressing on the desktop, choosing "widget" and then "Tasker Shortcut". Then you select the task you created in the first steps (ie View Cameras) to be associated with this shortcut.
3. I have also created a second task that automatically shuts down the VPN connection using these commands:
A. Test Net command (stores the current SSID into a variable)​
B1. Created an If Statement that if the variable above does NOT equal my home network SSID and does NOT equal my parent's home network SSID (I have a permanent VPN connection between the two locations)​
B2. THEN I disconnect from the VPN connection using this these commands:​
Code:
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

4. I have created a "Profile" in Tasker called "BlueIris" with the BI app selected and created and "Exit Task" that calls on the VPN disconnect task. This means anytime I close the BI app, or start another app "on top of" the BI app, and I'n not at home or my parents, it disconnects the VPN automatically. This is a very helpful step IMHO because I do not want the VPN open full time - only when I am trying to specifically connect to my home network - and this saves the the trouble of manually disconnecting from the VPN.

Please note - I do NOT put the "View Cameras" task in as the Enter Task on the "BlueIris" Profile. This would mean if you clicked on the BI app in the app drawer, it would automatically go through the VPN connection steps. However doing it this way means that BI would start before the VPN connection is established and so you have to wait for that connection to time out before trying to reconnect. That annoys me because it isn't done automatically and it obviously takes much longer make all of the connections, so I have chosen to NOT add it as the "Enter Task" and instead use the BI task shortcut as my normal method to access the BI app. Using the method described above with the desktop shortcut means the entire connection process is completely automatic and there is no user input needed unless something goes wrong. Usually because your mobile connection is slower than normal and it doesn't connect before the BI app opens. However if that happens regularly, then simply adjust the Wait time in step 1 to be longer - perhaps 4 seconds instead of 3. 3 seconds works 95% of the time for me, so that's what I use.
 
Last edited:
Joined
Oct 31, 2022
Messages
127
Reaction score
49
Location
Lower Alabama
I have my ZeroTier set to Always On and it has not affected my battery usage enough to notice it.

Is there any other reason not to use Always On?

If I use Tasker, then I'll have to set it up for my Plex app as well. Seems unnecessary if Always On works okay, unless I'm missing something.
 

Mike A.

Known around here
Joined
May 6, 2017
Messages
3,883
Reaction score
6,511
You take a little hit on throughput and battery but now most all have on-demand settings and can set it to only be active on whatever sites/Internet. I generally just leave mine on and run it all back through my home network to keep things private end-to-end and have all of my site and ad blocking no matter what device or where I am. I've not noticed much real world effect as far as battery/performance.
 
Joined
Oct 31, 2022
Messages
127
Reaction score
49
Location
Lower Alabama
I got a notification that I had not noticed until now... not sure when I received it.

zeroteir notification.png

However, the key shows in the upper left corner.

I see these settings, although the ZeroTier One app does show it toggled off and that it is OFFLINE. Toggling on does not make the notification go away or change anything that I know of.

Always On is checked in the settings.

zerotier showing offline.png

zerotier showing always on.png

zerotier always on setting.png
 
Top