@switchbot/homebridge-switchbot 2.2.2-beta.2 → 2.2.2-beta.21
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 +9 -0
- package/config.schema.json +0 -31
- package/dist/device/bot.d.ts +1 -3
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +2 -2
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +1 -3
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +5 -5
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +1 -3
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +7 -7
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +1 -3
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +1 -1
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.js +1 -1
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.d.ts +7 -9
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +16 -10
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/lock.js +1 -1
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +1 -3
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +1 -1
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +1 -3
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +1 -1
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +2 -3
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +17 -11
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +1 -3
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +2 -2
- package/dist/device/plug.js.map +1 -1
- package/dist/device/striplight.d.ts +8 -3
- package/dist/device/striplight.d.ts.map +1 -1
- package/dist/device/striplight.js +151 -132
- package/dist/device/striplight.js.map +1 -1
- package/dist/irdevice/airconditioner.js +2 -2
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.js +2 -2
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.js +2 -2
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.js +2 -2
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.js +2 -2
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.js +2 -2
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +18 -15
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +2 -2
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.js +2 -2
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/settings.d.ts +1 -16
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +1 -1
- package/src/device/bot.ts +2 -2
- package/src/device/ceilinglight.ts +5 -5
- package/src/device/colorbulb.ts +7 -7
- package/src/device/contact.ts +1 -1
- package/src/device/curtain.ts +1 -1
- package/src/device/humidifier.ts +14 -10
- package/src/device/lock.ts +1 -1
- package/src/device/meter.ts +1 -1
- package/src/device/meterplus.ts +1 -1
- package/src/device/motion.ts +18 -11
- package/src/device/plug.ts +2 -2
- package/src/device/striplight.ts +148 -127
- package/src/irdevice/airconditioner.ts +2 -2
- package/src/irdevice/airpurifier.ts +2 -2
- package/src/irdevice/camera.ts +2 -2
- package/src/irdevice/fan.ts +2 -2
- package/src/irdevice/light.ts +2 -2
- package/src/irdevice/other.ts +2 -2
- package/src/irdevice/tv.ts +14 -12
- package/src/irdevice/vacuumcleaner.ts +2 -2
- package/src/irdevice/waterheater.ts +2 -2
- package/src/settings.ts +1 -23
package/src/device/colorbulb.ts
CHANGED
|
@@ -392,7 +392,7 @@ export class ColorBulb {
|
|
|
392
392
|
if (this.serviceData) {
|
|
393
393
|
this.connected = true;
|
|
394
394
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
395
|
-
await this.stopScanning(
|
|
395
|
+
await this.stopScanning(switchbot);
|
|
396
396
|
} else {
|
|
397
397
|
this.connected = false;
|
|
398
398
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
@@ -403,7 +403,7 @@ export class ColorBulb {
|
|
|
403
403
|
})
|
|
404
404
|
.then(async () => {
|
|
405
405
|
// Stop to monitor
|
|
406
|
-
await this.stopScanning(
|
|
406
|
+
await this.stopScanning(switchbot);
|
|
407
407
|
})
|
|
408
408
|
.catch(async (e: any) => {
|
|
409
409
|
this.apiError(e);
|
|
@@ -689,7 +689,7 @@ export class ColorBulb {
|
|
|
689
689
|
'parameter': 'default',
|
|
690
690
|
'commandType': 'command',
|
|
691
691
|
});
|
|
692
|
-
this.
|
|
692
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
|
|
693
693
|
const options = {
|
|
694
694
|
hostname: HostDomain,
|
|
695
695
|
port: 443,
|
|
@@ -766,7 +766,7 @@ export class ColorBulb {
|
|
|
766
766
|
'parameter': `${red}:${green}:${blue}`,
|
|
767
767
|
'commandType': 'command',
|
|
768
768
|
});
|
|
769
|
-
this.
|
|
769
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
|
|
770
770
|
const options = {
|
|
771
771
|
hostname: HostDomain,
|
|
772
772
|
port: 443,
|
|
@@ -825,7 +825,7 @@ export class ColorBulb {
|
|
|
825
825
|
'parameter': `${kelvin}`,
|
|
826
826
|
'commandType': 'command',
|
|
827
827
|
});
|
|
828
|
-
this.
|
|
828
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
|
|
829
829
|
const options = {
|
|
830
830
|
hostname: HostDomain,
|
|
831
831
|
port: 443,
|
|
@@ -882,7 +882,7 @@ export class ColorBulb {
|
|
|
882
882
|
'parameter': `${this.Brightness}`,
|
|
883
883
|
'commandType': 'command',
|
|
884
884
|
});
|
|
885
|
-
this.
|
|
885
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
|
|
886
886
|
const options = {
|
|
887
887
|
hostname: HostDomain,
|
|
888
888
|
port: 443,
|
|
@@ -1065,7 +1065,7 @@ export class ColorBulb {
|
|
|
1065
1065
|
}
|
|
1066
1066
|
}
|
|
1067
1067
|
|
|
1068
|
-
async stopScanning(
|
|
1068
|
+
async stopScanning(switchbot: any) {
|
|
1069
1069
|
await switchbot.stopScan();
|
|
1070
1070
|
if (this.connected) {
|
|
1071
1071
|
await this.BLEparseStatus();
|
package/src/device/contact.ts
CHANGED
package/src/device/curtain.ts
CHANGED
|
@@ -617,7 +617,7 @@ export class Curtain {
|
|
|
617
617
|
'parameter': `0,${adjustedMode},${adjustedTargetPosition}`,
|
|
618
618
|
'commandType': 'command',
|
|
619
619
|
});
|
|
620
|
-
this.
|
|
620
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
|
|
621
621
|
const options = {
|
|
622
622
|
hostname: HostDomain,
|
|
623
623
|
port: 443,
|
package/src/device/humidifier.ts
CHANGED
|
@@ -484,7 +484,7 @@ export class Humidifier {
|
|
|
484
484
|
'parameter': `${this.RelativeHumidityHumidifierThreshold}`,
|
|
485
485
|
'commandType': 'command',
|
|
486
486
|
});
|
|
487
|
-
this.
|
|
487
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
|
|
488
488
|
const options = {
|
|
489
489
|
hostname: HostDomain,
|
|
490
490
|
port: 443,
|
|
@@ -552,7 +552,7 @@ export class Humidifier {
|
|
|
552
552
|
'parameter': 'auto',
|
|
553
553
|
'commandType': 'command',
|
|
554
554
|
});
|
|
555
|
-
this.
|
|
555
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
|
|
556
556
|
const options = {
|
|
557
557
|
hostname: HostDomain,
|
|
558
558
|
port: 443,
|
|
@@ -613,7 +613,7 @@ export class Humidifier {
|
|
|
613
613
|
'parameter': 'default',
|
|
614
614
|
'commandType': 'command',
|
|
615
615
|
});
|
|
616
|
-
this.
|
|
616
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
|
|
617
617
|
const options = {
|
|
618
618
|
hostname: HostDomain,
|
|
619
619
|
port: 443,
|
|
@@ -765,7 +765,7 @@ export class Humidifier {
|
|
|
765
765
|
}
|
|
766
766
|
}
|
|
767
767
|
|
|
768
|
-
async stopScanning(
|
|
768
|
+
async stopScanning(switchbot: any) {
|
|
769
769
|
await switchbot.stopScan();
|
|
770
770
|
if (this.connected) {
|
|
771
771
|
await this.BLEparseStatus();
|
|
@@ -923,11 +923,15 @@ export class Humidifier {
|
|
|
923
923
|
}
|
|
924
924
|
if (this.TargetHumidifierDehumidifierState === undefined) {
|
|
925
925
|
this.TargetHumidifierDehumidifierState = this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
|
|
926
|
+
} else if (this.accessory.context.TargetHumidifierDehumidifierState === undefined) {
|
|
927
|
+
this.TargetHumidifierDehumidifierState = this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
|
|
926
928
|
} else {
|
|
927
929
|
this.TargetHumidifierDehumidifierState = this.accessory.context.TargetHumidifierDehumidifierState;
|
|
928
930
|
}
|
|
929
931
|
if (this.CurrentHumidifierDehumidifierState === undefined) {
|
|
930
932
|
this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
|
|
933
|
+
} else if (this.accessory.context.CurrentHumidifierDehumidifierState === undefined) {
|
|
934
|
+
this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
|
|
931
935
|
} else {
|
|
932
936
|
this.CurrentHumidifierDehumidifierState = this.accessory.context.CurrentHumidifierDehumidifierState;
|
|
933
937
|
}
|
|
@@ -1000,19 +1004,19 @@ export class Humidifier {
|
|
|
1000
1004
|
/**
|
|
1001
1005
|
* Logging for Device
|
|
1002
1006
|
*/
|
|
1003
|
-
infoLog(...log: any[]): void {
|
|
1007
|
+
async infoLog(...log: any[]): Promise<void> {
|
|
1004
1008
|
if (this.enablingDeviceLogging()) {
|
|
1005
1009
|
this.platform.log.info(String(...log));
|
|
1006
1010
|
}
|
|
1007
1011
|
}
|
|
1008
1012
|
|
|
1009
|
-
warnLog(...log: any[]): void {
|
|
1013
|
+
async warnLog(...log: any[]): Promise<void> {
|
|
1010
1014
|
if (this.enablingDeviceLogging()) {
|
|
1011
1015
|
this.platform.log.warn(String(...log));
|
|
1012
1016
|
}
|
|
1013
1017
|
}
|
|
1014
1018
|
|
|
1015
|
-
debugWarnLog(...log: any[]): void {
|
|
1019
|
+
async debugWarnLog(...log: any[]): Promise<void> {
|
|
1016
1020
|
if (this.enablingDeviceLogging()) {
|
|
1017
1021
|
if (this.deviceLogging?.includes('debug')) {
|
|
1018
1022
|
this.platform.log.warn('[DEBUG]', String(...log));
|
|
@@ -1020,13 +1024,13 @@ export class Humidifier {
|
|
|
1020
1024
|
}
|
|
1021
1025
|
}
|
|
1022
1026
|
|
|
1023
|
-
errorLog(...log: any[]): void {
|
|
1027
|
+
async errorLog(...log: any[]): Promise<void> {
|
|
1024
1028
|
if (this.enablingDeviceLogging()) {
|
|
1025
1029
|
this.platform.log.error(String(...log));
|
|
1026
1030
|
}
|
|
1027
1031
|
}
|
|
1028
1032
|
|
|
1029
|
-
debugErrorLog(...log: any[]): void {
|
|
1033
|
+
async debugErrorLog(...log: any[]): Promise<void> {
|
|
1030
1034
|
if (this.enablingDeviceLogging()) {
|
|
1031
1035
|
if (this.deviceLogging?.includes('debug')) {
|
|
1032
1036
|
this.platform.log.error('[DEBUG]', String(...log));
|
|
@@ -1034,7 +1038,7 @@ export class Humidifier {
|
|
|
1034
1038
|
}
|
|
1035
1039
|
}
|
|
1036
1040
|
|
|
1037
|
-
debugLog(...log: any[]): void {
|
|
1041
|
+
async debugLog(...log: any[]): Promise<void> {
|
|
1038
1042
|
if (this.enablingDeviceLogging()) {
|
|
1039
1043
|
if (this.deviceLogging === 'debug') {
|
|
1040
1044
|
this.platform.log.info('[DEBUG]', String(...log));
|
package/src/device/lock.ts
CHANGED
|
@@ -408,7 +408,7 @@ export class Lock {
|
|
|
408
408
|
'parameter': 'default',
|
|
409
409
|
'commandType': 'command',
|
|
410
410
|
});
|
|
411
|
-
this.
|
|
411
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
|
|
412
412
|
const options = {
|
|
413
413
|
hostname: HostDomain,
|
|
414
414
|
port: 443,
|
package/src/device/meter.ts
CHANGED
package/src/device/meterplus.ts
CHANGED
|
@@ -487,7 +487,7 @@ export class MeterPlus {
|
|
|
487
487
|
: null;
|
|
488
488
|
}
|
|
489
489
|
|
|
490
|
-
async stopScanning(
|
|
490
|
+
async stopScanning(switchbot: any) {
|
|
491
491
|
await switchbot.stopScan();
|
|
492
492
|
if (this.connected) {
|
|
493
493
|
await this.BLEparseStatus();
|
package/src/device/motion.ts
CHANGED
|
@@ -44,6 +44,7 @@ export class Motion {
|
|
|
44
44
|
led!: any;
|
|
45
45
|
iot!: any;
|
|
46
46
|
sense_distance!: any;
|
|
47
|
+
scanning!: boolean;
|
|
47
48
|
|
|
48
49
|
// Config
|
|
49
50
|
set_minLux!: number;
|
|
@@ -255,6 +256,7 @@ export class Motion {
|
|
|
255
256
|
})
|
|
256
257
|
.then(async () => {
|
|
257
258
|
// Set an event hander
|
|
259
|
+
this.scanning = true;
|
|
258
260
|
switchbot.onadvertisement = async (ad: any) => {
|
|
259
261
|
this.address = ad.address;
|
|
260
262
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},`
|
|
@@ -278,6 +280,8 @@ export class Motion {
|
|
|
278
280
|
this.connected = true;
|
|
279
281
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
280
282
|
await this.stopScanning(switchbot);
|
|
283
|
+
this.scanning = false;
|
|
284
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} scanning: ${this.scanning}`);
|
|
281
285
|
} else {
|
|
282
286
|
this.connected = false;
|
|
283
287
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
@@ -288,7 +292,10 @@ export class Motion {
|
|
|
288
292
|
})
|
|
289
293
|
.then(async () => {
|
|
290
294
|
// Stop to monitor
|
|
291
|
-
|
|
295
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} scanning: ${this.scanning}`);
|
|
296
|
+
if (this.scanning) {
|
|
297
|
+
await this.stopScanning(switchbot);
|
|
298
|
+
}
|
|
292
299
|
})
|
|
293
300
|
.catch(async (e: any) => {
|
|
294
301
|
this.apiError(e);
|
|
@@ -301,6 +308,16 @@ export class Motion {
|
|
|
301
308
|
}
|
|
302
309
|
}
|
|
303
310
|
|
|
311
|
+
async stopScanning(switchbot: any) {
|
|
312
|
+
await switchbot.stopScan();
|
|
313
|
+
if (this.connected) {
|
|
314
|
+
await this.BLEparseStatus();
|
|
315
|
+
await this.updateHomeKitCharacteristics();
|
|
316
|
+
} else {
|
|
317
|
+
await this.BLERefreshConnection(switchbot);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
304
321
|
async openAPIRefreshStatus(): Promise<void> {
|
|
305
322
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
|
|
306
323
|
try {
|
|
@@ -394,16 +411,6 @@ export class Motion {
|
|
|
394
411
|
}
|
|
395
412
|
}
|
|
396
413
|
|
|
397
|
-
async stopScanning({ switchbot }: { switchbot: any; }): Promise<void> {
|
|
398
|
-
await await switchbot.stopScan();
|
|
399
|
-
if (this.connected) {
|
|
400
|
-
await this.BLEparseStatus();
|
|
401
|
-
await this.updateHomeKitCharacteristics();
|
|
402
|
-
} else {
|
|
403
|
-
await this.BLERefreshConnection(switchbot);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
|
|
407
414
|
async getCustomBLEAddress(switchbot: any) {
|
|
408
415
|
if (this.device.customBLEaddress && this.deviceLogging.includes('debug')) {
|
|
409
416
|
(async () => {
|
package/src/device/plug.ts
CHANGED
|
@@ -392,7 +392,7 @@ export class Plug {
|
|
|
392
392
|
'parameter': 'default',
|
|
393
393
|
'commandType': 'command',
|
|
394
394
|
});
|
|
395
|
-
this.
|
|
395
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
|
|
396
396
|
const options = {
|
|
397
397
|
hostname: HostDomain,
|
|
398
398
|
port: 443,
|
|
@@ -458,7 +458,7 @@ export class Plug {
|
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
460
|
|
|
461
|
-
async stopScanning(
|
|
461
|
+
async stopScanning(switchbot: any) {
|
|
462
462
|
await switchbot.stopScan();
|
|
463
463
|
if (this.connected) {
|
|
464
464
|
await this.BLEparseStatus();
|