Attributes

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})
Ví dụ
var attrs = {};
let logged = false
attrs['Led'] = 'ON;
await Thing('036116ed-38fc-458b-b91f-b3f774706247').UpsertAttributes(attrs, {logged: logged});

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ề entitiesList

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 tthấ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
}

Last updated