@switchbot/homebridge-switchbot 2.8.2-beta.0 → 2.8.2-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/config.schema.json +1 -1
- package/dist/device/blindtilt.d.ts +2 -1
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +26 -14
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +2 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +19 -15
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +2 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +16 -14
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +2 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +21 -14
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +2 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +16 -14
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +2 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +19 -14
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +2 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +16 -14
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +5 -4
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +16 -14
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +2 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +16 -14
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +2 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +21 -14
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +2 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +16 -14
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +3 -2
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +35 -26
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +3 -2
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +33 -23
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +5 -4
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +16 -14
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +2 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +17 -14
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +2 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +19 -13
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +7 -19
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +36 -18
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +4 -7
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +26 -12
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +4 -7
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +24 -12
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +4 -7
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +23 -12
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +4 -7
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +24 -12
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +4 -7
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +24 -12
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +5 -10
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +27 -14
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +4 -7
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +24 -12
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +6 -16
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +28 -16
- package/dist/irdevice/waterheater.js.map +1 -1
- package/package.json +2 -2
- package/src/device/blindtilt.ts +28 -16
- package/src/device/bot.ts +21 -15
- package/src/device/ceilinglight.ts +20 -14
- package/src/device/colorbulb.ts +23 -14
- package/src/device/contact.ts +20 -14
- package/src/device/curtain.ts +22 -15
- package/src/device/hub.ts +20 -14
- package/src/device/humidifier.ts +23 -17
- package/src/device/iosensor.ts +20 -14
- package/src/device/lightstrip.ts +23 -14
- package/src/device/lock.ts +20 -14
- package/src/device/meter.ts +39 -27
- package/src/device/meterplus.ts +38 -26
- package/src/device/motion.ts +24 -23
- package/src/device/plug.ts +20 -14
- package/src/device/robotvacuumcleaner.ts +21 -13
- package/src/irdevice/airconditioner.ts +36 -18
- package/src/irdevice/airpurifier.ts +26 -12
- package/src/irdevice/camera.ts +24 -12
- package/src/irdevice/fan.ts +23 -12
- package/src/irdevice/light.ts +24 -12
- package/src/irdevice/other.ts +24 -12
- package/src/irdevice/tv.ts +27 -14
- package/src/irdevice/vacuumcleaner.ts +24 -12
- package/src/irdevice/waterheater.ts +28 -16
package/src/device/lightstrip.ts
CHANGED
|
@@ -22,6 +22,7 @@ export class StripLight {
|
|
|
22
22
|
Hue!: CharacteristicValue;
|
|
23
23
|
Saturation!: CharacteristicValue;
|
|
24
24
|
Brightness!: CharacteristicValue;
|
|
25
|
+
FirmwareRevision!: CharacteristicValue;
|
|
25
26
|
ColorTemperature?: CharacteristicValue;
|
|
26
27
|
|
|
27
28
|
// OpenAPI Status
|
|
@@ -86,9 +87,9 @@ export class StripLight {
|
|
|
86
87
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
87
88
|
.setCharacteristic(this.platform.Characteristic.Model, 'W1701100')
|
|
88
89
|
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
89
|
-
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.
|
|
90
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.setFirmwareRevision(accessory, device))
|
|
90
91
|
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
91
|
-
.updateValue(this.
|
|
92
|
+
.updateValue(this.setFirmwareRevision(accessory, device));
|
|
92
93
|
|
|
93
94
|
// get the Lightbulb service if it exists, otherwise create a new Lightbulb service
|
|
94
95
|
// you can create multiple services for each accessory
|
|
@@ -275,6 +276,9 @@ export class StripLight {
|
|
|
275
276
|
this.Saturation = saturation;
|
|
276
277
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${this.Saturation}`);
|
|
277
278
|
}
|
|
279
|
+
|
|
280
|
+
// FirmwareRevision
|
|
281
|
+
this.FirmwareRevision = JSON.stringify(this.OpenAPI_FirmwareRevision);
|
|
278
282
|
}
|
|
279
283
|
|
|
280
284
|
/**
|
|
@@ -816,6 +820,7 @@ export class StripLight {
|
|
|
816
820
|
}
|
|
817
821
|
|
|
818
822
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
823
|
+
// On
|
|
819
824
|
if (this.On === undefined) {
|
|
820
825
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
821
826
|
} else {
|
|
@@ -823,6 +828,7 @@ export class StripLight {
|
|
|
823
828
|
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.On, this.On);
|
|
824
829
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
825
830
|
}
|
|
831
|
+
// Brightness
|
|
826
832
|
if (this.Brightness === undefined) {
|
|
827
833
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Brightness: ${this.Brightness}`);
|
|
828
834
|
} else {
|
|
@@ -830,6 +836,7 @@ export class StripLight {
|
|
|
830
836
|
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Brightness, this.Brightness);
|
|
831
837
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Brightness: ${this.Brightness}`);
|
|
832
838
|
}
|
|
839
|
+
// ColorTemperature
|
|
833
840
|
if (this.ColorTemperature === undefined) {
|
|
834
841
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ColorTemperature: ${this.ColorTemperature}`);
|
|
835
842
|
} else {
|
|
@@ -837,6 +844,7 @@ export class StripLight {
|
|
|
837
844
|
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, this.ColorTemperature);
|
|
838
845
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic ColorTemperature: ${this.ColorTemperature}`);
|
|
839
846
|
}
|
|
847
|
+
// Hue
|
|
840
848
|
if (this.Hue === undefined) {
|
|
841
849
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${this.Hue}`);
|
|
842
850
|
} else {
|
|
@@ -844,6 +852,7 @@ export class StripLight {
|
|
|
844
852
|
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Hue, this.Hue);
|
|
845
853
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Hue: ${this.Hue}`);
|
|
846
854
|
}
|
|
855
|
+
// Saturation
|
|
847
856
|
if (this.Saturation === undefined) {
|
|
848
857
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${this.Saturation}`);
|
|
849
858
|
} else {
|
|
@@ -852,14 +861,14 @@ export class StripLight {
|
|
|
852
861
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Saturation: ${this.Saturation}`);
|
|
853
862
|
}
|
|
854
863
|
// FirmwareRevision
|
|
855
|
-
if (this.
|
|
856
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.
|
|
864
|
+
if (this.FirmwareRevision === undefined) {
|
|
865
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
|
|
857
866
|
} else {
|
|
858
|
-
this.accessory.context.
|
|
867
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
859
868
|
this.accessory.getService(this.platform.Service.AccessoryInformation)!
|
|
860
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.
|
|
869
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
861
870
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
862
|
-
+ `updateCharacteristic FirmwareRevision: ${this.
|
|
871
|
+
+ `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
|
|
863
872
|
}
|
|
864
873
|
}
|
|
865
874
|
|
|
@@ -1016,23 +1025,23 @@ export class StripLight {
|
|
|
1016
1025
|
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Saturation, e);
|
|
1017
1026
|
}
|
|
1018
1027
|
|
|
1019
|
-
|
|
1020
|
-
let FirmwareRevision: string;
|
|
1028
|
+
setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
|
|
1021
1029
|
this.debugLog(
|
|
1022
1030
|
`${this.device.deviceType}: ${this.accessory.displayName} ` + `accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
|
|
1023
1031
|
);
|
|
1024
1032
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
1025
1033
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
1026
1034
|
if (device.firmware) {
|
|
1027
|
-
FirmwareRevision = device.firmware;
|
|
1035
|
+
this.FirmwareRevision = device.firmware;
|
|
1028
1036
|
} else if (device.version) {
|
|
1029
|
-
FirmwareRevision = JSON.stringify(device.version);
|
|
1037
|
+
this.FirmwareRevision = JSON.stringify(device.version);
|
|
1030
1038
|
} else if (accessory.context.FirmwareRevision) {
|
|
1031
|
-
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
1039
|
+
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
1032
1040
|
} else {
|
|
1033
|
-
FirmwareRevision = this.platform.version;
|
|
1041
|
+
this.FirmwareRevision = this.platform.version;
|
|
1034
1042
|
}
|
|
1035
|
-
|
|
1043
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
1044
|
+
return this.FirmwareRevision;
|
|
1036
1045
|
}
|
|
1037
1046
|
|
|
1038
1047
|
async context() {
|
package/src/device/lock.ts
CHANGED
|
@@ -18,6 +18,7 @@ export class Lock {
|
|
|
18
18
|
BatteryLevel!: CharacteristicValue;
|
|
19
19
|
LockTargetState!: CharacteristicValue;
|
|
20
20
|
LockCurrentState!: CharacteristicValue;
|
|
21
|
+
FirmwareRevision!: CharacteristicValue;
|
|
21
22
|
StatusLowBattery!: CharacteristicValue;
|
|
22
23
|
ContactSensorState!: CharacteristicValue;
|
|
23
24
|
|
|
@@ -74,9 +75,9 @@ export class Lock {
|
|
|
74
75
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
75
76
|
.setCharacteristic(this.platform.Characteristic.Model, 'W1601700')
|
|
76
77
|
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
77
|
-
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.
|
|
78
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.setFirmwareRevision(accessory, device))
|
|
78
79
|
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
79
|
-
.updateValue(this.
|
|
80
|
+
.updateValue(this.setFirmwareRevision(accessory, device));
|
|
80
81
|
|
|
81
82
|
// get the LockMechanism service if it exists, otherwise create a new LockMechanism service
|
|
82
83
|
// you can create multiple services for each accessory
|
|
@@ -236,6 +237,9 @@ export class Lock {
|
|
|
236
237
|
this.BatteryLevel = 100;
|
|
237
238
|
}
|
|
238
239
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
|
|
240
|
+
|
|
241
|
+
// FirmwareRevision
|
|
242
|
+
this.FirmwareRevision = JSON.stringify(this.OpenAPI_FirmwareRevision);
|
|
239
243
|
}
|
|
240
244
|
|
|
241
245
|
/**
|
|
@@ -527,15 +531,16 @@ export class Lock {
|
|
|
527
531
|
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
|
|
528
532
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
|
|
529
533
|
}
|
|
534
|
+
|
|
530
535
|
// FirmwareRevision
|
|
531
|
-
if (this.
|
|
532
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.
|
|
536
|
+
if (this.FirmwareRevision === undefined) {
|
|
537
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
|
|
533
538
|
} else {
|
|
534
|
-
this.accessory.context.
|
|
539
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
535
540
|
this.accessory.getService(this.platform.Service.AccessoryInformation)!
|
|
536
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.
|
|
541
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
537
542
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
538
|
-
+ `updateCharacteristic FirmwareRevision: ${this.
|
|
543
|
+
+ `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
|
|
539
544
|
}
|
|
540
545
|
}
|
|
541
546
|
|
|
@@ -653,23 +658,24 @@ export class Lock {
|
|
|
653
658
|
this.lockService.updateCharacteristic(this.platform.Characteristic.LockCurrentState, e);
|
|
654
659
|
}
|
|
655
660
|
|
|
656
|
-
|
|
657
|
-
|
|
661
|
+
setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
|
|
662
|
+
|
|
658
663
|
this.debugLog(
|
|
659
664
|
`${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
|
|
660
665
|
);
|
|
661
666
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
662
667
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
663
668
|
if (device.firmware) {
|
|
664
|
-
FirmwareRevision = device.firmware;
|
|
669
|
+
this.FirmwareRevision = device.firmware;
|
|
665
670
|
} else if (device.version) {
|
|
666
|
-
FirmwareRevision = JSON.stringify(device.version);
|
|
671
|
+
this.FirmwareRevision = JSON.stringify(device.version);
|
|
667
672
|
} else if (accessory.context.FirmwareRevision) {
|
|
668
|
-
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
673
|
+
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
669
674
|
} else {
|
|
670
|
-
FirmwareRevision = this.platform.version;
|
|
675
|
+
this.FirmwareRevision = this.platform.version;
|
|
671
676
|
}
|
|
672
|
-
|
|
677
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
678
|
+
return this.FirmwareRevision;
|
|
673
679
|
}
|
|
674
680
|
|
|
675
681
|
async context() {
|
package/src/device/meter.ts
CHANGED
|
@@ -23,9 +23,10 @@ export class Meter {
|
|
|
23
23
|
|
|
24
24
|
// Characteristic Values
|
|
25
25
|
BatteryLevel!: CharacteristicValue;
|
|
26
|
+
FirmwareRevision!: CharacteristicValue;
|
|
26
27
|
StatusLowBattery!: CharacteristicValue;
|
|
27
28
|
CurrentTemperature?: CharacteristicValue;
|
|
28
|
-
CurrentRelativeHumidity
|
|
29
|
+
CurrentRelativeHumidity?: CharacteristicValue;
|
|
29
30
|
|
|
30
31
|
// OpenAPI Status
|
|
31
32
|
OpenAPI_BatteryLevel: deviceStatus['battery'];
|
|
@@ -89,9 +90,9 @@ export class Meter {
|
|
|
89
90
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
90
91
|
.setCharacteristic(this.platform.Characteristic.Model, 'METERTH-S1')
|
|
91
92
|
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
92
|
-
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.
|
|
93
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.setFirmwareRevision(accessory, device))
|
|
93
94
|
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
94
|
-
.updateValue(this.
|
|
95
|
+
.updateValue(this.setFirmwareRevision(accessory, device));
|
|
95
96
|
|
|
96
97
|
// Temperature Sensor Service
|
|
97
98
|
if (device.meter?.hide_temperature) {
|
|
@@ -145,7 +146,7 @@ export class Meter {
|
|
|
145
146
|
minStep: 0.1,
|
|
146
147
|
})
|
|
147
148
|
.onGet(() => {
|
|
148
|
-
return this.CurrentRelativeHumidity
|
|
149
|
+
return this.CurrentRelativeHumidity!;
|
|
149
150
|
});
|
|
150
151
|
} else {
|
|
151
152
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Humidity Sensor Service Not Added`);
|
|
@@ -193,7 +194,7 @@ export class Meter {
|
|
|
193
194
|
async BLEparseStatus(): Promise<void> {
|
|
194
195
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLEparseStatus`);
|
|
195
196
|
|
|
196
|
-
//
|
|
197
|
+
// BatteryLevel
|
|
197
198
|
this.BatteryLevel = Number(this.BLE_BatteryLevel);
|
|
198
199
|
if (this.BatteryLevel < 15) {
|
|
199
200
|
this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
|
|
@@ -202,13 +203,13 @@ export class Meter {
|
|
|
202
203
|
}
|
|
203
204
|
this.debugLog(`${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, StatusLowBattery: ${this.StatusLowBattery}`);
|
|
204
205
|
|
|
205
|
-
//
|
|
206
|
+
// CurrentRelativeHumidity
|
|
206
207
|
if (!this.device.meter?.hide_humidity) {
|
|
207
208
|
this.CurrentRelativeHumidity = this.BLE_CurrentRelativeHumidity!;
|
|
208
209
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Humidity: ${this.CurrentRelativeHumidity}%`);
|
|
209
210
|
}
|
|
210
211
|
|
|
211
|
-
//
|
|
212
|
+
// CurrentTemperature
|
|
212
213
|
if (!this.device.meter?.hide_temperature) {
|
|
213
214
|
this.BLE_Celsius < 0 ? 0 : this.BLE_Celsius > 100 ? 100 : this.BLE_Celsius;
|
|
214
215
|
this.CurrentTemperature = this.BLE_Celsius;
|
|
@@ -219,7 +220,7 @@ export class Meter {
|
|
|
219
220
|
async openAPIparseStatus(): Promise<void> {
|
|
220
221
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIparseStatus`);
|
|
221
222
|
|
|
222
|
-
//
|
|
223
|
+
// BatteryLevel
|
|
223
224
|
this.BatteryLevel = Number(this.OpenAPI_BatteryLevel);
|
|
224
225
|
if (this.BatteryLevel < 15) {
|
|
225
226
|
this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
|
|
@@ -228,17 +229,20 @@ export class Meter {
|
|
|
228
229
|
}
|
|
229
230
|
this.debugLog(`${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, StatusLowBattery: ${this.StatusLowBattery}`);
|
|
230
231
|
|
|
231
|
-
//
|
|
232
|
+
// CurrentRelativeHumidity
|
|
232
233
|
if (!this.device.meter?.hide_humidity) {
|
|
233
234
|
this.CurrentRelativeHumidity = this.OpenAPI_CurrentRelativeHumidity!;
|
|
234
235
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Humidity: ${this.CurrentRelativeHumidity}%`);
|
|
235
236
|
}
|
|
236
237
|
|
|
237
|
-
//
|
|
238
|
+
// CurrentTemperature
|
|
238
239
|
if (!this.device.meter?.hide_temperature) {
|
|
239
240
|
this.CurrentTemperature = this.OpenAPI_CurrentTemperature!;
|
|
240
241
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Temperature: ${this.CurrentTemperature}°c`);
|
|
241
242
|
}
|
|
243
|
+
|
|
244
|
+
// FirmwareRevision
|
|
245
|
+
this.FirmwareRevision = JSON.stringify(this.OpenAPI_FirmwareRevision);
|
|
242
246
|
}
|
|
243
247
|
|
|
244
248
|
/**
|
|
@@ -369,6 +373,8 @@ export class Meter {
|
|
|
369
373
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
370
374
|
const mqttmessage: string[] = [];
|
|
371
375
|
const entry = { time: Math.round(new Date().valueOf() / 1000) };
|
|
376
|
+
|
|
377
|
+
// CurrentRelativeHumidity
|
|
372
378
|
if (!this.device.meter?.hide_humidity) {
|
|
373
379
|
if (this.CurrentRelativeHumidity === undefined) {
|
|
374
380
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
|
|
@@ -387,6 +393,7 @@ export class Meter {
|
|
|
387
393
|
}
|
|
388
394
|
}
|
|
389
395
|
}
|
|
396
|
+
// CurrentTemperature
|
|
390
397
|
if (!this.device.meter?.hide_temperature) {
|
|
391
398
|
if (this.CurrentTemperature === undefined) {
|
|
392
399
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
|
|
@@ -402,6 +409,7 @@ export class Meter {
|
|
|
402
409
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
|
|
403
410
|
}
|
|
404
411
|
}
|
|
412
|
+
// BatteryLevel
|
|
405
413
|
if (this.BatteryLevel === undefined) {
|
|
406
414
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
|
|
407
415
|
} else {
|
|
@@ -422,7 +430,21 @@ export class Meter {
|
|
|
422
430
|
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
|
|
423
431
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
|
|
424
432
|
}
|
|
433
|
+
// FirmwareRevision
|
|
434
|
+
if (this.FirmwareRevision === undefined) {
|
|
435
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
|
|
436
|
+
} else {
|
|
437
|
+
if (this.device.mqttURL) {
|
|
438
|
+
mqttmessage.push(`"FirmwareRevision": ${this.FirmwareRevision}`);
|
|
439
|
+
}
|
|
440
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
441
|
+
this.accessory.getService(this.platform.Service.AccessoryInformation)!
|
|
442
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
443
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
444
|
+
+ `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
|
|
445
|
+
}
|
|
425
446
|
|
|
447
|
+
// MQTT
|
|
426
448
|
if (this.device.mqttURL) {
|
|
427
449
|
this.mqttPublish(`{${mqttmessage.join(',')}}`);
|
|
428
450
|
}
|
|
@@ -432,16 +454,6 @@ export class Meter {
|
|
|
432
454
|
this.historyService?.addEntry(entry);
|
|
433
455
|
}
|
|
434
456
|
}
|
|
435
|
-
// FirmwareRevision
|
|
436
|
-
if (this.OpenAPI_FirmwareRevision === undefined) {
|
|
437
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
|
|
438
|
-
} else {
|
|
439
|
-
this.accessory.context.OpenAPI_FirmwareRevision = this.OpenAPI_FirmwareRevision;
|
|
440
|
-
this.accessory.getService(this.platform.Service.AccessoryInformation)!
|
|
441
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
|
|
442
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
443
|
-
+ `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
|
|
444
|
-
}
|
|
445
457
|
}
|
|
446
458
|
|
|
447
459
|
/*
|
|
@@ -603,23 +615,23 @@ export class Meter {
|
|
|
603
615
|
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
604
616
|
}
|
|
605
617
|
|
|
606
|
-
|
|
607
|
-
let FirmwareRevision: string;
|
|
618
|
+
setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
|
|
608
619
|
this.debugLog(
|
|
609
620
|
`${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
|
|
610
621
|
);
|
|
611
622
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
612
623
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
613
624
|
if (device.firmware) {
|
|
614
|
-
FirmwareRevision = device.firmware;
|
|
625
|
+
this.FirmwareRevision = device.firmware;
|
|
615
626
|
} else if (device.version) {
|
|
616
|
-
FirmwareRevision = JSON.stringify(device.version);
|
|
627
|
+
this.FirmwareRevision = JSON.stringify(device.version);
|
|
617
628
|
} else if (accessory.context.FirmwareRevision) {
|
|
618
|
-
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
629
|
+
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
619
630
|
} else {
|
|
620
|
-
FirmwareRevision = this.platform.version;
|
|
631
|
+
this.FirmwareRevision = this.platform.version;
|
|
621
632
|
}
|
|
622
|
-
|
|
633
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
634
|
+
return this.FirmwareRevision;
|
|
623
635
|
}
|
|
624
636
|
|
|
625
637
|
async context() {
|
package/src/device/meterplus.ts
CHANGED
|
@@ -23,9 +23,10 @@ export class MeterPlus {
|
|
|
23
23
|
|
|
24
24
|
// Characteristic Values
|
|
25
25
|
BatteryLevel!: CharacteristicValue;
|
|
26
|
+
FirmwareRevision!: CharacteristicValue;
|
|
26
27
|
StatusLowBattery!: CharacteristicValue;
|
|
27
28
|
CurrentTemperature?: CharacteristicValue;
|
|
28
|
-
CurrentRelativeHumidity
|
|
29
|
+
CurrentRelativeHumidity?: CharacteristicValue;
|
|
29
30
|
|
|
30
31
|
// OpenAPI Status
|
|
31
32
|
OpenAPI_BatteryLevel: deviceStatus['battery'];
|
|
@@ -89,9 +90,9 @@ export class MeterPlus {
|
|
|
89
90
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
90
91
|
.setCharacteristic(this.platform.Characteristic.Model, this.model(device))
|
|
91
92
|
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
92
|
-
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.
|
|
93
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.setFirmwareRevision(accessory, device))
|
|
93
94
|
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
94
|
-
.updateValue(this.
|
|
95
|
+
.updateValue(this.setFirmwareRevision(accessory, device));
|
|
95
96
|
|
|
96
97
|
// Temperature Sensor Service
|
|
97
98
|
if (device.meter?.hide_temperature) {
|
|
@@ -145,7 +146,7 @@ export class MeterPlus {
|
|
|
145
146
|
minStep: 0.1,
|
|
146
147
|
})
|
|
147
148
|
.onGet(() => {
|
|
148
|
-
return this.CurrentRelativeHumidity
|
|
149
|
+
return this.CurrentRelativeHumidity!;
|
|
149
150
|
});
|
|
150
151
|
} else {
|
|
151
152
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Humidity Sensor Service Not Added`);
|
|
@@ -219,7 +220,7 @@ export class MeterPlus {
|
|
|
219
220
|
async openAPIparseStatus(): Promise<void> {
|
|
220
221
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIparseStatus`);
|
|
221
222
|
|
|
222
|
-
//
|
|
223
|
+
// BatteryLevel
|
|
223
224
|
this.BatteryLevel = Number(this.OpenAPI_BatteryLevel);
|
|
224
225
|
if (this.BatteryLevel < 15) {
|
|
225
226
|
this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
|
|
@@ -228,17 +229,20 @@ export class MeterPlus {
|
|
|
228
229
|
}
|
|
229
230
|
this.debugLog(`${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, StatusLowBattery: ${this.StatusLowBattery}`);
|
|
230
231
|
|
|
231
|
-
//
|
|
232
|
+
// CurrentRelativeHumidity
|
|
232
233
|
if (!this.device.meter?.hide_humidity) {
|
|
233
234
|
this.CurrentRelativeHumidity = this.OpenAPI_CurrentRelativeHumidity!;
|
|
234
235
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Humidity: ${this.CurrentRelativeHumidity}%`);
|
|
235
236
|
}
|
|
236
237
|
|
|
237
|
-
//
|
|
238
|
+
// CurrentTemperature
|
|
238
239
|
if (!this.device.meter?.hide_temperature) {
|
|
239
240
|
this.CurrentTemperature = this.OpenAPI_CurrentTemperature!;
|
|
240
241
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Temperature: ${this.CurrentTemperature}°c`);
|
|
241
242
|
}
|
|
243
|
+
|
|
244
|
+
// FirmwareRevision
|
|
245
|
+
this.FirmwareRevision = JSON.stringify(this.OpenAPI_FirmwareRevision);
|
|
242
246
|
}
|
|
243
247
|
|
|
244
248
|
/**
|
|
@@ -369,6 +373,8 @@ export class MeterPlus {
|
|
|
369
373
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
370
374
|
const mqttmessage: string[] = [];
|
|
371
375
|
const entry = { time: Math.round(new Date().valueOf() / 1000) };
|
|
376
|
+
|
|
377
|
+
// CurrentRelativeHumidity
|
|
372
378
|
if (!this.device.meter?.hide_humidity) {
|
|
373
379
|
if (this.CurrentRelativeHumidity === undefined) {
|
|
374
380
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
|
|
@@ -387,6 +393,7 @@ export class MeterPlus {
|
|
|
387
393
|
}
|
|
388
394
|
}
|
|
389
395
|
}
|
|
396
|
+
// CurrentTemperature
|
|
390
397
|
if (!this.device.meter?.hide_temperature) {
|
|
391
398
|
if (this.CurrentTemperature === undefined) {
|
|
392
399
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
|
|
@@ -402,7 +409,7 @@ export class MeterPlus {
|
|
|
402
409
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
|
|
403
410
|
}
|
|
404
411
|
}
|
|
405
|
-
|
|
412
|
+
// BatteryLevel
|
|
406
413
|
if (this.BatteryLevel === undefined) {
|
|
407
414
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
|
|
408
415
|
} else {
|
|
@@ -413,7 +420,7 @@ export class MeterPlus {
|
|
|
413
420
|
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
|
|
414
421
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
|
|
415
422
|
}
|
|
416
|
-
|
|
423
|
+
// StatusLowBattery
|
|
417
424
|
if (this.StatusLowBattery === undefined) {
|
|
418
425
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
|
|
419
426
|
} else {
|
|
@@ -424,6 +431,21 @@ export class MeterPlus {
|
|
|
424
431
|
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
|
|
425
432
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
|
|
426
433
|
}
|
|
434
|
+
// FirmwareRevision
|
|
435
|
+
if (this.FirmwareRevision === undefined) {
|
|
436
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
|
|
437
|
+
} else {
|
|
438
|
+
if (this.device.mqttURL) {
|
|
439
|
+
mqttmessage.push(`"FirmwareRevision": ${this.FirmwareRevision}`);
|
|
440
|
+
}
|
|
441
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
442
|
+
this.accessory.getService(this.platform.Service.AccessoryInformation)!
|
|
443
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
444
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
445
|
+
+ `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// MQTT
|
|
427
449
|
if (this.device.mqttURL) {
|
|
428
450
|
this.mqttPublish(`{${mqttmessage.join(',')}}`);
|
|
429
451
|
}
|
|
@@ -433,16 +455,6 @@ export class MeterPlus {
|
|
|
433
455
|
this.historyService?.addEntry(entry);
|
|
434
456
|
}
|
|
435
457
|
}
|
|
436
|
-
// FirmwareRevision
|
|
437
|
-
if (this.OpenAPI_FirmwareRevision === undefined) {
|
|
438
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
|
|
439
|
-
} else {
|
|
440
|
-
this.accessory.context.OpenAPI_FirmwareRevision = this.OpenAPI_FirmwareRevision;
|
|
441
|
-
this.accessory.getService(this.platform.Service.AccessoryInformation)!
|
|
442
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
|
|
443
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
444
|
-
+ `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
|
|
445
|
-
}
|
|
446
458
|
}
|
|
447
459
|
|
|
448
460
|
/*
|
|
@@ -614,23 +626,23 @@ export class MeterPlus {
|
|
|
614
626
|
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
615
627
|
}
|
|
616
628
|
|
|
617
|
-
|
|
618
|
-
let FirmwareRevision: string;
|
|
629
|
+
setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
|
|
619
630
|
this.debugLog(
|
|
620
631
|
`${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
|
|
621
632
|
);
|
|
622
633
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
623
634
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
624
635
|
if (device.firmware) {
|
|
625
|
-
FirmwareRevision = device.firmware;
|
|
636
|
+
this.FirmwareRevision = device.firmware;
|
|
626
637
|
} else if (device.version) {
|
|
627
|
-
FirmwareRevision = JSON.stringify(device.version);
|
|
638
|
+
this.FirmwareRevision = JSON.stringify(device.version);
|
|
628
639
|
} else if (accessory.context.FirmwareRevision) {
|
|
629
|
-
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
640
|
+
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
630
641
|
} else {
|
|
631
|
-
FirmwareRevision = this.platform.version;
|
|
642
|
+
this.FirmwareRevision = this.platform.version;
|
|
632
643
|
}
|
|
633
|
-
|
|
644
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
645
|
+
return this.FirmwareRevision;
|
|
634
646
|
}
|
|
635
647
|
|
|
636
648
|
async context() {
|
package/src/device/motion.ts
CHANGED
|
@@ -14,15 +14,16 @@ import { device, devicesConfig, serviceData, deviceStatus, ad, Devices } from '.
|
|
|
14
14
|
*/
|
|
15
15
|
export class Motion {
|
|
16
16
|
// Services
|
|
17
|
-
motionSensorService: Service;
|
|
18
|
-
lightSensorService?: Service;
|
|
19
17
|
batteryService: Service;
|
|
18
|
+
motionSensorService!: Service;
|
|
19
|
+
lightSensorService?: Service;
|
|
20
20
|
|
|
21
21
|
// Characteristic Values
|
|
22
|
-
MotionDetected!: CharacteristicValue;
|
|
23
|
-
CurrentAmbientLightLevel!: CharacteristicValue;
|
|
24
22
|
BatteryLevel!: CharacteristicValue;
|
|
23
|
+
MotionDetected!: CharacteristicValue;
|
|
25
24
|
StatusLowBattery!: CharacteristicValue;
|
|
25
|
+
FirmwareRevision!: CharacteristicValue;
|
|
26
|
+
CurrentAmbientLightLevel!: CharacteristicValue;
|
|
26
27
|
|
|
27
28
|
// OpenAPI Others
|
|
28
29
|
OpenAPI_BatteryLevel: deviceStatus['battery'];
|
|
@@ -38,11 +39,6 @@ export class Motion {
|
|
|
38
39
|
// BLE Others
|
|
39
40
|
scanning!: boolean;
|
|
40
41
|
BLE_IsConnected?: boolean;
|
|
41
|
-
/*is_light!: any; //serviceData['is_light'];
|
|
42
|
-
tested!: any;
|
|
43
|
-
led!: any;
|
|
44
|
-
iot!: any;
|
|
45
|
-
sense_distance!: any;*/
|
|
46
42
|
|
|
47
43
|
// Config
|
|
48
44
|
set_minLux!: number;
|
|
@@ -84,9 +80,9 @@ export class Motion {
|
|
|
84
80
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
85
81
|
.setCharacteristic(this.platform.Characteristic.Model, 'W1101500')
|
|
86
82
|
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
87
|
-
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.
|
|
83
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.setFirmwareRevision(accessory, device))
|
|
88
84
|
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
89
|
-
.updateValue(this.
|
|
85
|
+
.updateValue(this.setFirmwareRevision(accessory, device));
|
|
90
86
|
|
|
91
87
|
// get the Battery service if it exists, otherwise create a new Motion service
|
|
92
88
|
// you can create multiple services for each accessory
|
|
@@ -231,6 +227,9 @@ export class Motion {
|
|
|
231
227
|
this.debugLog(
|
|
232
228
|
`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel},` + ` StatusLowBattery: ${this.StatusLowBattery}`,
|
|
233
229
|
);
|
|
230
|
+
|
|
231
|
+
// FirmwareRevision
|
|
232
|
+
this.FirmwareRevision = JSON.stringify(this.OpenAPI_FirmwareRevision);
|
|
234
233
|
}
|
|
235
234
|
|
|
236
235
|
/**
|
|
@@ -403,15 +402,16 @@ export class Motion {
|
|
|
403
402
|
);
|
|
404
403
|
}
|
|
405
404
|
}
|
|
405
|
+
|
|
406
406
|
// FirmwareRevision
|
|
407
|
-
if (this.
|
|
408
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.
|
|
407
|
+
if (this.FirmwareRevision === undefined) {
|
|
408
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
|
|
409
409
|
} else {
|
|
410
|
-
this.accessory.context.
|
|
410
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
411
411
|
this.accessory.getService(this.platform.Service.AccessoryInformation)!
|
|
412
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.
|
|
412
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
413
413
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
414
|
-
+ `updateCharacteristic FirmwareRevision: ${this.
|
|
414
|
+
+ `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
417
|
|
|
@@ -561,23 +561,24 @@ export class Motion {
|
|
|
561
561
|
}
|
|
562
562
|
}
|
|
563
563
|
|
|
564
|
-
|
|
565
|
-
|
|
564
|
+
setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
|
|
565
|
+
|
|
566
566
|
this.debugLog(
|
|
567
567
|
`${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
|
|
568
568
|
);
|
|
569
569
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
570
570
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
571
571
|
if (device.firmware) {
|
|
572
|
-
FirmwareRevision = device.firmware;
|
|
572
|
+
this.FirmwareRevision = device.firmware;
|
|
573
573
|
} else if (device.version) {
|
|
574
|
-
FirmwareRevision = JSON.stringify(device.version);
|
|
574
|
+
this.FirmwareRevision = JSON.stringify(device.version);
|
|
575
575
|
} else if (accessory.context.FirmwareRevision) {
|
|
576
|
-
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
576
|
+
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
577
577
|
} else {
|
|
578
|
-
FirmwareRevision = this.platform.version;
|
|
578
|
+
this.FirmwareRevision = this.platform.version;
|
|
579
579
|
}
|
|
580
|
-
|
|
580
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
581
|
+
return this.FirmwareRevision;
|
|
581
582
|
}
|
|
582
583
|
|
|
583
584
|
async context() {
|