tsvesync 1.0.80 → 1.0.82

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.
@@ -21,7 +21,7 @@ class VeSyncAir131 extends vesyncFan_1.VeSyncFan {
21
21
  async getDetails() {
22
22
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
23
23
  logger_1.logger.debug(`Getting details for device: ${this.deviceName}`);
24
- const [response, status] = await this.callApi('/131airPurifier/v1/device/devicedetail', 'post', {
24
+ const [response, status] = await this.callApi('/131airPurifier/v1/device/deviceDetail', 'post', {
25
25
  acceptLanguage: 'en',
26
26
  accountID: this.manager.accountId,
27
27
  appVersion: '2.8.6',
@@ -31,6 +31,7 @@ class VeSyncAir131 extends vesyncFan_1.VeSyncFan {
31
31
  phoneOS: 'Android',
32
32
  timeZone: this.manager.timeZone,
33
33
  token: this.manager.token,
34
+ traceId: new Date().getTime().toString(),
34
35
  uuid: this.uuid
35
36
  }, {
36
37
  'accept-language': 'en',
@@ -54,12 +55,24 @@ class VeSyncAir131 extends vesyncFan_1.VeSyncFan {
54
55
  };
55
56
  return true;
56
57
  }
58
+ // Log additional details on failure
59
+ if (!success && (response === null || response === void 0 ? void 0 : response.code)) {
60
+ logger_1.logger.error(`${this.deviceName}: getDetails failed with code ${response.code} - ${response.msg || 'Unknown error'}`);
61
+ if (response.traceId) {
62
+ logger_1.logger.error(`${this.deviceName}: TraceId for debugging: ${response.traceId}`);
63
+ }
64
+ }
57
65
  return false;
58
66
  }
59
67
  /**
60
68
  * Turn device on
61
69
  */
62
70
  async turnOn() {
71
+ // Check if device is already on
72
+ if (this.deviceStatus === 'on') {
73
+ logger_1.logger.debug(`Device ${this.deviceName} is already on`);
74
+ return false; // Return false to match pyvesync behavior
75
+ }
63
76
  logger_1.logger.info(`Turning on device: ${this.deviceName}`);
64
77
  const [response, status] = await this.callApi('/131airPurifier/v1/device/deviceStatus', 'put', {
65
78
  acceptLanguage: 'en',
@@ -77,7 +90,11 @@ class VeSyncAir131 extends vesyncFan_1.VeSyncFan {
77
90
  'tz': this.manager.timeZone
78
91
  });
79
92
  const success = this.checkResponse([response, status], 'turnOn');
80
- if (!success) {
93
+ if (success) {
94
+ // Update device status immediately
95
+ this.deviceStatus = 'on';
96
+ }
97
+ else {
81
98
  logger_1.logger.error(`Failed to turn on device: ${this.deviceName}`);
82
99
  }
83
100
  return success;
@@ -86,6 +103,11 @@ class VeSyncAir131 extends vesyncFan_1.VeSyncFan {
86
103
  * Turn device off
87
104
  */
88
105
  async turnOff() {
106
+ // Check if device is already off
107
+ if (this.deviceStatus !== 'on') {
108
+ logger_1.logger.debug(`Device ${this.deviceName} is already off`);
109
+ return true;
110
+ }
89
111
  logger_1.logger.info(`Turning off device: ${this.deviceName}`);
90
112
  const [response, status] = await this.callApi('/131airPurifier/v1/device/deviceStatus', 'put', {
91
113
  acceptLanguage: 'en',
@@ -103,7 +125,11 @@ class VeSyncAir131 extends vesyncFan_1.VeSyncFan {
103
125
  'tz': this.manager.timeZone
104
126
  });
105
127
  const success = this.checkResponse([response, status], 'turnOff');
106
- if (!success) {
128
+ if (success) {
129
+ // Update device status immediately
130
+ this.deviceStatus = 'off';
131
+ }
132
+ else {
107
133
  logger_1.logger.error(`Failed to turn off device: ${this.deviceName}`);
108
134
  }
109
135
  return success;
@@ -115,7 +141,7 @@ class VeSyncAir131 extends vesyncFan_1.VeSyncFan {
115
141
  logger_1.logger.info(`Changing fan speed to ${speed} for device: ${this.deviceName}`);
116
142
  // Check if device is in manual mode
117
143
  if (this.details.mode !== 'manual') {
118
- logger_1.logger.debug(`${this.deviceName} not in manual mode, cannot change speed`);
144
+ logger_1.logger.error(`${this.deviceName}: Cannot change fan speed - device is in ${this.details.mode} mode, manual mode required`);
119
145
  return false;
120
146
  }
121
147
  // Validate speed for LV series (1-3)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsvesync",
3
- "version": "1.0.80",
3
+ "version": "1.0.82",
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",
@@ -24,7 +24,7 @@ export class VeSyncAir131 extends VeSyncFan {
24
24
  logger.debug(`Getting details for device: ${this.deviceName}`);
25
25
 
26
26
  const [response, status] = await this.callApi(
27
- '/131airPurifier/v1/device/devicedetail',
27
+ '/131airPurifier/v1/device/deviceDetail',
28
28
  'post',
29
29
  {
30
30
  acceptLanguage: 'en',
@@ -36,6 +36,7 @@ export class VeSyncAir131 extends VeSyncFan {
36
36
  phoneOS: 'Android',
37
37
  timeZone: this.manager.timeZone!,
38
38
  token: this.manager.token!,
39
+ traceId: new Date().getTime().toString(),
39
40
  uuid: this.uuid
40
41
  },
41
42
  {
@@ -62,6 +63,14 @@ export class VeSyncAir131 extends VeSyncFan {
62
63
  };
63
64
  return true;
64
65
  }
66
+
67
+ // Log additional details on failure
68
+ if (!success && response?.code) {
69
+ logger.error(`${this.deviceName}: getDetails failed with code ${response.code} - ${response.msg || 'Unknown error'}`);
70
+ if (response.traceId) {
71
+ logger.error(`${this.deviceName}: TraceId for debugging: ${response.traceId}`);
72
+ }
73
+ }
65
74
  return false;
66
75
  }
67
76
 
@@ -69,6 +78,12 @@ export class VeSyncAir131 extends VeSyncFan {
69
78
  * Turn device on
70
79
  */
71
80
  async turnOn(): Promise<boolean> {
81
+ // Check if device is already on
82
+ if (this.deviceStatus === 'on') {
83
+ logger.debug(`Device ${this.deviceName} is already on`);
84
+ return false; // Return false to match pyvesync behavior
85
+ }
86
+
72
87
  logger.info(`Turning on device: ${this.deviceName}`);
73
88
 
74
89
  const [response, status] = await this.callApi(
@@ -93,7 +108,10 @@ export class VeSyncAir131 extends VeSyncFan {
93
108
  );
94
109
 
95
110
  const success = this.checkResponse([response, status], 'turnOn');
96
- if (!success) {
111
+ if (success) {
112
+ // Update device status immediately
113
+ this.deviceStatus = 'on';
114
+ } else {
97
115
  logger.error(`Failed to turn on device: ${this.deviceName}`);
98
116
  }
99
117
  return success;
@@ -103,6 +121,12 @@ export class VeSyncAir131 extends VeSyncFan {
103
121
  * Turn device off
104
122
  */
105
123
  async turnOff(): Promise<boolean> {
124
+ // Check if device is already off
125
+ if (this.deviceStatus !== 'on') {
126
+ logger.debug(`Device ${this.deviceName} is already off`);
127
+ return true;
128
+ }
129
+
106
130
  logger.info(`Turning off device: ${this.deviceName}`);
107
131
 
108
132
  const [response, status] = await this.callApi(
@@ -127,7 +151,10 @@ export class VeSyncAir131 extends VeSyncFan {
127
151
  );
128
152
 
129
153
  const success = this.checkResponse([response, status], 'turnOff');
130
- if (!success) {
154
+ if (success) {
155
+ // Update device status immediately
156
+ this.deviceStatus = 'off';
157
+ } else {
131
158
  logger.error(`Failed to turn off device: ${this.deviceName}`);
132
159
  }
133
160
  return success;
@@ -141,7 +168,7 @@ export class VeSyncAir131 extends VeSyncFan {
141
168
 
142
169
  // Check if device is in manual mode
143
170
  if (this.details.mode !== 'manual') {
144
- logger.debug(`${this.deviceName} not in manual mode, cannot change speed`);
171
+ logger.error(`${this.deviceName}: Cannot change fan speed - device is in ${this.details.mode} mode, manual mode required`);
145
172
  return false;
146
173
  }
147
174