tsvesync 1.0.55 → 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.
- package/dist/lib/vesyncBaseDevice.d.ts +5 -0
- package/dist/lib/vesyncBaseDevice.js +29 -1
- package/dist/lib/vesyncFan.js +12 -1
- package/dist/lib/vesyncFanImpl.js +4 -3
- package/package.json +1 -1
- package/src/lib/vesyncBaseDevice.ts +33 -1
- package/src/lib/vesyncFan.ts +16 -1
- package/src/lib/vesyncFanImpl.ts +3 -2
|
@@ -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
|
*/
|
package/dist/lib/vesyncFan.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
@@ -210,11 +210,12 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
|
|
|
210
210
|
* Change fan speed
|
|
211
211
|
*/
|
|
212
212
|
async changeFanSpeed(speed) {
|
|
213
|
-
var _a, _b
|
|
213
|
+
var _a, _b;
|
|
214
214
|
logger_1.logger.debug(`Attempting to change fan speed to ${speed} for device: ${this.deviceName}`);
|
|
215
215
|
logger_1.logger.debug(`Available speeds: ${(_a = this.config.levels) === null || _a === void 0 ? void 0 : _a.join(', ')}`);
|
|
216
|
-
|
|
217
|
-
|
|
216
|
+
const speeds = (_b = this.config.levels) !== null && _b !== void 0 ? _b : [];
|
|
217
|
+
if (!speeds.includes(speed)) {
|
|
218
|
+
logger_1.logger.debug(`Invalid speed: ${speed}. Must be one of: ${speeds.join(', ')}`);
|
|
218
219
|
return false;
|
|
219
220
|
}
|
|
220
221
|
logger_1.logger.info(`Changing fan speed to ${speed} for device: ${this.deviceName}`);
|
package/package.json
CHANGED
|
@@ -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
|
*/
|
package/src/lib/vesyncFan.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
/**
|
package/src/lib/vesyncFanImpl.ts
CHANGED
|
@@ -261,8 +261,9 @@ export class VeSyncAirBypass extends VeSyncFan {
|
|
|
261
261
|
logger.debug(`Attempting to change fan speed to ${speed} for device: ${this.deviceName}`);
|
|
262
262
|
logger.debug(`Available speeds: ${this.config.levels?.join(', ')}`);
|
|
263
263
|
|
|
264
|
-
|
|
265
|
-
|
|
264
|
+
const speeds = this.config.levels ?? [];
|
|
265
|
+
if (!speeds.includes(speed)) {
|
|
266
|
+
logger.debug(`Invalid speed: ${speed}. Must be one of: ${speeds.join(', ')}`);
|
|
266
267
|
return false;
|
|
267
268
|
}
|
|
268
269
|
|