tsvesync 1.0.56 → 1.0.57

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.
@@ -16,6 +16,11 @@ export declare abstract class VeSyncBaseDevice {
16
16
  deviceCategory: string;
17
17
  connectionStatus: string;
18
18
  constructor(details: Record<string, any>, manager: VeSync);
19
+ /**
20
+ * Normalize device type to match configuration keys
21
+ * This handles variations in device type strings from the API
22
+ */
23
+ protected normalizeDeviceType(deviceType: string): string;
19
24
  /**
20
25
  * Return formatted device info to stdout
21
26
  */
@@ -13,7 +13,7 @@ class VeSyncBaseDevice {
13
13
  this.cid = details.cid || '';
14
14
  this.deviceName = details.deviceName || '';
15
15
  this.deviceStatus = details.deviceStatus || 'off';
16
- this.deviceType = details.deviceType || '';
16
+ this.deviceType = this.normalizeDeviceType(details.deviceType || '');
17
17
  this.deviceRegion = details.deviceRegion || '';
18
18
  this.uuid = details.uuid || '';
19
19
  this.configModule = details.configModule || '';
@@ -21,6 +21,34 @@ class VeSyncBaseDevice {
21
21
  this.deviceCategory = details.deviceCategory || '';
22
22
  this.connectionStatus = details.connectionStatus || 'offline';
23
23
  }
24
+ /**
25
+ * Normalize device type to match configuration keys
26
+ * This handles variations in device type strings from the API
27
+ */
28
+ normalizeDeviceType(deviceType) {
29
+ // Remove any region suffixes (e.g. -USA, -EU)
30
+ const baseType = deviceType.split('-')[0];
31
+ // Handle known prefix mappings
32
+ const prefixMap = {
33
+ 'Core': 'Core',
34
+ 'LAP': 'LAP',
35
+ 'LTF': 'LTF',
36
+ 'Classic': 'Classic',
37
+ 'Dual': 'Dual',
38
+ 'LUH': 'LUH',
39
+ 'LEH': 'LEH',
40
+ 'LV-PUR': 'LV-PUR',
41
+ 'LV-RH': 'LV-RH'
42
+ };
43
+ // Check if the device type starts with any known prefix
44
+ for (const [prefix, normalized] of Object.entries(prefixMap)) {
45
+ if (deviceType.startsWith(prefix)) {
46
+ return deviceType; // Keep the full device type for exact matches
47
+ }
48
+ }
49
+ // If no prefix match, return the base type
50
+ return baseType;
51
+ }
24
52
  /**
25
53
  * Return formatted device info to stdout
26
54
  */
@@ -328,11 +328,22 @@ class VeSyncFan extends vesyncBaseDevice_1.VeSyncBaseDevice {
328
328
  this.speed_dict = {};
329
329
  this._timer = null;
330
330
  this.details = details;
331
- this.config = exports.fanConfig[this.deviceType] || {
331
+ // Try exact match first
332
+ let config = exports.fanConfig[this.deviceType];
333
+ // If no exact match, try base type
334
+ if (!config) {
335
+ const baseType = this.deviceType.split('-')[0];
336
+ config = exports.fanConfig[baseType];
337
+ }
338
+ // If still no match, use default
339
+ this.config = config || {
332
340
  module: 'VeSyncAirBypass',
333
341
  features: [],
334
342
  levels: []
335
343
  };
344
+ if (!config) {
345
+ logger_1.logger.debug(`No configuration found for device type: ${this.deviceType}`);
346
+ }
336
347
  }
337
348
  /**
338
349
  * Check if feature is supported
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsvesync",
3
- "version": "1.0.56",
3
+ "version": "1.0.57",
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",
@@ -26,7 +26,7 @@ export abstract class VeSyncBaseDevice {
26
26
  this.cid = details.cid || '';
27
27
  this.deviceName = details.deviceName || '';
28
28
  this.deviceStatus = details.deviceStatus || 'off';
29
- this.deviceType = details.deviceType || '';
29
+ this.deviceType = this.normalizeDeviceType(details.deviceType || '');
30
30
  this.deviceRegion = details.deviceRegion || '';
31
31
  this.uuid = details.uuid || '';
32
32
  this.configModule = details.configModule || '';
@@ -35,6 +35,38 @@ export abstract class VeSyncBaseDevice {
35
35
  this.connectionStatus = details.connectionStatus || 'offline';
36
36
  }
37
37
 
38
+ /**
39
+ * Normalize device type to match configuration keys
40
+ * This handles variations in device type strings from the API
41
+ */
42
+ protected normalizeDeviceType(deviceType: string): string {
43
+ // Remove any region suffixes (e.g. -USA, -EU)
44
+ const baseType = deviceType.split('-')[0];
45
+
46
+ // Handle known prefix mappings
47
+ const prefixMap: Record<string, string> = {
48
+ 'Core': 'Core',
49
+ 'LAP': 'LAP',
50
+ 'LTF': 'LTF',
51
+ 'Classic': 'Classic',
52
+ 'Dual': 'Dual',
53
+ 'LUH': 'LUH',
54
+ 'LEH': 'LEH',
55
+ 'LV-PUR': 'LV-PUR',
56
+ 'LV-RH': 'LV-RH'
57
+ };
58
+
59
+ // Check if the device type starts with any known prefix
60
+ for (const [prefix, normalized] of Object.entries(prefixMap)) {
61
+ if (deviceType.startsWith(prefix)) {
62
+ return deviceType; // Keep the full device type for exact matches
63
+ }
64
+ }
65
+
66
+ // If no prefix match, return the base type
67
+ return baseType;
68
+ }
69
+
38
70
  /**
39
71
  * Return formatted device info to stdout
40
72
  */
@@ -362,11 +362,26 @@ export abstract class VeSyncFan extends VeSyncBaseDevice {
362
362
  constructor(details: Record<string, any>, manager: VeSync) {
363
363
  super(details, manager);
364
364
  this.details = details;
365
- this.config = fanConfig[this.deviceType] || {
365
+
366
+ // Try exact match first
367
+ let config = fanConfig[this.deviceType];
368
+
369
+ // If no exact match, try base type
370
+ if (!config) {
371
+ const baseType = this.deviceType.split('-')[0];
372
+ config = fanConfig[baseType];
373
+ }
374
+
375
+ // If still no match, use default
376
+ this.config = config || {
366
377
  module: 'VeSyncAirBypass',
367
378
  features: [],
368
379
  levels: []
369
380
  };
381
+
382
+ if (!config) {
383
+ logger.debug(`No configuration found for device type: ${this.deviceType}`);
384
+ }
370
385
  }
371
386
 
372
387
  /**