@tuya-miniapp/ark-extension-virtual-device 1.8.2-beta-4 → 1.8.2-beta-6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/worker/index.js +77 -11
- package/package.json +1 -1
package/dist/worker/index.js
CHANGED
|
@@ -220752,7 +220752,7 @@ var require_package2 = __commonJS({
|
|
|
220752
220752
|
"package.json"(exports, module2) {
|
|
220753
220753
|
module2.exports = {
|
|
220754
220754
|
name: "@tuya-miniapp/ark-extension-virtual-device",
|
|
220755
|
-
version: "1.8.2-beta-
|
|
220755
|
+
version: "1.8.2-beta-5",
|
|
220756
220756
|
license: "MIT",
|
|
220757
220757
|
files: [
|
|
220758
220758
|
"manifest.json",
|
|
@@ -262807,8 +262807,6 @@ var getDeviceInfo = async (body) => {
|
|
|
262807
262807
|
devId: body?.deviceId
|
|
262808
262808
|
}
|
|
262809
262809
|
});
|
|
262810
|
-
console.log("devInfo>>>>>", JSON.stringify(devInfo));
|
|
262811
|
-
console.log("devINfo2>>>", JSON.stringify(devInfo32));
|
|
262812
262810
|
if (!devInfo.success && !devInfo.result) {
|
|
262813
262811
|
return null;
|
|
262814
262812
|
}
|
|
@@ -262819,6 +262817,7 @@ var getDeviceInfo = async (body) => {
|
|
|
262819
262817
|
devInfo.result.accessType = devInfo32.result?.accessType;
|
|
262820
262818
|
devInfo.result.parentId = devInfo32.result?.deviceTopo.parentDevId;
|
|
262821
262819
|
devInfo.result.nodeId = devInfo32.result?.deviceTopo.nodeId;
|
|
262820
|
+
devInfo.result.devAttribute = devInfo32.result?.devAttribute;
|
|
262822
262821
|
if (Object.hasOwn(devInfo32.result, "cloudOnline")) {
|
|
262823
262822
|
devInfo.result.cloudOnline = devInfo32.result?.cloudOnline;
|
|
262824
262823
|
}
|
|
@@ -262862,7 +262861,7 @@ var getDeviceInfo = async (body) => {
|
|
|
262862
262861
|
const oDps = { ...dps };
|
|
262863
262862
|
JSON.parse(schema).map((item) => {
|
|
262864
262863
|
const { id, type, property } = item;
|
|
262865
|
-
if (Object.keys(oDps).includes(`${id}`) &&
|
|
262864
|
+
if (Object.keys(oDps).includes(`${id}`) && type === "raw") {
|
|
262866
262865
|
if (!isHexString(oDps[id])) {
|
|
262867
262866
|
const b2 = Buffer.from(oDps[id], "base64");
|
|
262868
262867
|
oDps[id] = b2.toString("hex");
|
|
@@ -263750,7 +263749,7 @@ function parseRawMessage(result, devInfo) {
|
|
|
263750
263749
|
schema.map((item) => {
|
|
263751
263750
|
const { id, property, type: oType } = item;
|
|
263752
263751
|
const { type } = property || {};
|
|
263753
|
-
if (Object.keys(result.data.dps).includes(`${id}`) && (oType === "raw" || type === "raw"
|
|
263752
|
+
if (Object.keys(result.data.dps).includes(`${id}`) && (oType === "raw" || type === "raw")) {
|
|
263754
263753
|
const b2 = Buffer.from(result.data.dps[id], "base64");
|
|
263755
263754
|
result.data.dps[id] = b2.toString("hex");
|
|
263756
263755
|
}
|
|
@@ -280389,13 +280388,73 @@ async function setDeviceProperty(params) {
|
|
|
280389
280388
|
}
|
|
280390
280389
|
async function getDeviceListByDevIds(params) {
|
|
280391
280390
|
const { deviceIds } = params;
|
|
280392
|
-
const
|
|
280391
|
+
const homeId = await getHomeId();
|
|
280392
|
+
const homeAllDeviceResponse = await apiRequestByAtop({
|
|
280393
|
+
api: "tuya.m.my.group.device.list",
|
|
280394
|
+
version: "2.1",
|
|
280395
|
+
params: {
|
|
280396
|
+
gid: homeId
|
|
280397
|
+
},
|
|
280398
|
+
meta: {
|
|
280399
|
+
gid: homeId
|
|
280400
|
+
}
|
|
280401
|
+
});
|
|
280402
|
+
const { result: allDevices = [] } = homeAllDeviceResponse || {};
|
|
280403
|
+
const productIds = [];
|
|
280404
|
+
allDevices.map((item) => {
|
|
280405
|
+
if (!productIds.includes(item.productId)) {
|
|
280406
|
+
productIds.push(item.productId);
|
|
280407
|
+
}
|
|
280408
|
+
});
|
|
280409
|
+
const { result: productInfos } = await apiRequestByAtop({
|
|
280410
|
+
api: "tuya.m.device.ref.info.list",
|
|
280411
|
+
version: "3.0",
|
|
280412
|
+
params: {
|
|
280413
|
+
productIds
|
|
280414
|
+
}
|
|
280415
|
+
});
|
|
280416
|
+
const tempList = allDevices.filter((item) => deviceIds.includes(item.devId));
|
|
280417
|
+
const resetList = [];
|
|
280418
|
+
deviceIds.map((devId) => {
|
|
280419
|
+
const d2 = tempList.find((item) => item.devId === devId);
|
|
280420
|
+
if (!d2) {
|
|
280421
|
+
resetList.push(devId);
|
|
280422
|
+
}
|
|
280423
|
+
});
|
|
280424
|
+
const promises = resetList.map((devId) => {
|
|
280393
280425
|
return getDeviceInfo2({ deviceId: devId });
|
|
280394
280426
|
});
|
|
280395
280427
|
const list = await Promise.all(promises);
|
|
280396
|
-
const
|
|
280428
|
+
const restList = list.map((item) => {
|
|
280397
280429
|
return item.data;
|
|
280398
|
-
})
|
|
280430
|
+
});
|
|
280431
|
+
const devices = [...tempList, ...restList].filter((item) => !!item);
|
|
280432
|
+
const result = devices.map((item) => {
|
|
280433
|
+
const { productId, dataPointInfo, iconUrl } = item;
|
|
280434
|
+
const productInfo = productInfos.find((product) => product.id === productId);
|
|
280435
|
+
const {
|
|
280436
|
+
schemaInfo: { schema },
|
|
280437
|
+
attribute,
|
|
280438
|
+
capability,
|
|
280439
|
+
category,
|
|
280440
|
+
supportGroup,
|
|
280441
|
+
otaInfo
|
|
280442
|
+
} = productInfo;
|
|
280443
|
+
if (productInfo) {
|
|
280444
|
+
item.productInfo = productInfo;
|
|
280445
|
+
}
|
|
280446
|
+
return {
|
|
280447
|
+
...item,
|
|
280448
|
+
schema: JSON.parse(schema),
|
|
280449
|
+
...dataPointInfo,
|
|
280450
|
+
icon: iconUrl,
|
|
280451
|
+
isSupportGroup: supportGroup,
|
|
280452
|
+
attribute,
|
|
280453
|
+
capability,
|
|
280454
|
+
category,
|
|
280455
|
+
isSupportOTA: !!otaInfo
|
|
280456
|
+
};
|
|
280457
|
+
});
|
|
280399
280458
|
return {
|
|
280400
280459
|
data: { deviceInfos: result },
|
|
280401
280460
|
errorCode: 0,
|
|
@@ -282490,9 +282549,16 @@ ark.miniapp.addPluginMethod(
|
|
|
282490
282549
|
var import_TYUniCode12 = __toESM(require_dist());
|
|
282491
282550
|
async function getDeviceThingModelInfo(params) {
|
|
282492
282551
|
const { devId } = params;
|
|
282493
|
-
await getDeviceInfo2({ deviceId: devId });
|
|
282494
|
-
const dev =
|
|
282495
|
-
|
|
282552
|
+
const devInfo = await getDeviceInfo2({ deviceId: devId });
|
|
282553
|
+
const dev = devInfo.data;
|
|
282554
|
+
if (!dev) {
|
|
282555
|
+
return {
|
|
282556
|
+
data: null,
|
|
282557
|
+
errorCode: 1,
|
|
282558
|
+
errorMsg: "device not found"
|
|
282559
|
+
};
|
|
282560
|
+
}
|
|
282561
|
+
const { productVer = "1.0.0", productId } = dev;
|
|
282496
282562
|
const thing = await apiRequestByAtop({
|
|
282497
282563
|
api: "tuya.m.product.thing.model",
|
|
282498
282564
|
version: "1.0",
|