Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kkclstuff

macrumors 6502
Original poster
Apr 18, 2015
312
206
NYC
HI All, Im excited to start using Shortcuts and Automation but confused by what  has omitted, AND how to build what I need using the scripting language.

heres what I'd like to build..

1. Every time my phone 'joins a wifi network' Airplane mode is toggled ON
I can do this with automations BUT, it only prompts me with a notification to 'run' the automation. I set it NOT to ask, and it worked for a day. Ive tried restarting the phone, but still not automated.

For the most part the Automation above is fine, but I also want to make the reverse of it...
2. Every time my phone 'loses/un-joins a known wifi network' Airplane mode is toggled OFF
There is NO automation for this that I can think off. Why didnt Apple have this as a build in option to the listed functions?!?


Ive been trying to conceive of a way to build these with scripting modules but no luck. I believe an "IF" statement should work but I just can't seem to understand the 'variables' and logical order of how the language works. im currently searching the internet for similar shortcuts that I can edit into what I need. Please let me know if you have any suggestions. (and yes, im currently reading through/studing the  guide, but I don't find it very illuminating)
Thanks!
 
Last edited:

Jessica Lares

macrumors G3
Oct 31, 2009
9,612
1,057
Near Dallas, Texas, USA
Personal automations are supposed to be things that happen based on common user actions. Like when I connect to my Bluetooth speaker, open TuneIn Radio, or like when I connect to this specific wifi network, do this and that.

You're right on using an If statement though. Looks something like this:

ifstatement.png
 

kkclstuff

macrumors 6502
Original poster
Apr 18, 2015
312
206
NYC
hi thanks for the example. yes thats the 'IF' statement ive been trying. while it works its not 'self-enabling' ie automated. My goal is to have this shortcut automated, if I have to manually activate I might as well use the control center's Airplane Mode toggle button.

Im abit baffled that I can automate 'when wifi joins' action, but theres no reverse of this? (when wifi un-joins)
there must be a way to add this IF shortcut into an automation.

I just tried creating an 'IF wifi' Shortcut then adding it to an automation but its only triggered by 'connecting to a network'
IMG_0188.png



I need a way to automatically (with a passive trigger) turn Airplane mode off 'if there is NO network'.
I would like to use the 'leave home' automation BUT its activation distance is too large to trigger as needed.
Any suggestions?
 
Last edited:

Jessica Lares

macrumors G3
Oct 31, 2009
9,612
1,057
Near Dallas, Texas, USA
Yeah, the distance is that high so you don't trigger it walking to the other side of the house which the GPS is going to already read as the next address. That is pretty much your best option.

It's just that when the wifi network gets turned off it's usually like a power outage, or a webpage isn't loading on wifi, if it's not that you're leaving the house. So they'd rather you get into your car and put the phone in the charger and then do something like that.
 

kkclstuff

macrumors 6502
Original poster
Apr 18, 2015
312
206
NYC
to be clear I don't want to turn wifi off, just toggle Airplane mode when there's NO known network. Personally I want to limit my cellular usage and use Wifi when I'm connected to a known network. I use airplane mode in my apt while on my wifi network, I just want Airplane mode to toggle off once I 'leave that network'.


Living in NYC on the 25th floor, I can be 'in the same gps location' but nowhere near my wifi. I tried setting the distance trigger to minimum (328 ft) but thats too far here in the city—it won't even trigger on my block. (Not to mention that the GPS is 'locating me' from the tower on the next block).

its just really frustrating that something so simple (and seemly possible) could be obfuscated or omitted.
 
Last edited:

kkclstuff

macrumors 6502
Original poster
Apr 18, 2015
312
206
NYC
ive been thinking about the 'scripting logic' (and setup a "location" script to set Airplane Mode OFF when connected to my car, but still need a way to Automatically turn off AirMode while walking around my neighborhood.)

SO it seems I need two types of actions/functions:

1. a way to 'get' the network status and 'if no wifi network is joined' - turn airplane mode OFF
2. a way to program a script to 'run' without user input (ie passive trigger)

Please let me know if you know of a way to use Shortcut scripting OR is there a third party scripting I can use 'inside' of Shortcuts app to build this.
 

nicho

macrumors 601
Feb 15, 2008
4,250
3,250
to be clear I don't want to turn wifi off, just toggle Airplane mode when there's NO known network. Personally I want to limit my cellular usage and use Wifi when I'm connected to a known network. I use airplane mode in my apt while on my wifi network, I just want Airplane mode to toggle off once I 'leave that network'.

1) Wouldn't this be an infinite loop, since airplane mode turns off the wifi. Thus airplane mode would then disable, to infinity.

2) It sounds like maybe you just need to disable "wifi assist" in your settings and have done with it. Then when you have a wifi connection, cellular won't be used.
 

kkclstuff

macrumors 6502
Original poster
Apr 18, 2015
312
206
NYC
No, airplane mode does not turn off wifi - I use wifi all the time in airplane mode. (basically to move off my phones cellular signal and connect via a wifi signal)

wifi assist: maybe im not understanding its true function? (no , just checked its OFF and I don't want that function) I want to have my cell to connect via wifi while at home (cell service reception in my apt is awful).
 
Last edited:

nicho

macrumors 601
Feb 15, 2008
4,250
3,250
no, airplane mode doesn't turn off wifi - I use wifi all the time in airplane mode. (basically to move off my phones cellular signal and connect via a wifi signal)

ah, wifi assist. maybe im not understanding its true function? I want to have my cell to connect via wifi while at home (call service reception in my apt is awful).

I just enabled airplane mode and wifi turned off. That's the default behaviour. You can re-enable wifi separately, of course - but a shortcut wouldn't do that automatically.



Did I misread before, and this is actually a case of you wanting to make us of Wifi Calling for your phone, rather than worries about using cellular data while connected to wifi?

Best I can suggest for your use case would be two cheap NFC tags you stick above and below the light switch by your door... one to turn on airplane mode & connect to wifi, one to do the opposite.
 

kkclstuff

macrumors 6502
Original poster
Apr 18, 2015
312
206
NYC
I just enabled airplane mode and wifi turned off. That's the default behaviour. You can re-enable wifi separately, of course - but a shortcut wouldn't do that automatically.



Did I misread before, and this is actually a case of you wanting to make us of Wifi Calling for your phone, rather than worries about using cellular data while connected to wifi?

Best I can suggest for your use case would be two cheap NFC tags you stick above and below the light switch by your door... one to turn on airplane mode & connect to wifi, one to do the opposite.
I already thought of that this morning after reading NFC option here on MR. ;)

but that is just more absurdity—having to purchase another product or having a shortcut created that I STILL have to press "run" to activate. very frustrating.

Ive been setup and using airplane mode with wifi and toggling AM on/off for quite a while—everything works as needed. Im just looking for an automated solution to pressing the button in control center. If I have to continue to press 'run' to activate a 'glorified notification' I might as well stick with the manual option (same action/same result).

I appreciate your ideas, just not what im looking for as a solution.
 
Last edited:

kkclstuff

macrumors 6502
Original poster
Apr 18, 2015
312
206
NYC
for those following along... has anyone used SPLASH or JELLYCUTS programming language for shortcuts?

its a step up in programing language, but im willing to give it a try to get what I need. Please let me know if you've used it, your experience, and if theres a better option.


also curious if I could get what I need via a 'callback URL' function?

Thanks
 
Last edited:

kkclstuff

macrumors 6502
Original poster
Apr 18, 2015
312
206
NYC
Last night I was thinking about Nicho's comment and clicking thru the control center options to test my connectivity. I see that I don't necessarily need to toggle Airplane Mode. Since I have 'Wifi Calling' enabled, I could toggle 'Cellular Data' instead.

This is another option but with the same limitation cul-de-sac.
 

nicho

macrumors 601
Feb 15, 2008
4,250
3,250
Last night I was thinking about Nicho's comment and clicking thru the control center options to test my connectivity. I see that I don't necessarily need to toggle Airplane Mode. Since I have 'Wifi Calling' enabled, I could toggle 'Cellular Data' instead.

This is another option but with the same limitation cul-de-sac.

That actually won't help - I misunderstood your purpose as not wanting to accidentally use cellular data while on spotty wifi, rather than wanting to receive calls.

One thing I discovered today is that I actually have an NFC tag in my home... an old hotel room key. It's going in my car tomorrow to see if it helps with maps/music to and from work. You might have the necessary equipment lying around too...
 

kkclstuff

macrumors 6502
Original poster
Apr 18, 2015
312
206
NYC
yes as I said, its another option but with the same limitations- ie not a solution.

curious to hear about the NFC tag test
 

MacNutts

macrumors newbie
Mar 8, 2022
1
0
@kkclstuff your right on the money and fighting the good fight. It is so frustrating that Apple didn’t include an opposite automation to connecting to a known Wi-Fi network. I would love to use the automation you describe.

To go further, I would love to turn on and off airplane mode/data when the known Wi-Fi data rate is =<> a specified rate. Sometimes the Wi-Fi can be at full strength but no data flowing. Or one could be at the front of their network and not get enough signal to be useful.
 

kkclstuff

macrumors 6502
Original poster
Apr 18, 2015
312
206
NYC
@MacNutts thanks, I hear ya.

I found the easiest, yet still not automatic, option for me was to setup activating the shortcut to toggle wifi in presence of my network with a 'triple tap' on the back of my phone. When away from home, I can 'triple' tap and the wifi toggles; and returning home toggles agin. actually its a super powerful feature, but I'd love it to be basic on data (and not a physical action) this is only BArELY better then taking the phone out and going to the control center.

ive tried working with MFC Deck and Toolbox pro to setup more elaborate shortcuts, but alas  got the phone locked down. A big disappointment for something so basic.
 

NoBoMac

Moderator
Staff member
Jul 1, 2014
6,285
4,973
Here's a hack for some: Focuses. They do not require any action on user's part.

Example: Setup an "at home" Focus, does not matter what settings are in there, just have a location set for home. In Shortcuts, setup Automation to trigger when "at home" Focus turns on. Automation turns off "at home" Focus and toggles on airplane mode.

If one goes ahead and makes a "real" Focus for home (ie. Setup who/what can break through), can add "when Focus ends" Automation to toggle airplane mode off (remove the "focus off" for "on" Automation).
 

kkclstuff

macrumors 6502
Original poster
Apr 18, 2015
312
206
NYC
Thanks @NoBoMac. I'll check Focuses out.

I think (If I understand your example) that (for me) the problem is the "trigger". I can't use the GPS to use "location" since I live on the 25th fl if im in my apt or on the street in front of my bldg the location shows the same. The gps won't account for altitude for location in my device. Street level and 250ft up are the same location to the phone. (be nice for  to correct/modify/adapt this)

Ultimately I'd like to walk into my apt and have the phone 'see' my wifi and switch all settings as needed...
hmm, I setup automations for when my phone 'senses' my car via bluetooth (ie phone pairs with car via bluetooth). I wonder if it could be setup to run automations when my phone 'senses' my iMac at home?
 
Last edited:

NoBoMac

Moderator
Staff member
Jul 1, 2014
6,285
4,973
A hacky way might be that when Focus turns on, call a shortcut that is a loop for X occurrences. Contents of loop are a "wait" for 1-2 minutes, then check to see if connected to home wifi (probably connecting before reaching the door). If connected, do stuff and then have the "stop shortcut" action to exit the loop (and Shortcut). However, Shortcuts has a time-out value set for running too long which might get in the way (have not tested to see what that exactly is).

Doesn't help with leaving though.
 

DamDD

macrumors newbie
Oct 3, 2022
1
0
I think i found a solution. still not perfect but maybe someone here could assist with it.
so as the OP says, the issue is with the trigger which needs to be one that happens and require no user intervention.
the shortcut for when wifi connects, is not enabling to toggle off the "ask before running" but i found that other shortcut does enable this option. the automation for the airplane mode. you can set the trigger to be "airplane mode on" / off and uncheck "ask before running". afterwards i put all the script inside a "repeat" loop and ask the network details, if "contains any value" (wifi) then put airplane mode on, else if the network name "does not contain any value" turn airplane mode off. between each one i've set a "wait" timer to do that every one minute and set the repeat number of times to be 3600.
it kinda works. i mean the phone automatically turn on airplane mode (and leaves wifi on) and when there is no wifi it is turning off the airplane mode. but its only works for testing, ie in short amount of time, like 10-15 minutes.
i re enabled the background app activity and asked the shortcut to notify when running. so now the app notify me every few minutes that the shortcut failed to run because it took too long and then the shortcut is restarts and repeat.
it seems to work but my guess is that shortcut never intended to run that long time thus the app terminate it and for some reason it restarts it even when there is no trigger to do so automatically.

first I'm trying to understand if this kind of a shortcut can be expensive, battery wise, both on wifi or cellular. i mean i do save a lot of battery turning airplane mode since i have very bad reception and it is noticeable that the battery drain is much faster in those conditions. on the other end i have to let the shortcut run even when on cellular network and this could be to much, what do you think?
second, maybe you could suggest a better way to use this shortcut.

if someone is trying this and got a fix it would be great reading from you here.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.