Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

Methods

  • delete(deviceID: string): Promise<string>
  • deleteChunk(deviceID: string, chunkID: string): Promise<string>
  • deleteDeviceData(deviceId: string, queryParams?: DataQuery): 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, all data for the device will be deleted.

    example
    const myDevice = new Device({ token: "my_device_token" });

    await myDevice.deleteDeviceData("myDeviceId", { ids: ["recordIdToDelete", "anotherRecordIdToDelete" ] });

    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).

  • edit(deviceID: string, deviceObj: Partial<Omit<DeviceCreateInfo, "type" | "chunk_period"> & { chunk_retention: number }>): Promise<string>
  • editDeviceData(deviceId: string, updatedData: DataEdit | DataEdit[]): 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.

    example
    const myDevice = new Device({ token: "my_device_token" });

    await myDevice.editDeviceData("myDeviceId", { id: "idOfTheRecord", value: "new value", unit: "new unit" });

    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).

  • emptyDeviceData(deviceId: string): Promise<string>
  • getDeviceData(deviceId: string, queryParams?: DataQuery): Promise<Data[]>
  • Get data from all variables in the device.

    example
    const myDevice = new Device({ token: "my_device_token" });

    const lastTenValues = await myDevice.getVariablesData("myDeviceId", { qty: 10 });

    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.

  • Retrieves a list with all devices from the account

    default

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

    Parameters

    Returns Promise<DeviceListItem[]>

  • paramRemove(deviceID: string, paramID: string): Promise<string>
  • tokenDelete(token: string): Promise<string>