Today’s mobile device management (MDM) platforms, as you know, severely limit their ability to build and test applications — especially for Android devices. The problem lies with limitations to the functionality exposed through the GUI of the vendor’s dashboard or console, that prevents developers from systemic changes to the device(s). 

One common challenge developers face during the test lab or test deployment phases is how to efficiently orchestrate changes to provision an entire set of devices. Actions like uninstalling an app provisioned on a set of devices, incrementally adjusting screen brightness based on user feedback, or regularly pinging devices to keep them from going to sleep are just some of the many features that developers prefer to do on the fly. With Esper, device management is a cakewalk. 

We expose our platform’s functionality through an API set that is also supported by our Esper SDK for Python and through our CLI, & developers are free to build on our APIs to create automated routines without being blocked by the GUI.

Rather than having to go through and re-provision the group of devices or use the GUI to perform desired actions on each device one-by-one, with Esper you can use our APIs and Python SDK combined with our Group functionality to perform device deployments systematically and efficiently throughout your entire device fleet. (See our previous example of how to use the Esper APIs to whitelist an app for a fleet of deployed devices across a grocery store chain.)

How To Build Automated Routines Using Esper API

We’ve built a sample Python script called esper_group_actions demonstrating how you can do this quickly. Feel free to download it from here. Our SDK for Python installation instructions are here.

  1. Configure the script for your endpoint. As an example, we’ll use our favorite fictitious enterprise (tyrellcorp) with a placeholder API key and Enterprise ID. 

Note: Change the configuration information for your own Esper endpoint as indicated in bold below (endpoint name, api key, and enterprise id):

# Configure API key authorisation: Endpoint name, apiKey, enterprise id
# below are example values, substitute them with your Esper trial values
CONFIG = esperclient.Configuration() = ''
CONFIG.api_key['Authorization'] = 'RaCh1Ty3L181AdE4uN32e593rD3ck36'
CONFIG.api_key_prefix['Authorization'] = 'Bearer'
ENTERPRISE_ID = '5da4cf47-398c-4cea-82be-2796a3f23c3c'

If you haven’t done so already, get your own Esper endpoint with an Enterprise ID and generate an API key by signing up for the Esper Trial

Create a Group using Python or the Esper Console and then include all the desired test or deployment devices in your group. For Python, use the DeviceGroupAPI to first create the Group using create_group. Note the resulting GROUP_ID UUID which will be used for subsequent calls. You can now add devices to the Group using update_group for the GROUP_ID.

Alternatively, you can use the Esper Console to create a Group and add devices go here. You will still need to use either Python or the CLI to obtain the GROUP_ID UUID.

Here is the top-level usage for the script:

   -g GROUP_ID
   -c { uninstall, whitelist, brightness, alarm_volume, 
        ring_volume, music_volume, notification_volume, bluetooth, 
        wifi, gps, ping, reboot }
   -v VALUE

The table below summaries the commands provided by esper_group_actions.

uninstallUninstalls the specified APKpackage_name
whitelistWhitelists an APK for installationpackage_name
brightnessSets screen brightnessint value between 0 & 100
alarm_volumeSets alarm volumeint value between 0 & 100
ring_volumeSets ringer volumeint value between 0 & 100
music_volumeSets music volumeint value between 0 & 100
notification_volumeSets notification volumeint value between 0 & 100
bluetoothTurns Bluetooth on and offbool, 0 is off, 1 is on
wifiTurns WiFi on and offbool, 0 is off, 1 is on
gpsSets the location accuracy across GPS, WiFi, BT, and the mobile GPS off
sensors_only: GPS on
 battery_saving: Uses WiFi, BT,
mobile networks but GPS off
high: Uses WiFi, BT, mobile networks with GPS on
pingPings each deviceN/A
rebootReboots all devicesN/A

We purposely left out the ‘Wipe command’ due to a concern that you mistakenly use it and find yourself with a batch of dead devices. This might not be so much of a concern during early development, but it can certainly can become an issue if you plan to use this command for deployed devices. Feel free to extend the script to support ‘Wipe’ in your case. To run the process, you can package the script up as an executable format to run on a Mac or Windows machine.

Email Andi, our geeky mascot, if you’d like to get more details on how to do this.

Now that you realize how easy it is to use Esper to automate a lot of repetitive tasks – one of our favorites is writing a cron job that uses this script to reboot a group of devices every night. Here are a few other example use cases.

# Set the ring volume at 50% for all devices in the Group:
./esper_group_actions -g 83ecfa3c-d2ad-4e76-2cf1-75daff8d7f3d -c ring_volume -v 50

# Ping all devices in the Group:
./esper_group_actions -g 83ecfa3c-d2ad-4e76-2cf1-75daff8d7f3dc -c ping
# Reboot all devices in the Group:
./esper_group_actions -g 83ecfa3c-d2ad-4e76-2cf1-75daff8d7f3d -c reboot

These actions on the group will only be executed on such devices which are active and able to communicate to the backend at the time of running the commands.  

Device Management- Made Simple!

The magic behind our rich API set is that it gives developers the power to turn their app management into code. Now with Esper you can manage your entire Android device fleet quickly and seamlessly at the speed of the market without getting bogged down with endless policies and processes.

Feel free to modify the script as you see fit. We are curious to learn what cool things you accomplish with our Python SDK; and while you’re at it, please share it with the Esper Dev community. Just email Andi to let us know!

SignUp With Esper