Hierarchy

Constructors

Methods

  • Get amount of data stored in the Device.

    Parameters

    • deviceID: string

      Device ID

    Returns Promise<number>

  • Deletes an device from the account

    Parameters

    • deviceID: string

      Device ID

    Returns Promise<string>

  • Experimental

    Delete the chunk data.

    Parameters

    • deviceID: string

      Device ID

    • chunkID: string

      Chunk ID

    Returns Promise<string>

  • Delete data records in a 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

      Device ID.

    • Optional queryParams: DataQuery

      Parameters to specify what should be deleted on the device's data.

    Returns Promise<string>

    Success message indicating amount of records deleted (can be 0).

    Example

    await Resources.devices.deleteDeviceData("myDeviceId", { ids: ["recordIdToDelete", "anotherRecordIdToDelete" ] });
    
  • Modify any property of the device

    Parameters

    • deviceID: string

      Device ID

    • deviceObj: Partial<Omit<DeviceCreateInfo, "type" | "chunk_period"> & {
          chunk_retention: number;
      }>

      Device object with fields to replace

    Returns Promise<string>

  • Edit data records in a 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

    • deviceId: string

      Device ID.

    • updatedData: DataEdit | DataEdit[]

      A single or an array of updated data records.

    Returns Promise<string>

    Success message indicating amount of records updated (can be 0).

    Example

    await Resources.devices.editDeviceData("myDeviceId", { id: "idOfTheRecord", value: "new value", unit: "new unit" });
    
  • Empty all data in a device.

    Parameters

    • deviceId: string

      Device ID.

    Returns Promise<string>

    Success message.

  • Get data from all variables in the device.

    Parameters

    • deviceId: string

      Device ID.

    • Optional queryParams: DataQuery

      Query parameters to filter the results.

    Returns Promise<Data[]>

    Array with the data values stored in the device.

    Example

    const lastTenValues = await Resources.devices.getDeviceData("myDeviceId", { qty: 10 });
    
  • Experimental

    Get Data Streaming

    Parameters

    Returns AsyncGenerator<Data[], void, unknown>

    Example

    for await (const items of Resources.devices.getDeviceDataStreaming("myDeviceId")) {
    console.log(items);
    }
  • Retrieves a list with all devices from the account

    Type Parameters

    Parameters

    • Optional queryObj: T

      Search query params

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

    Default

    queryObj: {
    page: 1,
    fields: ["id", "name"],
    filter: {},
    amount: 20,
    orderBy: "name,asc",
    resolveBucketName: false
    resolveConnectorName: false
    }
  • Experimental

    Get a Streaming list of Devices from the account

    Parameters

    Returns AsyncGenerator<DeviceListItem<"type" | "id" | "active" | "network" | "name" | "visible" | "description" | "created_at" | "profile" | "updated_at" | "tags" | "connector" | "last_input" | "bucket" | "payload_decoder" | "rpm">[], void, unknown>

    Example

    for await (const items of Resources.devices.listStreaming({ name: "*sensor*" })) {
    console.log(items);
    }
  • Remove param for the Device

    Parameters

    • deviceID: string

      Device ID

    • paramID: string

      Parameter ID

    Returns Promise<string>

  • Send data to device

    Parameters

    • deviceId: string

      Device ID.

    • data: DataCreate | DataCreate[]

      An array or one object with data to be send to TagoIO

    Returns Promise<string>

    amount of data added

    Example

    const result = await Resources.devices.sendDeviceData("myDeviceId", {
    variable: "temperature",
    unit: "F",
    value: 55,
    time: "2015-11-03 13:44:33",
    location: { lat: 42.2974279, lng: -85.628292 },
    });
  • Experimental

    Stream data to device

    Parameters

    • deviceId: string

      Device ID.

    • data: DataCreate[]

      An array or one object with data to be send to TagoIO using device token

    • Optional options: Omit<OptionsStreaming, "neverStop">

      Stream options

    Returns Promise<string>

    Example

    const data = [
    {
    variable: "temperature",
    unit: "F",
    value: 55,
    time: "2015-11-03 13:44:33",
    location: { lat: 42.2974279, lng: -85.628292 },
    },
    {
    variable: "temperature",
    unit: "F",
    value: 53,
    time: "2015-11-03 13:44:33",
    location: { lat: 43.2974279, lng: -86.628292 },
    },
    // ...
    ];

    const result = await Resources.devices.sendDeviceDataStreaming("myDeviceId", data, {
    poolingRecordQty: 1000,
    poolingTime: 1000,
    });
  • Retrieves a list of all tokens

    Type Parameters

    Parameters

    • deviceID: string

      Device ID

    • Optional queryObj: T

      Search query params

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

    Default

    queryObj: {
    page: 1,
    fields: ["name", "token", "permission"],
    filter: {},
    amount: 20,
    orderBy: "created_at,desc",
    }