tsvesync 1.0.65 → 1.0.66

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.
@@ -1,9 +1,9 @@
1
- import { VeSyncWarmHumidifier } from './warmHumidifier';
1
+ import { VeSyncHumidifier } from './humidifier';
2
2
  import { VeSync } from '../vesync';
3
3
  /**
4
4
  * VeSync Humidifier 200/300S Class
5
5
  */
6
- export declare class VeSyncHumid200300S extends VeSyncWarmHumidifier {
6
+ export declare class VeSyncHumid200300S extends VeSyncHumidifier {
7
7
  protected readonly modes: readonly ["auto", "manual", "sleep"];
8
8
  protected readonly features: string[];
9
9
  protected readonly mistLevels: number[];
@@ -20,14 +20,6 @@ export declare class VeSyncHumid200300S extends VeSyncWarmHumidifier {
20
20
  * Set mist level
21
21
  */
22
22
  setMistLevel(level: number): Promise<boolean>;
23
- /**
24
- * Set night light brightness
25
- */
26
- setNightLightBrightness(brightness: number): Promise<boolean>;
27
- /**
28
- * Get night light brightness
29
- */
30
- get nightLightBrightness(): number;
31
23
  /**
32
24
  * Get configuration
33
25
  */
@@ -39,12 +31,11 @@ export declare class VeSyncHumid200300S extends VeSyncWarmHumidifier {
39
31
  get mistLevel(): number;
40
32
  /**
41
33
  * Get target humidity
42
- * Override base class to return target humidity instead of current humidity
34
+ * Override base class to return target humidity from configuration
43
35
  */
44
36
  get humidity(): number;
45
37
  /**
46
- * Set target humidity
47
- * Override base class to properly update target humidity
38
+ * Get automatic stop configuration
48
39
  */
49
- setHumidity(humidity: number): Promise<boolean>;
40
+ get automaticStopConfigured(): boolean;
50
41
  }
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VeSyncHumid200300S = void 0;
4
- const warmHumidifier_1 = require("./warmHumidifier");
4
+ const humidifier_1 = require("./humidifier");
5
5
  const helpers_1 = require("../helpers");
6
6
  const logger_1 = require("../logger");
7
7
  /**
8
8
  * VeSync Humidifier 200/300S Class
9
9
  */
10
- class VeSyncHumid200300S extends warmHumidifier_1.VeSyncWarmHumidifier {
10
+ class VeSyncHumid200300S extends humidifier_1.VeSyncHumidifier {
11
11
  constructor(details, manager) {
12
12
  super(details, manager);
13
13
  this.modes = ['auto', 'manual', 'sleep'];
@@ -20,7 +20,7 @@ class VeSyncHumid200300S extends warmHumidifier_1.VeSyncWarmHumidifier {
20
20
  * Get device details
21
21
  */
22
22
  async getDetails() {
23
- var _a;
23
+ var _a, _b, _c;
24
24
  logger_1.logger.debug(`Getting details for device: ${this.deviceName}`);
25
25
  const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
26
26
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
@@ -43,15 +43,15 @@ class VeSyncHumid200300S extends warmHumidifier_1.VeSyncWarmHumidifier {
43
43
  target_humidity: result.target_humidity || result.humidity || 0, // Target humidity
44
44
  mist_level: result.mist_level || 0,
45
45
  mist_virtual_level: result.mist_virtual_level || 0,
46
- warm_level: result.warm_level || 0,
47
46
  water_lacks: result.water_lacks || false,
48
47
  humidity_high: result.humidity_high || false,
49
48
  water_tank_lifted: result.water_tank_lifted || false,
50
49
  display: result.display || false,
51
50
  automatic_stop: result.automatic_stop_reach_target || false,
51
+ automatic_stop_configured: ((_b = result.configuration) === null || _b === void 0 ? void 0 : _b.automatic_stop) || false,
52
+ auto_target_humidity: ((_c = result.configuration) === null || _c === void 0 ? void 0 : _c.auto_target_humidity) || 0,
52
53
  configuration: result.configuration || {},
53
- connection_status: result.connection_status || null,
54
- night_light_brightness: result.night_light_brightness || 0
54
+ connection_status: result.connection_status || null
55
55
  };
56
56
  // Log raw response for debugging
57
57
  logger_1.logger.debug(`Raw API Response: ${JSON.stringify(response)}`);
@@ -99,43 +99,6 @@ class VeSyncHumid200300S extends warmHumidifier_1.VeSyncWarmHumidifier {
99
99
  }
100
100
  return success;
101
101
  }
102
- /**
103
- * Set night light brightness
104
- */
105
- async setNightLightBrightness(brightness) {
106
- if (brightness < 0 || brightness > 100) {
107
- const error = `Invalid brightness: ${brightness}. Must be between 0 and 100`;
108
- logger_1.logger.error(`${error} for device: ${this.deviceName}`);
109
- throw new Error(error);
110
- }
111
- logger_1.logger.debug(`Setting night light brightness to ${brightness} for device: ${this.deviceName}`);
112
- const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
113
- ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
114
- cid: this.cid,
115
- configModule: this.configModule,
116
- payload: {
117
- data: {
118
- brightness
119
- },
120
- method: 'setNightLight',
121
- source: 'APP'
122
- }
123
- }, helpers_1.Helpers.reqHeaderBypass());
124
- const success = this.checkResponse([response, status], 'setNightLightBrightness');
125
- if (success) {
126
- this.details.night_light_brightness = brightness;
127
- }
128
- else {
129
- logger_1.logger.error(`Failed to set night light brightness to ${brightness} for device: ${this.deviceName}`);
130
- }
131
- return success;
132
- }
133
- /**
134
- * Get night light brightness
135
- */
136
- get nightLightBrightness() {
137
- return this.details.night_light_brightness || 0;
138
- }
139
102
  /**
140
103
  * Get configuration
141
104
  */
@@ -151,50 +114,16 @@ class VeSyncHumid200300S extends warmHumidifier_1.VeSyncWarmHumidifier {
151
114
  }
152
115
  /**
153
116
  * Get target humidity
154
- * Override base class to return target humidity instead of current humidity
117
+ * Override base class to return target humidity from configuration
155
118
  */
156
119
  get humidity() {
157
- return this.details.target_humidity || 0;
120
+ return this.details.auto_target_humidity || 0;
158
121
  }
159
122
  /**
160
- * Set target humidity
161
- * Override base class to properly update target humidity
123
+ * Get automatic stop configuration
162
124
  */
163
- async setHumidity(humidity) {
164
- if (!this.hasFeature('humidity')) {
165
- const error = 'Humidity control not supported';
166
- logger_1.logger.error(`${error} for device: ${this.deviceName}`);
167
- throw new Error(error);
168
- }
169
- if (humidity < this.humidityRange.min || humidity > this.humidityRange.max) {
170
- const error = `Invalid humidity: ${humidity}. Must be between ${this.humidityRange.min} and ${this.humidityRange.max}`;
171
- logger_1.logger.error(`${error} for device: ${this.deviceName}`);
172
- throw new Error(error);
173
- }
174
- logger_1.logger.debug(`Setting target humidity to ${humidity}% for device: ${this.deviceName}`);
175
- const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
176
- ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
177
- cid: this.cid,
178
- configModule: this.configModule,
179
- payload: {
180
- data: {
181
- target_humidity: humidity
182
- },
183
- method: 'setTargetHumidity',
184
- source: 'APP'
185
- }
186
- }, helpers_1.Helpers.reqHeaderBypass());
187
- const success = this.checkResponse([response, status], 'setHumidity');
188
- if (success) {
189
- this.details.target_humidity = humidity;
190
- // Get latest state and log it
191
- await this.getDetails();
192
- logger_1.logger.debug(`Device state after humidity change: ${JSON.stringify(this.details)}`);
193
- }
194
- else {
195
- logger_1.logger.error(`Failed to set target humidity to ${humidity}% for device: ${this.deviceName}`);
196
- }
197
- return success;
125
+ get automaticStopConfigured() {
126
+ return this.details.automatic_stop_configured || false;
198
127
  }
199
128
  }
200
129
  exports.VeSyncHumid200300S = VeSyncHumid200300S;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsvesync",
3
- "version": "1.0.65",
3
+ "version": "1.0.66",
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",
@@ -1,4 +1,4 @@
1
- import { VeSyncWarmHumidifier } from './warmHumidifier';
1
+ import { VeSyncHumidifier } from './humidifier';
2
2
  import { VeSync } from '../vesync';
3
3
  import { Helpers } from '../helpers';
4
4
  import { logger } from '../logger';
@@ -6,7 +6,7 @@ import { logger } from '../logger';
6
6
  /**
7
7
  * VeSync Humidifier 200/300S Class
8
8
  */
9
- export class VeSyncHumid200300S extends VeSyncWarmHumidifier {
9
+ export class VeSyncHumid200300S extends VeSyncHumidifier {
10
10
  protected readonly modes = ['auto', 'manual', 'sleep'] as const;
11
11
  protected readonly features = ['humidity', 'mist', 'display', 'timer', 'auto_mode'];
12
12
  protected readonly mistLevels = [1, 2, 3, 4, 5, 6, 7, 8, 9];
@@ -51,15 +51,15 @@ export class VeSyncHumid200300S extends VeSyncWarmHumidifier {
51
51
  target_humidity: result.target_humidity || result.humidity || 0, // Target humidity
52
52
  mist_level: result.mist_level || 0,
53
53
  mist_virtual_level: result.mist_virtual_level || 0,
54
- warm_level: result.warm_level || 0,
55
54
  water_lacks: result.water_lacks || false,
56
55
  humidity_high: result.humidity_high || false,
57
56
  water_tank_lifted: result.water_tank_lifted || false,
58
57
  display: result.display || false,
59
58
  automatic_stop: result.automatic_stop_reach_target || false,
59
+ automatic_stop_configured: result.configuration?.automatic_stop || false,
60
+ auto_target_humidity: result.configuration?.auto_target_humidity || 0,
60
61
  configuration: result.configuration || {},
61
- connection_status: result.connection_status || null,
62
- night_light_brightness: result.night_light_brightness || 0
62
+ connection_status: result.connection_status || null
63
63
  };
64
64
 
65
65
  // Log raw response for debugging
@@ -116,51 +116,6 @@ export class VeSyncHumid200300S extends VeSyncWarmHumidifier {
116
116
  return success;
117
117
  }
118
118
 
119
- /**
120
- * Set night light brightness
121
- */
122
- async setNightLightBrightness(brightness: number): Promise<boolean> {
123
- if (brightness < 0 || brightness > 100) {
124
- const error = `Invalid brightness: ${brightness}. Must be between 0 and 100`;
125
- logger.error(`${error} for device: ${this.deviceName}`);
126
- throw new Error(error);
127
- }
128
-
129
- logger.debug(`Setting night light brightness to ${brightness} for device: ${this.deviceName}`);
130
- const [response, status] = await this.callApi(
131
- '/cloud/v2/deviceManaged/bypassV2',
132
- 'post',
133
- {
134
- ...Helpers.reqBody(this.manager, 'bypassV2'),
135
- cid: this.cid,
136
- configModule: this.configModule,
137
- payload: {
138
- data: {
139
- brightness
140
- },
141
- method: 'setNightLight',
142
- source: 'APP'
143
- }
144
- },
145
- Helpers.reqHeaderBypass()
146
- );
147
-
148
- const success = this.checkResponse([response, status], 'setNightLightBrightness');
149
- if (success) {
150
- this.details.night_light_brightness = brightness;
151
- } else {
152
- logger.error(`Failed to set night light brightness to ${brightness} for device: ${this.deviceName}`);
153
- }
154
- return success;
155
- }
156
-
157
- /**
158
- * Get night light brightness
159
- */
160
- get nightLightBrightness(): number {
161
- return this.details.night_light_brightness || 0;
162
- }
163
-
164
119
  /**
165
120
  * Get configuration
166
121
  */
@@ -178,57 +133,16 @@ export class VeSyncHumid200300S extends VeSyncWarmHumidifier {
178
133
 
179
134
  /**
180
135
  * Get target humidity
181
- * Override base class to return target humidity instead of current humidity
136
+ * Override base class to return target humidity from configuration
182
137
  */
183
138
  get humidity(): number {
184
- return this.details.target_humidity || 0;
139
+ return this.details.auto_target_humidity || 0;
185
140
  }
186
141
 
187
142
  /**
188
- * Set target humidity
189
- * Override base class to properly update target humidity
143
+ * Get automatic stop configuration
190
144
  */
191
- async setHumidity(humidity: number): Promise<boolean> {
192
- if (!this.hasFeature('humidity')) {
193
- const error = 'Humidity control not supported';
194
- logger.error(`${error} for device: ${this.deviceName}`);
195
- throw new Error(error);
196
- }
197
-
198
- if (humidity < this.humidityRange.min || humidity > this.humidityRange.max) {
199
- const error = `Invalid humidity: ${humidity}. Must be between ${this.humidityRange.min} and ${this.humidityRange.max}`;
200
- logger.error(`${error} for device: ${this.deviceName}`);
201
- throw new Error(error);
202
- }
203
-
204
- logger.debug(`Setting target humidity to ${humidity}% for device: ${this.deviceName}`);
205
- const [response, status] = await this.callApi(
206
- '/cloud/v2/deviceManaged/bypassV2',
207
- 'post',
208
- {
209
- ...Helpers.reqBody(this.manager, 'bypassV2'),
210
- cid: this.cid,
211
- configModule: this.configModule,
212
- payload: {
213
- data: {
214
- target_humidity: humidity
215
- },
216
- method: 'setTargetHumidity',
217
- source: 'APP'
218
- }
219
- },
220
- Helpers.reqHeaderBypass()
221
- );
222
-
223
- const success = this.checkResponse([response, status], 'setHumidity');
224
- if (success) {
225
- this.details.target_humidity = humidity;
226
- // Get latest state and log it
227
- await this.getDetails();
228
- logger.debug(`Device state after humidity change: ${JSON.stringify(this.details)}`);
229
- } else {
230
- logger.error(`Failed to set target humidity to ${humidity}% for device: ${this.deviceName}`);
231
- }
232
- return success;
145
+ get automaticStopConfigured(): boolean {
146
+ return this.details.automatic_stop_configured || false;
233
147
  }
234
148
  }