@switchbot/homebridge-switchbot 2.9.0-beta.9 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/config.schema.json +11 -5
- package/dist/device/blindtilt.d.ts +1 -1
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +38 -17
- 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 +64 -17
- 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 +34 -17
- 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 +31 -17
- 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 +41 -17
- 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 +38 -17
- 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 +172 -55
- 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 +37 -17
- 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 +41 -18
- 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 +34 -17
- 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 +38 -17
- 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 +47 -32
- 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 +69 -50
- 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 +38 -17
- 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 +35 -17
- 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 +35 -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 +28 -14
- 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 +28 -14
- 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 +28 -14
- 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 +28 -14
- 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 +28 -14
- 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 +35 -14
- 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 +28 -14
- 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 +28 -14
- 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 +28 -14
- 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/package.json +11 -11
- package/src/device/blindtilt.ts +38 -18
- package/src/device/bot.ts +55 -18
- package/src/device/ceilinglight.ts +34 -19
- package/src/device/colorbulb.ts +31 -18
- package/src/device/contact.ts +41 -19
- package/src/device/curtain.ts +38 -18
- package/src/device/hub.ts +188 -65
- package/src/device/humidifier.ts +37 -19
- package/src/device/iosensor.ts +41 -20
- package/src/device/lightstrip.ts +34 -18
- package/src/device/lock.ts +39 -20
- package/src/device/meter.ts +48 -40
- package/src/device/meterplus.ts +74 -60
- package/src/device/motion.ts +38 -20
- package/src/device/plug.ts +35 -19
- package/src/device/robotvacuumcleaner.ts +35 -18
- package/src/irdevice/airconditioner.ts +28 -15
- package/src/irdevice/airpurifier.ts +30 -15
- package/src/irdevice/camera.ts +30 -15
- package/src/irdevice/fan.ts +30 -15
- package/src/irdevice/light.ts +30 -15
- package/src/irdevice/other.ts +37 -15
- package/src/irdevice/tv.ts +30 -15
- package/src/irdevice/vacuumcleaner.ts +30 -15
- package/src/irdevice/waterheater.ts +30 -15
- package/src/platform.ts +4 -0
- package/.github/npm-version-script.js +0 -81
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,7 +247,7 @@ 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
253
|
this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
|
|
@@ -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
|
});
|
|
@@ -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() {
|
package/src/device/meterplus.ts
CHANGED
|
@@ -2,8 +2,7 @@ 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';
|
|
@@ -18,8 +17,8 @@ import { sleep } from '../utils';
|
|
|
18
17
|
export class MeterPlus {
|
|
19
18
|
// Services
|
|
20
19
|
batteryService: Service;
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
humidityService?: Service;
|
|
21
|
+
temperatureService?: Service;
|
|
23
22
|
|
|
24
23
|
// Characteristic Values
|
|
25
24
|
BatteryLevel!: CharacteristicValue;
|
|
@@ -55,10 +54,6 @@ export class MeterPlus {
|
|
|
55
54
|
deviceLogging!: string;
|
|
56
55
|
deviceRefreshRate!: number;
|
|
57
56
|
|
|
58
|
-
// Updates
|
|
59
|
-
meterUpdateInProgress!: boolean;
|
|
60
|
-
doMeterUpdate: Subject<void>;
|
|
61
|
-
|
|
62
57
|
// Connection
|
|
63
58
|
private readonly BLE = this.device.connectionType === 'BLE' || this.device.connectionType === 'BLE/OpenAPI';
|
|
64
59
|
private readonly OpenAPI = this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI';
|
|
@@ -72,15 +67,11 @@ export class MeterPlus {
|
|
|
72
67
|
this.logs(device);
|
|
73
68
|
this.scan(device);
|
|
74
69
|
this.refreshRate(device);
|
|
75
|
-
this.context();
|
|
70
|
+
this.context(accessory, device);
|
|
76
71
|
this.setupHistoryService(device);
|
|
77
72
|
this.setupMqtt(device);
|
|
78
73
|
this.config(device);
|
|
79
74
|
|
|
80
|
-
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
81
|
-
this.doMeterUpdate = new Subject();
|
|
82
|
-
this.meterUpdateInProgress = false;
|
|
83
|
-
|
|
84
75
|
// Retrieve initial values and updateHomekit
|
|
85
76
|
this.refreshStatus();
|
|
86
77
|
|
|
@@ -89,27 +80,37 @@ export class MeterPlus {
|
|
|
89
80
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
90
81
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
91
82
|
.setCharacteristic(this.platform.Characteristic.Model, this.model(device))
|
|
92
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
.
|
|
83
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
|
|
84
|
+
|
|
85
|
+
if (accessory.context.FirmwareRevision) {
|
|
86
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
87
|
+
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
88
|
+
accessory
|
|
89
|
+
.getService(this.platform.Service.AccessoryInformation)!
|
|
90
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
91
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
92
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
93
|
+
.updateValue(accessory.context.FirmwareRevision);
|
|
94
|
+
} else {
|
|
95
|
+
this.setFirmwareRevision(accessory, device);
|
|
96
|
+
}
|
|
96
97
|
|
|
97
98
|
// Temperature Sensor Service
|
|
98
99
|
if (device.meter?.hide_temperature) {
|
|
99
100
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Temperature Sensor Service`);
|
|
100
|
-
this.
|
|
101
|
-
accessory.removeService(this.
|
|
102
|
-
} else if (!this.
|
|
101
|
+
this.temperatureService = this.accessory.getService(this.platform.Service.TemperatureSensor);
|
|
102
|
+
accessory.removeService(this.temperatureService!);
|
|
103
|
+
} else if (!this.temperatureService) {
|
|
103
104
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Temperature Sensor Service`);
|
|
104
|
-
(this.
|
|
105
|
+
(this.temperatureService =
|
|
105
106
|
this.accessory.getService(this.platform.Service.TemperatureSensor) || this.accessory.addService(this.platform.Service.TemperatureSensor)),
|
|
106
107
|
`${accessory.displayName} Temperature Sensor`;
|
|
107
108
|
|
|
108
|
-
this.
|
|
109
|
-
if (!this.
|
|
110
|
-
this.
|
|
109
|
+
this.temperatureService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
|
|
110
|
+
if (!this.temperatureService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
111
|
+
this.temperatureService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Temperature Sensor`);
|
|
111
112
|
}
|
|
112
|
-
this.
|
|
113
|
+
this.temperatureService
|
|
113
114
|
.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
|
|
114
115
|
.setProps({
|
|
115
116
|
unit: Units['CELSIUS'],
|
|
@@ -128,19 +129,19 @@ export class MeterPlus {
|
|
|
128
129
|
// Humidity Sensor Service
|
|
129
130
|
if (device.meter?.hide_humidity) {
|
|
130
131
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Humidity Sensor Service`);
|
|
131
|
-
this.
|
|
132
|
-
accessory.removeService(this.
|
|
133
|
-
} else if (!this.
|
|
132
|
+
this.humidityService = this.accessory.getService(this.platform.Service.HumiditySensor);
|
|
133
|
+
accessory.removeService(this.humidityService!);
|
|
134
|
+
} else if (!this.humidityService) {
|
|
134
135
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Humidity Sensor Service`);
|
|
135
|
-
(this.
|
|
136
|
+
(this.humidityService =
|
|
136
137
|
this.accessory.getService(this.platform.Service.HumiditySensor) || this.accessory.addService(this.platform.Service.HumiditySensor)),
|
|
137
138
|
`${accessory.displayName} Humidity Sensor`;
|
|
138
139
|
|
|
139
|
-
this.
|
|
140
|
-
if (!this.
|
|
141
|
-
this.
|
|
140
|
+
this.humidityService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Humidity Sensor`);
|
|
141
|
+
if (!this.humidityService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
142
|
+
this.humidityService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Humidity Sensor`);
|
|
142
143
|
}
|
|
143
|
-
this.
|
|
144
|
+
this.humidityService
|
|
144
145
|
.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
|
|
145
146
|
.setProps({
|
|
146
147
|
minStep: 0.1,
|
|
@@ -167,7 +168,6 @@ export class MeterPlus {
|
|
|
167
168
|
|
|
168
169
|
// Start an update interval
|
|
169
170
|
interval(this.deviceRefreshRate * 1000)
|
|
170
|
-
.pipe(skipWhile(() => this.meterUpdateInProgress))
|
|
171
171
|
.subscribe(async () => {
|
|
172
172
|
await this.refreshStatus();
|
|
173
173
|
});
|
|
@@ -392,18 +392,18 @@ export class MeterPlus {
|
|
|
392
392
|
if (this.CurrentRelativeHumidity === undefined) {
|
|
393
393
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
|
|
394
394
|
} 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}` +
|
|
399
|
-
` updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`,
|
|
400
|
-
);
|
|
401
395
|
if (this.device.mqttURL) {
|
|
402
396
|
mqttmessage.push(`"humidity": ${this.CurrentRelativeHumidity}`);
|
|
403
397
|
}
|
|
404
398
|
if (this.device.history) {
|
|
405
399
|
entry['humidity'] = this.CurrentRelativeHumidity;
|
|
406
400
|
}
|
|
401
|
+
this.accessory.context.CurrentRelativeHumidity = this.CurrentRelativeHumidity;
|
|
402
|
+
this.humidityService?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
|
|
403
|
+
this.debugLog(
|
|
404
|
+
`${this.device.deviceType}: ${this.accessory.displayName}` +
|
|
405
|
+
` updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`,
|
|
406
|
+
);
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
409
|
// CurrentTemperature
|
|
@@ -418,7 +418,7 @@ export class MeterPlus {
|
|
|
418
418
|
entry['temp'] = this.CurrentTemperature;
|
|
419
419
|
}
|
|
420
420
|
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
421
|
-
this.
|
|
421
|
+
this.temperatureService?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
|
|
422
422
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
|
|
423
423
|
}
|
|
424
424
|
}
|
|
@@ -452,8 +452,14 @@ export class MeterPlus {
|
|
|
452
452
|
mqttmessage.push(`"FirmwareRevision": ${this.FirmwareRevision}`);
|
|
453
453
|
}
|
|
454
454
|
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
455
|
-
|
|
456
|
-
|
|
455
|
+
|
|
456
|
+
this.batteryService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
457
|
+
if (!this.device.meter?.hide_humidity) {
|
|
458
|
+
this.humidityService!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
459
|
+
}
|
|
460
|
+
if (!this.device.meter?.hide_temperature) {
|
|
461
|
+
this.temperatureService!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
462
|
+
}
|
|
457
463
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
458
464
|
+ `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
|
|
459
465
|
}
|
|
@@ -623,42 +629,44 @@ export class MeterPlus {
|
|
|
623
629
|
|
|
624
630
|
async offlineOff(): Promise<void> {
|
|
625
631
|
if (this.device.offline) {
|
|
626
|
-
await this.context();
|
|
632
|
+
await this.context(this.accessory, this.device);
|
|
627
633
|
await this.updateHomeKitCharacteristics();
|
|
628
634
|
}
|
|
629
635
|
}
|
|
630
636
|
|
|
631
637
|
async apiError(e: any): Promise<void> {
|
|
632
638
|
if (!this.device.meter?.hide_humidity) {
|
|
633
|
-
this.
|
|
639
|
+
this.humidityService?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, e);
|
|
634
640
|
}
|
|
635
641
|
if (!this.device.meter?.hide_temperature) {
|
|
636
|
-
this.
|
|
642
|
+
this.temperatureService?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
|
|
637
643
|
}
|
|
638
644
|
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
|
|
639
645
|
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
640
646
|
}
|
|
641
647
|
|
|
642
|
-
setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig)
|
|
643
|
-
this.
|
|
644
|
-
`${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
|
|
645
|
-
);
|
|
646
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
647
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
648
|
+
async setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig) {
|
|
649
|
+
await this.refreshStatus();
|
|
648
650
|
if (device.firmware) {
|
|
649
|
-
this.
|
|
650
|
-
|
|
651
|
-
this.FirmwareRevision = device.version;
|
|
652
|
-
} else if (accessory.context.FirmwareRevision) {
|
|
651
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
652
|
+
accessory.context.FirmwareRevision = device.firmware;
|
|
653
653
|
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
654
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
654
655
|
} else {
|
|
655
|
-
this.
|
|
656
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
|
|
657
|
+
accessory.context.FirmwareRevision = device.version;
|
|
658
|
+
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
659
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
656
660
|
}
|
|
657
|
-
this.
|
|
658
|
-
|
|
661
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
662
|
+
accessory
|
|
663
|
+
.getService(this.platform.Service.AccessoryInformation)!
|
|
664
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
665
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
666
|
+
.updateValue(this.FirmwareRevision);
|
|
659
667
|
}
|
|
660
668
|
|
|
661
|
-
async context() {
|
|
669
|
+
async context(accessory, device) {
|
|
662
670
|
if (this.CurrentRelativeHumidity === undefined) {
|
|
663
671
|
this.CurrentRelativeHumidity = 0;
|
|
664
672
|
} else {
|
|
@@ -680,6 +688,12 @@ export class MeterPlus {
|
|
|
680
688
|
} else {
|
|
681
689
|
this.StatusLowBattery = this.accessory.context.StatusLowBattery;
|
|
682
690
|
}
|
|
691
|
+
if (this.FirmwareRevision === undefined) {
|
|
692
|
+
this.FirmwareRevision = this.platform.version;
|
|
693
|
+
} else {
|
|
694
|
+
this.setFirmwareRevision(accessory, device);
|
|
695
|
+
this.FirmwareRevision = this.accessory.context.FirmwareRevision;
|
|
696
|
+
}
|
|
683
697
|
}
|
|
684
698
|
|
|
685
699
|
async refreshRate(device: device & devicesConfig): Promise<void> {
|
package/src/device/motion.ts
CHANGED
|
@@ -79,10 +79,20 @@ export class Motion {
|
|
|
79
79
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
80
80
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
81
81
|
.setCharacteristic(this.platform.Characteristic.Model, 'W1101500')
|
|
82
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
.
|
|
82
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
|
|
83
|
+
|
|
84
|
+
if (accessory.context.FirmwareRevision) {
|
|
85
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
86
|
+
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
87
|
+
accessory
|
|
88
|
+
.getService(this.platform.Service.AccessoryInformation)!
|
|
89
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
90
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
91
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
92
|
+
.updateValue(accessory.context.FirmwareRevision);
|
|
93
|
+
} else {
|
|
94
|
+
this.setFirmwareRevision(accessory, device);
|
|
95
|
+
}
|
|
86
96
|
|
|
87
97
|
// get the Battery service if it exists, otherwise create a new Motion service
|
|
88
98
|
// you can create multiple services for each accessory
|
|
@@ -402,14 +412,16 @@ export class Motion {
|
|
|
402
412
|
);
|
|
403
413
|
}
|
|
404
414
|
}
|
|
405
|
-
|
|
406
415
|
// FirmwareRevision
|
|
407
416
|
if (this.FirmwareRevision === undefined) {
|
|
408
417
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
|
|
409
418
|
} else {
|
|
410
419
|
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
411
|
-
this.
|
|
412
|
-
|
|
420
|
+
this.motionSensorService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
421
|
+
this.batteryService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
422
|
+
if (!this.device.motion?.hide_lightsensor) {
|
|
423
|
+
this.lightSensorService!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
424
|
+
}
|
|
413
425
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
414
426
|
+ `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
|
|
415
427
|
}
|
|
@@ -561,24 +573,30 @@ export class Motion {
|
|
|
561
573
|
}
|
|
562
574
|
}
|
|
563
575
|
|
|
564
|
-
setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig)
|
|
565
|
-
|
|
566
|
-
this.debugLog(
|
|
567
|
-
`${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
|
|
568
|
-
);
|
|
569
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
570
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
576
|
+
async setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig) {
|
|
577
|
+
await this.refreshStatus();
|
|
571
578
|
if (device.firmware) {
|
|
572
|
-
this.
|
|
579
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
580
|
+
accessory.context.FirmwareRevision = device.firmware;
|
|
581
|
+
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
582
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
573
583
|
} else if (device.version) {
|
|
574
|
-
this.
|
|
575
|
-
|
|
584
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
|
|
585
|
+
accessory.context.FirmwareRevision = device.version;
|
|
576
586
|
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
587
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
577
588
|
} else {
|
|
578
|
-
this.
|
|
589
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
590
|
+
accessory.context.FirmwareRevision = this.platform.version;
|
|
591
|
+
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
592
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
579
593
|
}
|
|
580
|
-
this.
|
|
581
|
-
|
|
594
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
595
|
+
accessory
|
|
596
|
+
.getService(this.platform.Service.AccessoryInformation)!
|
|
597
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
598
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
599
|
+
.updateValue(this.FirmwareRevision);
|
|
582
600
|
}
|
|
583
601
|
|
|
584
602
|
async context() {
|