tsvesync 1.0.66 → 1.0.67

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.
@@ -38,4 +38,12 @@ export declare class VeSyncHumid200300S extends VeSyncHumidifier {
38
38
  * Get automatic stop configuration
39
39
  */
40
40
  get automaticStopConfigured(): boolean;
41
+ /**
42
+ * Get night light brightness
43
+ */
44
+ get nightLightBrightness(): number;
45
+ /**
46
+ * Set night light brightness
47
+ */
48
+ setNightLightBrightness(brightness: number): Promise<boolean>;
41
49
  }
@@ -11,7 +11,7 @@ class VeSyncHumid200300S extends humidifier_1.VeSyncHumidifier {
11
11
  constructor(details, manager) {
12
12
  super(details, manager);
13
13
  this.modes = ['auto', 'manual', 'sleep'];
14
- this.features = ['humidity', 'mist', 'display', 'timer', 'auto_mode'];
14
+ this.features = ['humidity', 'mist', 'display', 'timer', 'auto_mode', 'night_light'];
15
15
  this.mistLevels = [1, 2, 3, 4, 5, 6, 7, 8, 9];
16
16
  this.humidityRange = { min: 30, max: 80 };
17
17
  logger_1.logger.debug(`Initialized VeSyncHumid200300S device: ${this.deviceName}`);
@@ -51,7 +51,8 @@ class VeSyncHumid200300S extends humidifier_1.VeSyncHumidifier {
51
51
  automatic_stop_configured: ((_b = result.configuration) === null || _b === void 0 ? void 0 : _b.automatic_stop) || false,
52
52
  auto_target_humidity: ((_c = result.configuration) === null || _c === void 0 ? void 0 : _c.auto_target_humidity) || 0,
53
53
  configuration: result.configuration || {},
54
- connection_status: result.connection_status || null
54
+ connection_status: result.connection_status || null,
55
+ night_light_brightness: result.night_light_brightness || 0
55
56
  };
56
57
  // Log raw response for debugging
57
58
  logger_1.logger.debug(`Raw API Response: ${JSON.stringify(response)}`);
@@ -125,5 +126,51 @@ class VeSyncHumid200300S extends humidifier_1.VeSyncHumidifier {
125
126
  get automaticStopConfigured() {
126
127
  return this.details.automatic_stop_configured || false;
127
128
  }
129
+ /**
130
+ * Get night light brightness
131
+ */
132
+ get nightLightBrightness() {
133
+ return this.details.night_light_brightness || 0;
134
+ }
135
+ /**
136
+ * Set night light brightness
137
+ */
138
+ async setNightLightBrightness(brightness) {
139
+ var _a;
140
+ if (brightness < 0 || brightness > 100) {
141
+ const error = `Invalid brightness: ${brightness}. Must be between 0 and 100`;
142
+ logger_1.logger.error(`${error} for device: ${this.deviceName}`);
143
+ throw new Error(error);
144
+ }
145
+ logger_1.logger.debug(`Setting night light brightness to ${brightness} for device: ${this.deviceName}`);
146
+ const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
147
+ ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
148
+ cid: this.cid,
149
+ configModule: this.configModule,
150
+ payload: {
151
+ data: {
152
+ brightness
153
+ },
154
+ method: 'setNightLight',
155
+ source: 'APP'
156
+ }
157
+ }, helpers_1.Helpers.reqHeaderBypass());
158
+ // Check for error code 11000000 which indicates feature not supported
159
+ if (((_a = response === null || response === void 0 ? void 0 : response.result) === null || _a === void 0 ? void 0 : _a.code) === 11000000) {
160
+ logger_1.logger.warn(`Night light control not supported by device: ${this.deviceName} (${this.deviceType})`);
161
+ return false;
162
+ }
163
+ const success = this.checkResponse([response, status], 'setNightLightBrightness');
164
+ if (success) {
165
+ this.details.night_light_brightness = brightness;
166
+ // Get latest state and log it
167
+ await this.getDetails();
168
+ logger_1.logger.debug(`Device state after night light brightness change: ${JSON.stringify(this.details)}`);
169
+ }
170
+ else {
171
+ logger_1.logger.error(`Failed to set night light brightness to ${brightness} for device: ${this.deviceName}`);
172
+ }
173
+ return success;
174
+ }
128
175
  }
129
176
  exports.VeSyncHumid200300S = VeSyncHumid200300S;
@@ -203,7 +203,7 @@ exports.fanConfig = {
203
203
  // LUH Series
204
204
  'LUH-A601S-WUSB': {
205
205
  module: 'VeSyncWarmHumidifier',
206
- features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode']
206
+ features: ['display', 'humidity', 'mist', 'timer', 'auto_mode', 'night_light']
207
207
  },
208
208
  'LUH-A601S-AUSW': {
209
209
  module: 'VeSyncWarmHumidifier',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsvesync",
3
- "version": "1.0.66",
3
+ "version": "1.0.67",
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",
@@ -8,7 +8,7 @@ import { logger } from '../logger';
8
8
  */
9
9
  export class VeSyncHumid200300S extends VeSyncHumidifier {
10
10
  protected readonly modes = ['auto', 'manual', 'sleep'] as const;
11
- protected readonly features = ['humidity', 'mist', 'display', 'timer', 'auto_mode'];
11
+ protected readonly features = ['humidity', 'mist', 'display', 'timer', 'auto_mode', 'night_light'];
12
12
  protected readonly mistLevels = [1, 2, 3, 4, 5, 6, 7, 8, 9];
13
13
  protected readonly humidityRange = { min: 30, max: 80 };
14
14
 
@@ -59,7 +59,8 @@ export class VeSyncHumid200300S extends VeSyncHumidifier {
59
59
  automatic_stop_configured: result.configuration?.automatic_stop || false,
60
60
  auto_target_humidity: result.configuration?.auto_target_humidity || 0,
61
61
  configuration: result.configuration || {},
62
- connection_status: result.connection_status || null
62
+ connection_status: result.connection_status || null,
63
+ night_light_brightness: result.night_light_brightness || 0
63
64
  };
64
65
 
65
66
  // Log raw response for debugging
@@ -145,4 +146,58 @@ export class VeSyncHumid200300S extends VeSyncHumidifier {
145
146
  get automaticStopConfigured(): boolean {
146
147
  return this.details.automatic_stop_configured || false;
147
148
  }
149
+
150
+ /**
151
+ * Get night light brightness
152
+ */
153
+ get nightLightBrightness(): number {
154
+ return this.details.night_light_brightness || 0;
155
+ }
156
+
157
+ /**
158
+ * Set night light brightness
159
+ */
160
+ async setNightLightBrightness(brightness: number): Promise<boolean> {
161
+ if (brightness < 0 || brightness > 100) {
162
+ const error = `Invalid brightness: ${brightness}. Must be between 0 and 100`;
163
+ logger.error(`${error} for device: ${this.deviceName}`);
164
+ throw new Error(error);
165
+ }
166
+
167
+ logger.debug(`Setting night light brightness to ${brightness} for device: ${this.deviceName}`);
168
+ const [response, status] = await this.callApi(
169
+ '/cloud/v2/deviceManaged/bypassV2',
170
+ 'post',
171
+ {
172
+ ...Helpers.reqBody(this.manager, 'bypassV2'),
173
+ cid: this.cid,
174
+ configModule: this.configModule,
175
+ payload: {
176
+ data: {
177
+ brightness
178
+ },
179
+ method: 'setNightLight',
180
+ source: 'APP'
181
+ }
182
+ },
183
+ Helpers.reqHeaderBypass()
184
+ );
185
+
186
+ // Check for error code 11000000 which indicates feature not supported
187
+ if (response?.result?.code === 11000000) {
188
+ logger.warn(`Night light control not supported by device: ${this.deviceName} (${this.deviceType})`);
189
+ return false;
190
+ }
191
+
192
+ const success = this.checkResponse([response, status], 'setNightLightBrightness');
193
+ if (success) {
194
+ this.details.night_light_brightness = brightness;
195
+ // Get latest state and log it
196
+ await this.getDetails();
197
+ logger.debug(`Device state after night light brightness change: ${JSON.stringify(this.details)}`);
198
+ } else {
199
+ logger.error(`Failed to set night light brightness to ${brightness} for device: ${this.deviceName}`);
200
+ }
201
+ return success;
202
+ }
148
203
  }
@@ -216,7 +216,7 @@ export const fanConfig: FanConfig = {
216
216
  // LUH Series
217
217
  'LUH-A601S-WUSB': {
218
218
  module: 'VeSyncWarmHumidifier',
219
- features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode']
219
+ features: ['display', 'humidity', 'mist', 'timer', 'auto_mode', 'night_light']
220
220
  },
221
221
  'LUH-A601S-AUSW': {
222
222
  module: 'VeSyncWarmHumidifier',