tsvesync 1.0.84 → 1.0.86
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 +28 -1
- package/package.json +1 -1
- package/src/lib/fans/air131.ts +33 -1
|
@@ -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
|
}
|
|
@@ -95,6 +107,20 @@ class VeSyncAir131 extends vesyncFan_1.VeSyncFan {
|
|
|
95
107
|
if (success) {
|
|
96
108
|
// Update device status immediately
|
|
97
109
|
this.deviceStatus = 'on';
|
|
110
|
+
// Fetch device details to get current speed and other settings
|
|
111
|
+
logger_1.logger.debug(`${this.deviceName}: Fetching device details after turning on`);
|
|
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
|
+
}
|
|
98
124
|
}
|
|
99
125
|
else {
|
|
100
126
|
logger_1.logger.error(`Failed to turn on device: ${this.deviceName}`);
|
|
@@ -169,6 +195,7 @@ class VeSyncAir131 extends vesyncFan_1.VeSyncFan {
|
|
|
169
195
|
const success = this.checkResponse([response, status], 'changeFanSpeed');
|
|
170
196
|
if (success) {
|
|
171
197
|
this.details.speed = speed;
|
|
198
|
+
this.lastKnownSpeed = speed; // Update last known speed
|
|
172
199
|
return true;
|
|
173
200
|
}
|
|
174
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
|
}
|
|
@@ -116,6 +130,23 @@ export class VeSyncAir131 extends VeSyncFan {
|
|
|
116
130
|
if (success) {
|
|
117
131
|
// Update device status immediately
|
|
118
132
|
this.deviceStatus = 'on';
|
|
133
|
+
|
|
134
|
+
// Fetch device details to get current speed and other settings
|
|
135
|
+
logger.debug(`${this.deviceName}: Fetching device details after turning on`);
|
|
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
|
+
}
|
|
119
150
|
} else {
|
|
120
151
|
logger.error(`Failed to turn on device: ${this.deviceName}`);
|
|
121
152
|
}
|
|
@@ -207,6 +238,7 @@ export class VeSyncAir131 extends VeSyncFan {
|
|
|
207
238
|
const success = this.checkResponse([response, status], 'changeFanSpeed');
|
|
208
239
|
if (success) {
|
|
209
240
|
this.details.speed = speed;
|
|
241
|
+
this.lastKnownSpeed = speed; // Update last known speed
|
|
210
242
|
return true;
|
|
211
243
|
} else {
|
|
212
244
|
logger.error(`Failed to change fan speed to ${speed} for device: ${this.deviceName}`);
|