Turn airplane mode on then off if no 4G or 3G or wifi for more than 5 minutes unless there is also no cell service

745 views
Skip to first unread message

Heather

unread,
Jul 30, 2012, 5:54:04 PM7/30/12
to tas...@googlegroups.com
Hello! I have been trying to create the following profile:
 
- if there has been no data connection (4G/3G/wifi) for more than 5 minutes
(that time frame is to give the data connection time to reconnect on its own after airplane mode has been toggled or even before the profile activates)
- unless there is also no cell service
(because if there is also no cell service, it would be pointless to do airplane mode every 5 minutes unless there is an issue with service that could be resolved with toggling airplane mode, but that's a story for another profile)

- turn airplane mode on for 10 seconds

(sometimes it takes a few seconds to turn on on my phone, hence the delay there) 
- then turn airplane mode off and repeat if necessary
 
 
I thought about adding the context state - net - Mobile Network - check 3G and 4G and Invert, but I think that is saying that the setting is turned off, not that the data signal/connection is lost. Am I wrong? Can anyone help?

Heather

unread,
Aug 1, 2012, 4:16:29 AM8/1/12
to tas...@googlegroups.com
I hate to bump my own post, but does anyone have any ideas? My inconsistent data connection is driving me crazy and I'd love for Tasker to toggle airplane mode automatically when I lose data since that resolves it the majority of the time.

Thanks!

Matt R

unread,
Aug 1, 2012, 11:34:06 AM8/1/12
to tas...@googlegroups.com
Did you try it with the Mobile Network (inverted) context?  According to the userguide, that context is whether there is data connectivity, so I believe it should work (you can press the blue question mark in the bottom right of most windows in Tasker for more information on what they do).  Are you having trouble setting up the rest of the profile/task?
 
Matt

Heather

unread,
Aug 1, 2012, 4:23:39 PM8/1/12
to Tasker
Yes, I have inverted selected. Conveniently (*eyeroll*) I just lost my
data connection and the profile activated, but I do need help with the
rest of the profile. Here is what I have and the part I am struggling
with:

Profile: No Mobile Data (15)
State: Not Mobile Network [ 2G:Off 3G:On 3G - HSPA:Off 4G:On ]
State: Not Wifi Connected [ SSID:* MAC:* IP:* ]
Enter: Check For Service (4)
A1: Wait [ MS:0 Seconds:30 Minutes:0 Hours:0 Days:0 ]
A2: ***This is where I need help.. I basically want it to say if the
context states are still in effect, then do the following***
A3: Airplane Mode [ Set:On ]
A4: Wait [ MS:0 Seconds:0 Minutes:5 Hours:0 Days:0 ]
A5: Airplane Mode [ Set:Off ]
A6: End If ***Assuming A2 is an if statement***

As of right now my data connection is still not working until I cycle
airplane mode so no rush, but if we get this fixed soon I can test it
before I really need my data back =P

Matt R

unread,
Aug 1, 2012, 4:57:38 PM8/1/12
to tas...@googlegroups.com
Most easily, you can do A2 as Stop If %PACTIVE !~ *,No Mobile Data,* .  What this does is checks %PACTIVE (a comma separated list of currently active profiles) to see if the profile in question (No Mobile Data) is still active.  Then no A6 action is necessary.  I'm not sure if this will repeat though.  That is, after airplane mode is turned back off at the end, I don't think this will trigger the profile to start again.  So you might need to add a Go To A1 at the end.
 
Matt

Heather

unread,
Aug 1, 2012, 5:18:16 PM8/1/12
to Tasker
I just added that in and airplane mode never turned on. Just to make
sure I did it right, I chose Stop under the Task option and manually
typed %PACTIVE (maybe it's because I haven't defined PACTIVE? What
does that do?) and I changed the ~ to !~ and manually typed *,No
Mobile Data,*
That is in place of A2 and I also deleted A6. I wanted to try it
without adding a Go To A1 at the end, but either way it should have at
least turned on airplane mode once, right?

Heather

unread,
Aug 1, 2012, 6:28:42 PM8/1/12
to Tasker
Hmm I just looked at my phone right now, a little over an hour later,
and it was in airplane mode. I just adjusted the 5 min wait to 10
seconds (previously I copied it from another profile I had for no
signal altogether) and it went off! Now it seems to be working. I have
no idea what happened during that hour that it wasn't working....
Is there any way to make it so if it does it 5 times and there is
still no data connection that the phone will reboot?
> > Matt- Hide quoted text -
>
> - Show quoted text -

Matt R

unread,
Aug 1, 2012, 6:32:50 PM8/1/12
to tas...@googlegroups.com
%PACTIVE is a comma-separated list of all the profiles that are currently active (e.g. ,No Mobile Data,Profile2,Profile 3,..., ).  Was the profile active, or were you trying to test it using the play button?  If you use the play button, it won't turn on airplane mode unless that profile is currently running.  Check the run log if you aren't sure what's happening (menu button -> more -> run log).
 
Matt

Heather

unread,
Aug 1, 2012, 7:25:11 PM8/1/12
to Tasker
It was running, not because of the play button. Thanks for telling me
about the log! I used it to figure out I was careless about the tasks
and had the same task assigned to two profiles. Oops! So now it's
working perfectly! Now I"m just hoping for a task that will reboot the
phone after A1-A7 (or A6 since A7 is Goto A2?) have repeated 5 times?

Heather

unread,
Aug 1, 2012, 9:08:28 PM8/1/12
to Tasker
Yay I figured it out!

Profile: No Mobile Data (15)
State: Not Mobile Network [ 2G:Off 3G:On 3G - HSPA:Off 4G:On ]
State: Not Wifi Connected [ SSID:* MAC:* IP:* ]
Enter: Check For Service (4)
A1: Wait [ MS:0 Seconds:0 Minutes:1 Hours:0 Days:0 ]
A2: Variable Set [ Name:%count To:0 Do Maths:Off Append:Off ]
A3: Stop [ With Error:Off ] If [ %PACTIVE !~ *,No Mobile Data,* ]
A4: Airplane Mode [ Set:On ]
A5: Wait [ MS:0 Seconds:10 Minutes:0 Hours:0 Days:0 ]
A6: Airplane Mode [ Set:Off ]
A7: Wait [ MS:0 Seconds:0 Minutes:2 Hours:0 Days:0 ]
A8: Variable Add [ Name:%count Value:1 Wrap Around:0 ]
A9: Goto [ Type:Action Number Number:3 Label: ] If [ %count < 6 ]
A10: Reboot [ Type:Normal ]

Here's another question. One of the tasks I had in there previously
(in error while I was trying to figure this out) was to turn mobile
data off (OOPS!) so that's why my data connection stayed off during
all of the airplane mode cycles. Good for my testing but bad because I
had no data for several hours! Just in case my mobile data turns off
in the future, how can I add a context for the actual mobile data
setting being set to on? I can't seem to find anything for that.

Heather

unread,
Aug 2, 2012, 12:51:07 AM8/2/12
to tas...@googlegroups.com
In addition to my other question (about adding the actual setting of mobile data to the context), I have another issue. This profile and my Wifi profile (enable Wifi when it's near) are running into a conflict.

I had added a context to my Wifi profile of Not Profile Active No Mobile Data because the Wifi profile kept checking for the Wifi network while the No Mobile Data profile was running. This was kicking off the No Mobile Data profile since one of the contexts for No Mobile Data is Not Wifi Connected *,*,*

What should I do? Because now that I'm home, my Wifi connects for a second, then No Mobile Data runs (I assume to verify if the contexts are true?), which kicks off the Wifi profile because of the Not Profile Active No Mobile Data context. Then No Mobile Data realizes mobile data is enabled, like it was the whole time, and it ends, so the Wifi profile jumps in again. I also keep getting the error about Tasker ignoring tasks because too many tasks are queued. I wonder, what's the timeframe for Tasker checking for a data connection? I didn't see anything in the preferences about it.

Unless someone can think of another resolution, my idea (if it is even possible) is to somehow make the context for Wifi: If "Not Profile Active No Mobile Data" for greater than 2 minutes. Or if that profile passed its contexts? Then again, its context include Wifi! Gosh I'm at a loss. I wish there were a way for Tasker to be alerted of no data connection rather than having to seek it out and then activate the profile.

I hope someone can help because now my brain hurts =P

Matt R

unread,
Aug 2, 2012, 3:17:23 PM8/2/12
to tas...@googlegroups.com
You've found where the true complexity of Tasker is revealed.  When you start having multiple profiles that modify the same settings/variables, it can be quite tricky to know what's going on and think of all the edge cases.  So on the one hand you want to toggle airplane mode if there is no data, and on the other you want to toggle WiFi if it's available, correct?  What exactly does your WiFi profile(s) look like?  If you paste them here maybe I can help you work through the logic.  You can long-press on a profile and select export description (not xml) and then just past it here.
 
Matt

Heather

unread,
Aug 2, 2012, 3:41:32 PM8/2/12
to Tasker
I just switched my WiFi profile to the ones listed here (Home, WiFi
On, WiFi Off, Connected):
http://tasker.wikidot.com/low-battery-usage-wifi-enableing-profile-using-wifi-near

And my current No Mobile Data profile is:

Profile: No Mobile Data (15)
State: Not Mobile Network [ 2G:Off 3G:On 3G - HSPA:Off 4G:On ]
State: Not Wifi Connected [ SSID:* MAC:* IP:* ]
Enter: Check For Data (4)
A1: Wait [ MS:0 Seconds:0 Minutes:1 Hours:0 Days:0 ]
A2: Variable Set [ Name:%count To:0 Do Maths:Off Append:Off ]
A3: Stop [ With Error:Off ] If [ %PACTIVE !~ *,No Mobile Data,* ]
A4: Airplane Mode [ Set:On ]
A5: Wait [ MS:0 Seconds:10 Minutes:0 Hours:0 Days:0 ]
A6: Airplane Mode [ Set:Off ]
A7: Wait [ MS:0 Seconds:0 Minutes:2 Hours:0 Days:0 ]
A8: Variable Add [ Name:%count Value:1 Wrap Around:0 ]
A9: Goto [ Type:Action Number Number:3 Label: ] If [ %count < 6 ]
A10: Reboot [ Type:Normal ]

I think the change of the WiFi profiles may have resolved my issues
because now WiFi won't toggle unless I'm at home, in which case I will
be using my WiFi. Does that sound right? And do the profiles support
that theory?

Matt R

unread,
Aug 2, 2012, 7:13:11 PM8/2/12
to tas...@googlegroups.com
So you changed to this new set of profiles for toggling WiFi and haven't had any problems since?  I don't see any obvious conflicts between the two, so if you haven't noticed any more problems it may be resolved.  The WiFi toggling profile set you linked to seems reasonable (if a bit overly complicated).  I guess keep an eye on it and if you notice it not working in certain situations or toggling when you don't expect it to you can repost and we can look at it.
 
Matt

Heather

unread,
Aug 2, 2012, 7:17:24 PM8/2/12
to Tasker
Sounds like a plan. Thanks so much for your help!!
Reply all
Reply to author
Forward
0 new messages