tsvesync 1.0.61 → 1.0.62

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.
@@ -209,11 +209,12 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
209
209
  * Change fan speed
210
210
  */
211
211
  async changeFanSpeed(speed) {
212
- // const speeds = this.config.levels ?? [];
213
- // if (!speeds.includes(speed)) {
214
- // logger.error(`Invalid speed: ${speed}. Must be one of: ${speeds.join(', ')} for device: ${this.deviceName}`);
215
- // return false;
216
- // }
212
+ var _a;
213
+ const speeds = (_a = this.config.levels) !== null && _a !== void 0 ? _a : [];
214
+ if (!speeds.includes(speed)) {
215
+ logger_1.logger.error(`Invalid speed: ${speed}. Must be one of: ${speeds.join(', ')} for device: ${this.deviceName}`);
216
+ return false;
217
+ }
217
218
  logger_1.logger.info(`Changing fan speed to ${speed} for device: ${this.deviceName}`);
218
219
  const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
219
220
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
@@ -1061,10 +1062,13 @@ class VeSyncAirBaseV2 extends VeSyncAirBypass {
1061
1062
  }
1062
1063
  buildConfigDict(configDict) {
1063
1064
  if (configDict) {
1065
+ // Only merge non-critical configuration fields
1066
+ const { module, features, levels, ...otherConfig } = configDict;
1064
1067
  this.config = {
1065
- ...this.config, // Preserve existing config
1066
- ...configDict // Merge in new config
1068
+ ...this.config, // Keep base config (including module, features, levels)
1069
+ ...otherConfig // Only merge other configuration fields
1067
1070
  };
1071
+ logger_1.logger.debug(`Updated configuration for device: ${this.deviceName}, preserved base config fields`);
1068
1072
  }
1069
1073
  }
1070
1074
  get mode() {
@@ -1210,11 +1214,12 @@ class VeSyncAirBaseV2 extends VeSyncAirBypass {
1210
1214
  * Change fan speed
1211
1215
  */
1212
1216
  async changeFanSpeed(speed) {
1213
- // const speeds = this.config.levels ?? [];
1214
- // if (!speeds.includes(speed)) {
1215
- // logger.error(`Invalid speed: ${speed}. Must be one of: ${speeds.join(', ')} for device: ${this.deviceName}`);
1216
- // return false;
1217
- // }
1217
+ var _a;
1218
+ const speeds = (_a = this.config.levels) !== null && _a !== void 0 ? _a : [];
1219
+ if (!speeds.includes(speed)) {
1220
+ logger_1.logger.error(`Invalid speed: ${speed}. Must be one of: ${speeds.join(', ')} for device: ${this.deviceName}`);
1221
+ return false;
1222
+ }
1218
1223
  logger_1.logger.info(`Changing fan speed to ${speed} for device: ${this.deviceName}`);
1219
1224
  const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
1220
1225
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
@@ -1617,11 +1622,12 @@ class VeSyncTowerFan extends VeSyncAirBaseV2 {
1617
1622
  * Change fan speed
1618
1623
  */
1619
1624
  async changeFanSpeed(speed) {
1620
- // const speeds = this.config.levels ?? [];
1621
- // if (!speeds.includes(speed)) {
1622
- // logger.debug(`Invalid speed: ${speed}. Must be one of: ${speeds.join(', ')}`);
1623
- // return false;
1624
- // }
1625
+ var _a;
1626
+ const speeds = (_a = this.config.levels) !== null && _a !== void 0 ? _a : [];
1627
+ if (!speeds.includes(speed)) {
1628
+ logger_1.logger.error(`Invalid speed: ${speed}. Must be one of: ${speeds.join(', ')} for device: ${this.deviceName}`);
1629
+ return false;
1630
+ }
1625
1631
  const [head, body] = this.buildApiDict('setLevel');
1626
1632
  body.payload.data = {
1627
1633
  levelIdx: 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsvesync",
3
- "version": "1.0.61",
3
+ "version": "1.0.62",
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",
@@ -257,11 +257,11 @@ export class VeSyncAirBypass extends VeSyncFan {
257
257
  * Change fan speed
258
258
  */
259
259
  async changeFanSpeed(speed: number): Promise<boolean> {
260
- // const speeds = this.config.levels ?? [];
261
- // if (!speeds.includes(speed)) {
262
- // logger.error(`Invalid speed: ${speed}. Must be one of: ${speeds.join(', ')} for device: ${this.deviceName}`);
263
- // return false;
264
- // }
260
+ const speeds = this.config.levels ?? [];
261
+ if (!speeds.includes(speed)) {
262
+ logger.error(`Invalid speed: ${speed}. Must be one of: ${speeds.join(', ')} for device: ${this.deviceName}`);
263
+ return false;
264
+ }
265
265
 
266
266
  logger.info(`Changing fan speed to ${speed} for device: ${this.deviceName}`);
267
267
  const [response, status] = await this.callApi(
@@ -1291,10 +1291,13 @@ export class VeSyncAirBaseV2 extends VeSyncAirBypass {
1291
1291
 
1292
1292
  protected buildConfigDict(configDict: Record<string, any>): void {
1293
1293
  if (configDict) {
1294
+ // Only merge non-critical configuration fields
1295
+ const { module, features, levels, ...otherConfig } = configDict;
1294
1296
  this.config = {
1295
- ...this.config, // Preserve existing config
1296
- ...configDict // Merge in new config
1297
+ ...this.config, // Keep base config (including module, features, levels)
1298
+ ...otherConfig // Only merge other configuration fields
1297
1299
  };
1300
+ logger.debug(`Updated configuration for device: ${this.deviceName}, preserved base config fields`);
1298
1301
  }
1299
1302
  }
1300
1303
 
@@ -1469,11 +1472,11 @@ export class VeSyncAirBaseV2 extends VeSyncAirBypass {
1469
1472
  * Change fan speed
1470
1473
  */
1471
1474
  async changeFanSpeed(speed: number): Promise<boolean> {
1472
- // const speeds = this.config.levels ?? [];
1473
- // if (!speeds.includes(speed)) {
1474
- // logger.error(`Invalid speed: ${speed}. Must be one of: ${speeds.join(', ')} for device: ${this.deviceName}`);
1475
- // return false;
1476
- // }
1475
+ const speeds = this.config.levels ?? [];
1476
+ if (!speeds.includes(speed)) {
1477
+ logger.error(`Invalid speed: ${speed}. Must be one of: ${speeds.join(', ')} for device: ${this.deviceName}`);
1478
+ return false;
1479
+ }
1477
1480
 
1478
1481
  logger.info(`Changing fan speed to ${speed} for device: ${this.deviceName}`);
1479
1482
  const [response, status] = await this.callApi(
@@ -1998,11 +2001,11 @@ export class VeSyncTowerFan extends VeSyncAirBaseV2 {
1998
2001
  * Change fan speed
1999
2002
  */
2000
2003
  async changeFanSpeed(speed: number): Promise<boolean> {
2001
- // const speeds = this.config.levels ?? [];
2002
- // if (!speeds.includes(speed)) {
2003
- // logger.debug(`Invalid speed: ${speed}. Must be one of: ${speeds.join(', ')}`);
2004
- // return false;
2005
- // }
2004
+ const speeds = this.config.levels ?? [];
2005
+ if (!speeds.includes(speed)) {
2006
+ logger.error(`Invalid speed: ${speed}. Must be one of: ${speeds.join(', ')} for device: ${this.deviceName}`);
2007
+ return false;
2008
+ }
2006
2009
 
2007
2010
  const [head, body] = this.buildApiDict('setLevel');
2008
2011
  body.payload.data = {