How to upload a bulk of Devices with CSV File

In this article, we’ll learn how to set up a dashboard where you can upload a bulk of csv files to create several devices at once.

By following all the steps in this article, you’ll end up with:

  • A dashboard to upload the CSV File to
  • An analysis that will handle the device creation
  • A dummy device needed to work with the dashboard widgets and store error information

Setting up the device

For this article, we’ll need one device to store our data.
To create a device, you need to go to https://admin.tago.io/devices

  1. Click on the “Add device” button located at the top right corner
  2. Then, look for the “Custom HTTP” connector and click on it
  3. Give the device a name and create it
  4. You will be redirected to the device page

Setting up the analysis

To get this analysis, go to: http://admin.tago.io/template/5d4c9399de7f46001bfc70cb

The only thing we need to do here is set up the Environment variable.

  1. Enter the following link: https://admin.tago.io/account/
  2. Select your Profile
  3. Enter the Tokens tab
  4. Generate a new Token, setting Expires to Never
  5. Press the Copy Button and paste it on the Environment Variables tab of the analysis

Setting up the dashboard

You can get the dashboard that we’ll use by clicking here.

You’ll select the device that we created when asked for it.
After selecting the device, you will be redirected to the dashboard.

Next thing we need to do for the dashboard to work as expected is to set which analysis the input widget must trigger when we press the button Create devices.
In order to do that, click on the three dots of the widget to edit its properties.

Then go to User Control and change the Run Analysis to run the analysis we created earlier.

The CSV File

The dashboard has a link for you to download the example.csv file any time you need.

This is a very simple CSV file containing the:

  • Device name
  • Device serial, which represents the EUI or ID, depending on which network you’re using. You don’t need to change the csv header
  • Data retention value, which must be written as forever or 1 day or 1 month or 1 year

csv file content

Using the dashboard

The dashboard itself has some instructions on how to get the network and connector ID. Those are both required features for you to create your devices from the CSV.

This also means that you can only create a list of one type of device at a time.
In other words, if you want to create both HTTP and MQTT devices, you will need to have one CSV file for each type and get the network and connector ID for each.

Once it’s done, you can just press Create Devices and check for any error that the widget returns as feedback to you.

1 Like

Thank you for this Vitor, very well documented and exactly what I’ve been looking for!

Hi @vitor.

I tried this script using Custom HTTPS device type, but nothing was reported in the error log and no devices were created. Any ideas where to check?

I was going to work through the analysis script as an exercise, but I notice that the script is weirdly formatted - snippet below. Is this essentially a compresses JS script from the tago builder - I have not seen this before? Interesting.

/*!
 * @tago-builder
 * Tago (https://tago.io/)
 * Tago Builder V2.2.3 (https://git.io/vhEW5)
 * 
 * Generated at: 1565299425350 (Thu Aug 08 2019 18:23:45 GMT-0300 (Brasilia Standard Time))
 * Machine     : Vitors-MacBook-Pro.local - darwin
 * 
 */
/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {