@tuya-miniapp/ark-extension-virtual-device 0.0.8 → 0.0.9

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.
@@ -21538,16 +21538,6 @@ async function getDeviceInfo2(params) {
21538
21538
  }
21539
21539
  const response = await getDeviceInfo({ deviceId });
21540
21540
  const { result: devInfo } = response || {};
21541
- let product = {};
21542
- try {
21543
- const presponse = await getProductInfo({
21544
- productIds: [devInfo.productId]
21545
- });
21546
- const { result: productInfo } = presponse || {};
21547
- product = productInfo[0] || {};
21548
- } catch (e) {
21549
- console.log("\u672A\u83B7\u53D6\u5230\u4EA7\u54C1\u4FE1\u606F");
21550
- }
21551
21541
  if (!devInfo) {
21552
21542
  return {
21553
21543
  data: null,
@@ -21555,6 +21545,21 @@ async function getDeviceInfo2(params) {
21555
21545
  errorMsg: import_TYUniCode.TYUniPluginError.DEVICEKIT_DEVICE_ID_INVALID.des
21556
21546
  };
21557
21547
  }
21548
+ let product = {};
21549
+ let dev = {};
21550
+ try {
21551
+ const presponse = await getProductInfo2({
21552
+ productId: devInfo.productId,
21553
+ getDevices: true
21554
+ });
21555
+ const { data: productInfo, devices } = presponse || {};
21556
+ product = productInfo || {};
21557
+ if (devices) {
21558
+ dev = devices.filter((item) => item.devId === deviceId).pop();
21559
+ }
21560
+ } catch (e) {
21561
+ console.log("\u672A\u83B7\u53D6\u5230\u4EA7\u54C1\u4FE1\u606F");
21562
+ }
21558
21563
  const { dps, schema } = devInfo;
21559
21564
  const objSchema = {};
21560
21565
  JSON.parse(schema).map((item) => {
@@ -21570,11 +21575,37 @@ async function getDeviceInfo2(params) {
21570
21575
  ...devInfo,
21571
21576
  dps,
21572
21577
  dpCodes: objSchema,
21573
- deviceOnline: devInfo.isOnline,
21574
21578
  icon: devInfo.iconUrl,
21575
21579
  schema: JSON.parse(devInfo.schema),
21576
- capability: product.capability
21580
+ capability: product.capability,
21581
+ category: product.category,
21582
+ attribute: product.attribute,
21583
+ devAttribute: dev.devAttribute,
21584
+ devTimezoneId: dev.timezoneId,
21585
+ isCloudOnline: dev.cloudOnline,
21586
+ latitude: devInfo.lat,
21587
+ longitude: devInfo.lon,
21588
+ ...dev.dataPointInfo,
21589
+ isVirtualDevice: dev.virtual
21577
21590
  };
21591
+ delete deviceInfo["accessType"];
21592
+ delete deviceInfo["appRnVersion"];
21593
+ delete deviceInfo["panelConfig"];
21594
+ delete deviceInfo["rnFind"];
21595
+ delete deviceInfo["runtimeEnv"];
21596
+ delete deviceInfo["supportGroup"];
21597
+ delete deviceInfo["time"];
21598
+ delete deviceInfo["ui"];
21599
+ delete deviceInfo["uiConfig"];
21600
+ delete deviceInfo["uiPhase"];
21601
+ delete deviceInfo["uiType"];
21602
+ delete deviceInfo["verSw"];
21603
+ delete deviceInfo["iconUrl"];
21604
+ delete deviceInfo["isActive"];
21605
+ delete deviceInfo["lat"];
21606
+ delete deviceInfo["lon"];
21607
+ delete deviceInfo["gwType"];
21608
+ delete deviceInfo["dpMaxTime"];
21578
21609
  return {
21579
21610
  data: deviceInfo,
21580
21611
  errorCode: 0,
@@ -21616,8 +21647,53 @@ async function getProductInfo2(params) {
21616
21647
  const productInfo = await getProductInfo({
21617
21648
  productIds: [params.productId]
21618
21649
  });
21650
+ const {
21651
+ uiInfo = { ui: "", type: "SMART_MINIPG" },
21652
+ schemaInfo = {},
21653
+ shortcut = {},
21654
+ ...other
21655
+ } = productInfo.result[0];
21656
+ const productData = {
21657
+ ...other,
21658
+ ...shortcut,
21659
+ ...schemaInfo,
21660
+ ui: uiInfo.ui,
21661
+ uiId: uiInfo.ui.split("_").shift(),
21662
+ uiType: uiInfo.type,
21663
+ uiVersion: uiInfo.ui.split("_").pop()
21664
+ };
21665
+ let devices = null;
21666
+ try {
21667
+ const userInfo = await ark.auth.getCustomerUserInfo();
21668
+ if (userInfo) {
21669
+ const {
21670
+ extras: { homeId }
21671
+ } = userInfo;
21672
+ const deviceList = await ark.http.atop({
21673
+ api: "tuya.m.my.group.device.list",
21674
+ version: "2.1",
21675
+ meta: {
21676
+ gid: homeId
21677
+ }
21678
+ });
21679
+ if (deviceList) {
21680
+ const {
21681
+ data: { result }
21682
+ } = deviceList;
21683
+ devices = result;
21684
+ const p = result.filter((item) => item.productId === params.productId).pop();
21685
+ if (p) {
21686
+ const { productVer } = p;
21687
+ productData["productVer"] = productVer;
21688
+ }
21689
+ }
21690
+ }
21691
+ } catch (error) {
21692
+ console.error(error);
21693
+ }
21619
21694
  return {
21620
- data: productInfo.result[0],
21695
+ data: productData,
21696
+ devices,
21621
21697
  errorCode: !!productInfo ? 0 : import_TYUniCode.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.code,
21622
21698
  errorMsg: !!productInfo ? import_TYUniCode.TYUniPluginError.SUCCESS.des : import_TYUniCode.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.des
21623
21699
  };
@@ -22108,14 +22184,14 @@ function unsubscribeTYBLEConnectStatus(params) {
22108
22184
  data: null
22109
22185
  };
22110
22186
  }
22111
- ark.miniapp.addPluginMethod("TUNIOTAManager", "onTYBLEConnectStatusChange", onTYBLEConnectStatusChange);
22112
- ark.miniapp.addPluginMethod("TUNIOTAManager", "offTYBLEConnectStatusChange", offTYBLEConnectStatusChange);
22113
- ark.miniapp.addPluginMethod("TUNIOTAManager", "subscribeTYBLEConnectStatus", subscribeTYBLEConnectStatus);
22114
- ark.miniapp.addPluginMethod("TUNIOTAManager", "unsubscribeTYBLEConnectStatus", unsubscribeTYBLEConnectStatus);
22115
- ark.miniapp.addPluginMethod("TYUniOTAManager", "onTYBLEConnectStatusChange", onTYBLEConnectStatusChange);
22116
- ark.miniapp.addPluginMethod("TYUniOTAManager", "offTYBLEConnectStatusChange", offTYBLEConnectStatusChange);
22117
- ark.miniapp.addPluginMethod("TYUniOTAManager", "subscribeTYBLEConnectStatus", subscribeTYBLEConnectStatus);
22118
- ark.miniapp.addPluginMethod("TYUniOTAManager", "unsubscribeTYBLEConnectStatus", unsubscribeTYBLEConnectStatus);
22187
+ ark.miniapp.addPluginMethod("TUNIBluetoothManager", "onBLEConnectStatusChange", onTYBLEConnectStatusChange);
22188
+ ark.miniapp.addPluginMethod("TUNIBluetoothManager", "offBLEConnectStatusChange", offTYBLEConnectStatusChange);
22189
+ ark.miniapp.addPluginMethod("TUNIBluetoothManager", "subscribeBLEConnectStatus", subscribeTYBLEConnectStatus);
22190
+ ark.miniapp.addPluginMethod("TUNIBluetoothManager", "unsubscribeBLEConnectStatus", unsubscribeTYBLEConnectStatus);
22191
+ ark.miniapp.addPluginMethod("TYUniBluetoothManager", "onTYBLEConnectStatusChange", onTYBLEConnectStatusChange);
22192
+ ark.miniapp.addPluginMethod("TYUniBluetoothManager", "offTYBLEConnectStatusChange", offTYBLEConnectStatusChange);
22193
+ ark.miniapp.addPluginMethod("TYUniBluetoothManager", "subscribeTYBLEConnectStatus", subscribeTYBLEConnectStatus);
22194
+ ark.miniapp.addPluginMethod("TYUniBluetoothManager", "unsubscribeTYBLEConnectStatus", unsubscribeTYBLEConnectStatus);
22119
22195
 
22120
22196
  // worker/api/TYUniGroupControlManager.ts
22121
22197
  var import_TYUniCode6 = __toESM(require_dist());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-miniapp/ark-extension-virtual-device",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "files": [
5
5
  "manifest.json",
6
6
  "dist/"
@@ -20,7 +20,7 @@
20
20
  "@babel/preset-typescript": "^7.16.7",
21
21
  "@tuya-fe/react-hooks": "^2.0.7",
22
22
  "@tuya-miniapp/TYUniCode": "0.0.75",
23
- "@tuya-miniapp/ark-api": "0.5.0",
23
+ "@tuya-miniapp/ark-api": "^0.5.4",
24
24
  "@types/fs-extra": "^9.0.13",
25
25
  "@types/node": "^17.0.34",
26
26
  "@types/react": "^16.8.19",