@tuya-miniapp/ark-extension-virtual-device 1.8.2-beta-5 → 1.8.2-beta-7

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.
@@ -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-4",
220755
+ version: "1.8.2-beta-6",
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
  }
@@ -262863,7 +262861,7 @@ var getDeviceInfo = async (body) => {
262863
262861
  const oDps = { ...dps };
262864
262862
  JSON.parse(schema).map((item) => {
262865
262863
  const { id, type, property } = item;
262866
- if (Object.keys(oDps).includes(`${id}`) && (type === "raw" || type === "obj" && property?.type === "string")) {
262864
+ if (Object.keys(oDps).includes(`${id}`) && type === "raw") {
262867
262865
  if (!isHexString(oDps[id])) {
262868
262866
  const b2 = Buffer.from(oDps[id], "base64");
262869
262867
  oDps[id] = b2.toString("hex");
@@ -263751,7 +263749,7 @@ function parseRawMessage(result, devInfo) {
263751
263749
  schema.map((item) => {
263752
263750
  const { id, property, type: oType } = item;
263753
263751
  const { type } = property || {};
263754
- if (Object.keys(result.data.dps).includes(`${id}`) && (oType === "raw" || type === "raw" || oType === "obj" && type === "string")) {
263752
+ if (Object.keys(result.data.dps).includes(`${id}`) && (oType === "raw" || type === "raw")) {
263755
263753
  const b2 = Buffer.from(result.data.dps[id], "base64");
263756
263754
  result.data.dps[id] = b2.toString("hex");
263757
263755
  }
@@ -280390,13 +280388,73 @@ async function setDeviceProperty(params) {
280390
280388
  }
280391
280389
  async function getDeviceListByDevIds(params) {
280392
280390
  const { deviceIds } = params;
280393
- const promises = deviceIds.map((devId) => {
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) => {
280394
280425
  return getDeviceInfo2({ deviceId: devId });
280395
280426
  });
280396
280427
  const list = await Promise.all(promises);
280397
- const result = list.map((item) => {
280428
+ const restList = list.map((item) => {
280398
280429
  return item.data;
280399
- }).filter((item) => !!item);
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
+ });
280400
280458
  return {
280401
280459
  data: { deviceInfos: result },
280402
280460
  errorCode: 0,
@@ -282491,9 +282549,16 @@ ark.miniapp.addPluginMethod(
282491
282549
  var import_TYUniCode12 = __toESM(require_dist());
282492
282550
  async function getDeviceThingModelInfo(params) {
282493
282551
  const { devId } = params;
282494
- await getDeviceInfo2({ deviceId: devId });
282495
- const dev = cachedDeviceList.find((d2) => d2.devId === devId);
282496
- const { productVer, productId } = dev;
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;
282497
282562
  const thing = await apiRequestByAtop({
282498
282563
  api: "tuya.m.product.thing.model",
282499
282564
  version: "1.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-miniapp/ark-extension-virtual-device",
3
- "version": "1.8.2-beta-5",
3
+ "version": "1.8.2-beta-7",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "manifest.json",