@switchbot/homebridge-switchbot 1.4.1-beta.2 → 1.4.1-beta.6
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/CHANGELOG.md +13 -7
- package/config.schema.json +1 -1
- package/dist/devices/bots.d.ts +1 -1
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +32 -17
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +1 -1
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +28 -8
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +1 -1
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +30 -4
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +1 -1
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +35 -7
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +1 -1
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +35 -9
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +1 -1
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +27 -4
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +1 -1
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +25 -4
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +1 -1
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +20 -4
- package/dist/devices/plugs.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +30 -14
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +292 -152
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +1 -1
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +7 -3
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +1 -1
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +4 -3
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +1 -1
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +6 -3
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +1 -1
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +4 -3
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +1 -1
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +4 -3
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +1 -1
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +5 -3
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +4 -3
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +1 -1
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +4 -3
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/package.json +10 -6
- package/src/devices/bots.ts +32 -18
- package/src/devices/colorbulb.ts +29 -9
- package/src/devices/contact.ts +31 -5
- package/src/devices/curtains.ts +35 -7
- package/src/devices/humidifiers.ts +36 -10
- package/src/devices/meters.ts +28 -5
- package/src/devices/motion.ts +26 -5
- package/src/devices/plugs.ts +21 -5
- package/src/irdevices/airconditioners.ts +301 -160
- package/src/irdevices/airpurifiers.ts +8 -4
- package/src/irdevices/cameras.ts +5 -4
- package/src/irdevices/fans.ts +7 -4
- package/src/irdevices/lights.ts +5 -4
- package/src/irdevices/others.ts +4 -3
- package/src/irdevices/tvs.ts +6 -4
- package/src/irdevices/vacuumcleaners.ts +5 -4
- package/src/irdevices/waterheaters.ts +5 -4
package/src/devices/meters.ts
CHANGED
|
@@ -2,7 +2,7 @@ import Switchbot from 'node-switchbot';
|
|
|
2
2
|
import { interval, Subject } from 'rxjs';
|
|
3
3
|
import { skipWhile } from 'rxjs/operators';
|
|
4
4
|
import { SwitchBotPlatform } from '../platform';
|
|
5
|
-
import { Service, PlatformAccessory, Units, CharacteristicValue
|
|
5
|
+
import { Service, PlatformAccessory, Units, CharacteristicValue } from 'homebridge';
|
|
6
6
|
import { DeviceURL, device, devicesConfig, serviceData, ad, switchbot, deviceStatusResponse, temperature } from '../settings';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -183,18 +183,33 @@ export class Meter {
|
|
|
183
183
|
refreshRate() {
|
|
184
184
|
if (this.device.refreshRate) {
|
|
185
185
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
|
|
186
|
+
if (this.platform.debugMode) {
|
|
187
|
+
this.warnLog(`Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
188
|
+
}
|
|
186
189
|
} else if (this.platform.config.options!.refreshRate) {
|
|
187
190
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
191
|
+
if (this.platform.debugMode) {
|
|
192
|
+
this.warnLog(`Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
193
|
+
}
|
|
188
194
|
}
|
|
189
195
|
}
|
|
190
196
|
|
|
191
197
|
logs() {
|
|
192
198
|
if (this.device.logging) {
|
|
193
199
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
200
|
+
if (this.platform.debugMode) {
|
|
201
|
+
this.warnLog(`Using Device Config Logging: ${this.deviceLogging}`);
|
|
202
|
+
}
|
|
194
203
|
} else if (this.platform.config.options?.logging) {
|
|
195
204
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
205
|
+
if (this.platform.debugMode) {
|
|
206
|
+
this.warnLog(`Using Platform Config Logging: ${this.deviceLogging}`);
|
|
207
|
+
}
|
|
196
208
|
} else {
|
|
197
209
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
210
|
+
if (this.platform.debugMode) {
|
|
211
|
+
this.warnLog('Using Device Standard Logging');
|
|
212
|
+
}
|
|
198
213
|
}
|
|
199
214
|
}
|
|
200
215
|
|
|
@@ -343,7 +358,7 @@ export class Meter {
|
|
|
343
358
|
this.warnLog(`Meter: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
344
359
|
this.openAPIRefreshStatus();
|
|
345
360
|
}
|
|
346
|
-
this.apiError();
|
|
361
|
+
this.apiError(e);
|
|
347
362
|
});
|
|
348
363
|
}
|
|
349
364
|
|
|
@@ -371,7 +386,7 @@ export class Meter {
|
|
|
371
386
|
this.errorLog(`Meter: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
372
387
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
373
388
|
}
|
|
374
|
-
this.apiError();
|
|
389
|
+
this.apiError(e);
|
|
375
390
|
}
|
|
376
391
|
}
|
|
377
392
|
}
|
|
@@ -410,8 +425,16 @@ export class Meter {
|
|
|
410
425
|
}
|
|
411
426
|
}
|
|
412
427
|
|
|
413
|
-
public apiError() {
|
|
414
|
-
|
|
428
|
+
public apiError(e: any) {
|
|
429
|
+
this.service.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
430
|
+
this.service.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
|
|
431
|
+
if (!this.device.meter?.hide_humidity) {
|
|
432
|
+
this.humidityservice?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, e);
|
|
433
|
+
}
|
|
434
|
+
if (!this.device.meter?.hide_temperature) {
|
|
435
|
+
this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
|
|
436
|
+
}
|
|
437
|
+
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
415
438
|
}
|
|
416
439
|
|
|
417
440
|
/**
|
package/src/devices/motion.ts
CHANGED
|
@@ -2,7 +2,7 @@ import Switchbot from 'node-switchbot';
|
|
|
2
2
|
import { interval, Subject } from 'rxjs';
|
|
3
3
|
import { skipWhile } from 'rxjs/operators';
|
|
4
4
|
import { SwitchBotPlatform } from '../platform';
|
|
5
|
-
import { Service, PlatformAccessory, CharacteristicValue
|
|
5
|
+
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
6
6
|
import { DeviceURL, device, devicesConfig, serviceData, switchbot, deviceStatusResponse } from '../settings';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -114,18 +114,33 @@ export class Motion {
|
|
|
114
114
|
refreshRate() {
|
|
115
115
|
if (this.device.refreshRate) {
|
|
116
116
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
|
|
117
|
+
if (this.platform.debugMode) {
|
|
118
|
+
this.warnLog(`Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
119
|
+
}
|
|
117
120
|
} else if (this.platform.config.options!.refreshRate) {
|
|
118
121
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
122
|
+
if (this.platform.debugMode) {
|
|
123
|
+
this.warnLog(`Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
124
|
+
}
|
|
119
125
|
}
|
|
120
126
|
}
|
|
121
127
|
|
|
122
128
|
logs() {
|
|
123
129
|
if (this.device.logging) {
|
|
124
130
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
131
|
+
if (this.platform.debugMode) {
|
|
132
|
+
this.warnLog(`Using Device Config Logging: ${this.deviceLogging}`);
|
|
133
|
+
}
|
|
125
134
|
} else if (this.platform.config.options?.logging) {
|
|
126
135
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
136
|
+
if (this.platform.debugMode) {
|
|
137
|
+
this.warnLog(`Using Platform Config Logging: ${this.deviceLogging}`);
|
|
138
|
+
}
|
|
127
139
|
} else {
|
|
128
140
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
141
|
+
if (this.platform.debugMode) {
|
|
142
|
+
this.warnLog('Using Device Standard Logging');
|
|
143
|
+
}
|
|
129
144
|
}
|
|
130
145
|
}
|
|
131
146
|
|
|
@@ -244,7 +259,7 @@ export class Motion {
|
|
|
244
259
|
this.warnLog(`Motion Sensor: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
245
260
|
await this.openAPIRefreshStatus();
|
|
246
261
|
}
|
|
247
|
-
this.apiError();
|
|
262
|
+
this.apiError(e);
|
|
248
263
|
});
|
|
249
264
|
}
|
|
250
265
|
|
|
@@ -266,7 +281,7 @@ export class Motion {
|
|
|
266
281
|
this.errorLog(`Motion Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
267
282
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
268
283
|
}
|
|
269
|
-
this.apiError();
|
|
284
|
+
this.apiError(e);
|
|
270
285
|
}
|
|
271
286
|
}
|
|
272
287
|
}
|
|
@@ -304,8 +319,14 @@ export class Motion {
|
|
|
304
319
|
}
|
|
305
320
|
}
|
|
306
321
|
|
|
307
|
-
public apiError() {
|
|
308
|
-
|
|
322
|
+
public apiError(e: any) {
|
|
323
|
+
this.service.updateCharacteristic(this.platform.Characteristic.MotionDetected, e);
|
|
324
|
+
if (this.device.ble) {
|
|
325
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
|
|
326
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
327
|
+
this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e);
|
|
328
|
+
}
|
|
329
|
+
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
309
330
|
}
|
|
310
331
|
|
|
311
332
|
/**
|
package/src/devices/plugs.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { AxiosResponse } from 'axios';
|
|
|
3
3
|
import { interval, Subject } from 'rxjs';
|
|
4
4
|
import { SwitchBotPlatform } from '../platform';
|
|
5
5
|
import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
|
|
6
|
-
import { Service, PlatformAccessory, CharacteristicValue
|
|
6
|
+
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
7
7
|
import { DeviceURL, device, devicesConfig, deviceStatusResponse, payload } from '../settings';
|
|
8
8
|
|
|
9
9
|
export class Plug {
|
|
@@ -108,7 +108,7 @@ export class Plug {
|
|
|
108
108
|
this.errorLog(`Plug: ${this.accessory.displayName} failed pushChanges,`
|
|
109
109
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
110
110
|
}
|
|
111
|
-
this.apiError();
|
|
111
|
+
this.apiError(e);
|
|
112
112
|
}
|
|
113
113
|
this.plugUpdateInProgress = false;
|
|
114
114
|
});
|
|
@@ -117,18 +117,33 @@ export class Plug {
|
|
|
117
117
|
refreshRate() {
|
|
118
118
|
if (this.device.refreshRate) {
|
|
119
119
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
|
|
120
|
+
if (this.platform.debugMode) {
|
|
121
|
+
this.warnLog(`Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
122
|
+
}
|
|
120
123
|
} else if (this.platform.config.options!.refreshRate) {
|
|
121
124
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
125
|
+
if (this.platform.debugMode) {
|
|
126
|
+
this.warnLog(`Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
127
|
+
}
|
|
122
128
|
}
|
|
123
129
|
}
|
|
124
130
|
|
|
125
131
|
logs() {
|
|
126
132
|
if (this.device.logging) {
|
|
127
133
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
134
|
+
if (this.platform.debugMode) {
|
|
135
|
+
this.warnLog(`Using Device Config Logging: ${this.deviceLogging}`);
|
|
136
|
+
}
|
|
128
137
|
} else if (this.platform.config.options?.logging) {
|
|
129
138
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
139
|
+
if (this.platform.debugMode) {
|
|
140
|
+
this.warnLog(`Using Platform Config Logging: ${this.deviceLogging}`);
|
|
141
|
+
}
|
|
130
142
|
} else {
|
|
131
143
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
144
|
+
if (this.platform.debugMode) {
|
|
145
|
+
this.warnLog('Using Device Standard Logging');
|
|
146
|
+
}
|
|
132
147
|
}
|
|
133
148
|
}
|
|
134
149
|
|
|
@@ -159,7 +174,7 @@ export class Plug {
|
|
|
159
174
|
this.errorLog(`Plug: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
160
175
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
161
176
|
}
|
|
162
|
-
this.apiError();
|
|
177
|
+
this.apiError(e);
|
|
163
178
|
}
|
|
164
179
|
}
|
|
165
180
|
|
|
@@ -209,8 +224,9 @@ export class Plug {
|
|
|
209
224
|
}
|
|
210
225
|
}
|
|
211
226
|
|
|
212
|
-
public apiError() {
|
|
213
|
-
|
|
227
|
+
public apiError(e: any) {
|
|
228
|
+
this.service.updateCharacteristic(this.platform.Characteristic.On, e);
|
|
229
|
+
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
214
230
|
}
|
|
215
231
|
|
|
216
232
|
private statusCode(push: AxiosResponse<{ statusCode: number; }>) {
|