TagoIO SDK for JavaScript and TypeScript
    Preparing search index...

    Class Devices

    Index

    Constructors

    Methods

    • Deletes a device from your application.

      Parameters

      • deviceID: string

      Returns Promise<string>

      If receive an error "Authorization Denied", check policy Device / Delete in Access Management.

      const result = await Resources.devices.delete("device-id-123");
      console.log(result); // Successfully Removed
    • Experimental

      Deletes a chunk from a immutable device.

      Parameters

      • deviceID: string
      • chunkID: string

      Returns Promise<string>

      If receive an error "Authorization Denied", check policy Device / Manage chunks in Access Management.

      const result = await Resources.devices.deleteChunk("device-id-123", "chunk-id-123");
      console.log(result); // Chunk chunk-id-123 deleted
    • Delete data records in a mutable device using the profile token and device ID.

      See the example to understand how to use this method properly to have full control on what to delete.

      ! If query parameters are empty, last 15 data for the device will be deleted.

      Parameters

      • deviceId: string
      • OptionalqueryParams: DataQuery

      Returns Promise<string>

      If receive an error "Authorization Denied", check policy Device / Delete data in Access Management.

      const result = await Resources.devices.deleteDeviceData("device-id-123", {
      ids: ["record-id-1", "record-id-2"]
      });
      console.log(result); // 1 Data Removed
    • Edit data records in a mutable device using the profile token and device ID.

      The updatedData can be a single data record or an array of records to be updated, each of the records must have the id of the record and the fields to be updated.

      Parameters

      Returns Promise<string>

      If receive an error "Authorization Denied", check policy Device / Edit data in Access Management.

      const result = await Resources.devices.editDeviceData("myDeviceId", {
      id: "idOfTheRecord",
      value: "new value",
      unit: "new unit"
      });
      console.log(result); // 1 item(s) updated
    • Retrieves data from all variables in the device.

      Parameters

      • deviceId: string
      • OptionalqueryParams: DataQuery

      Returns Promise<Data[]>

      If receive an error "Authorization Denied", check policy Device / Get data in Access Management.

      const data = await Resources.devices.getDeviceData("device-id-123", {
      qty: 10,
      variables: ["temperature"]
      });
      console.log(data); // [ { id: 'data-id-123', value: 55, variable: 'temperature' ... } ]
    • Retrieves detailed information about a specific device.

      Parameters

      • deviceID: string

      Returns Promise<DeviceInfo>

      If receive an error "Authorization Denied", check policy Device / Access in Access Management.

      const deviceInfo = await Resources.devices.info("device-id-123");
      console.log(deviceInfo); // { active: true, bucket: { id: 'device-id-123', name: 'My Device' } ... }
    • Lists all devices from your application with pagination support.

      Type Parameters

      Parameters

      • OptionalqueryObj: T

      Returns Promise<
          DeviceListItem<
              T["fields"] extends (
                  | "type"
                  | "id"
                  | "created_at"
                  | "name"
                  | "visible"
                  | "last_input"
                  | "updated_at"
                  | "active"
                  | "profile"
                  | "connector"
                  | "network"
                  | "bucket"
                  | "description"
                  | "tags"
                  | "payload_decoder"
                  | "rpm"
              )[]
                  ? any[any] extends readonly (string | number | symbol)[]
                      ? any[any][number]
                      : "id" | "name"
                  : "id" | "name",
          >[],
      >

      If receive an error "Authorization Denied", check policy Device / Access in Access Management.

      const list = await Resources.devices.list({
      page: 1,
      fields: ["id", "name"],
      amount: 10,
      orderBy: ["name", "asc"]
      });
      console.log(list); // [ { id: '123', name: 'Device #1' ...}, { id: '456', name: 'Device #2' ...} ]
    • Removes a parameter from a device.

      Parameters

      • deviceID: string
      • paramID: string

      Returns Promise<string>

      If receive an error "Authorization Denied", check policy Device / Edit in Access Management.

      const result = await Resources.devices.paramRemove("device-id-123", "param-id-123");
      console.log(result); // Successfully Removed
    • Experimental

      Streams data to a device in chunks.

      Parameters

      Returns Promise<string>

      If receive an error "Authorization Denied", check policy Device / Send data in Access Management.

      const result = await Resources.devices.sendDeviceDataStreaming("device-id-123",
      [{
      variable: "temperature",
      value: 55,
      unit: "F",
      }],
      { poolingRecordQty: 1000 }
      );
      console.log(result);
    • Deletes a device token.

      Parameters

      • token: string

      Returns Promise<string>

      If receive an error "Authorization Denied", check policy Device / Token access in Access Management.

      const result = await Resources.devices.tokenDelete("token-123");
      console.log(result); // Token Successfully Removed
    • Lists all tokens for a device with pagination support.

      Type Parameters

      Parameters

      • deviceID: string
      • OptionalqueryObj: T

      Returns Promise<
          DeviceTokenDataList<
              T["fields"] extends (keyof DeviceTokenData)[]
                  ? any[any] extends readonly (string | number | symbol)[]
                      ? any[any][number]
                      : "token" | "name" | "permission"
                  : "token" | "name" | "permission",
          >[],
      >

      If receive an error "Authorization Denied", check policy Device / Token access in Access Management.

      const tokens = await Resources.devices.tokenList("device-id-123", {
      page: 1,
      fields: ["name", "token"],
      amount: 10
      });
      console.log(tokens); // [ { name: 'Default', token: 'token-id-123', expire_time: 'never' } ]