Monitor the state of your AirPort base stations. Get alerts when your external IP changes or when the internet connection goes up or down. Track connected clients and perform scripted reboots.
AirPorts are terrific WiFi access points and routers, but they don’t run forever without a restart. I got tired of waiting till things started to go goofy with mine and manually restarting them and began work on this plugin. Unfortunately AirPorts don’t support any documented connection method to them directly for such information and Apple’s AirPort Utility is not scriptable so the only choice left was to use User Interface Scripting. It is a requirement of this plugin that you enable Accessibility for XTension before starting this plugin. Your AirPort utility must be able to load up your AirPorts and connect to them without requiring a password. Make sure that the passwords of your airports are in your keychain.
The AirPort plugin is not included as part of the standard XTension install so you must download and install it separately. This plugin requires at least XTension version 9.4.9.
Download: Airport Info Plugin v1.0 8/18/2018
download the linked file and unzip it if your browser doesn’t do so automatically. In XTension pull down the Database menu and select “Install Plugin” Select the plugin folder that you unzipped above.
Open the Interface window from XTension’s window menu and click the “New” button in the toolbar. The Airport Info plugin should now be listed in the Device popup menu. Once selected you’ll get the setup options for this plugin.
When a scan starts the AirPort Utility app will launch in the background on the machine if it’s not already running. It will appear that someone is clicking each of the icons on the page and as it walks through them the units in XTension will update to the current status if anything has changed. If no airports are found to be offline the AirPort Utility will quit. If an AirPort is found to be offline or otherwise returning an unknown state the Utility will be left running and a scan will be performed every 30 seconds until the AirPort comes back up again.
Since the interface is being scripted it is not necessary to stop doing anything else on your computer. It can run quite happily behind other windows unless a reboot is being performed. In order to select the menu item for restart via user interface scripting it is necessary to bring the app to the front. In that case it will become the frontmost app and interrupt you if you’re using the machine at that moment. It only takes a second to perform the command however and after that you can move it back to the background.
If you wish to use the AirPort utility to manually make changes to an AirPort’s configuration you should disable the Interface in XTension so that it won’t be inserting clicks and attempting to read the status of the AirPorts off the wrong windows while you’re working with it.
You can manually trigger a scan at anytime with the Scan Now button in the Edit Interface window or via a script like:
tell xInterface “name of your AirPort interface” to scanNow()
The full text of the status of your AirPort will be put in the Description of the Status Unit.
Two unit properties are set as well. The “client count” which is the number of clients currently connected to that base station and “address” which holds the IP address of the base station. In the case of the router that will also be the internet IP address.
A single “Internet Status” unit is also created that will turn off if the connection to the internet goes down.
The AirPort that is your router will have the external internet IP address in it’s IP address field. The plugin will create a unit with he address of “IP” and set the Description of that unit to the current IP address. It will also run an optional handler in that units On script called “internetIPChanged” like:
(* I N T E R N E T I P C H A N G E D This handler will be called when your external IP changes and the new IP address will be passed to you. This handler can only be added to the "IP" addressed unit. *) on InternetIpChanged( newAddress) write log "your IP address has changed to: " & newAddress end InternetIpChanged
You can use the “Insert” toolbar button when editing the unit script to insert that template directly.
In order to know for sure which AirPort is your router you may need to check the “ThisAirPort is the Router” checkbox in it’s Edit Unit dialog. By default XTension will setup the first AirPort that it finds in the window as the router and take the IP address from that one to place into the IP unit. Depending on the layout of your window however that might not always be correct. If the IP address is coming from the wrong AirPort then uncheck the checkbox in the wrong device, and check it for the correct device. On the next scan it will pick up the address from the correct device.
The restart can be scripted by telling the unit to reboot like:
tell xUnit “Airport: Kitchen” to reboot()