tsvesync 1.0.85 → 1.0.87
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/fans/air131.d.ts +1 -0
- package/dist/lib/fans/air131.js +26 -2
- package/package.json +1 -1
- package/src/lib/fans/air131.ts +30 -2
|
@@ -8,6 +8,7 @@ export declare class VeSyncAir131 extends VeSyncFan {
|
|
|
8
8
|
protected readonly modes: readonly ["auto", "manual", "sleep"];
|
|
9
9
|
protected readonly displayModes: readonly ["on", "off"];
|
|
10
10
|
protected readonly childLockModes: readonly ["on", "off"];
|
|
11
|
+
private lastKnownSpeed;
|
|
11
12
|
constructor(details: Record<string, any>, manager: VeSync);
|
|
12
13
|
/**
|
|
13
14
|
* Get device details
|
package/dist/lib/fans/air131.js
CHANGED
|
@@ -13,7 +13,15 @@ class VeSyncAir131 extends vesyncFan_1.VeSyncFan {
|
|
|
13
13
|
this.modes = ['auto', 'manual', 'sleep'];
|
|
14
14
|
this.displayModes = ['on', 'off'];
|
|
15
15
|
this.childLockModes = ['on', 'off'];
|
|
16
|
-
|
|
16
|
+
this.lastKnownSpeed = 1;
|
|
17
|
+
// Initialize last known speed from device details if available
|
|
18
|
+
if (details.speed && details.speed > 0) {
|
|
19
|
+
this.lastKnownSpeed = details.speed;
|
|
20
|
+
}
|
|
21
|
+
else if (details.level && details.level > 0) {
|
|
22
|
+
this.lastKnownSpeed = details.level;
|
|
23
|
+
}
|
|
24
|
+
logger_1.logger.debug(`Initialized VeSyncAir131 device: ${this.deviceName}, lastKnownSpeed: ${this.lastKnownSpeed}`);
|
|
17
25
|
}
|
|
18
26
|
/**
|
|
19
27
|
* Get device details
|
|
@@ -54,6 +62,10 @@ class VeSyncAir131 extends vesyncFan_1.VeSyncFan {
|
|
|
54
62
|
airQuality: data.airQuality || 'unknown',
|
|
55
63
|
active_time: data.activeTime || 0
|
|
56
64
|
};
|
|
65
|
+
// Store last known speed when device is on and has a valid speed
|
|
66
|
+
if (this.deviceStatus === 'on' && this.details.speed && this.details.speed > 0) {
|
|
67
|
+
this.lastKnownSpeed = this.details.speed;
|
|
68
|
+
}
|
|
57
69
|
logger_1.logger.debug(`${this.deviceName}: Updated details - mode: ${this.details.mode}, speed: ${this.details.speed}, status: ${this.deviceStatus}`);
|
|
58
70
|
return true;
|
|
59
71
|
}
|
|
@@ -97,7 +109,18 @@ class VeSyncAir131 extends vesyncFan_1.VeSyncFan {
|
|
|
97
109
|
this.deviceStatus = 'on';
|
|
98
110
|
// Fetch device details to get current speed and other settings
|
|
99
111
|
logger_1.logger.debug(`${this.deviceName}: Fetching device details after turning on`);
|
|
100
|
-
await this.getDetails();
|
|
112
|
+
let detailsSuccess = await this.getDetails();
|
|
113
|
+
// If getDetails failed or returned 0 speed, retry once after a short delay
|
|
114
|
+
if (!detailsSuccess || this.details.speed === 0) {
|
|
115
|
+
logger_1.logger.debug(`${this.deviceName}: First getDetails attempt failed or returned 0 speed, retrying in 2 seconds...`);
|
|
116
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
117
|
+
detailsSuccess = await this.getDetails();
|
|
118
|
+
}
|
|
119
|
+
// If still no speed, use last known speed
|
|
120
|
+
if (!detailsSuccess || this.details.speed === 0) {
|
|
121
|
+
logger_1.logger.debug(`${this.deviceName}: getDetails still failed or returned 0 speed after retry, using last known speed: ${this.lastKnownSpeed}`);
|
|
122
|
+
this.details.speed = this.lastKnownSpeed;
|
|
123
|
+
}
|
|
101
124
|
}
|
|
102
125
|
else {
|
|
103
126
|
logger_1.logger.error(`Failed to turn on device: ${this.deviceName}`);
|
|
@@ -172,6 +195,7 @@ class VeSyncAir131 extends vesyncFan_1.VeSyncFan {
|
|
|
172
195
|
const success = this.checkResponse([response, status], 'changeFanSpeed');
|
|
173
196
|
if (success) {
|
|
174
197
|
this.details.speed = speed;
|
|
198
|
+
this.lastKnownSpeed = speed; // Update last known speed
|
|
175
199
|
return true;
|
|
176
200
|
}
|
|
177
201
|
else {
|
package/package.json
CHANGED
package/src/lib/fans/air131.ts
CHANGED
|
@@ -11,10 +11,19 @@ export class VeSyncAir131 extends VeSyncFan {
|
|
|
11
11
|
protected readonly modes = ['auto', 'manual', 'sleep'] as const;
|
|
12
12
|
protected readonly displayModes = ['on', 'off'] as const;
|
|
13
13
|
protected readonly childLockModes = ['on', 'off'] as const;
|
|
14
|
+
private lastKnownSpeed: number = 1;
|
|
14
15
|
|
|
15
16
|
constructor(details: Record<string, any>, manager: VeSync) {
|
|
16
17
|
super(details, manager);
|
|
17
|
-
|
|
18
|
+
|
|
19
|
+
// Initialize last known speed from device details if available
|
|
20
|
+
if (details.speed && details.speed > 0) {
|
|
21
|
+
this.lastKnownSpeed = details.speed;
|
|
22
|
+
} else if (details.level && details.level > 0) {
|
|
23
|
+
this.lastKnownSpeed = details.level;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
logger.debug(`Initialized VeSyncAir131 device: ${this.deviceName}, lastKnownSpeed: ${this.lastKnownSpeed}`);
|
|
18
27
|
}
|
|
19
28
|
|
|
20
29
|
/**
|
|
@@ -65,6 +74,11 @@ export class VeSyncAir131 extends VeSyncFan {
|
|
|
65
74
|
active_time: data.activeTime || 0
|
|
66
75
|
};
|
|
67
76
|
|
|
77
|
+
// Store last known speed when device is on and has a valid speed
|
|
78
|
+
if (this.deviceStatus === 'on' && this.details.speed && this.details.speed > 0) {
|
|
79
|
+
this.lastKnownSpeed = this.details.speed;
|
|
80
|
+
}
|
|
81
|
+
|
|
68
82
|
logger.debug(`${this.deviceName}: Updated details - mode: ${this.details.mode}, speed: ${this.details.speed}, status: ${this.deviceStatus}`);
|
|
69
83
|
return true;
|
|
70
84
|
}
|
|
@@ -119,7 +133,20 @@ export class VeSyncAir131 extends VeSyncFan {
|
|
|
119
133
|
|
|
120
134
|
// Fetch device details to get current speed and other settings
|
|
121
135
|
logger.debug(`${this.deviceName}: Fetching device details after turning on`);
|
|
122
|
-
await this.getDetails();
|
|
136
|
+
let detailsSuccess = await this.getDetails();
|
|
137
|
+
|
|
138
|
+
// If getDetails failed or returned 0 speed, retry once after a short delay
|
|
139
|
+
if (!detailsSuccess || this.details.speed === 0) {
|
|
140
|
+
logger.debug(`${this.deviceName}: First getDetails attempt failed or returned 0 speed, retrying in 2 seconds...`);
|
|
141
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
142
|
+
detailsSuccess = await this.getDetails();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// If still no speed, use last known speed
|
|
146
|
+
if (!detailsSuccess || this.details.speed === 0) {
|
|
147
|
+
logger.debug(`${this.deviceName}: getDetails still failed or returned 0 speed after retry, using last known speed: ${this.lastKnownSpeed}`);
|
|
148
|
+
this.details.speed = this.lastKnownSpeed;
|
|
149
|
+
}
|
|
123
150
|
} else {
|
|
124
151
|
logger.error(`Failed to turn on device: ${this.deviceName}`);
|
|
125
152
|
}
|
|
@@ -211,6 +238,7 @@ export class VeSyncAir131 extends VeSyncFan {
|
|
|
211
238
|
const success = this.checkResponse([response, status], 'changeFanSpeed');
|
|
212
239
|
if (success) {
|
|
213
240
|
this.details.speed = speed;
|
|
241
|
+
this.lastKnownSpeed = speed; // Update last known speed
|
|
214
242
|
return true;
|
|
215
243
|
} else {
|
|
216
244
|
logger.error(`Failed to change fan speed to ${speed} for device: ${this.deviceName}`);
|