Entity object

Definition

An entityObject reflects the JSON representation of entities from the API, but it's provided with 3 methods that allow interacting with that particular instance.

Example

Suppose that you retrieve data from a device as:

const firstDevice = await Ubidots.devices.first();

Here, firstDevice is an object containing all the properties of the dictionary representation of a device from the API:

{
  "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
}

But, not only does this object have the properties shown above, you can also invoke the following methods on firstDevice:

firstDevice.refresh();
firstDevice.update(args);
firstDevice.save(args);

Entity object methods

Last updated