User Tools

Site Tools


supported_hardware:airport

AirPort Monitor

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.

Setup Accesibility

In order to work this plugin requires that you give XTension Accessibility access. This will allow it to use User Interface Scripting to get the necessary info and perform restarts.

  • Open the System Preferences and select the “Security & Privacy” control panel
  • switch to the “Privacy” tab and then select “Accessibility” from the list on the left hand side.
  • If necessary “click the lock” at the bottom of the window and enter your admin password so you can add to the list.
  • click the “+” button and select XTension when the select app window appears.
  • Make sure that the checkbox next to XTension’s icon is checked.
  • Close the preferences or switch back to the main page to make sure the settings have been saved.

Download and Install

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.

Setup

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.

  • Check Airports Every… Minutes. How often do you want to run a check. The default is every 5 minutes but can be set to anything from every minute on up.
  • Create presence units for all wireless clients. If this checkbox is checked then during the first scan a unit will be created for every connected client that is found on any of your base stations. These are wireless clients and not the same as the old DHCP server list that is no longer available in this version of the airport utility. As they connect and disconnect the units in XTension will turn on and off. This is not as useful as you might think for knowing that someone is home or not since iphones and other portable devices will disconnect from the wifi quite often just to save their batteries. It might be useful for tracking the presence or absence of other devices or to know that a device is actually working and hasn’t hung up or something similar to that. Potentially a lot of units will be created with this turned on.
  • Scan Now. This button just asks the plugin to perform a scan right now.

The Scan

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.

Getting your IP address

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.

Restarting an AirPort

The restart can be scripted by telling the unit to reboot like:

tell xUnit “Airport: Kitchen” to reboot()

through the user interface you can access it via the contextual menu or by clicking the gear menu on the detailed unit controls for that unit:

History

  • Airport Monitor Plugin v1.0 was released on 8/18/2018 and required XTension version 9.4.9
/home/e805485/machomeautomation.com/data/pages/supported_hardware/airport.txt · Last modified: 2023/02/13 14:52 by 127.0.0.1