Python – Auto-Populate Tag Values in Ekahau Pro

Ekahau released a new version (v10.2) last month. The best feature out of this new version (for me at least) is the ability to create personalized tags for AP objects. Each tag can have a key and a value.


My good friend Haydn Andrews had the idea to create a script that would auto populate the value of some tags based on the AP properties. This could be used for a lot of AP related properties if you think about it:

  • Installation details
  • Special bracket needed
  • Antenna related information (internet, external, model…)
  • PoE budget information
  • Service loop required

In our case we focused on the antenna(s). So we wanted to auto populate the value of three tags that we created:

  • antenna-type
  • antenna-vendor
  • antenna-name

antenna-type would be set to “internal” or “external” depending on the type of antenna used.
antenna-vendor would be set to the antenna vendor (for external antenna only).
antenna-name would be set to the model of antenna (for external antenna only).

That’s how the following script was born:

The script will create a modified copy of your esx project and leave the original unchanged. However, we recommend running the script against a copy of the original esx project file.

This script will only works if you create the tags within your project before running the script. The easier to do this is to create the three tags on an AP that has external antennas. The three tags to create are: “antenna-name”, “antenna-type”, and “antenna-vendor”.

The Code

import argparse
import time
import os
import zipfile
import json
import pathlib
import shutil
from pprint import pprint

def main():
    parser = argparse.ArgumentParser(
        description='This scrip auto configure antenna tags based on AP properties')
    parser.add_argument('file', metavar='esx_file', help='Ekahau project file')
    args = parser.parse_args()

    current_filename = pathlib.PurePath(args.file).stem
    working_directory = os.getcwd()

    # Load & Unzip the Ekahau Project File
    with zipfile.ZipFile(args.file, 'r') as myzip:

        # Load the accessPoints.json file into the accessPoints dictionary
        with'accessPoints.json') as json_file:
            accessPoints = json.load(json_file)

        # Load the simulatedRadios.json file into the simulatedRadios dictionary
        with'simulatedRadios.json') as json_file:
            simulatedRadios = json.load(json_file)

        # Load the antennaTypes.json file into the antennaTypes dictionary
        with'antennaTypes.json') as json_file:
            antennaTypes = json.load(json_file)

        # Load the tagKeys.json file into the tagKeys dictionary
        with'tagKeys.json') as json_file:
            tagKeys = json.load(json_file)

        # Retreive the ID corresponding to each antenna related tags
        for tag in tagKeys['tagKeys']:
            if tag['key'] == 'antenna-name':
                antenna_tag_id = tag['id']
            elif tag['key'] == 'antenna-type':
                antenna_type_tag_id = tag['id']
            elif tag['key'] == 'antenna-vendor':
                antenna_vendor_tag_id = tag['id']

        # Loop through the AP and auto populate the tag values based on the AP properties
        for ap in accessPoints['accessPoints']:
            for radio in simulatedRadios['simulatedRadios']:
                if ap['id'] == radio['accessPointId']:
                    for antenna in antennaTypes['antennaTypes']:
                        if radio['antennaTypeId'] == antenna['id']:
                            if antenna['frequencyBand'] == "FIVE":
                                if antenna['apCoupling'] == "EXTERNAL_ANTENNA":
                                    ext_antenna_name = antenna['name'].split(' ')[1]
                                    ext_antenna_vendor = antenna['name'].split(' ')[0]
                                        {"tagKeyId": antenna_tag_id, "value": ext_antenna_name})
                                        f"{ap['name']}: 'antenna-name' tag set to '{ext_antenna_name}'")
                                        {"tagKeyId": antenna_type_tag_id, "value": "External"})
                                        f"{ap['name']}: 'antenna-type' tag set to 'External'")
                                        {"tagKeyId": antenna_vendor_tag_id, "value": ext_antenna_vendor})
                                        f"{ap['name']}: 'antenna-vendor' tag set to '{ext_antenna_vendor}'\n")
                                        {"tagKeyId": antenna_type_tag_id, "value": "Internal"})
                                        f"{ap['name']}: 'antenna-type' tag set to 'Internal'\n")

    # Write the changes into the accessPoints.json File
    with open(working_directory + '/' + current_filename + '/accessPoints.json', 'w') as file:
        json.dump(accessPoints, file, indent=4)

    # Create a new version of the Ekahau Project
    new_filename = current_filename + '_modified'
    shutil.make_archive(new_filename, 'zip', current_filename)
    shutil.move(new_filename + '.zip', new_filename + '.esx')

    # Cleaning Up

if __name__ == "__main__":
    start_time = time.time()
    print('** Creating Antenna Tags...\n')
    run_time = time.time() - start_time
    print("\n** Time to run: %s sec" % round(run_time, 2))

Feel free to modify it so you can use it with your own tags.

Note: we might update it in the future. So make sure to also check the GitHub repository to see the latest version available:


As mentioned previously, the tags (key only) need to be created on the original project file on at least 1 AP object as shown below:

You can then create a copy of your project file (.esx file) and run the script against it:

A modified version of your project file will be created. When you open it, you should see the tags configured with the proper values on all access points:

The flexibility of creating our own tags opens a lot of opportunities for us. Feel free to take this and modify it to your needs.

Links & Resources

Leave a Reply

Your email address will not be published. Required fields are marked *