tsvesync 1.0.75 → 1.0.76

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.
@@ -49,9 +49,36 @@ class VeSyncAirBaseV2 extends airBypass_1.VeSyncAirBypass {
49
49
  * Get device details
50
50
  */
51
51
  async getDetails() {
52
+ var _a;
52
53
  logger_1.logger.debug(`Getting details for device: ${this.deviceName}`);
53
54
  const [head, body] = this.buildApiDict('getPurifierStatus');
54
55
  const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', body, head);
56
+ // Check if this is a Vital series device (LAP-V102S or LAP-V201S)
57
+ const isVitalSeries = this.deviceType.includes('LAP-V102S') || this.deviceType.includes('LAP-V201S');
58
+ // First check the outer response
59
+ if (!response || status !== 200) {
60
+ logger_1.logger.debug(`Error getting purifier details for ${this.deviceName}: Invalid response`);
61
+ this.connectionStatus = 'offline';
62
+ return false;
63
+ }
64
+ // For Vital series, we need special handling as they return inner code -1 for details
65
+ // but still provide valid status information
66
+ if (isVitalSeries && response.result) {
67
+ // Check if we have a valid getPurifierStatus response
68
+ if (response.code === 0 && ((_a = response.result) === null || _a === void 0 ? void 0 : _a.result)) {
69
+ const statusResponse = response.result.result;
70
+ // If we have valid status data, use it regardless of inner result code
71
+ logger_1.logger.debug(`Using status data for Vital series device: ${this.deviceName}`);
72
+ this.buildPurifierDict(statusResponse);
73
+ if (statusResponse.configuration) {
74
+ this.buildConfigDict(statusResponse.configuration);
75
+ }
76
+ // Keep device online since we have valid status
77
+ this.connectionStatus = 'online';
78
+ return true;
79
+ }
80
+ }
81
+ // Standard processing for non-Vital devices or when no status data is available
55
82
  if (!this.checkResponse([response, status], 'getDetails') || !(response === null || response === void 0 ? void 0 : response.result)) {
56
83
  logger_1.logger.debug('Error getting purifier details');
57
84
  this.connectionStatus = 'offline';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsvesync",
3
- "version": "1.0.75",
3
+ "version": "1.0.76",
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",
@@ -68,6 +68,36 @@ export class VeSyncAirBaseV2 extends VeSyncAirBypass {
68
68
  head
69
69
  );
70
70
 
71
+ // Check if this is a Vital series device (LAP-V102S or LAP-V201S)
72
+ const isVitalSeries = this.deviceType.includes('LAP-V102S') || this.deviceType.includes('LAP-V201S');
73
+
74
+ // First check the outer response
75
+ if (!response || status !== 200) {
76
+ logger.debug(`Error getting purifier details for ${this.deviceName}: Invalid response`);
77
+ this.connectionStatus = 'offline';
78
+ return false;
79
+ }
80
+
81
+ // For Vital series, we need special handling as they return inner code -1 for details
82
+ // but still provide valid status information
83
+ if (isVitalSeries && response.result) {
84
+ // Check if we have a valid getPurifierStatus response
85
+ if (response.code === 0 && response.result?.result) {
86
+ const statusResponse = response.result.result;
87
+
88
+ // If we have valid status data, use it regardless of inner result code
89
+ logger.debug(`Using status data for Vital series device: ${this.deviceName}`);
90
+ this.buildPurifierDict(statusResponse);
91
+ if (statusResponse.configuration) {
92
+ this.buildConfigDict(statusResponse.configuration);
93
+ }
94
+ // Keep device online since we have valid status
95
+ this.connectionStatus = 'online';
96
+ return true;
97
+ }
98
+ }
99
+
100
+ // Standard processing for non-Vital devices or when no status data is available
71
101
  if (!this.checkResponse([response, status], 'getDetails') || !response?.result) {
72
102
  logger.debug('Error getting purifier details');
73
103
  this.connectionStatus = 'offline';