tsvesync 1.4.10 → 1.4.11

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.
@@ -45,6 +45,7 @@ export declare class VeSyncAirBaseV2 extends VeSyncAirBypass {
45
45
  * Determine whether this purifier requires the powerSwitch payload and nested response handling.
46
46
  */
47
47
  private requiresPowerSwitchPayload;
48
+ shouldPollDetailsWhenOffline(): boolean;
48
49
  /**
49
50
  * Override turn on to use the powerSwitch payload required by bypassV2 purifiers.
50
51
  */
@@ -197,6 +197,9 @@ class VeSyncAirBaseV2 extends airBypass_1.VeSyncAirBypass {
197
197
  const type = (this.deviceType || '').toUpperCase();
198
198
  return type.startsWith('LAP-V') || type.startsWith('LAP-EL');
199
199
  }
200
+ shouldPollDetailsWhenOffline() {
201
+ return this.requiresPowerSwitchPayload();
202
+ }
200
203
  /**
201
204
  * Override turn on to use the powerSwitch payload required by bypassV2 purifiers.
202
205
  */
@@ -863,7 +863,8 @@ class VeSync {
863
863
  logger_1.logger.debug(`Skipping details update for excluded device: ${device.deviceName}`);
864
864
  continue;
865
865
  }
866
- if (String(device.connectionStatus || '').toLowerCase() === 'offline') {
866
+ if (String(device.connectionStatus || '').toLowerCase() === 'offline' &&
867
+ !device.shouldPollDetailsWhenOffline()) {
867
868
  logger_1.logger.debug(`Skipping details update for offline device: ${device.deviceName}`);
868
869
  continue;
869
870
  }
@@ -36,6 +36,12 @@ export declare abstract class VeSyncBaseDevice {
36
36
  * Get device details
37
37
  */
38
38
  abstract getDetails(): Promise<Boolean>;
39
+ /**
40
+ * Some device families have a detail endpoint that is more reliable than
41
+ * the device-list connection status. Those devices can opt into detail
42
+ * polling even when the list reports them offline.
43
+ */
44
+ shouldPollDetailsWhenOffline(): boolean;
39
45
  /**
40
46
  * Update device details
41
47
  */
@@ -80,6 +80,14 @@ class VeSyncBaseDevice {
80
80
  logger_1.logger.error(`Response: ${msg}`);
81
81
  }
82
82
  }
83
+ /**
84
+ * Some device families have a detail endpoint that is more reliable than
85
+ * the device-list connection status. Those devices can opt into detail
86
+ * polling even when the list reports them offline.
87
+ */
88
+ shouldPollDetailsWhenOffline() {
89
+ return false;
90
+ }
83
91
  /**
84
92
  * Update device details
85
93
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsvesync",
3
- "version": "1.4.10",
3
+ "version": "1.4.11",
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",
@@ -223,6 +223,10 @@ export class VeSyncAirBaseV2 extends VeSyncAirBypass {
223
223
  return type.startsWith('LAP-V') || type.startsWith('LAP-EL');
224
224
  }
225
225
 
226
+ override shouldPollDetailsWhenOffline(): boolean {
227
+ return this.requiresPowerSwitchPayload();
228
+ }
229
+
226
230
  /**
227
231
  * Override turn on to use the powerSwitch payload required by bypassV2 purifiers.
228
232
  */
package/src/lib/vesync.ts CHANGED
@@ -1032,7 +1032,10 @@ export class VeSync {
1032
1032
  logger.debug(`Skipping details update for excluded device: ${device.deviceName}`);
1033
1033
  continue;
1034
1034
  }
1035
- if (String(device.connectionStatus || '').toLowerCase() === 'offline') {
1035
+ if (
1036
+ String(device.connectionStatus || '').toLowerCase() === 'offline' &&
1037
+ !device.shouldPollDetailsWhenOffline()
1038
+ ) {
1036
1039
  logger.debug(`Skipping details update for offline device: ${device.deviceName}`);
1037
1040
  continue;
1038
1041
  }
@@ -107,6 +107,15 @@ export abstract class VeSyncBaseDevice {
107
107
  */
108
108
  abstract getDetails(): Promise<Boolean>;
109
109
 
110
+ /**
111
+ * Some device families have a detail endpoint that is more reliable than
112
+ * the device-list connection status. Those devices can opt into detail
113
+ * polling even when the list reports them offline.
114
+ */
115
+ shouldPollDetailsWhenOffline(): boolean {
116
+ return false;
117
+ }
118
+
110
119
  /**
111
120
  * Update device details
112
121
  */
@@ -125,4 +134,4 @@ export abstract class VeSyncBaseDevice {
125
134
  ): Promise<[any, number]> {
126
135
  return await Helpers.callApi(endpoint, method, data, headers, this.manager);
127
136
  }
128
- }
137
+ }