@switchbot/homebridge-switchbot 3.5.1-beta.0 → 3.5.1-beta.2
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/README.md +16 -0
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +32 -126
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +3 -5
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +14 -47
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +9 -46
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +20 -56
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +1 -0
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +34 -147
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +25 -2
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +75 -5
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +34 -50
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +2 -3
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +3 -5
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +2 -3
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +3 -5
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +3 -5
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +2 -3
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +2 -3
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +2 -3
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +3 -5
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +7 -11
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +2 -3
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +2 -3
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +2 -3
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +2 -3
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +2 -3
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +1 -0
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +4 -0
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +2 -3
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +2 -3
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +2 -3
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +2 -3
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +2 -3
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/settings.d.ts +3 -2
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +5 -5
- package/src/device/blindtilt.ts +42 -124
- package/src/device/bot.ts +3 -5
- package/src/device/ceilinglight.ts +19 -42
- package/src/device/colorbulb.ts +14 -41
- package/src/device/contact.ts +29 -55
- package/src/device/curtain.ts +43 -140
- package/src/device/device.ts +89 -7
- package/src/device/fan.ts +36 -51
- package/src/device/hub.ts +2 -3
- package/src/device/humidifier.ts +3 -5
- package/src/device/iosensor.ts +2 -3
- package/src/device/lightstrip.ts +3 -5
- package/src/device/lock.ts +3 -5
- package/src/device/meter.ts +2 -3
- package/src/device/meterplus.ts +2 -3
- package/src/device/motion.ts +2 -3
- package/src/device/plug.ts +3 -5
- package/src/device/robotvacuumcleaner.ts +7 -11
- package/src/device/waterdetector.ts +2 -3
- package/src/irdevice/airconditioner.ts +2 -3
- package/src/irdevice/airpurifier.ts +2 -3
- package/src/irdevice/camera.ts +2 -3
- package/src/irdevice/fan.ts +2 -3
- package/src/irdevice/irdevice.ts +5 -0
- package/src/irdevice/light.ts +2 -3
- package/src/irdevice/other.ts +2 -3
- package/src/irdevice/tv.ts +2 -3
- package/src/irdevice/vacuumcleaner.ts +2 -3
- package/src/irdevice/waterheater.ts +2 -3
- package/src/settings.ts +3 -2
package/src/device/blindtilt.ts
CHANGED
|
@@ -265,14 +265,13 @@ export class BlindTilt extends deviceBase {
|
|
|
265
265
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentPosition: ${this.WindowCovering.CurrentPosition},`
|
|
266
266
|
+ ` TargetPosition: ${this.WindowCovering.TargetPosition}, PositionState: ${this.WindowCovering.PositionState},`);
|
|
267
267
|
|
|
268
|
-
if (!this.device.blindTilt?.hide_lightsensor) {
|
|
269
|
-
const set_minLux = this.device.blindTilt?.set_minLux ?? 1;
|
|
270
|
-
const set_maxLux = this.device.blindTilt?.set_maxLux ?? 6001;
|
|
271
|
-
const spaceBetweenLevels = 9;
|
|
272
|
-
|
|
268
|
+
if (!this.device.blindTilt?.hide_lightsensor && this.LightSensor?.Service) {
|
|
273
269
|
if (this.LightSensor?.CurrentAmbientLightLevel === 0) {
|
|
274
270
|
this.LightSensor!.CurrentAmbientLightLevel = 0.0001;
|
|
275
271
|
}
|
|
272
|
+
const set_minLux = this.device.blindTilt?.set_minLux ?? 1;
|
|
273
|
+
const set_maxLux = this.device.blindTilt?.set_maxLux ?? 6001;
|
|
274
|
+
const spaceBetweenLevels = 9;
|
|
276
275
|
|
|
277
276
|
// Brightness
|
|
278
277
|
switch (serviceData.lightLevel) {
|
|
@@ -465,9 +464,9 @@ export class BlindTilt extends deviceBase {
|
|
|
465
464
|
if (switchbot === undefined) {
|
|
466
465
|
await this.BLERefreshConnection(switchbot);
|
|
467
466
|
} else {
|
|
468
|
-
// Start to monitor advertisement packets
|
|
469
|
-
(async () => {
|
|
470
467
|
// Start to monitor advertisement packets
|
|
468
|
+
(async () => {
|
|
469
|
+
// Start to monitor advertisement packets
|
|
471
470
|
const serviceData: serviceData = await this.monitorAdvertisementPackets(switchbot);
|
|
472
471
|
// Update HomeKit
|
|
473
472
|
if (serviceData.model !== '' && serviceData.modelName !== '') {
|
|
@@ -495,9 +494,8 @@ export class BlindTilt extends deviceBase {
|
|
|
495
494
|
await this.statusCodes(statusCode, deviceStatus);
|
|
496
495
|
}
|
|
497
496
|
} catch (e: any) {
|
|
498
|
-
this.apiError(e);
|
|
499
|
-
this.
|
|
500
|
-
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
497
|
+
await this.apiError(e);
|
|
498
|
+
await this.openAPIRefreshError(e);
|
|
501
499
|
}
|
|
502
500
|
}
|
|
503
501
|
|
|
@@ -518,7 +516,7 @@ export class BlindTilt extends deviceBase {
|
|
|
518
516
|
if (!device.blindTilt?.hide_lightsensor) {
|
|
519
517
|
this.LightSensor!.CurrentAmbientLightLevel = lightLevel;
|
|
520
518
|
}
|
|
521
|
-
this.updateHomeKitCharacteristics();
|
|
519
|
+
await this.updateHomeKitCharacteristics();
|
|
522
520
|
} catch (e: any) {
|
|
523
521
|
this.errorLog(`${device.deviceType}: ${accessory.displayName} failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`);
|
|
524
522
|
}
|
|
@@ -537,8 +535,7 @@ export class BlindTilt extends deviceBase {
|
|
|
537
535
|
await this.openAPIpushChanges();
|
|
538
536
|
} else {
|
|
539
537
|
await this.offlineOff();
|
|
540
|
-
this.
|
|
541
|
-
+ ` ${this.device.connectionType}, pushChanges will not happen.`);
|
|
538
|
+
await this.pushChangeDisabled();
|
|
542
539
|
}
|
|
543
540
|
// Refresh the status from the API
|
|
544
541
|
interval(15000)
|
|
@@ -575,13 +572,12 @@ export class BlindTilt extends deviceBase {
|
|
|
575
572
|
+ `Target Position: ${this.WindowCovering.TargetPosition} sent over BLE, sent successfully`);
|
|
576
573
|
})
|
|
577
574
|
.catch(async (e: any) => {
|
|
578
|
-
this.apiError(e);
|
|
579
|
-
this.
|
|
580
|
-
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
575
|
+
await this.apiError(e);
|
|
576
|
+
await this.failedBLEChanges(e);
|
|
581
577
|
await this.BLEPushConnection();
|
|
582
578
|
});
|
|
583
579
|
} else {
|
|
584
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection
|
|
580
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection,`);
|
|
585
581
|
await this.BLEPushConnection();
|
|
586
582
|
}
|
|
587
583
|
} else {
|
|
@@ -652,36 +648,31 @@ export class BlindTilt extends deviceBase {
|
|
|
652
648
|
* Handle requests to set the value of the "Target Horizontal Tilt" characteristic
|
|
653
649
|
*/
|
|
654
650
|
async TargetHorizontalTiltAngleSet(value: CharacteristicValue): Promise<void> {
|
|
655
|
-
if (this.WindowCovering.TargetHorizontalTiltAngle
|
|
656
|
-
this.
|
|
651
|
+
if (this.WindowCovering.TargetHorizontalTiltAngle !== this.accessory.context.TargetHorizontalTiltAngle) {
|
|
652
|
+
await this.changeSet(value, 'TargetHorizontalTiltAngle');
|
|
657
653
|
} else {
|
|
658
|
-
this.
|
|
654
|
+
await this.noChangeSet(value, 'TargetHorizontalTiltAngle');
|
|
659
655
|
}
|
|
660
656
|
|
|
661
657
|
//value = value < 0 ? -90 : 90;
|
|
662
658
|
this.WindowCovering.TargetHorizontalTiltAngle = value;
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
this.startUpdatingBlindTiltIfNeeded();
|
|
659
|
+
await this.mqtt('TargetHorizontalTiltAngle', this.WindowCovering.TargetHorizontalTiltAngle);
|
|
660
|
+
await this.startUpdatingBlindTiltIfNeeded();
|
|
668
661
|
}
|
|
669
662
|
|
|
670
663
|
/**
|
|
671
664
|
* Handle requests to set the value of the "Target Position" characteristic
|
|
672
665
|
*/
|
|
673
666
|
async TargetPositionSet(value: CharacteristicValue): Promise<void> {
|
|
674
|
-
if (this.WindowCovering.TargetPosition
|
|
675
|
-
this.
|
|
667
|
+
if (this.WindowCovering.TargetPosition !== this.accessory.context.TargetPosition) {
|
|
668
|
+
await this.changeSet(value, 'TargetPosition');
|
|
676
669
|
} else {
|
|
677
|
-
this.
|
|
670
|
+
await this.noChangeSet(value, 'TargetPosition');
|
|
678
671
|
}
|
|
679
672
|
|
|
680
673
|
this.WindowCovering.TargetPosition = value;
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
}
|
|
684
|
-
this.startUpdatingBlindTiltIfNeeded();
|
|
674
|
+
await this.mqtt('TargetPosition', this.WindowCovering.TargetPosition);
|
|
675
|
+
await this.startUpdatingBlindTiltIfNeeded();
|
|
685
676
|
}
|
|
686
677
|
|
|
687
678
|
async startUpdatingBlindTiltIfNeeded(): Promise<void> {
|
|
@@ -726,106 +717,33 @@ export class BlindTilt extends deviceBase {
|
|
|
726
717
|
await this.setMinMax();
|
|
727
718
|
// CurrentHorizontalTiltAngle
|
|
728
719
|
if (this.mappingMode === BlindTiltMappingMode.UseTiltForDirection) {
|
|
729
|
-
|
|
730
|
-
this.
|
|
731
|
-
+ ` CurrentHorizontalTiltAngle: ${this.WindowCovering.CurrentHorizontalTiltAngle}`);
|
|
732
|
-
} else {
|
|
733
|
-
if (this.device.mqttURL) {
|
|
734
|
-
this.mqttPublish('CurrentHorizontalTiltAngle', this.WindowCovering.CurrentHorizontalTiltAngle.toString());
|
|
735
|
-
}
|
|
736
|
-
this.accessory.context.CurrentHorizontalTiltAngle = this.WindowCovering.CurrentHorizontalTiltAngle;
|
|
737
|
-
this.WindowCovering.Service.updateCharacteristic(
|
|
738
|
-
this.hap.Characteristic.CurrentHorizontalTiltAngle,
|
|
739
|
-
Number(this.WindowCovering.CurrentHorizontalTiltAngle));
|
|
740
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}
|
|
741
|
-
updateCharacteristic CurrentHorizontalTiltAngle: ${this.WindowCovering.CurrentHorizontalTiltAngle}`);
|
|
742
|
-
}
|
|
720
|
+
await this.updateCharacteristic(this.WindowCovering.Service, this.hap.Characteristic.CurrentHorizontalTiltAngle,
|
|
721
|
+
this.WindowCovering.CurrentHorizontalTiltAngle, 'CurrentHorizontalTiltAngle');
|
|
743
722
|
}
|
|
744
723
|
// CurrentPosition
|
|
745
|
-
|
|
746
|
-
this.
|
|
747
|
-
} else {
|
|
748
|
-
if (this.device.mqttURL) {
|
|
749
|
-
this.mqttPublish('CurrentPosition', this.WindowCovering.CurrentPosition.toString());
|
|
750
|
-
}
|
|
751
|
-
this.accessory.context.CurrentPosition = this.WindowCovering.CurrentPosition;
|
|
752
|
-
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, Number(this.WindowCovering.CurrentPosition));
|
|
753
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
754
|
-
+ ` updateCharacteristic CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
|
|
755
|
-
}
|
|
724
|
+
await this.updateCharacteristic(this.WindowCovering.Service, this.hap.Characteristic.CurrentPosition,
|
|
725
|
+
this.WindowCovering.CurrentPosition, 'CurrentPosition');
|
|
756
726
|
// PositionState
|
|
757
|
-
|
|
758
|
-
this.
|
|
759
|
-
} else {
|
|
760
|
-
if (this.device.mqttURL) {
|
|
761
|
-
this.mqttPublish('PositionState', this.WindowCovering.PositionState.toString());
|
|
762
|
-
}
|
|
763
|
-
this.accessory.context.PositionState = this.WindowCovering.PositionState;
|
|
764
|
-
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, Number(this.WindowCovering.PositionState));
|
|
765
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
766
|
-
+ ` PositionState: ${this.WindowCovering.PositionState}`);
|
|
767
|
-
}
|
|
727
|
+
await this.updateCharacteristic(this.WindowCovering.Service, this.hap.Characteristic.PositionState,
|
|
728
|
+
this.WindowCovering.PositionState, 'PositionState');
|
|
768
729
|
// TargetPosition
|
|
769
|
-
|
|
770
|
-
this.
|
|
771
|
-
} else {
|
|
772
|
-
if (this.device.mqttURL) {
|
|
773
|
-
this.mqttPublish('TargetPosition', this.WindowCovering.TargetPosition.toString());
|
|
774
|
-
}
|
|
775
|
-
this.accessory.context.TargetPosition = this.WindowCovering.TargetPosition;
|
|
776
|
-
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, Number(this.WindowCovering.TargetPosition));
|
|
777
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
778
|
-
+ ` TargetPosition: ${this.WindowCovering.TargetPosition}`);
|
|
779
|
-
}
|
|
730
|
+
await this.updateCharacteristic(this.WindowCovering.Service, this.hap.Characteristic.TargetPosition,
|
|
731
|
+
this.WindowCovering.TargetPosition, 'TargetPosition');
|
|
780
732
|
// CurrentAmbientLightLevel
|
|
781
|
-
if (!this.device.blindTilt?.hide_lightsensor) {
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
} else {
|
|
786
|
-
if (this.device.mqttURL) {
|
|
787
|
-
this.mqttPublish('CurrentAmbientLightLevel', this.LightSensor!.CurrentAmbientLightLevel.toString());
|
|
788
|
-
}
|
|
789
|
-
this.accessory.context.CurrentAmbientLightLevel = this.LightSensor!.CurrentAmbientLightLevel;
|
|
790
|
-
this.LightSensor!.Service.updateCharacteristic(this.hap.Characteristic.CurrentAmbientLightLevel, this.LightSensor!.CurrentAmbientLightLevel);
|
|
791
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
792
|
-
+ ` updateCharacteristic CurrentAmbientLightLevel: ${this.LightSensor!.CurrentAmbientLightLevel}`);
|
|
793
|
-
}
|
|
733
|
+
if (!this.device.blindTilt?.hide_lightsensor && this.LightSensor?.Service) {
|
|
734
|
+
const history = { time: Math.round(new Date().valueOf() / 1000), lux: this.LightSensor.CurrentAmbientLightLevel };
|
|
735
|
+
await this.updateCharacteristic(this.LightSensor?.Service, this.hap.Characteristic.CurrentAmbientLightLevel,
|
|
736
|
+
this.LightSensor?.CurrentAmbientLightLevel, 'CurrentAmbientLightLevel', history);
|
|
794
737
|
}
|
|
795
738
|
// BatteryLevel
|
|
796
|
-
|
|
797
|
-
this.
|
|
798
|
-
} else {
|
|
799
|
-
if (this.device.mqttURL) {
|
|
800
|
-
this.mqttPublish('BatteryLevel', this.Battery.BatteryLevel.toString());
|
|
801
|
-
}
|
|
802
|
-
this.accessory.context.BatteryLevel = this.Battery.BatteryLevel;
|
|
803
|
-
this.Battery?.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, this.Battery.BatteryLevel);
|
|
804
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.Battery.BatteryLevel}`);
|
|
805
|
-
}
|
|
739
|
+
await this.updateCharacteristic(this.Battery.Service, this.hap.Characteristic.BatteryLevel,
|
|
740
|
+
this.Battery.BatteryLevel, 'BatteryLevel');
|
|
806
741
|
// StatusLowBattery
|
|
807
|
-
|
|
808
|
-
this.
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
}
|
|
813
|
-
this.accessory.context.StatusLowBattery = this.Battery.StatusLowBattery;
|
|
814
|
-
this.Battery?.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, this.Battery.StatusLowBattery);
|
|
815
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
816
|
-
+ ` StatusLowBattery: ${this.Battery.StatusLowBattery}`);
|
|
817
|
-
}
|
|
818
|
-
if (this.Battery.ChargingState === undefined) {
|
|
819
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ChargingState: ${this.Battery.ChargingState}`);
|
|
820
|
-
} else {
|
|
821
|
-
if (this.device.mqttURL) {
|
|
822
|
-
this.mqttPublish('ChargingState', this.Battery.ChargingState.toString());
|
|
823
|
-
}
|
|
824
|
-
this.accessory.context.ChargingState = this.Battery.ChargingState;
|
|
825
|
-
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.ChargingState, this.Battery.ChargingState);
|
|
826
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
827
|
-
+ ` ChargingState: ${this.Battery.ChargingState}`);
|
|
828
|
-
}
|
|
742
|
+
await this.updateCharacteristic(this.Battery.Service, this.hap.Characteristic.StatusLowBattery,
|
|
743
|
+
this.Battery.StatusLowBattery, 'StatusLowBattery');
|
|
744
|
+
// ChargingState
|
|
745
|
+
await this.updateCharacteristic(this.Battery.Service, this.hap.Characteristic.ChargingState,
|
|
746
|
+
this.Battery.ChargingState, 'ChargingState');
|
|
829
747
|
}
|
|
830
748
|
|
|
831
749
|
async BLEPushConnection() {
|
package/src/device/bot.ts
CHANGED
|
@@ -632,9 +632,8 @@ export class Bot extends deviceBase {
|
|
|
632
632
|
await this.statusCodes(statusCode, deviceStatus);
|
|
633
633
|
}
|
|
634
634
|
} catch (e: any) {
|
|
635
|
-
this.apiError(e);
|
|
636
|
-
this.
|
|
637
|
-
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
635
|
+
await this.apiError(e);
|
|
636
|
+
await this.openAPIRefreshError(e);
|
|
638
637
|
}
|
|
639
638
|
}
|
|
640
639
|
|
|
@@ -679,8 +678,7 @@ export class Bot extends deviceBase {
|
|
|
679
678
|
await this.openAPIpushChanges();
|
|
680
679
|
} else {
|
|
681
680
|
await this.offlineOff();
|
|
682
|
-
this.
|
|
683
|
-
+ ` ${this.device.connectionType}, pushChanges will not happen.`);
|
|
681
|
+
await this.pushChangeDisabled();
|
|
684
682
|
}
|
|
685
683
|
// Refresh the status from the API
|
|
686
684
|
interval(15000)
|
|
@@ -314,9 +314,8 @@ export class CeilingLight extends deviceBase {
|
|
|
314
314
|
await this.statusCodes(statusCode, deviceStatus);
|
|
315
315
|
}
|
|
316
316
|
} catch (e: any) {
|
|
317
|
-
this.apiError(e);
|
|
318
|
-
this.
|
|
319
|
-
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
317
|
+
await this.apiError(e);
|
|
318
|
+
await this.openAPIRefreshError(e);
|
|
320
319
|
}
|
|
321
320
|
}
|
|
322
321
|
|
|
@@ -387,8 +386,7 @@ export class CeilingLight extends deviceBase {
|
|
|
387
386
|
await this.openAPIpushChanges();
|
|
388
387
|
} else {
|
|
389
388
|
await this.offlineOff();
|
|
390
|
-
this.
|
|
391
|
-
+ ` ${this.device.connectionType}, pushChanges will not happen.`);
|
|
389
|
+
await this.pushChangeDisabled();
|
|
392
390
|
}
|
|
393
391
|
// Refresh the status from the API
|
|
394
392
|
interval(15000)
|
|
@@ -691,42 +689,21 @@ export class CeilingLight extends deviceBase {
|
|
|
691
689
|
}
|
|
692
690
|
|
|
693
691
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
this.
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
this.
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
this.LightBulb
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ColorTemperature: ${this.LightBulb.ColorTemperature}`);
|
|
710
|
-
} else {
|
|
711
|
-
this.accessory.context.ColorTemperature = this.LightBulb.ColorTemperature;
|
|
712
|
-
this.LightBulb!.Service.updateCharacteristic(this.hap.Characteristic.ColorTemperature, this.LightBulb.ColorTemperature);
|
|
713
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
714
|
-
+ ` updateCharacteristic ColorTemperature: ${this.LightBulb.ColorTemperature}`);
|
|
715
|
-
}
|
|
716
|
-
if (this.LightBulb.Hue === undefined) {
|
|
717
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${this.LightBulb.Hue}`);
|
|
718
|
-
} else {
|
|
719
|
-
this.accessory.context.Hue = this.LightBulb.Hue;
|
|
720
|
-
this.LightBulb!.Service.updateCharacteristic(this.hap.Characteristic.Hue, this.LightBulb.Hue);
|
|
721
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Hue: ${this.LightBulb.Hue}`);
|
|
722
|
-
}
|
|
723
|
-
if (this.LightBulb.Saturation === undefined) {
|
|
724
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${this.LightBulb.Saturation}`);
|
|
725
|
-
} else {
|
|
726
|
-
this.accessory.context.Saturation = this.LightBulb.Saturation;
|
|
727
|
-
this.LightBulb!.Service.updateCharacteristic(this.hap.Characteristic.Saturation, this.LightBulb.Saturation);
|
|
728
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Saturation: ${this.LightBulb.Saturation}`);
|
|
729
|
-
}
|
|
692
|
+
// On
|
|
693
|
+
await this.updateCharacteristic(this.LightBulb.Service, this.hap.Characteristic.On,
|
|
694
|
+
this.LightBulb.On, 'On');
|
|
695
|
+
// Brightness
|
|
696
|
+
await this.updateCharacteristic(this.LightBulb.Service, this.hap.Characteristic.Brightness,
|
|
697
|
+
this.LightBulb.Brightness, 'Brightness');
|
|
698
|
+
// ColorTemperature
|
|
699
|
+
await this.updateCharacteristic(this.LightBulb.Service, this.hap.Characteristic.ColorTemperature,
|
|
700
|
+
this.LightBulb.ColorTemperature, 'ColorTemperature');
|
|
701
|
+
// Hue
|
|
702
|
+
await this.updateCharacteristic(this.LightBulb.Service, this.hap.Characteristic.Hue,
|
|
703
|
+
this.LightBulb.Hue, 'Hue');
|
|
704
|
+
// Saturation
|
|
705
|
+
await this.updateCharacteristic(this.LightBulb.Service, this.hap.Characteristic.Saturation,
|
|
706
|
+
this.LightBulb.Saturation, 'Saturation');
|
|
730
707
|
}
|
|
731
708
|
|
|
732
709
|
async adaptiveLighting(device: device & devicesConfig): Promise<void> {
|
|
@@ -761,7 +738,7 @@ export class CeilingLight extends deviceBase {
|
|
|
761
738
|
}
|
|
762
739
|
}
|
|
763
740
|
|
|
764
|
-
apiError(e: any): void {
|
|
741
|
+
async apiError(e: any): Promise<void> {
|
|
765
742
|
this.LightBulb!.Service.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
766
743
|
this.LightBulb!.Service.updateCharacteristic(this.hap.Characteristic.Hue, e);
|
|
767
744
|
this.LightBulb!.Service.updateCharacteristic(this.hap.Characteristic.Brightness, e);
|
package/src/device/colorbulb.ts
CHANGED
|
@@ -341,9 +341,8 @@ export class ColorBulb extends deviceBase {
|
|
|
341
341
|
await this.statusCodes(statusCode, deviceStatus);
|
|
342
342
|
}
|
|
343
343
|
} catch (e: any) {
|
|
344
|
-
this.apiError(e);
|
|
345
|
-
this.
|
|
346
|
-
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
344
|
+
await this.apiError(e);
|
|
345
|
+
await this.openAPIRefreshError(e);
|
|
347
346
|
}
|
|
348
347
|
}
|
|
349
348
|
|
|
@@ -440,8 +439,7 @@ export class ColorBulb extends deviceBase {
|
|
|
440
439
|
await this.openAPIpushChanges();
|
|
441
440
|
} else {
|
|
442
441
|
await this.offlineOff();
|
|
443
|
-
this.
|
|
444
|
-
+ ` ${this.device.connectionType}, pushChanges will not happen.`);
|
|
442
|
+
await this.pushChangeDisabled();
|
|
445
443
|
}
|
|
446
444
|
// Refresh the status from the API
|
|
447
445
|
interval(15000)
|
|
@@ -499,6 +497,7 @@ export class ColorBulb extends deviceBase {
|
|
|
499
497
|
if (this.LightBulb.On) {
|
|
500
498
|
await this.BLEpushRGBChanges();
|
|
501
499
|
}
|
|
500
|
+
await this.updateHomeKitCharacteristics();
|
|
502
501
|
} else {
|
|
503
502
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No BLEpushChanges, On: ${this.LightBulb.On},`
|
|
504
503
|
+ ` OnCached: ${this.accessory.context.On}`);
|
|
@@ -852,46 +851,20 @@ export class ColorBulb extends deviceBase {
|
|
|
852
851
|
|
|
853
852
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
854
853
|
// On
|
|
855
|
-
|
|
856
|
-
this.
|
|
857
|
-
} else {
|
|
858
|
-
this.accessory.context.On = this.LightBulb.On;
|
|
859
|
-
this.LightBulb.Service.updateCharacteristic(this.hap.Characteristic.On, this.LightBulb.On);
|
|
860
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.LightBulb.On}`);
|
|
861
|
-
}
|
|
854
|
+
await this.updateCharacteristic(this.LightBulb.Service, this.hap.Characteristic.On,
|
|
855
|
+
this.LightBulb.On, 'On');
|
|
862
856
|
// Brightness
|
|
863
|
-
|
|
864
|
-
this.
|
|
865
|
-
} else {
|
|
866
|
-
this.accessory.context.Brightness = this.LightBulb.Brightness;
|
|
867
|
-
this.LightBulb.Service.updateCharacteristic(this.hap.Characteristic.Brightness, this.LightBulb.Brightness);
|
|
868
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Brightness: ${this.LightBulb.Brightness}`);
|
|
869
|
-
}
|
|
857
|
+
await this.updateCharacteristic(this.LightBulb.Service, this.hap.Characteristic.Brightness,
|
|
858
|
+
this.LightBulb.Brightness, 'Brightness');
|
|
870
859
|
// ColorTemperature
|
|
871
|
-
|
|
872
|
-
this.
|
|
873
|
-
} else {
|
|
874
|
-
this.accessory.context.ColorTemperature = this.LightBulb.ColorTemperature;
|
|
875
|
-
this.LightBulb.Service.updateCharacteristic(this.hap.Characteristic.ColorTemperature, this.LightBulb.ColorTemperature);
|
|
876
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
877
|
-
+ ` ColorTemperature: ${this.LightBulb.ColorTemperature}`);
|
|
878
|
-
}
|
|
860
|
+
await this.updateCharacteristic(this.LightBulb.Service, this.hap.Characteristic.ColorTemperature,
|
|
861
|
+
this.LightBulb.ColorTemperature, 'ColorTemperature');
|
|
879
862
|
// Hue
|
|
880
|
-
|
|
881
|
-
this.
|
|
882
|
-
} else {
|
|
883
|
-
this.accessory.context.Hue = this.LightBulb.Hue;
|
|
884
|
-
this.LightBulb.Service.updateCharacteristic(this.hap.Characteristic.Hue, this.LightBulb.Hue);
|
|
885
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Hue: ${this.LightBulb.Hue}`);
|
|
886
|
-
}
|
|
863
|
+
await this.updateCharacteristic(this.LightBulb.Service, this.hap.Characteristic.Hue,
|
|
864
|
+
this.LightBulb.Hue, 'Hue');
|
|
887
865
|
// Saturation
|
|
888
|
-
|
|
889
|
-
this.
|
|
890
|
-
} else {
|
|
891
|
-
this.accessory.context.Saturation = this.LightBulb.Saturation;
|
|
892
|
-
this.LightBulb.Service.updateCharacteristic(this.hap.Characteristic.Saturation, this.LightBulb.Saturation);
|
|
893
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Saturation: ${this.LightBulb.Saturation}`);
|
|
894
|
-
}
|
|
866
|
+
await this.updateCharacteristic(this.LightBulb.Service, this.hap.Characteristic.Saturation,
|
|
867
|
+
this.LightBulb.Saturation, 'Saturation');
|
|
895
868
|
}
|
|
896
869
|
|
|
897
870
|
async adaptiveLighting(device: device & devicesConfig): Promise<void> {
|
package/src/device/contact.ts
CHANGED
|
@@ -340,9 +340,8 @@ export class Contact extends deviceBase {
|
|
|
340
340
|
await this.statusCodes(statusCode, deviceStatus);
|
|
341
341
|
}
|
|
342
342
|
} catch (e: any) {
|
|
343
|
-
this.apiError(e);
|
|
344
|
-
this.
|
|
345
|
-
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
343
|
+
await this.apiError(e);
|
|
344
|
+
await this.openAPIRefreshError(e);
|
|
346
345
|
}
|
|
347
346
|
}
|
|
348
347
|
|
|
@@ -381,50 +380,25 @@ export class Contact extends deviceBase {
|
|
|
381
380
|
* Updates the status for each of the HomeKit Characteristics
|
|
382
381
|
*/
|
|
383
382
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
this.
|
|
390
|
-
|
|
383
|
+
// ContactSensorState
|
|
384
|
+
await this.updateCharacteristic(this.ContactSensor.Service, this.hap.Characteristic.ContactSensorState,
|
|
385
|
+
this.ContactSensor.ContactSensorState, 'ContactSensorState');
|
|
386
|
+
// MotionDetected
|
|
387
|
+
if (!this.device.contact?.hide_motionsensor && this.MotionSensor?.Service) {
|
|
388
|
+
await this.updateCharacteristic(this.MotionSensor.Service, this.hap.Characteristic.MotionDetected,
|
|
389
|
+
this.MotionSensor.MotionDetected, 'MotionDetected');
|
|
391
390
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
this.accessory.context.MotionDetected = this.MotionSensor!.MotionDetected;
|
|
397
|
-
this.MotionSensor!.Service.updateCharacteristic(this.hap.Characteristic.MotionDetected, this.MotionSensor!.MotionDetected);
|
|
398
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
399
|
-
+ ` MotionDetected: ${this.MotionSensor!.MotionDetected}`);
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
if (!this.device.contact?.hide_lightsensor) {
|
|
403
|
-
if (this.LightSensor?.CurrentAmbientLightLevel === undefined) {
|
|
404
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
405
|
-
+ ` CurrentAmbientLightLevel: ${this.LightSensor?.CurrentAmbientLightLevel}`);
|
|
406
|
-
} else {
|
|
407
|
-
this.accessory.context.CurrentAmbientLightLevel = this.LightSensor.CurrentAmbientLightLevel;
|
|
408
|
-
this.LightSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentAmbientLightLevel, this.LightSensor.CurrentAmbientLightLevel);
|
|
409
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
410
|
-
+ ` updateCharacteristic CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
if (this.Battery.BatteryLevel === undefined) {
|
|
414
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.Battery.BatteryLevel}`);
|
|
415
|
-
} else {
|
|
416
|
-
this.accessory.context.BatteryLevel = this.Battery.BatteryLevel;
|
|
417
|
-
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, this.Battery.BatteryLevel);
|
|
418
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.Battery.BatteryLevel}`);
|
|
419
|
-
}
|
|
420
|
-
if (this.Battery.StatusLowBattery === undefined) {
|
|
421
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.Battery.StatusLowBattery}`);
|
|
422
|
-
} else {
|
|
423
|
-
this.accessory.context.StatusLowBattery = this.Battery.StatusLowBattery;
|
|
424
|
-
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, this.Battery.StatusLowBattery);
|
|
425
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
426
|
-
+ ` StatusLowBattery: ${this.Battery.StatusLowBattery}`);
|
|
391
|
+
// CurrentAmbientLightLevel
|
|
392
|
+
if (!this.device.contact?.hide_lightsensor && this.LightSensor?.Service) {
|
|
393
|
+
await this.updateCharacteristic(this.LightSensor.Service, this.hap.Characteristic.CurrentAmbientLightLevel,
|
|
394
|
+
this.LightSensor.CurrentAmbientLightLevel, 'CurrentAmbientLightLevel');
|
|
427
395
|
}
|
|
396
|
+
// BatteryLevel
|
|
397
|
+
await this.updateCharacteristic(this.Battery.Service, this.hap.Characteristic.BatteryLevel,
|
|
398
|
+
this.Battery.BatteryLevel, 'BatteryLevel');
|
|
399
|
+
// StatusLowBattery
|
|
400
|
+
await this.updateCharacteristic(this.Battery.Service, this.hap.Characteristic.StatusLowBattery,
|
|
401
|
+
this.Battery.StatusLowBattery, 'StatusLowBattery');
|
|
428
402
|
}
|
|
429
403
|
|
|
430
404
|
async BLERefreshConnection(switchbot: any): Promise<void> {
|
|
@@ -440,11 +414,11 @@ export class Contact extends deviceBase {
|
|
|
440
414
|
if (this.device.offline) {
|
|
441
415
|
this.ContactSensor.Service.updateCharacteristic(this.hap.Characteristic.ContactSensorState,
|
|
442
416
|
this.hap.Characteristic.ContactSensorState.CONTACT_DETECTED);
|
|
443
|
-
if (!this.device.contact?.hide_motionsensor) {
|
|
444
|
-
this.MotionSensor
|
|
417
|
+
if (!this.device.contact?.hide_motionsensor && this.MotionSensor?.Service) {
|
|
418
|
+
this.MotionSensor.Service.updateCharacteristic(this.hap.Characteristic.MotionDetected, false);
|
|
445
419
|
}
|
|
446
|
-
if (!this.device.contact?.hide_lightsensor) {
|
|
447
|
-
this.LightSensor
|
|
420
|
+
if (!this.device.contact?.hide_lightsensor && this.LightSensor?.Service) {
|
|
421
|
+
this.LightSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentAmbientLightLevel, 100);
|
|
448
422
|
}
|
|
449
423
|
}
|
|
450
424
|
}
|
|
@@ -452,13 +426,13 @@ export class Contact extends deviceBase {
|
|
|
452
426
|
async apiError(e: any): Promise<void> {
|
|
453
427
|
this.ContactSensor.Service.updateCharacteristic(this.hap.Characteristic.ContactSensorState, e);
|
|
454
428
|
this.ContactSensor.Service.updateCharacteristic(this.hap.Characteristic.StatusActive, e);
|
|
455
|
-
if (!this.device.contact?.hide_motionsensor) {
|
|
456
|
-
this.MotionSensor
|
|
457
|
-
this.MotionSensor
|
|
429
|
+
if (!this.device.contact?.hide_motionsensor && this.MotionSensor?.Service) {
|
|
430
|
+
this.MotionSensor.Service.updateCharacteristic(this.hap.Characteristic.MotionDetected, e);
|
|
431
|
+
this.MotionSensor.Service.updateCharacteristic(this.hap.Characteristic.StatusActive, e);
|
|
458
432
|
}
|
|
459
|
-
if (!this.device.contact?.hide_lightsensor) {
|
|
460
|
-
this.LightSensor
|
|
461
|
-
this.LightSensor
|
|
433
|
+
if (!this.device.contact?.hide_lightsensor && this.LightSensor?.Service) {
|
|
434
|
+
this.LightSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentAmbientLightLevel, e);
|
|
435
|
+
this.LightSensor.Service.updateCharacteristic(this.hap.Characteristic.StatusActive, e);
|
|
462
436
|
}
|
|
463
437
|
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, e);
|
|
464
438
|
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, e);
|