@switchbot/homebridge-switchbot 2.8.0-beta.0 → 2.8.0-beta.10
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/.prettierrc +1 -1
- package/.vscode/settings.json +1 -1
- package/CHANGELOG.md +10 -0
- package/config.schema.json +8 -0
- package/dist/device/blindtilt.d.ts +1 -0
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +58 -65
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +1 -0
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +52 -55
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +1 -0
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +68 -68
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +1 -0
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +76 -75
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +2 -0
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +67 -59
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +2 -0
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +81 -94
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +9 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +197 -30
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +58 -62
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +1 -0
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +28 -26
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +1 -0
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +68 -67
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +2 -0
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +51 -47
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +5 -3
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +75 -74
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +4 -3
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +74 -74
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +2 -0
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +66 -54
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +1 -0
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +39 -39
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +1 -0
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +74 -53
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +64 -66
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +32 -34
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +20 -23
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +2 -2
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +30 -32
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +26 -29
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +22 -23
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +2 -2
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +47 -50
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +20 -23
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +22 -23
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +46 -44
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +1 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/device/blindtilt.ts +114 -78
- package/src/device/bot.ts +102 -63
- package/src/device/ceilinglight.ts +113 -73
- package/src/device/colorbulb.ts +144 -87
- package/src/device/contact.ts +98 -63
- package/src/device/curtain.ts +160 -134
- package/src/device/hub.ts +228 -39
- package/src/device/humidifier.ts +136 -85
- package/src/device/iosensor.ts +52 -32
- package/src/device/lightstrip.ts +118 -72
- package/src/device/lock.ts +85 -50
- package/src/device/meter.ts +104 -80
- package/src/device/meterplus.ts +103 -80
- package/src/device/motion.ts +95 -59
- package/src/device/plug.ts +70 -44
- package/src/device/robotvacuumcleaner.ts +107 -56
- package/src/irdevice/airconditioner.ts +116 -86
- package/src/irdevice/airpurifier.ts +60 -39
- package/src/irdevice/camera.ts +40 -28
- package/src/irdevice/fan.ts +52 -38
- package/src/irdevice/light.ts +48 -34
- package/src/irdevice/other.ts +44 -28
- package/src/irdevice/tv.ts +70 -56
- package/src/irdevice/vacuumcleaner.ts +40 -28
- package/src/irdevice/waterheater.ts +48 -32
- package/src/platform.ts +87 -56
- package/src/settings.ts +41 -40
- package/src/utils.ts +1 -1
package/src/device/bot.ts
CHANGED
|
@@ -32,6 +32,7 @@ export class Bot {
|
|
|
32
32
|
StatusLowBattery!: CharacteristicValue;
|
|
33
33
|
|
|
34
34
|
// OpenAPI Others
|
|
35
|
+
Version: deviceStatus['version'];
|
|
35
36
|
power: deviceStatus['power'];
|
|
36
37
|
deviceStatus!: any; //deviceStatusResponse;
|
|
37
38
|
|
|
@@ -60,19 +61,23 @@ export class Bot {
|
|
|
60
61
|
doBotUpdate!: Subject<void>;
|
|
61
62
|
|
|
62
63
|
// Connection
|
|
63
|
-
private readonly BLE =
|
|
64
|
-
private readonly OpenAPI =
|
|
65
|
-
|
|
66
|
-
constructor(
|
|
64
|
+
private readonly BLE = this.device.connectionType === 'BLE' || this.device.connectionType === 'BLE/OpenAPI';
|
|
65
|
+
private readonly OpenAPI = this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI';
|
|
66
|
+
|
|
67
|
+
constructor(
|
|
68
|
+
private readonly platform: SwitchBotPlatform,
|
|
69
|
+
private accessory: PlatformAccessory,
|
|
70
|
+
public device: device & devicesConfig,
|
|
71
|
+
) {
|
|
67
72
|
// default placeholders
|
|
68
73
|
this.logs(device);
|
|
69
74
|
this.scan(device);
|
|
70
75
|
this.refreshRate(device);
|
|
71
76
|
this.PressOrSwitch(device);
|
|
72
77
|
this.allowPushChanges(device);
|
|
73
|
-
this.config(device);
|
|
74
78
|
this.context();
|
|
75
79
|
this.DoublePress(device);
|
|
80
|
+
this.config(device);
|
|
76
81
|
|
|
77
82
|
this.multiPressCount = 0;
|
|
78
83
|
|
|
@@ -111,7 +116,6 @@ export class Bot {
|
|
|
111
116
|
`${accessory.displayName} Switch`;
|
|
112
117
|
this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Switch`);
|
|
113
118
|
|
|
114
|
-
|
|
115
119
|
this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
116
120
|
if (!this.switchService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
117
121
|
this.switchService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
@@ -392,8 +396,10 @@ export class Bot {
|
|
|
392
396
|
}
|
|
393
397
|
} catch (e: any) {
|
|
394
398
|
this.apiError(e);
|
|
395
|
-
this.errorLog(
|
|
396
|
-
|
|
399
|
+
this.errorLog(
|
|
400
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,` +
|
|
401
|
+
` Error Message: ${JSON.stringify(e.message)}`,
|
|
402
|
+
);
|
|
397
403
|
}
|
|
398
404
|
this.botUpdateInProgress = false;
|
|
399
405
|
});
|
|
@@ -411,8 +417,9 @@ export class Bot {
|
|
|
411
417
|
await this.openAPIparseStatus();
|
|
412
418
|
} else {
|
|
413
419
|
await this.offlineOff();
|
|
414
|
-
this.debugWarnLog(
|
|
415
|
-
+ ` ${this.device.connectionType}, parseStatus will not happen
|
|
420
|
+
this.debugWarnLog(
|
|
421
|
+
`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` + ` ${this.device.connectionType}, parseStatus will not happen.`,
|
|
422
|
+
);
|
|
416
423
|
}
|
|
417
424
|
}
|
|
418
425
|
|
|
@@ -469,8 +476,10 @@ export class Bot {
|
|
|
469
476
|
await this.openAPIRefreshStatus();
|
|
470
477
|
} else {
|
|
471
478
|
await this.offlineOff();
|
|
472
|
-
this.debugWarnLog(
|
|
473
|
-
|
|
479
|
+
this.debugWarnLog(
|
|
480
|
+
`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` +
|
|
481
|
+
` ${this.device.connectionType}, refreshStatus will not happen.`,
|
|
482
|
+
);
|
|
474
483
|
}
|
|
475
484
|
}
|
|
476
485
|
|
|
@@ -495,15 +504,19 @@ export class Bot {
|
|
|
495
504
|
// Set an event hander
|
|
496
505
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
497
506
|
this.address = ad.address;
|
|
498
|
-
this.debugLog(
|
|
499
|
-
|
|
507
|
+
this.debugLog(
|
|
508
|
+
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
|
509
|
+
` BLE Address Found: ${this.address}`,
|
|
510
|
+
);
|
|
500
511
|
this.serviceData = ad.serviceData;
|
|
501
512
|
this.mode = ad.serviceData.mode;
|
|
502
513
|
this.state = ad.serviceData.state;
|
|
503
514
|
this.battery = ad.serviceData.battery;
|
|
504
515
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
|
|
505
|
-
this.debugLog(
|
|
506
|
-
|
|
516
|
+
this.debugLog(
|
|
517
|
+
`${this.device.deviceType}: ${this.accessory.displayName}, model: ${ad.serviceData.model}, modelName: ` +
|
|
518
|
+
`${ad.serviceData.modelName}, mode: ${ad.serviceData.mode}, state: ${ad.serviceData.state}, battery: ${ad.serviceData.battery}`,
|
|
519
|
+
);
|
|
507
520
|
|
|
508
521
|
if (this.serviceData) {
|
|
509
522
|
this.connected = true;
|
|
@@ -523,8 +536,10 @@ export class Bot {
|
|
|
523
536
|
})
|
|
524
537
|
.catch(async (e: any) => {
|
|
525
538
|
this.apiError(e);
|
|
526
|
-
this.errorLog(
|
|
527
|
-
|
|
539
|
+
this.errorLog(
|
|
540
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed BLERefreshStatus with ${this.device.connectionType}` +
|
|
541
|
+
` Connection, Error Message: ${JSON.stringify(e.message)}`,
|
|
542
|
+
);
|
|
528
543
|
await this.BLERefreshConnection(switchbot);
|
|
529
544
|
});
|
|
530
545
|
} else {
|
|
@@ -542,17 +557,16 @@ export class Bot {
|
|
|
542
557
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
|
|
543
558
|
this.statusCode(statusCode);
|
|
544
559
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
|
|
545
|
-
this.debugLog(
|
|
546
|
-
`${this.device.deviceType}: ${this.accessory.displayName
|
|
547
|
-
} refreshStatus: ${JSON.stringify(deviceStatus)}`,
|
|
548
|
-
);
|
|
560
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
|
|
549
561
|
this.power = deviceStatus.body.power;
|
|
550
562
|
this.openAPIparseStatus();
|
|
551
563
|
this.updateHomeKitCharacteristics();
|
|
552
564
|
} catch (e: any) {
|
|
553
565
|
this.apiError(e);
|
|
554
|
-
this.errorLog(
|
|
555
|
-
|
|
566
|
+
this.errorLog(
|
|
567
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}` +
|
|
568
|
+
` Connection, Error Message: ${JSON.stringify(e.message)}`,
|
|
569
|
+
);
|
|
556
570
|
}
|
|
557
571
|
}
|
|
558
572
|
|
|
@@ -572,8 +586,9 @@ export class Bot {
|
|
|
572
586
|
await this.openAPIpushChanges();
|
|
573
587
|
} else {
|
|
574
588
|
await this.offlineOff();
|
|
575
|
-
this.debugWarnLog(
|
|
576
|
-
+ ` ${this.device.connectionType}, pushChanges will not happen
|
|
589
|
+
this.debugWarnLog(
|
|
590
|
+
`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` + ` ${this.device.connectionType}, pushChanges will not happen.`,
|
|
591
|
+
);
|
|
577
592
|
}
|
|
578
593
|
// Refresh the status from the API
|
|
579
594
|
interval(15000)
|
|
@@ -618,8 +633,10 @@ export class Bot {
|
|
|
618
633
|
})
|
|
619
634
|
.catch(async (e: any) => {
|
|
620
635
|
this.apiError(e);
|
|
621
|
-
this.errorLog(
|
|
622
|
-
|
|
636
|
+
this.errorLog(
|
|
637
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushChanges with ${this.device.connectionType}` +
|
|
638
|
+
` Connection & botMode: ${this.botMode}, Error Message: ${JSON.stringify(e.message)}`,
|
|
639
|
+
);
|
|
623
640
|
await this.BLEPushConnection();
|
|
624
641
|
});
|
|
625
642
|
} else if (this.botMode === 'switch') {
|
|
@@ -645,16 +662,19 @@ export class Bot {
|
|
|
645
662
|
})
|
|
646
663
|
.catch(async (e: any) => {
|
|
647
664
|
this.apiError(e);
|
|
648
|
-
this.errorLog(
|
|
649
|
-
|
|
665
|
+
this.errorLog(
|
|
666
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushChanges with ${this.device.connectionType}` +
|
|
667
|
+
` Connection & botMode: ${this.botMode}, Error Message: ${JSON.stringify(e.message)}`,
|
|
668
|
+
);
|
|
650
669
|
await this.BLEPushConnection();
|
|
651
670
|
});
|
|
652
671
|
} else {
|
|
653
672
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
|
|
654
673
|
}
|
|
655
674
|
} else {
|
|
656
|
-
this.debugLog(
|
|
657
|
-
+ `OnCached: ${this.accessory.context.On}
|
|
675
|
+
this.debugLog(
|
|
676
|
+
`${this.device.deviceType}: ${this.accessory.displayName} No BLEpushChanges.` + `On: ${this.On}, ` + `OnCached: ${this.accessory.context.On}`,
|
|
677
|
+
);
|
|
658
678
|
}
|
|
659
679
|
}
|
|
660
680
|
|
|
@@ -664,7 +684,7 @@ export class Bot {
|
|
|
664
684
|
this.debugLog(`${this.device.deviceType}: ${this.multiPressCount} request(s) queued.`);
|
|
665
685
|
this.On = true;
|
|
666
686
|
}
|
|
667
|
-
if (
|
|
687
|
+
if (this.On !== this.accessory.context.On || this.allowPush || this.multiPressCount > 0) {
|
|
668
688
|
let command = '';
|
|
669
689
|
if (this.botMode === 'switch' && this.On) {
|
|
670
690
|
command = 'turnOn';
|
|
@@ -682,9 +702,9 @@ export class Bot {
|
|
|
682
702
|
throw new Error(`${this.device.deviceType}: ${this.accessory.displayName} Device Paramters not set for this Bot.`);
|
|
683
703
|
}
|
|
684
704
|
const bodyChange = JSON.stringify({
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
705
|
+
command: `${command}`,
|
|
706
|
+
parameter: 'default',
|
|
707
|
+
commandType: 'command',
|
|
688
708
|
});
|
|
689
709
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
690
710
|
try {
|
|
@@ -707,13 +727,17 @@ export class Bot {
|
|
|
707
727
|
}
|
|
708
728
|
} catch (e: any) {
|
|
709
729
|
this.apiError(e);
|
|
710
|
-
this.errorLog(
|
|
711
|
-
|
|
730
|
+
this.errorLog(
|
|
731
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIpushChanges with ${this.device.connectionType}` +
|
|
732
|
+
` Connection, Error Message: ${JSON.stringify(e.message)}`,
|
|
712
733
|
);
|
|
713
734
|
}
|
|
714
735
|
} else {
|
|
715
|
-
this.debugLog(
|
|
716
|
-
|
|
736
|
+
this.debugLog(
|
|
737
|
+
`${this.device.deviceType}: ${this.accessory.displayName} No openAPIpushChanges.` +
|
|
738
|
+
`On: ${this.On}, ` +
|
|
739
|
+
`OnCached: ${this.accessory.context.On}`,
|
|
740
|
+
);
|
|
717
741
|
}
|
|
718
742
|
}
|
|
719
743
|
|
|
@@ -767,7 +791,6 @@ export class Bot {
|
|
|
767
791
|
this.multiPressCount++;
|
|
768
792
|
this.debugLog(`${this.device.deviceType} set to Multi-Press. Multi-Press count: ${this.multiPressCount}`);
|
|
769
793
|
}
|
|
770
|
-
|
|
771
794
|
}
|
|
772
795
|
this.On = value;
|
|
773
796
|
}
|
|
@@ -791,8 +814,9 @@ export class Bot {
|
|
|
791
814
|
this.platform.Characteristic.CurrentDoorState,
|
|
792
815
|
this.platform.Characteristic.CurrentDoorState.OPEN,
|
|
793
816
|
);
|
|
794
|
-
this.debugLog(
|
|
795
|
-
+ `${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open
|
|
817
|
+
this.debugLog(
|
|
818
|
+
`${this.device.deviceType}: ` + `${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`,
|
|
819
|
+
);
|
|
796
820
|
} else {
|
|
797
821
|
this.garageDoorService?.updateCharacteristic(
|
|
798
822
|
this.platform.Characteristic.TargetDoorState,
|
|
@@ -802,8 +826,9 @@ export class Bot {
|
|
|
802
826
|
this.platform.Characteristic.CurrentDoorState,
|
|
803
827
|
this.platform.Characteristic.CurrentDoorState.CLOSED,
|
|
804
828
|
);
|
|
805
|
-
this.debugLog(
|
|
806
|
-
+ `${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open
|
|
829
|
+
this.debugLog(
|
|
830
|
+
`${this.device.deviceType}: ` + `${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`,
|
|
831
|
+
);
|
|
807
832
|
}
|
|
808
833
|
}
|
|
809
834
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Garage Door On: ${this.On}`);
|
|
@@ -877,16 +902,19 @@ export class Bot {
|
|
|
877
902
|
this.platform.Characteristic.LockCurrentState,
|
|
878
903
|
this.platform.Characteristic.LockCurrentState.UNSECURED,
|
|
879
904
|
);
|
|
880
|
-
this.debugLog(
|
|
881
|
-
|
|
905
|
+
this.debugLog(
|
|
906
|
+
`${this.device.deviceType}: ` +
|
|
907
|
+
`${this.accessory.displayName} updateCharacteristic LockTargetState: UNSECURED, LockCurrentState: UNSECURED`,
|
|
908
|
+
);
|
|
882
909
|
} else {
|
|
883
910
|
this.lockService?.updateCharacteristic(this.platform.Characteristic.LockTargetState, this.platform.Characteristic.LockTargetState.SECURED);
|
|
884
911
|
this.lockService?.updateCharacteristic(
|
|
885
912
|
this.platform.Characteristic.LockCurrentState,
|
|
886
913
|
this.platform.Characteristic.LockCurrentState.SECURED,
|
|
887
914
|
);
|
|
888
|
-
this.debugLog(
|
|
889
|
-
+ `${this.accessory.displayName} updateCharacteristic LockTargetState: SECURED, LockCurrentState: SECURED
|
|
915
|
+
this.debugLog(
|
|
916
|
+
`${this.device.deviceType}: ` + `${this.accessory.displayName} updateCharacteristic LockTargetState: SECURED, LockCurrentState: SECURED`,
|
|
917
|
+
);
|
|
890
918
|
}
|
|
891
919
|
}
|
|
892
920
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Lock On: ${this.On}`);
|
|
@@ -926,16 +954,20 @@ export class Bot {
|
|
|
926
954
|
this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,
|
|
927
955
|
);
|
|
928
956
|
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, 1);
|
|
929
|
-
this.debugLog(
|
|
930
|
-
|
|
957
|
+
this.debugLog(
|
|
958
|
+
`${this.device.deviceType}: ` +
|
|
959
|
+
`${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 1`,
|
|
960
|
+
);
|
|
931
961
|
} else {
|
|
932
962
|
this.statefulProgrammableSwitchService?.updateCharacteristic(
|
|
933
963
|
this.platform.Characteristic.ProgrammableSwitchEvent,
|
|
934
964
|
this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,
|
|
935
965
|
);
|
|
936
966
|
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, 0);
|
|
937
|
-
this.debugLog(
|
|
938
|
-
|
|
967
|
+
this.debugLog(
|
|
968
|
+
`${this.device.deviceType}: ` +
|
|
969
|
+
`${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0`,
|
|
970
|
+
);
|
|
939
971
|
}
|
|
940
972
|
}
|
|
941
973
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatefulProgrammableSwitch On: ${this.On}`);
|
|
@@ -1193,8 +1225,10 @@ export class Bot {
|
|
|
1193
1225
|
this.offlineOff();
|
|
1194
1226
|
break;
|
|
1195
1227
|
case 171:
|
|
1196
|
-
this.errorLog(
|
|
1197
|
-
|
|
1228
|
+
this.errorLog(
|
|
1229
|
+
`${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
|
|
1230
|
+
`Hub: ${this.device.hubDeviceId}`,
|
|
1231
|
+
);
|
|
1198
1232
|
this.offlineOff();
|
|
1199
1233
|
break;
|
|
1200
1234
|
case 190:
|
|
@@ -1210,8 +1244,10 @@ export class Bot {
|
|
|
1210
1244
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
|
|
1211
1245
|
break;
|
|
1212
1246
|
default:
|
|
1213
|
-
this.infoLog(
|
|
1214
|
-
|
|
1247
|
+
this.infoLog(
|
|
1248
|
+
`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: ` +
|
|
1249
|
+
`${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
|
|
1250
|
+
);
|
|
1215
1251
|
}
|
|
1216
1252
|
}
|
|
1217
1253
|
|
|
@@ -1262,14 +1298,17 @@ export class Bot {
|
|
|
1262
1298
|
|
|
1263
1299
|
FirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
|
|
1264
1300
|
let FirmwareRevision: string;
|
|
1265
|
-
this.debugLog(
|
|
1266
|
-
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}
|
|
1301
|
+
this.debugLog(
|
|
1302
|
+
`${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
|
|
1303
|
+
);
|
|
1267
1304
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
1268
1305
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
1269
|
-
if (
|
|
1270
|
-
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
1271
|
-
} else if (device.firmware) {
|
|
1306
|
+
if (device.firmware) {
|
|
1272
1307
|
FirmwareRevision = device.firmware;
|
|
1308
|
+
} else if (device.version) {
|
|
1309
|
+
FirmwareRevision = JSON.stringify(device.version);
|
|
1310
|
+
} if (accessory.context.FirmwareRevision) {
|
|
1311
|
+
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
1273
1312
|
} else {
|
|
1274
1313
|
FirmwareRevision = this.platform.version;
|
|
1275
1314
|
}
|
|
@@ -1341,7 +1380,7 @@ export class Bot {
|
|
|
1341
1380
|
config['maxRetry'] = device.maxRetry;
|
|
1342
1381
|
}
|
|
1343
1382
|
if (Object.entries(config).length !== 0) {
|
|
1344
|
-
this.
|
|
1383
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
1345
1384
|
}
|
|
1346
1385
|
}
|
|
1347
1386
|
|