Apple’s airport devices are great routers and wifi access points that don’t so far suffer from the number of hacks and problems that other models seem to. One of the ways they get some of that extra security is by not having a web based interface, you have to run their custom application which makes a secure connection to the device to change it’s configuration.
The downside to that is that you could script talking to the web pages of other devices to get your IP address or to do a restart, you can’t do this to an airport.
The AirPort Utility is likewise not scriptable in any reasonable way, nor do they support any other communications methods such an SNMP or anything else. It turns out that the AirPort utility is scriptable through the User Interface Scripting system in OSX. I need to be able to give my airports a regular restart to keep things from getting weird or to force them to restart when the network stops working for whatever reason. I would like to automate this process so undertook to figure out the UI scripting to talk to them. It’s not at all straightforward but it turns out you actually can automate both the reading of the status of your airport units, the connection to the internet, the internet IP address and also restart an airport under scripting control.
Limitations in the user interface scripting or possibly bugs in it’s implementation in the AirPort Utility make it impractical to control it directly from a script running inside XTension. So this script is an external script saved as an Application. It will stay running on your machine as long as you wish and will query the AirPort utility every 30 seconds for changes in the status of the connection to the internet, the status of any connected airport and your internet IP address.
The script has lists of both the names of your airports and the names of pseudo units in XTension that you wish to keep in sync with their status. Create a non dimmable pseudo for each airport that you wish to scan and another for the state of the internet. The IP address that the airport thinks it’s getting from the internet will be saved to the description field of the internet state unit. You can add an on descriptionChanged event in that units On script to catch changes to the IP address and send yourself an email or anything else if you wish.
The names of those units must be filled into the proper places in the script.
Scripting a restart of any of your airports from XTension can be done from a global script something like this
tell app “airport helper” to restartAirportByName( “Office”)
For those looking for a way to script a restart of their airports without using this script or who don’t have XTension the meat of that is this:
on restartAirportByName(theName) tell application "System Events" tell process "AirPort Utility" click (first image of group 1 of scroll area 1 of window 1 where its name starts with theName) (* note that the "..." at the end of the Restart menu item name below is NOT just three periods it is the elipsis unicode character. It will not work if you retype that with just three periods. use the keyboard utility to enter it or just copy it from here. *) click menu item "Restart…" of menu "Base Station" of menu bar 1 end tell end tell end restartAirportByName
Please note that the same requirement to register your script or host application in the system preferences under allowed assistive scripting is a requirement for whatever you put that script into. Otherwise it will fail. There also seems to be either a bug in the AirPort Utility app or a limitation in user interface scripting that may not allow that to work if you run it from an application that was not launched specifically by a user action. You also may not be able to run it from a background app. Just cutting and pasting this into an XTension global script does not work. Thats why it became an external script application.
AirPort helper is offered for free to XTension users and completely open and free so that others might gain from it as well. The restart function could easily be pulled into your own scripts if you are not an XTension user. It is also free from warranties or expectations that it will work for you or that it won’t do anything horrible to your own system.
At this moment I know this script will run on OSX version 10.13.4 and with AirPort Utility version 6.3.8. It may run with older or newer versions though there may be problems getting the IP address on earlier OS versions. It will run against almost any XTension version in history.
Download: Airport Helper v1.1 (40k) 5/30/2018
MD5 Hash of the zipfile: c2d353d84e0fa6280d2359fbb5a267d2
The script has complete instructions in it’s initial comments for setting up the system with XTension. You must create the pseudos to hold your airport device status and create any other scripts needed to call the restartAirportByName( name) handler. Additionally the fact that it uses interface scripting means that you must also enable that for the application.
Apple does not make it easy to get any of this information out of the application. The WAN IP address is particularly susceptible to getting lost if there are changes to the popover window that displays the data. If you have a firmware update available it may not work or if other things are different there. If you have to temporarily just disable the ip address check by entering a blank name in the script then that will get you past the problem until I find a better way to collect that information.