Table of Contents

  1. Overview
    – Device Types
    – Why Device Types
  2. Creating a Device Type
  3. Testing Device Types

1. Overview

One feature developers using Ubidots love most is the automatic device creation when the first dot of data is received in a user's account. (In case you did not know this, check out the article “Automatically provision Devices and Variables with Ubidots API labels”.) Here’s a simplified flow diagram of how Ubidots understands and recognized a device:

Device Types

With the automated onboarding perfected, Ubidots released the Device Type which automates the device onboarding process event more by not only creating the new device in Ubidots, but also configuring its variables, properties, and appearance. With Ubidots Device Types, IoT Solution Deployments are as simple as uploading code with the correct TOKEN, and let Ubidots take care of the rest. 

Why Device Types?

To give you an idea of how much time you can save with this feature, here’s a real-life onboarding workflow prior to switching to Device Types:

  1. Create a device in Ubidots (optional)
  2. Flash firmware to device with API identifier given by IoT platform
  3. Create 10 variables within the device
  4. Specify units for each variable
  5. Specify range for each variable
  6. Specify custom offset for some of the variables
  7. Create properties: city, installation date, and firmware version

For a deployment of 1,000 devices, this would have to be done 1,000 times!

On the other hand, with Device Types, the process becomes as simple as:

  1. Creating a Device Type with corresponding properties, variables, units, ranges and formulas.
  2. Flashing the same firmware to all devices

With Device Types, every time a device is created, then the specified device type is automatically applied, saving you the configuration and development time needed to launch hundreds of the same device.

2. Creating a Device Type

Step 1 : Create a new Device Type

To create a device type, go to the “Device Management” tab in your Ubidots account, then click on “Types”, followed by the “+” icon in the upper right corner:

Step 2: Device Type Name and Appearance

Next, you'll be presented with a screen to enter your Device Type name and appearance. Please keep in mind that the API label of the device type will automatically be generated based on the name you enter.
IMPORTANT NOTE: The device type API label is a unique identifier that allows Ubidots to know which device type to apply when a new dot is received by the platform. This can be specified in your request using the parameter "type" in the request URL; for example,

curl -X POST 'https://industrial.api.ubidots.com/api/v1.6/devices/device-label/?type=device-type-label' \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: YOUR-TOKEN' \
-d '{"temperature":10}'

Step 3 (Optional): Configure Device Properties

If you use the Ubidots Device Properties feature in your App, then this step is for you.

By specifying a devices' custom properties, every new device will be created with the same applied set of properties. Here’s an example of what a Property configuration might look like: 

Step 4 (Optional): Configure Variables

Click on the button “Add variable” to add as many variables as needed. For each variable, you can set these basic fields:

  • Variable Name: The friendly variable name as it will appear in the variable list of a Device. You may want to add the name with the first letter in uppercase, since, without a device type, Ubidots default is lowercase. The Variable Name is simply a friendly name to fit your solution's nomenclature. 
  • Variable API Label: An identifier within all the device’s variables. It can be different than the variable name and should match the payload. Example: if payload from device is ”{“temp”:10}”, the variable API label in the device type should be “temp”. 
  • Unit: The unit of your variable
  • Type: Raw for the variables that you send through our API, “Synthetic” for variable that require additional Synthetic calculations. 

EXAMPLE: The Variable Name and Variable API Label can be the same or different. If the Variable Name is "Temperature" and the Variable API Label is "temp," Ubidots will recognize the "temp" API Label and update the corresponding variable, but display "Temperature" in the dashboard.

– Additional Configurations

By clicking the "downward-pointing arrow" icon to the right of the variable configuration, you’ll be presented with more advanced configuration options that include:

  • Allowed Range: The min and max ranges for your variable.
  • Synthetic Expression: The math or statistical expression used to compute new data based on one or more existing variables.
  • Description: The description of the variable as you’d like it to appear for to end-users.
  • Color: Optionally override the color of the variable, as set in the “Appearance” step above.
  • Visible to end-users: By default selected, if unselected then this variable will only be seen by the Admin, not an Apps users.
  • Location Variable: If selected, then Ubidots will understand this variable to be containing the context of latitude and longitude coordinates.

Here’s an example of how this configuration might look:

3. Testing Device Types

To access a listing of all Device Types in an account, select "Types" from the Device Management tab in the main navbar. 

To test the Device Type, copy and paste the below sample request into your computer's terminal. Make sure to update the TOKEN and the ?type= parameter.

IMPORTANT NOTE: Devices types are only applied when creating new devices. Sending the “?type=” parameter to an existing device will only update the data of the configured variables. 

curl -X POST 'https://industrial.api.ubidots.com/api/v1.6/devices/device-type-test/?type=new-type' \
> -H 'Content-Type: application/json' \
> -H 'X-Auth-Token: YOUR-TOKEN‘ \
> -d '{"Variable_API_Label":""}'

If the Device Types has been created properly, the 201 response code will be returned from your computer's terminal.

{"Variable_API_Label": [{"status_code": 201}]}

Lastly, in our Ubidots account, we can see the results. Not only will you see the new device created and named according to the credentials established in the Device Type, but you will also see the devices pre-configured variables with names, icons and units already updating according to your Device Type:

Plus.... the device properties are also added:

And, any Synthetic expression of the underlying variables:

Need help configuring your device types? Feel free to reach out to Ubidots Customer Success team using the in-app chat or by writing to support@ubidots.com for additional tips, tricks, and troubleshooting.

Other users also found helpful: 

Did this answer your question?