@switchbot/homebridge-switchbot 2.9.0-beta.2 → 2.9.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config.schema.json +18 -4
- package/dist/device/blindtilt.d.ts +1 -1
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +39 -18
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +73 -20
- 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 +35 -18
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +35 -18
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +42 -18
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +39 -18
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +8 -9
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +160 -56
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +38 -18
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +42 -19
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +35 -18
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +39 -18
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +1 -9
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +48 -33
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +4 -7
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +70 -51
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +39 -18
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +36 -18
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +38 -17
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +29 -15
- 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 +29 -15
- 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 +29 -15
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +29 -15
- 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 +29 -15
- 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 +50 -23
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +29 -15
- 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 +29 -15
- 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 +29 -15
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +4 -0
- 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/package.json +10 -10
- package/src/device/blindtilt.ts +39 -19
- package/src/device/bot.ts +63 -21
- package/src/device/ceilinglight.ts +35 -20
- package/src/device/colorbulb.ts +35 -19
- package/src/device/contact.ts +42 -20
- package/src/device/curtain.ts +39 -19
- package/src/device/hub.ts +176 -66
- package/src/device/humidifier.ts +38 -20
- package/src/device/iosensor.ts +42 -21
- package/src/device/lightstrip.ts +35 -19
- package/src/device/lock.ts +40 -21
- package/src/device/meter.ts +49 -41
- package/src/device/meterplus.ts +75 -61
- package/src/device/motion.ts +39 -21
- package/src/device/plug.ts +36 -20
- package/src/device/robotvacuumcleaner.ts +38 -19
- package/src/irdevice/airconditioner.ts +29 -16
- package/src/irdevice/airpurifier.ts +31 -16
- package/src/irdevice/camera.ts +31 -16
- package/src/irdevice/fan.ts +31 -16
- package/src/irdevice/light.ts +31 -16
- package/src/irdevice/other.ts +50 -24
- package/src/irdevice/tv.ts +31 -16
- package/src/irdevice/vacuumcleaner.ts +31 -16
- package/src/irdevice/waterheater.ts +31 -16
- package/src/platform.ts +4 -0
- package/src/settings.ts +1 -0
package/src/device/iosensor.ts
CHANGED
|
@@ -89,10 +89,20 @@ export class IOSensor {
|
|
|
89
89
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
90
90
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
91
91
|
.setCharacteristic(this.platform.Characteristic.Model, 'WoIOSensor')
|
|
92
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
.
|
|
92
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
|
|
93
|
+
|
|
94
|
+
if (accessory.context.FirmwareRevision) {
|
|
95
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
96
|
+
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
97
|
+
accessory
|
|
98
|
+
.getService(this.platform.Service.AccessoryInformation)!
|
|
99
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
100
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
101
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
102
|
+
.updateValue(accessory.context.FirmwareRevision);
|
|
103
|
+
} else {
|
|
104
|
+
this.setFirmwareRevision(accessory, device);
|
|
105
|
+
}
|
|
96
106
|
|
|
97
107
|
// Temperature Sensor Service
|
|
98
108
|
if (device.meter?.hide_temperature) {
|
|
@@ -254,7 +264,7 @@ export class IOSensor {
|
|
|
254
264
|
+ ` StatusLowBattery: ${this.StatusLowBattery}`);
|
|
255
265
|
|
|
256
266
|
// FirmwareRevision
|
|
257
|
-
this.FirmwareRevision =
|
|
267
|
+
this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
|
|
258
268
|
}
|
|
259
269
|
|
|
260
270
|
/**
|
|
@@ -290,7 +300,7 @@ export class IOSensor {
|
|
|
290
300
|
if (switchbot !== false) {
|
|
291
301
|
switchbot
|
|
292
302
|
.startScan({
|
|
293
|
-
model: '
|
|
303
|
+
model: 'w',
|
|
294
304
|
id: this.device.bleMac,
|
|
295
305
|
})
|
|
296
306
|
.then(async () => {
|
|
@@ -453,8 +463,13 @@ export class IOSensor {
|
|
|
453
463
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
|
|
454
464
|
} else {
|
|
455
465
|
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
456
|
-
this.
|
|
457
|
-
|
|
466
|
+
this.batteryService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
467
|
+
if (this.device.meter?.hide_humidity) {
|
|
468
|
+
this.humidityservice!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
469
|
+
}
|
|
470
|
+
if (this.device.meter?.hide_temperature) {
|
|
471
|
+
this.temperatureservice!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
472
|
+
}
|
|
458
473
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
459
474
|
+ `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
|
|
460
475
|
}
|
|
@@ -619,24 +634,30 @@ export class IOSensor {
|
|
|
619
634
|
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
620
635
|
}
|
|
621
636
|
|
|
622
|
-
setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig)
|
|
623
|
-
|
|
624
|
-
this.debugLog(
|
|
625
|
-
`${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
|
|
626
|
-
);
|
|
627
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
628
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
637
|
+
async setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig) {
|
|
638
|
+
await this.refreshStatus();
|
|
629
639
|
if (device.firmware) {
|
|
630
|
-
this.
|
|
640
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
641
|
+
accessory.context.FirmwareRevision = device.firmware;
|
|
642
|
+
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
643
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
631
644
|
} else if (device.version) {
|
|
632
|
-
this.
|
|
633
|
-
|
|
645
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
|
|
646
|
+
accessory.context.FirmwareRevision = device.version;
|
|
634
647
|
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
648
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
635
649
|
} else {
|
|
636
|
-
this.
|
|
650
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
651
|
+
accessory.context.FirmwareRevision = this.platform.version;
|
|
652
|
+
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
653
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
637
654
|
}
|
|
638
|
-
this.
|
|
639
|
-
|
|
655
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
656
|
+
accessory
|
|
657
|
+
.getService(this.platform.Service.AccessoryInformation)!
|
|
658
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
659
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
660
|
+
.updateValue(this.FirmwareRevision);
|
|
640
661
|
}
|
|
641
662
|
|
|
642
663
|
async context() {
|
package/src/device/lightstrip.ts
CHANGED
|
@@ -86,10 +86,20 @@ export class StripLight {
|
|
|
86
86
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
87
87
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
88
88
|
.setCharacteristic(this.platform.Characteristic.Model, 'W1701100')
|
|
89
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
.
|
|
89
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
|
|
90
|
+
|
|
91
|
+
if (accessory.context.FirmwareRevision) {
|
|
92
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
93
|
+
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
94
|
+
accessory
|
|
95
|
+
.getService(this.platform.Service.AccessoryInformation)!
|
|
96
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
97
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
98
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
99
|
+
.updateValue(accessory.context.FirmwareRevision);
|
|
100
|
+
} else {
|
|
101
|
+
this.setFirmwareRevision(accessory, device);
|
|
102
|
+
}
|
|
93
103
|
|
|
94
104
|
// get the Lightbulb service if it exists, otherwise create a new Lightbulb service
|
|
95
105
|
// you can create multiple services for each accessory
|
|
@@ -278,7 +288,7 @@ export class StripLight {
|
|
|
278
288
|
}
|
|
279
289
|
|
|
280
290
|
// FirmwareRevision
|
|
281
|
-
this.FirmwareRevision =
|
|
291
|
+
this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
|
|
282
292
|
}
|
|
283
293
|
|
|
284
294
|
/**
|
|
@@ -865,8 +875,7 @@ export class StripLight {
|
|
|
865
875
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
|
|
866
876
|
} else {
|
|
867
877
|
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
868
|
-
this.
|
|
869
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
878
|
+
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
870
879
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
871
880
|
+ `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
|
|
872
881
|
}
|
|
@@ -1025,23 +1034,30 @@ export class StripLight {
|
|
|
1025
1034
|
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Saturation, e);
|
|
1026
1035
|
}
|
|
1027
1036
|
|
|
1028
|
-
setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig)
|
|
1029
|
-
this.
|
|
1030
|
-
`${this.device.deviceType}: ${this.accessory.displayName} ` + `accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
|
|
1031
|
-
);
|
|
1032
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
1033
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
1037
|
+
async setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig) {
|
|
1038
|
+
await this.refreshStatus();
|
|
1034
1039
|
if (device.firmware) {
|
|
1035
|
-
this.
|
|
1040
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
1041
|
+
accessory.context.FirmwareRevision = device.firmware;
|
|
1042
|
+
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
1043
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
1036
1044
|
} else if (device.version) {
|
|
1037
|
-
this.
|
|
1038
|
-
|
|
1045
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
|
|
1046
|
+
accessory.context.FirmwareRevision = device.version;
|
|
1039
1047
|
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
1048
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
1040
1049
|
} else {
|
|
1041
|
-
this.
|
|
1050
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
1051
|
+
accessory.context.FirmwareRevision = this.platform.version;
|
|
1052
|
+
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
1053
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
1042
1054
|
}
|
|
1043
|
-
this.
|
|
1044
|
-
|
|
1055
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
1056
|
+
accessory
|
|
1057
|
+
.getService(this.platform.Service.AccessoryInformation)!
|
|
1058
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
1059
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
1060
|
+
.updateValue(this.FirmwareRevision);
|
|
1045
1061
|
}
|
|
1046
1062
|
|
|
1047
1063
|
async context() {
|
package/src/device/lock.ts
CHANGED
|
@@ -74,10 +74,20 @@ export class Lock {
|
|
|
74
74
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
75
75
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
76
76
|
.setCharacteristic(this.platform.Characteristic.Model, 'W1601700')
|
|
77
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
.
|
|
77
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
|
|
78
|
+
|
|
79
|
+
if (accessory.context.FirmwareRevision) {
|
|
80
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
81
|
+
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
82
|
+
accessory
|
|
83
|
+
.getService(this.platform.Service.AccessoryInformation)!
|
|
84
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
85
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
86
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
87
|
+
.updateValue(accessory.context.FirmwareRevision);
|
|
88
|
+
} else {
|
|
89
|
+
this.setFirmwareRevision(accessory, device);
|
|
90
|
+
}
|
|
81
91
|
|
|
82
92
|
// get the LockMechanism service if it exists, otherwise create a new LockMechanism service
|
|
83
93
|
// you can create multiple services for each accessory
|
|
@@ -237,10 +247,10 @@ export class Lock {
|
|
|
237
247
|
this.BatteryLevel = 100;
|
|
238
248
|
}
|
|
239
249
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel},`
|
|
240
|
-
|
|
250
|
+
+ ` StatusLowBattery: ${this.StatusLowBattery}`);
|
|
241
251
|
|
|
242
252
|
// FirmwareRevision
|
|
243
|
-
this.FirmwareRevision =
|
|
253
|
+
this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
|
|
244
254
|
}
|
|
245
255
|
|
|
246
256
|
/**
|
|
@@ -538,8 +548,11 @@ export class Lock {
|
|
|
538
548
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
|
|
539
549
|
} else {
|
|
540
550
|
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
541
|
-
this.
|
|
542
|
-
|
|
551
|
+
this.lockService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
552
|
+
this.batteryService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
553
|
+
if (this.device.lock?.hide_contactsensor) {
|
|
554
|
+
this.contactSensorService!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
555
|
+
}
|
|
543
556
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
544
557
|
+ `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
|
|
545
558
|
}
|
|
@@ -659,24 +672,30 @@ export class Lock {
|
|
|
659
672
|
this.lockService.updateCharacteristic(this.platform.Characteristic.LockCurrentState, e);
|
|
660
673
|
}
|
|
661
674
|
|
|
662
|
-
setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig)
|
|
663
|
-
|
|
664
|
-
this.debugLog(
|
|
665
|
-
`${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
|
|
666
|
-
);
|
|
667
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
668
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
675
|
+
async setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig) {
|
|
676
|
+
await this.refreshStatus();
|
|
669
677
|
if (device.firmware) {
|
|
670
|
-
this.
|
|
678
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
679
|
+
accessory.context.FirmwareRevision = device.firmware;
|
|
680
|
+
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
681
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
671
682
|
} else if (device.version) {
|
|
672
|
-
this.
|
|
673
|
-
|
|
683
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
|
|
684
|
+
accessory.context.FirmwareRevision = device.version;
|
|
674
685
|
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
686
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
675
687
|
} else {
|
|
676
|
-
this.
|
|
688
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
689
|
+
accessory.context.FirmwareRevision = this.platform.version;
|
|
690
|
+
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
691
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
677
692
|
}
|
|
678
|
-
this.
|
|
679
|
-
|
|
693
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
694
|
+
accessory
|
|
695
|
+
.getService(this.platform.Service.AccessoryInformation)!
|
|
696
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
697
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
698
|
+
.updateValue(this.FirmwareRevision);
|
|
680
699
|
}
|
|
681
700
|
|
|
682
701
|
async context() {
|
package/src/device/meter.ts
CHANGED
|
@@ -2,19 +2,13 @@ import { connectAsync } from 'async-mqtt';
|
|
|
2
2
|
import { CharacteristicValue, PlatformAccessory, Service, Units } from 'homebridge';
|
|
3
3
|
import { MqttClient } from 'mqtt';
|
|
4
4
|
import { hostname } from 'os';
|
|
5
|
-
import {
|
|
6
|
-
import { skipWhile } from 'rxjs/operators';
|
|
5
|
+
import { interval } from 'rxjs';
|
|
7
6
|
import { request } from 'undici';
|
|
8
7
|
import { Context } from 'vm';
|
|
9
8
|
import { SwitchBotPlatform } from '../platform';
|
|
10
9
|
import { Devices, ad, device, deviceStatus, devicesConfig, serviceData, temperature } from '../settings';
|
|
11
10
|
import { sleep } from '../utils';
|
|
12
11
|
|
|
13
|
-
/**
|
|
14
|
-
* Platform Accessory
|
|
15
|
-
* An instance of this class is created for each accessory your platform registers
|
|
16
|
-
* Each accessory may expose multiple services of different service types.
|
|
17
|
-
*/
|
|
18
12
|
export class Meter {
|
|
19
13
|
// Services
|
|
20
14
|
batteryService: Service;
|
|
@@ -55,10 +49,6 @@ export class Meter {
|
|
|
55
49
|
deviceLogging!: string;
|
|
56
50
|
deviceRefreshRate!: number;
|
|
57
51
|
|
|
58
|
-
// Updates
|
|
59
|
-
meterUpdateInProgress!: boolean;
|
|
60
|
-
doMeterUpdate: Subject<void>;
|
|
61
|
-
|
|
62
52
|
// Connection
|
|
63
53
|
private readonly BLE = this.device.connectionType === 'BLE' || this.device.connectionType === 'BLE/OpenAPI';
|
|
64
54
|
private readonly OpenAPI = this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI';
|
|
@@ -77,9 +67,8 @@ export class Meter {
|
|
|
77
67
|
this.setupMqtt(device);
|
|
78
68
|
this.config(device);
|
|
79
69
|
|
|
80
|
-
|
|
81
|
-
this.
|
|
82
|
-
this.meterUpdateInProgress = false;
|
|
70
|
+
this.CurrentRelativeHumidity = accessory.context.CurrentRelativeHumidity;
|
|
71
|
+
this.CurrentTemperature = accessory.context.CurrentTemperature;
|
|
83
72
|
|
|
84
73
|
// Retrieve initial values and updateHomekit
|
|
85
74
|
this.refreshStatus();
|
|
@@ -89,10 +78,20 @@ export class Meter {
|
|
|
89
78
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
90
79
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
91
80
|
.setCharacteristic(this.platform.Characteristic.Model, 'METERTH-S1')
|
|
92
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
.
|
|
81
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
|
|
82
|
+
|
|
83
|
+
if (accessory.context.FirmwareRevision) {
|
|
84
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
85
|
+
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
86
|
+
accessory
|
|
87
|
+
.getService(this.platform.Service.AccessoryInformation)!
|
|
88
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
89
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
90
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
91
|
+
.updateValue(accessory.context.FirmwareRevision);
|
|
92
|
+
} else {
|
|
93
|
+
this.setFirmwareRevision(accessory, device);
|
|
94
|
+
}
|
|
96
95
|
|
|
97
96
|
// Temperature Sensor Service
|
|
98
97
|
if (device.meter?.hide_temperature) {
|
|
@@ -162,12 +161,11 @@ export class Meter {
|
|
|
162
161
|
}
|
|
163
162
|
this.batteryService.setCharacteristic(this.platform.Characteristic.ChargingState, this.platform.Characteristic.ChargingState.NOT_CHARGEABLE);
|
|
164
163
|
|
|
165
|
-
// Retrieve initial values and
|
|
164
|
+
// Retrieve initial values and update Homekit
|
|
166
165
|
this.updateHomeKitCharacteristics();
|
|
167
166
|
|
|
168
167
|
// Start an update interval
|
|
169
168
|
interval(this.deviceRefreshRate * 1000)
|
|
170
|
-
.pipe(skipWhile(() => this.meterUpdateInProgress))
|
|
171
169
|
.subscribe(async () => {
|
|
172
170
|
await this.refreshStatus();
|
|
173
171
|
});
|
|
@@ -255,7 +253,7 @@ export class Meter {
|
|
|
255
253
|
+ ` StatusLowBattery: ${this.StatusLowBattery}`);
|
|
256
254
|
|
|
257
255
|
// FirmwareRevision
|
|
258
|
-
this.FirmwareRevision =
|
|
256
|
+
this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
|
|
259
257
|
}
|
|
260
258
|
|
|
261
259
|
/**
|
|
@@ -392,18 +390,16 @@ export class Meter {
|
|
|
392
390
|
if (this.CurrentRelativeHumidity === undefined) {
|
|
393
391
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
|
|
394
392
|
} else {
|
|
395
|
-
this.accessory.context.CurrentRelativeHumidity = this.CurrentRelativeHumidity;
|
|
396
|
-
this.humidityService?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
|
|
397
|
-
this.debugLog(
|
|
398
|
-
`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic` +
|
|
399
|
-
` CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`,
|
|
400
|
-
);
|
|
401
393
|
if (this.device.mqttURL) {
|
|
402
394
|
mqttmessage.push(`"humidity": ${this.CurrentRelativeHumidity}`);
|
|
403
395
|
}
|
|
404
396
|
if (this.device.history) {
|
|
405
397
|
entry['humidity'] = this.CurrentRelativeHumidity;
|
|
406
398
|
}
|
|
399
|
+
this.accessory.context.CurrentRelativeHumidity = this.CurrentRelativeHumidity;
|
|
400
|
+
this.humidityService?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
|
|
401
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
402
|
+
+ `updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
|
|
407
403
|
}
|
|
408
404
|
}
|
|
409
405
|
// CurrentTemperature
|
|
@@ -451,8 +447,13 @@ export class Meter {
|
|
|
451
447
|
mqttmessage.push(`"FirmwareRevision": ${this.FirmwareRevision}`);
|
|
452
448
|
}
|
|
453
449
|
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
454
|
-
this.
|
|
455
|
-
|
|
450
|
+
this.batteryService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
451
|
+
if (!this.device.meter?.hide_humidity) {
|
|
452
|
+
this.humidityService!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
453
|
+
}
|
|
454
|
+
if (!this.device.meter?.hide_temperature) {
|
|
455
|
+
this.temperatureService!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
456
|
+
}
|
|
456
457
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
457
458
|
+ `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
|
|
458
459
|
}
|
|
@@ -628,23 +629,30 @@ export class Meter {
|
|
|
628
629
|
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
629
630
|
}
|
|
630
631
|
|
|
631
|
-
setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig)
|
|
632
|
-
this.
|
|
633
|
-
`${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
|
|
634
|
-
);
|
|
635
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
636
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
632
|
+
async setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig) {
|
|
633
|
+
await this.refreshStatus();
|
|
637
634
|
if (device.firmware) {
|
|
638
|
-
this.
|
|
635
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
636
|
+
accessory.context.FirmwareRevision = device.firmware;
|
|
637
|
+
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
638
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
639
639
|
} else if (device.version) {
|
|
640
|
-
this.
|
|
641
|
-
|
|
640
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
|
|
641
|
+
accessory.context.FirmwareRevision = device.version;
|
|
642
642
|
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
643
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
643
644
|
} else {
|
|
644
|
-
this.
|
|
645
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
646
|
+
accessory.context.FirmwareRevision = this.platform.version;
|
|
647
|
+
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
648
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
645
649
|
}
|
|
646
|
-
this.
|
|
647
|
-
|
|
650
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
651
|
+
accessory
|
|
652
|
+
.getService(this.platform.Service.AccessoryInformation)!
|
|
653
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
654
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
655
|
+
.updateValue(this.FirmwareRevision);
|
|
648
656
|
}
|
|
649
657
|
|
|
650
658
|
async context() {
|