Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

BLE Import (Use Case)

This Juniper Mist use case shows you how to efficiently import your Bluetooth Low Energy (BLE) assets with their names using the power of Juniper Mist Asset Visibility.

When you set up and activate location-based services with Juniper Mist Asset Visibility, admins like you can see all BLE clients and assets. You can also see their precise locations, right on an indoor floor plan or map.

For sites that use BLE asset tags, it’s handy to track these devices by giving them easily readable names that provide some context. You can add and display these names individually within the Juniper Mist portal, but if you have a lot of assets to manage, doing it one by one can be quite time consuming. An easier way to do this is to run a script to import BLE assets and assign them a name in bulk.

For this use case, you need to:

  • Enable Asset Visibility in the Site Settings for each site.

  • Make sure that you have an active license for Asset Visibility.

  • Make sure that you have placed compatible APs on the floor plan.

This use case involves two scripts: main.py and mist-client.py. A third file, a CSV file called assets.csv, contains the BLE assets and their corresponding names.

Here's the order of steps you follow when you need to import BLE assets:

  1. Start by updating the main.py script with your Mist API token, Mist site universally unique identifier (UUID), and the region (or cloud) in which your organization is hosted.

  2. Next, you add, remove, or inspect the BLE devices and their names within the assets.csv file.

  3. Run the main.py script, which will use the CSV content to create the assets in Juniper Mist.

Main.py Script

A lot happens behind the scenes in the main.py script. The script imports the data from the CSV file and converts the data into JSON format. Then, for each device, the script creates a BLE asset and triggers the mist-client.py script. This mist-client.py script does the work of making all the necessary calls to the Juniper Mist API.

Mist_client.py Script

The mist_client.py script functions like a regular RESTful client for interacting with the Juniper Mist API. The script makes API calls based on the input from the CSV file and the output of the main.py script. The mist-client.py script also error-checks the HTTP response from the API and displays the output, as follows:

Assets.csv

In this example, the assets.csv file resides in the same directory as the mist_client.py and main.py files. The following example shows how to format the CSV file with the name of the BLE asset and its associated MAC address:

Automation goes beyond just using RESTful APIs and Python. Other options like WebSocket and webhook APIs are available. You can explore these other options for automation purposes.