tsvesync 1.0.83 → 1.0.85

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.
@@ -19,7 +19,6 @@ class VeSyncAir131 extends vesyncFan_1.VeSyncFan {
19
19
  * Get device details
20
20
  */
21
21
  async getDetails() {
22
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
23
22
  logger_1.logger.debug(`Getting details for device: ${this.deviceName}`);
24
23
  const [response, status] = await this.callApi('/131airPurifier/v1/device/deviceDetail', 'post', {
25
24
  acceptLanguage: 'en',
@@ -43,16 +42,19 @@ class VeSyncAir131 extends vesyncFan_1.VeSyncFan {
43
42
  });
44
43
  const success = this.checkResponse([response, status], 'getDetails');
45
44
  if (success && response) {
46
- this.deviceStatus = ((_b = (_a = response.result) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.deviceStatus) === 'on' ? 'on' : 'off';
45
+ // Check if data is in response.result or directly in response
46
+ const data = response.result || response;
47
+ this.deviceStatus = data.deviceStatus === 'on' ? 'on' : 'off';
47
48
  this.details = {
48
- mode: ((_d = (_c = response.result) === null || _c === void 0 ? void 0 : _c.result) === null || _d === void 0 ? void 0 : _d.mode) || '',
49
- speed: ((_f = (_e = response.result) === null || _e === void 0 ? void 0 : _e.result) === null || _f === void 0 ? void 0 : _f.level) || 0,
50
- filterLife: ((_h = (_g = response.result) === null || _g === void 0 ? void 0 : _g.result) === null || _h === void 0 ? void 0 : _h.filterLife) || 0,
51
- screenStatus: ((_k = (_j = response.result) === null || _j === void 0 ? void 0 : _j.result) === null || _k === void 0 ? void 0 : _k.display) ? 'on' : 'off',
52
- childLock: ((_m = (_l = response.result) === null || _l === void 0 ? void 0 : _l.result) === null || _m === void 0 ? void 0 : _m.childLock) || false,
53
- airQuality: ((_p = (_o = response.result) === null || _o === void 0 ? void 0 : _o.result) === null || _p === void 0 ? void 0 : _p.airQuality) || 0,
54
- active_time: ((_r = (_q = response.result) === null || _q === void 0 ? void 0 : _q.result) === null || _r === void 0 ? void 0 : _r.activeTime) || 0
49
+ mode: data.mode || 'manual', // Default to manual if not specified
50
+ speed: data.level || 0,
51
+ filterLife: data.filterLife || 0,
52
+ screenStatus: data.screenStatus || 'off',
53
+ childLock: data.childLock || false,
54
+ airQuality: data.airQuality || 'unknown',
55
+ active_time: data.activeTime || 0
55
56
  };
57
+ logger_1.logger.debug(`${this.deviceName}: Updated details - mode: ${this.details.mode}, speed: ${this.details.speed}, status: ${this.deviceStatus}`);
56
58
  return true;
57
59
  }
58
60
  // Log additional details on failure
@@ -93,6 +95,9 @@ class VeSyncAir131 extends vesyncFan_1.VeSyncFan {
93
95
  if (success) {
94
96
  // Update device status immediately
95
97
  this.deviceStatus = 'on';
98
+ // Fetch device details to get current speed and other settings
99
+ logger_1.logger.debug(`${this.deviceName}: Fetching device details after turning on`);
100
+ await this.getDetails();
96
101
  }
97
102
  else {
98
103
  logger_1.logger.error(`Failed to turn on device: ${this.deviceName}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsvesync",
3
- "version": "1.0.83",
3
+ "version": "1.0.85",
4
4
  "description": "A TypeScript library for interacting with VeSync smart home devices",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -51,16 +51,21 @@ export class VeSyncAir131 extends VeSyncFan {
51
51
 
52
52
  const success = this.checkResponse([response, status], 'getDetails');
53
53
  if (success && response) {
54
- this.deviceStatus = response.result?.result?.deviceStatus === 'on' ? 'on' : 'off';
54
+ // Check if data is in response.result or directly in response
55
+ const data = response.result || response;
56
+
57
+ this.deviceStatus = data.deviceStatus === 'on' ? 'on' : 'off';
55
58
  this.details = {
56
- mode: response.result?.result?.mode || '',
57
- speed: response.result?.result?.level || 0,
58
- filterLife: response.result?.result?.filterLife || 0,
59
- screenStatus: response.result?.result?.display ? 'on' : 'off',
60
- childLock: response.result?.result?.childLock || false,
61
- airQuality: response.result?.result?.airQuality || 0,
62
- active_time: response.result?.result?.activeTime || 0
59
+ mode: data.mode || 'manual', // Default to manual if not specified
60
+ speed: data.level || 0,
61
+ filterLife: data.filterLife || 0,
62
+ screenStatus: data.screenStatus || 'off',
63
+ childLock: data.childLock || false,
64
+ airQuality: data.airQuality || 'unknown',
65
+ active_time: data.activeTime || 0
63
66
  };
67
+
68
+ logger.debug(`${this.deviceName}: Updated details - mode: ${this.details.mode}, speed: ${this.details.speed}, status: ${this.deviceStatus}`);
64
69
  return true;
65
70
  }
66
71
 
@@ -111,6 +116,10 @@ export class VeSyncAir131 extends VeSyncFan {
111
116
  if (success) {
112
117
  // Update device status immediately
113
118
  this.deviceStatus = 'on';
119
+
120
+ // Fetch device details to get current speed and other settings
121
+ logger.debug(`${this.deviceName}: Fetching device details after turning on`);
122
+ await this.getDetails();
114
123
  } else {
115
124
  logger.error(`Failed to turn on device: ${this.deviceName}`);
116
125
  }