Device Object

Describes the JSON object of a Device.

A Device in Ubidots can store one or more Variables. Devices can have an exact location and a predefined type.

PropertyTypeDescription
idStringId of Device
labelStringLabel of Device
nameStringName of Device
createdAtStringDate Device was created
descriptionStringDescription of Device
isActiveBooleanTrue if Device is active
lastActivityNumberDate of of Device's last activity
organizationOrganization ModelOrganization the Device belongs to.
locationObjectGPS position as set in Device properties. This is a read-only field; to set a position, send the _location_fixed object in the properties body parameter.
tagsString ArrayTags of Device
urlStringURL of Device
variablesStringVariables URL of Device
variablesCountIntegerNumber of Variables in the Device
propertiesObjectProperties of Device, including support for:
- _color: Device color in #rrggbb hexadecimal format.
- _icon: Font Awesome v6.1.1 label of device icon.

Device

{
    "properties": {
        "_color": "#EA6F4C",
        "_icon": "cloud-sun",
        "_location_fixed": {
            "lat": 6.2486,
            "lng": 75.5742
           }
    },
    "createdAt": "2019-11-25T19:35:08.975270Z",
    "description": "some description",
    "id": "6e309da44fc8455a9cceb5aa",
    "isActive": true,
    "label": "first-device",
    "lastActivity": null,
    "name": "First Device",
    "organization": {
        "id": "af92e4c82bf1d39cc21882f5b",
        "label": "my-first-customer",
        "name": "My First Customer",
        "url": "http://industrial.ubidots.com/api/v2.0/organizations/af92e4c82bf1d39cc21882f5b"
    },
    "tags": ["first"],
    "url": "http://industrial.ubidots.com/api/v2.0/devices/6e309da44fc8455a9cceb5aa",
    "variables": "http://industrial.ubidots.com/api/v2.0/devices/6e309da44fc8455a9cceb5aa/variables",
    "variablesNumber": 1
}

Properties object

The properties key object describes the following about a Device:

  • Color.
  • Icon.
  • Configuration for of these types of properties : Boolean, Date, List, Number, Text.
  • Properties values.
  • Device type (Read only).
  • Location mode and its respective derivates.
PropertyTypeDescription
_iconStringFontawesome’s icon name. This icon will be set to the device.
For example, "cow"
_colorStringDevice color in hexadecimal format. For example, "#rrggbb"
_configObjectObject to configure the properties of a device. See examples below.
_device_typeStringDevice Type label applied to the device. Read only.
_location_typeStringIt can be either auto, specified or manual. Learn more

Configuration of properties

Setting up properties for a Device is done through the _config key object. All properties will follow the below structure, and then some of them will apply some modifications:

{
  "<property-key>": {
    "key": "<property-key>",
    "text": "Text here", // How the property will be seen in the platform
    "type": "<type>", // Can be "boolean", "date", "list", "number" or "text"
    "value": "<default-value>",
    "description": "Description here"
  }
}

This is how each type of property should be set up in the _config key object:

{
  "key": "boolean",
  "Text": "Boolean property",
  "type": "boolean",
  "value": true,
  "description": "description"
}
{
  "key": "date",
  "Text": "Date property",
  "type": "date",
  "value": null,
  "description": "description"
}
{
  "key": "list",
  "Text": "List property",
  "type": "list",
  "value": "",
  "options": [
    {
      "text": "Option 1",
      "value": "option-1"
    },
    {
      "text": "Option 2",
      "value": "option-2"
    }
  "description": "description"
}
{
  "key": "number",
  "Text": "Number property",
  "type": "number",
  "value": "10",
  "description" "description"
}
{
  "key": "text",
  "Text": "Text property",
  "type": "text",
  "value": "",
  "description" "description"
}
{
  "key": "json",
  "text": "JSON",
  "type": "json",
  "value": {},
  "description": "Description"
}

Properties object example:

{
  "properties": {
    "p1": "Test Demo",
    "p2": 10,
    "p3": "t1",
    "p4": "2021-01-21",
    "p5": true,
    "p6": {},
    "_icon": "cloud",
    "_color": "#477bbe",
    "number": "3174427149",
    "_config": {
      "p1": {
        "key": "p1",
        "text": "P1",
        "type": "text",
        "value": "",
        "description": "P1"
      },
      "p2": {
        "key": "p2",
        "text": "P2",
        "type": "number",
        "value": 10,
        "description": "P2"
      },
      "p3": {
        "key": "p3",
        "text": "P3",
        "type": "list",
        "value": "",
        "options": [
          {
            "text": "t1",
            "value": "t1"
          },
          {
            "text": "t2",
            "value": "t2"
          }
        ],
        "description": "P3"
      },
      "p4": {
        "key": "p4",
        "text": "P4",
        "type": "date",
        "value": null,
        "description": "P4"
      },
      "p5": {
        "key": "p5",
        "text": "P5",
        "type": "boolean",
        "value": true,
        "description": "P5"
      },
      "p6": {
  			"key": "p6",
  			"text": "P6",
  			"type": "json",
  			"value": {},
  			"description": "Description 6"
			}
    },
    "_device_type": "demo-devices",
    "_location_type": "manual",
    "_location_fixed": {
      "lat": 6.1232,
      "lng": -75.34
    },
    "_location_variable": "demo"
  }
}