Innoway
  • Giới thiệu về Innoway
  • Release Note
    • 25/04
      • Device
      • Attributes
      • Adapter
  • Bắt đầu sử dụng
    • Đăng kí tài khoản
    • Tạo dự án mới
    • Hướng dẫn kết nối thiết bị
      • Hướng dẫn kết nối tới MQTT Broker của nền tảng
    • Giải pháp mẫu
      • Tích hợp đồng hồ nước thông minh
  • Tính năng
    • Quản lí tổ chức
      • Tổ chức
      • Nhóm
      • Thiết bị
      • Người dùng
      • Sự kiện
      • Thuộc tính
    • Quản lí nghiệp vụ
      • Quản lí Thing
      • Quản lí nghiệp vụ (Service)
    • Quản lý Firmware
    • Mẫu thiết bị
    • Bảng điều khiển
    • Vai trò
    • Custom Adapter
      • MQTT
      • TCP
      • UDP
    • Tính năng khác
      • Provision Device
      • Time Correction
  • Tài liệu
    • SDK
      • Device
      • Attributes
      • Adapter
      • ESP32
      • pg
    • API
      • MQTT Device API
      • HTTP Device API
      • REST API
Powered by GitBook
On this page
  • UpsertAttributes
  • GetAttributesLatest
  • Type
  • entitiesList
  • entity
  • attribute
  1. Tài liệu
  2. SDK

Attributes

PreviousDeviceNextAdapter

Last updated 1 year ago

UpsertAttributes

Lưu attributes với key, value vào thiết bị với id tương ứng

Thing(id: string).UpsertAttributes(attrs: {[key: string]: any}, 
{logged: boolean, ts: number})
  • logged: Nếu true thì sẽ lưu lịch sử thuộc tính

  • ts: Xác định dấu thời gian (timestamp) của thuộc tính (unix milliseconds)

Ví dụ
var attrs = {};
let logged = false
attrs['Led'] = 'ON;
await Thing('036116ed-38fc-458b-b91f-b3f774706247').UpsertAttributes(attrs, {logged: logged, ts: 1716296846000});

GetAttributesLatest

Lấy giá trị của các attributes với keys của thiết bị với id tương ứng, trả về

GetAttributesLatest(req: {keys: string[], ids: string[], entityType: string})
Ví dụ
let arrayKeys = ["led", "data"];
let arrayIDs = ["bba8dd8e-4932-11ee-be56-0242ac120002", "c6134e44-4932-11ee-be56-0242ac120002"]
let res = await Things().GetAttributesLatest({ ids: arrayIDs, entityType: "DEVICE", keys: arrayKeys });
if (res.success){
  // Lấy dữ liệu thành công
}else{
  // Lấy dữ liệu thất bại hoặc không tồn tại
}

Type

entitiesList

{
    entitiesList: entity[];
}

entity

{
    attributesList: attribute[];
    entityId: string;
    entityType: string;
}

attribute

{
    key: string;
    logged: boolean;
    ts: number;
    value: string | Uint8Array;
    valueAsString: string;
    valueType: string
}
entitiesList