@switchbot/homebridge-switchbot 2.8.0-beta.1 → 2.8.0-beta.11
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/dist/device/blindtilt.d.ts +1 -0
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +9 -6
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +2 -0
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +53 -44
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +1 -0
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +12 -9
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +1 -0
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +8 -5
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +2 -0
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +45 -34
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +2 -0
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +33 -36
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +3 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +29 -4
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +9 -6
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +1 -0
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +10 -6
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +1 -0
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +9 -6
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +2 -0
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +11 -6
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +2 -0
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +12 -8
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +4 -3
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +56 -54
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +2 -0
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +46 -31
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +1 -0
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +9 -6
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +2 -0
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +27 -2
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +7 -5
- 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 +3 -3
- 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 +3 -3
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +2 -2
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +3 -3
- 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 +3 -3
- 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 +3 -3
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +2 -2
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +3 -3
- 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 +3 -3
- 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 +3 -3
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +3 -2
- package/dist/platform.js.map +1 -1
- package/package.json +3 -3
- package/src/device/blindtilt.ts +8 -6
- package/src/device/bot.ts +53 -41
- package/src/device/ceilinglight.ts +12 -6
- package/src/device/colorbulb.ts +10 -5
- package/src/device/contact.ts +44 -30
- package/src/device/curtain.ts +32 -33
- package/src/device/hub.ts +30 -4
- package/src/device/humidifier.ts +8 -5
- package/src/device/iosensor.ts +10 -6
- package/src/device/lightstrip.ts +10 -5
- package/src/device/lock.ts +12 -5
- package/src/device/meter.ts +12 -7
- package/src/device/meterplus.ts +61 -54
- package/src/device/motion.ts +45 -27
- package/src/device/plug.ts +8 -5
- package/src/device/robotvacuumcleaner.ts +31 -2
- package/src/irdevice/airconditioner.ts +7 -5
- package/src/irdevice/airpurifier.ts +5 -5
- package/src/irdevice/camera.ts +5 -5
- package/src/irdevice/fan.ts +5 -5
- package/src/irdevice/light.ts +5 -5
- package/src/irdevice/other.ts +5 -5
- package/src/irdevice/tv.ts +5 -5
- package/src/irdevice/vacuumcleaner.ts +5 -5
- package/src/irdevice/waterheater.ts +5 -5
- package/src/platform.ts +3 -2
- package/src/settings.ts +1 -1
package/src/device/hub.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { interval } from 'rxjs';
|
|
|
3
3
|
import { request } from 'undici';
|
|
4
4
|
import { Context } from 'vm';
|
|
5
5
|
import { SwitchBotPlatform } from '../platform';
|
|
6
|
-
import { Devices, device, devicesConfig } from '../settings';
|
|
6
|
+
import { Devices, device, deviceStatus, devicesConfig } from '../settings';
|
|
7
7
|
import { sleep } from '../utils';
|
|
8
8
|
|
|
9
9
|
export class Hub {
|
|
@@ -18,6 +18,7 @@ export class Hub {
|
|
|
18
18
|
CurrentAmbientLightLevel!: number;
|
|
19
19
|
|
|
20
20
|
// OpenAPI Others
|
|
21
|
+
Version: deviceStatus['version'];
|
|
21
22
|
deviceStatus!: any; //deviceStatusResponse;
|
|
22
23
|
lightLevel!: number;
|
|
23
24
|
spaceBetweenLevels!: number;
|
|
@@ -43,6 +44,7 @@ export class Hub {
|
|
|
43
44
|
// default placeholders
|
|
44
45
|
this.logs(device);
|
|
45
46
|
this.refreshRate(device);
|
|
47
|
+
this.config(device);
|
|
46
48
|
|
|
47
49
|
this.CurrentRelativeHumidity = accessory.context.CurrentRelativeHumidity;
|
|
48
50
|
this.CurrentTemperature = accessory.context.CurrentTemperature;
|
|
@@ -443,10 +445,12 @@ export class Hub {
|
|
|
443
445
|
);
|
|
444
446
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
445
447
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
446
|
-
if (
|
|
447
|
-
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
448
|
-
} else if (device.firmware) {
|
|
448
|
+
if (device.firmware) {
|
|
449
449
|
FirmwareRevision = device.firmware;
|
|
450
|
+
} else if (device.version) {
|
|
451
|
+
FirmwareRevision = JSON.stringify(device.version);
|
|
452
|
+
} else if (accessory.context.FirmwareRevision) {
|
|
453
|
+
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
450
454
|
} else {
|
|
451
455
|
FirmwareRevision = this.platform.version;
|
|
452
456
|
}
|
|
@@ -472,6 +476,28 @@ export class Hub {
|
|
|
472
476
|
}
|
|
473
477
|
}
|
|
474
478
|
|
|
479
|
+
async config(device: device & devicesConfig): Promise<void> {
|
|
480
|
+
let config = {};
|
|
481
|
+
if (device.hub) {
|
|
482
|
+
config = device.hub;
|
|
483
|
+
}
|
|
484
|
+
if (device.connectionType !== undefined) {
|
|
485
|
+
config['connectionType'] = device.connectionType;
|
|
486
|
+
}
|
|
487
|
+
if (device.external !== undefined) {
|
|
488
|
+
config['external'] = device.external;
|
|
489
|
+
}
|
|
490
|
+
if (device.logging !== undefined) {
|
|
491
|
+
config['logging'] = device.logging;
|
|
492
|
+
}
|
|
493
|
+
if (device.refreshRate !== undefined) {
|
|
494
|
+
config['refreshRate'] = device.refreshRate;
|
|
495
|
+
}
|
|
496
|
+
if (Object.entries(config).length !== 0) {
|
|
497
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
475
501
|
async logs(device: device & devicesConfig): Promise<void> {
|
|
476
502
|
if (this.platform.debugMode) {
|
|
477
503
|
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
package/src/device/humidifier.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable brace-style */
|
|
1
2
|
import { Context } from 'vm';
|
|
2
3
|
import { request } from 'undici';
|
|
3
4
|
import { sleep } from '../utils';
|
|
@@ -66,8 +67,8 @@ export class Humidifier {
|
|
|
66
67
|
this.logs(device);
|
|
67
68
|
this.scan(device);
|
|
68
69
|
this.refreshRate(device);
|
|
69
|
-
this.config(device);
|
|
70
70
|
this.context();
|
|
71
|
+
this.config(device);
|
|
71
72
|
|
|
72
73
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
73
74
|
this.doHumidifierUpdate = new Subject();
|
|
@@ -844,10 +845,12 @@ export class Humidifier {
|
|
|
844
845
|
);
|
|
845
846
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
846
847
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
847
|
-
if (
|
|
848
|
-
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
849
|
-
} else if (device.firmware) {
|
|
848
|
+
if (device.firmware) {
|
|
850
849
|
FirmwareRevision = device.firmware;
|
|
850
|
+
} else if (device.version) {
|
|
851
|
+
FirmwareRevision = JSON.stringify(device.version);
|
|
852
|
+
} else if (accessory.context.FirmwareRevision) {
|
|
853
|
+
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
851
854
|
} else {
|
|
852
855
|
FirmwareRevision = this.platform.version;
|
|
853
856
|
}
|
|
@@ -930,7 +933,7 @@ export class Humidifier {
|
|
|
930
933
|
config['offline'] = device.offline;
|
|
931
934
|
}
|
|
932
935
|
if (Object.entries(config).length !== 0) {
|
|
933
|
-
this.
|
|
936
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
934
937
|
}
|
|
935
938
|
}
|
|
936
939
|
|
package/src/device/iosensor.ts
CHANGED
|
@@ -29,6 +29,7 @@ export class IOSensor {
|
|
|
29
29
|
StatusLowBattery?: CharacteristicValue;
|
|
30
30
|
|
|
31
31
|
// OpenAPI Others
|
|
32
|
+
Version: deviceStatus['version'];
|
|
32
33
|
Battery: deviceStatus['battery'];
|
|
33
34
|
Temperature: deviceStatus['temperature'];
|
|
34
35
|
Humidity: deviceStatus['humidity'];
|
|
@@ -73,10 +74,10 @@ export class IOSensor {
|
|
|
73
74
|
this.logs(device);
|
|
74
75
|
this.scan(device);
|
|
75
76
|
this.refreshRate(device);
|
|
76
|
-
this.config(device);
|
|
77
77
|
this.context();
|
|
78
78
|
this.setupHistoryService(device);
|
|
79
79
|
this.setupMqtt(device);
|
|
80
|
+
this.config(device);
|
|
80
81
|
|
|
81
82
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
82
83
|
this.doIOSensorUpdate = new Subject();
|
|
@@ -344,7 +345,8 @@ export class IOSensor {
|
|
|
344
345
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
|
|
345
346
|
this.Humidity = deviceStatus.body.humidity!;
|
|
346
347
|
this.Temperature = deviceStatus.body.temperature!;
|
|
347
|
-
this.Battery = deviceStatus.body.battery
|
|
348
|
+
this.Battery = deviceStatus.body.battery;
|
|
349
|
+
this.Version = deviceStatus.body.version;
|
|
348
350
|
this.openAPIparseStatus();
|
|
349
351
|
this.updateHomeKitCharacteristics();
|
|
350
352
|
} catch (e: any) {
|
|
@@ -592,10 +594,12 @@ export class IOSensor {
|
|
|
592
594
|
);
|
|
593
595
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
594
596
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
595
|
-
if (
|
|
596
|
-
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
597
|
-
} else if (device.firmware) {
|
|
597
|
+
if (device.firmware) {
|
|
598
598
|
FirmwareRevision = device.firmware;
|
|
599
|
+
} else if (device.version) {
|
|
600
|
+
FirmwareRevision = JSON.stringify(device.version);
|
|
601
|
+
} else if (accessory.context.FirmwareRevision) {
|
|
602
|
+
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
599
603
|
} else {
|
|
600
604
|
FirmwareRevision = this.platform.version;
|
|
601
605
|
}
|
|
@@ -660,7 +664,7 @@ export class IOSensor {
|
|
|
660
664
|
config['scanDuration'] = device.scanDuration;
|
|
661
665
|
}
|
|
662
666
|
if (Object.entries(config).length !== 0) {
|
|
663
|
-
this.
|
|
667
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
664
668
|
}
|
|
665
669
|
}
|
|
666
670
|
|
package/src/device/lightstrip.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable brace-style */
|
|
1
2
|
import { Context } from 'vm';
|
|
2
3
|
import { request } from 'undici';
|
|
3
4
|
import { sleep } from '../utils';
|
|
@@ -24,6 +25,7 @@ export class StripLight {
|
|
|
24
25
|
ColorTemperature?: CharacteristicValue;
|
|
25
26
|
|
|
26
27
|
// OpenAPI Others
|
|
28
|
+
Version: deviceStatus['version'];
|
|
27
29
|
power: deviceStatus['power'];
|
|
28
30
|
color: deviceStatus['color'];
|
|
29
31
|
brightness: deviceStatus['brightness'];
|
|
@@ -71,8 +73,9 @@ export class StripLight {
|
|
|
71
73
|
this.logs(device);
|
|
72
74
|
this.scan(device);
|
|
73
75
|
this.refreshRate(device);
|
|
74
|
-
this.config(device);
|
|
75
76
|
this.context();
|
|
77
|
+
this.config(device);
|
|
78
|
+
|
|
76
79
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
77
80
|
this.doStripLightUpdate = new Subject();
|
|
78
81
|
this.stripLightUpdateInProgress = false;
|
|
@@ -988,10 +991,12 @@ export class StripLight {
|
|
|
988
991
|
);
|
|
989
992
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
990
993
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
991
|
-
if (
|
|
992
|
-
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
993
|
-
} else if (device.firmware) {
|
|
994
|
+
if (device.firmware) {
|
|
994
995
|
FirmwareRevision = device.firmware;
|
|
996
|
+
} else if (device.version) {
|
|
997
|
+
FirmwareRevision = JSON.stringify(device.version);
|
|
998
|
+
} else if (accessory.context.FirmwareRevision) {
|
|
999
|
+
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
995
1000
|
} else {
|
|
996
1001
|
FirmwareRevision = this.platform.version;
|
|
997
1002
|
}
|
|
@@ -1065,7 +1070,7 @@ export class StripLight {
|
|
|
1065
1070
|
config['maxRetry'] = device.maxRetry;
|
|
1066
1071
|
}
|
|
1067
1072
|
if (Object.entries(config).length !== 0) {
|
|
1068
|
-
this.
|
|
1073
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
1069
1074
|
}
|
|
1070
1075
|
}
|
|
1071
1076
|
|
package/src/device/lock.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable brace-style */
|
|
1
2
|
import { Context } from 'vm';
|
|
2
3
|
import { request } from 'undici';
|
|
3
4
|
import { sleep } from '../utils';
|
|
@@ -18,6 +19,8 @@ export class Lock {
|
|
|
18
19
|
LockTargetState!: CharacteristicValue;
|
|
19
20
|
|
|
20
21
|
// OpenAPI Others
|
|
22
|
+
Version: deviceStatus['version'];
|
|
23
|
+
Battery: deviceStatus['battery'];
|
|
21
24
|
doorState!: deviceStatus['doorState'];
|
|
22
25
|
lockState!: deviceStatus['lockState'];
|
|
23
26
|
deviceStatus!: any; //deviceStatusResponse;
|
|
@@ -59,8 +62,8 @@ export class Lock {
|
|
|
59
62
|
this.logs(device);
|
|
60
63
|
this.scan(device);
|
|
61
64
|
this.refreshRate(device);
|
|
62
|
-
this.config(device);
|
|
63
65
|
this.context();
|
|
66
|
+
this.config(device);
|
|
64
67
|
|
|
65
68
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
66
69
|
this.doLockUpdate = new Subject();
|
|
@@ -316,6 +319,8 @@ export class Lock {
|
|
|
316
319
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
|
|
317
320
|
this.lockState = deviceStatus.body.lockState;
|
|
318
321
|
this.doorState = deviceStatus.body.doorState;
|
|
322
|
+
this.Battery = deviceStatus.body.battery;
|
|
323
|
+
this.Version = deviceStatus.body.version;
|
|
319
324
|
this.openAPIparseStatus();
|
|
320
325
|
this.updateHomeKitCharacteristics();
|
|
321
326
|
} catch (e: any) {
|
|
@@ -597,10 +602,12 @@ export class Lock {
|
|
|
597
602
|
);
|
|
598
603
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
599
604
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
600
|
-
if (
|
|
601
|
-
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
602
|
-
} else if (device.firmware) {
|
|
605
|
+
if (device.firmware) {
|
|
603
606
|
FirmwareRevision = device.firmware;
|
|
607
|
+
} else if (device.version) {
|
|
608
|
+
FirmwareRevision = JSON.stringify(device.version);
|
|
609
|
+
} else if (accessory.context.FirmwareRevision) {
|
|
610
|
+
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
604
611
|
} else {
|
|
605
612
|
FirmwareRevision = this.platform.version;
|
|
606
613
|
}
|
|
@@ -646,7 +653,7 @@ export class Lock {
|
|
|
646
653
|
config['scanDuration'] = device.scanDuration;
|
|
647
654
|
}
|
|
648
655
|
if (Object.entries(config).length !== 0) {
|
|
649
|
-
this.
|
|
656
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
650
657
|
}
|
|
651
658
|
}
|
|
652
659
|
|
package/src/device/meter.ts
CHANGED
|
@@ -29,6 +29,8 @@ export class Meter {
|
|
|
29
29
|
StatusLowBattery?: CharacteristicValue;
|
|
30
30
|
|
|
31
31
|
// OpenAPI Others
|
|
32
|
+
Version: deviceStatus['version'];
|
|
33
|
+
Battery: deviceStatus['battery'];
|
|
32
34
|
Temperature: deviceStatus['temperature'];
|
|
33
35
|
Humidity: deviceStatus['humidity'];
|
|
34
36
|
deviceStatus!: any; //deviceStatusResponse;
|
|
@@ -72,10 +74,10 @@ export class Meter {
|
|
|
72
74
|
this.logs(device);
|
|
73
75
|
this.scan(device);
|
|
74
76
|
this.refreshRate(device);
|
|
75
|
-
this.config(device);
|
|
76
77
|
this.context();
|
|
77
78
|
this.setupHistoryService(device);
|
|
78
79
|
this.setupMqtt(device);
|
|
80
|
+
this.config(device);
|
|
79
81
|
|
|
80
82
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
81
83
|
this.doMeterUpdate = new Subject();
|
|
@@ -226,7 +228,7 @@ export class Meter {
|
|
|
226
228
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIparseStatus`);
|
|
227
229
|
|
|
228
230
|
// Battery
|
|
229
|
-
this.BatteryLevel = Number(this.
|
|
231
|
+
this.BatteryLevel = Number(this.Battery);
|
|
230
232
|
if (this.BatteryLevel < 15) {
|
|
231
233
|
this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
|
|
232
234
|
} else {
|
|
@@ -349,7 +351,8 @@ export class Meter {
|
|
|
349
351
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
|
|
350
352
|
this.Humidity = deviceStatus.body.humidity!;
|
|
351
353
|
this.Temperature = deviceStatus.body.temperature!;
|
|
352
|
-
this.
|
|
354
|
+
this.Battery = deviceStatus.body.battery;
|
|
355
|
+
this.Version = deviceStatus.body.version;
|
|
353
356
|
this.openAPIparseStatus();
|
|
354
357
|
this.updateHomeKitCharacteristics();
|
|
355
358
|
} catch (e: any) {
|
|
@@ -599,10 +602,12 @@ export class Meter {
|
|
|
599
602
|
);
|
|
600
603
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
601
604
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
602
|
-
if (
|
|
603
|
-
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
604
|
-
} else if (device.firmware) {
|
|
605
|
+
if (device.firmware) {
|
|
605
606
|
FirmwareRevision = device.firmware;
|
|
607
|
+
} else if (device.version) {
|
|
608
|
+
FirmwareRevision = JSON.stringify(device.version);
|
|
609
|
+
} else if (accessory.context.FirmwareRevision) {
|
|
610
|
+
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
606
611
|
} else {
|
|
607
612
|
FirmwareRevision = this.platform.version;
|
|
608
613
|
}
|
|
@@ -667,7 +672,7 @@ export class Meter {
|
|
|
667
672
|
config['scanDuration'] = device.scanDuration;
|
|
668
673
|
}
|
|
669
674
|
if (Object.entries(config).length !== 0) {
|
|
670
|
-
this.
|
|
675
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
671
676
|
}
|
|
672
677
|
}
|
|
673
678
|
|
package/src/device/meterplus.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Context } from 'vm';
|
|
2
|
-
import { hostname } from 'os';
|
|
3
|
-
import { request } from 'undici';
|
|
4
|
-
import { sleep } from '../utils';
|
|
5
|
-
import { MqttClient } from 'mqtt';
|
|
6
|
-
import { interval, Subject } from 'rxjs';
|
|
7
1
|
import { connectAsync } from 'async-mqtt';
|
|
2
|
+
import { CharacteristicValue, PlatformAccessory, Service, Units } from 'homebridge';
|
|
3
|
+
import { MqttClient } from 'mqtt';
|
|
4
|
+
import { hostname } from 'os';
|
|
5
|
+
import { Subject, interval } from 'rxjs';
|
|
8
6
|
import { skipWhile } from 'rxjs/operators';
|
|
7
|
+
import { request } from 'undici';
|
|
8
|
+
import { Context } from 'vm';
|
|
9
9
|
import { SwitchBotPlatform } from '../platform';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { Devices, ad, device, deviceStatus, devicesConfig, serviceData, switchbot, temperature } from '../settings';
|
|
11
|
+
import { sleep } from '../utils';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Platform Accessory
|
|
@@ -29,6 +29,7 @@ export class MeterPlus {
|
|
|
29
29
|
StatusLowBattery?: CharacteristicValue;
|
|
30
30
|
|
|
31
31
|
// OpenAPI Others
|
|
32
|
+
Version: deviceStatus['version'];
|
|
32
33
|
Battery: deviceStatus['battery'];
|
|
33
34
|
Temperature: deviceStatus['temperature'];
|
|
34
35
|
Humidity: deviceStatus['humidity'];
|
|
@@ -73,10 +74,10 @@ export class MeterPlus {
|
|
|
73
74
|
this.logs(device);
|
|
74
75
|
this.scan(device);
|
|
75
76
|
this.refreshRate(device);
|
|
76
|
-
this.config(device);
|
|
77
77
|
this.context();
|
|
78
78
|
this.setupHistoryService(device);
|
|
79
79
|
this.setupMqtt(device);
|
|
80
|
+
this.config(device);
|
|
80
81
|
|
|
81
82
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
82
83
|
this.doMeterUpdate = new Subject();
|
|
@@ -154,11 +155,7 @@ export class MeterPlus {
|
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
// Battery Service
|
|
157
|
-
if (!this.
|
|
158
|
-
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Battery Service`);
|
|
159
|
-
this.batteryService = this.accessory.getService(this.platform.Service.Battery);
|
|
160
|
-
accessory.removeService(this.batteryService!);
|
|
161
|
-
} else if (this.BLE && !this.batteryService) {
|
|
158
|
+
if (!this.batteryService) {
|
|
162
159
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Battery Service`);
|
|
163
160
|
(this.batteryService = this.accessory.getService(this.platform.Service.Battery) || this.accessory.addService(this.platform.Service.Battery)),
|
|
164
161
|
`${accessory.displayName} Battery`;
|
|
@@ -229,6 +226,16 @@ export class MeterPlus {
|
|
|
229
226
|
|
|
230
227
|
async openAPIparseStatus(): Promise<void> {
|
|
231
228
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIparseStatus`);
|
|
229
|
+
|
|
230
|
+
// Battery
|
|
231
|
+
this.BatteryLevel = Number(this.Battery);
|
|
232
|
+
if (this.BatteryLevel < 15) {
|
|
233
|
+
this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
|
|
234
|
+
} else {
|
|
235
|
+
this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
|
|
236
|
+
}
|
|
237
|
+
this.debugLog(`${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, StatusLowBattery: ${this.StatusLowBattery}`);
|
|
238
|
+
|
|
232
239
|
// Current Relative Humidity
|
|
233
240
|
if (!this.device.meter?.hide_humidity) {
|
|
234
241
|
this.CurrentRelativeHumidity = this.Humidity!;
|
|
@@ -344,7 +351,8 @@ export class MeterPlus {
|
|
|
344
351
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
|
|
345
352
|
this.Humidity = deviceStatus.body.humidity!;
|
|
346
353
|
this.Temperature = deviceStatus.body.temperature!;
|
|
347
|
-
this.Battery = deviceStatus.body.battery
|
|
354
|
+
this.Battery = deviceStatus.body.battery;
|
|
355
|
+
this.Version = deviceStatus.body.version;
|
|
348
356
|
this.openAPIparseStatus();
|
|
349
357
|
this.updateHomeKitCharacteristics();
|
|
350
358
|
} catch (e: any) {
|
|
@@ -395,28 +403,29 @@ export class MeterPlus {
|
|
|
395
403
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
|
|
396
404
|
}
|
|
397
405
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
}
|
|
405
|
-
this.accessory.context.BatteryLevel = this.BatteryLevel;
|
|
406
|
-
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
|
|
407
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
|
|
406
|
+
|
|
407
|
+
if (this.BatteryLevel === undefined) {
|
|
408
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
|
|
409
|
+
} else {
|
|
410
|
+
if (this.device.mqttURL) {
|
|
411
|
+
mqttmessage.push(`"battery": ${this.BatteryLevel}`);
|
|
408
412
|
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
413
|
+
this.accessory.context.BatteryLevel = this.BatteryLevel;
|
|
414
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
|
|
415
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
if (this.StatusLowBattery === undefined) {
|
|
419
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
|
|
420
|
+
} else {
|
|
421
|
+
if (this.device.mqttURL) {
|
|
422
|
+
mqttmessage.push(`"lowBattery": ${this.StatusLowBattery}`);
|
|
418
423
|
}
|
|
424
|
+
this.accessory.context.StatusLowBattery = this.StatusLowBattery;
|
|
425
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
|
|
426
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
|
|
419
427
|
}
|
|
428
|
+
|
|
420
429
|
if (this.device.mqttURL) {
|
|
421
430
|
this.mqttPublish(`{${mqttmessage.join(',')}}`);
|
|
422
431
|
}
|
|
@@ -593,10 +602,8 @@ export class MeterPlus {
|
|
|
593
602
|
if (!this.device.meter?.hide_temperature) {
|
|
594
603
|
this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
|
|
595
604
|
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
599
|
-
}
|
|
605
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
|
|
606
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
600
607
|
}
|
|
601
608
|
|
|
602
609
|
FirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
|
|
@@ -606,10 +613,12 @@ export class MeterPlus {
|
|
|
606
613
|
);
|
|
607
614
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
608
615
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
609
|
-
if (
|
|
610
|
-
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
611
|
-
} else if (device.firmware) {
|
|
616
|
+
if (device.firmware) {
|
|
612
617
|
FirmwareRevision = device.firmware;
|
|
618
|
+
} else if (device.version) {
|
|
619
|
+
FirmwareRevision = JSON.stringify(device.version);
|
|
620
|
+
} else if (accessory.context.FirmwareRevision) {
|
|
621
|
+
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
613
622
|
} else {
|
|
614
623
|
FirmwareRevision = this.platform.version;
|
|
615
624
|
}
|
|
@@ -627,18 +636,16 @@ export class MeterPlus {
|
|
|
627
636
|
} else {
|
|
628
637
|
this.CurrentTemperature = this.accessory.context.CurrentTemperature;
|
|
629
638
|
}
|
|
630
|
-
if (this.
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
this.StatusLowBattery = this.accessory.context.StatusLowBattery;
|
|
641
|
-
}
|
|
639
|
+
if (this.BatteryLevel === undefined) {
|
|
640
|
+
this.BatteryLevel = 100;
|
|
641
|
+
} else {
|
|
642
|
+
this.BatteryLevel = this.accessory.context.BatteryLevel;
|
|
643
|
+
}
|
|
644
|
+
if (this.StatusLowBattery === undefined) {
|
|
645
|
+
this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
|
|
646
|
+
this.accessory.context.StatusLowBattery = this.StatusLowBattery;
|
|
647
|
+
} else {
|
|
648
|
+
this.StatusLowBattery = this.accessory.context.StatusLowBattery;
|
|
642
649
|
}
|
|
643
650
|
}
|
|
644
651
|
|
|
@@ -676,7 +683,7 @@ export class MeterPlus {
|
|
|
676
683
|
config['scanDuration'] = device.scanDuration;
|
|
677
684
|
}
|
|
678
685
|
if (Object.entries(config).length !== 0) {
|
|
679
|
-
this.
|
|
686
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
680
687
|
}
|
|
681
688
|
}
|
|
682
689
|
|
package/src/device/motion.ts
CHANGED
|
@@ -25,6 +25,8 @@ export class Motion {
|
|
|
25
25
|
StatusLowBattery?: CharacteristicValue;
|
|
26
26
|
|
|
27
27
|
// OpenAPI Others
|
|
28
|
+
Version: deviceStatus['version'];
|
|
29
|
+
Battery: deviceStatus['battery'];
|
|
28
30
|
deviceStatus!: any; //deviceStatusResponse;
|
|
29
31
|
moveDetected: deviceStatus['moveDetected'];
|
|
30
32
|
brightness: deviceStatus['brightness'];
|
|
@@ -68,8 +70,8 @@ export class Motion {
|
|
|
68
70
|
this.logs(device);
|
|
69
71
|
this.scan(device);
|
|
70
72
|
this.refreshRate(device);
|
|
71
|
-
this.config(device);
|
|
72
73
|
this.context();
|
|
74
|
+
this.config(device);
|
|
73
75
|
|
|
74
76
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
75
77
|
this.doMotionUpdate = new Subject();
|
|
@@ -124,17 +126,16 @@ export class Motion {
|
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
// Battery Service
|
|
127
|
-
if (!this.
|
|
128
|
-
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Battery Service`);
|
|
129
|
-
this.batteryService = this.accessory.getService(this.platform.Service.Battery);
|
|
130
|
-
accessory.removeService(this.batteryService!);
|
|
131
|
-
} else if (this.BLE && !this.batteryService) {
|
|
129
|
+
if (!this.batteryService) {
|
|
132
130
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Battery Service`);
|
|
133
131
|
(this.batteryService = this.accessory.getService(this.platform.Service.Battery) || this.accessory.addService(this.platform.Service.Battery)),
|
|
134
132
|
`${accessory.displayName} Battery`;
|
|
135
133
|
|
|
136
134
|
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
137
|
-
this.batteryService.
|
|
135
|
+
if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
136
|
+
this.batteryService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
|
|
137
|
+
}
|
|
138
|
+
this.batteryService.setCharacteristic(this.platform.Characteristic.ChargingState, this.platform.Characteristic.ChargingState.NOT_CHARGEABLE);
|
|
138
139
|
} else {
|
|
139
140
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Battery Service Not Added`);
|
|
140
141
|
}
|
|
@@ -230,6 +231,19 @@ export class Motion {
|
|
|
230
231
|
}
|
|
231
232
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
|
|
232
233
|
}
|
|
234
|
+
// Battery
|
|
235
|
+
if (this.battery === undefined) {
|
|
236
|
+
this.battery = 100;
|
|
237
|
+
}
|
|
238
|
+
this.BatteryLevel = this.Battery!;
|
|
239
|
+
if (this.BatteryLevel < 10) {
|
|
240
|
+
this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
|
|
241
|
+
} else {
|
|
242
|
+
this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
|
|
243
|
+
}
|
|
244
|
+
this.debugLog(
|
|
245
|
+
`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel},` + ` StatusLowBattery: ${this.StatusLowBattery}`,
|
|
246
|
+
);
|
|
233
247
|
}
|
|
234
248
|
|
|
235
249
|
/**
|
|
@@ -350,6 +364,8 @@ export class Motion {
|
|
|
350
364
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
|
|
351
365
|
this.moveDetected = deviceStatus.body.moveDetected;
|
|
352
366
|
this.brightness = deviceStatus.body.brightness;
|
|
367
|
+
this.Battery = deviceStatus.body.battery;
|
|
368
|
+
this.Version = deviceStatus.body.version;
|
|
353
369
|
this.openAPIparseStatus();
|
|
354
370
|
this.updateHomeKitCharacteristics();
|
|
355
371
|
} catch (e: any) {
|
|
@@ -372,21 +388,21 @@ export class Motion {
|
|
|
372
388
|
this.motionSensorService.updateCharacteristic(this.platform.Characteristic.MotionDetected, this.MotionDetected);
|
|
373
389
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic MotionDetected: ${this.MotionDetected}`);
|
|
374
390
|
}
|
|
391
|
+
if (this.BatteryLevel === undefined) {
|
|
392
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
|
|
393
|
+
} else {
|
|
394
|
+
this.accessory.context.BatteryLevel = this.BatteryLevel;
|
|
395
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
|
|
396
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
|
|
397
|
+
}
|
|
398
|
+
if (this.StatusLowBattery === undefined) {
|
|
399
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
|
|
400
|
+
} else {
|
|
401
|
+
this.accessory.context.StatusLowBattery = this.StatusLowBattery;
|
|
402
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
|
|
403
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
|
|
404
|
+
}
|
|
375
405
|
if (this.BLE) {
|
|
376
|
-
if (this.BatteryLevel === undefined) {
|
|
377
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
|
|
378
|
-
} else {
|
|
379
|
-
this.accessory.context.BatteryLevel = this.BatteryLevel;
|
|
380
|
-
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
|
|
381
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
|
|
382
|
-
}
|
|
383
|
-
if (this.StatusLowBattery === undefined) {
|
|
384
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
|
|
385
|
-
} else {
|
|
386
|
-
this.accessory.context.StatusLowBattery = this.StatusLowBattery;
|
|
387
|
-
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
|
|
388
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
|
|
389
|
-
}
|
|
390
406
|
if (this.CurrentAmbientLightLevel === undefined) {
|
|
391
407
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
|
|
392
408
|
} else {
|
|
@@ -539,9 +555,9 @@ export class Motion {
|
|
|
539
555
|
|
|
540
556
|
async apiError(e: any): Promise<void> {
|
|
541
557
|
this.motionSensorService.updateCharacteristic(this.platform.Characteristic.MotionDetected, e);
|
|
558
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
|
|
559
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
542
560
|
if (this.BLE) {
|
|
543
|
-
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
|
|
544
|
-
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
545
561
|
this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e);
|
|
546
562
|
}
|
|
547
563
|
}
|
|
@@ -553,10 +569,12 @@ export class Motion {
|
|
|
553
569
|
);
|
|
554
570
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
555
571
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
556
|
-
if (
|
|
557
|
-
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
558
|
-
} else if (device.firmware) {
|
|
572
|
+
if (device.firmware) {
|
|
559
573
|
FirmwareRevision = device.firmware;
|
|
574
|
+
} else if (device.version) {
|
|
575
|
+
FirmwareRevision = JSON.stringify(device.version);
|
|
576
|
+
} else if (accessory.context.FirmwareRevision) {
|
|
577
|
+
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
560
578
|
} else {
|
|
561
579
|
FirmwareRevision = this.platform.version;
|
|
562
580
|
}
|
|
@@ -605,7 +623,7 @@ export class Motion {
|
|
|
605
623
|
config['offline'] = device.offline;
|
|
606
624
|
}
|
|
607
625
|
if (Object.entries(config).length !== 0) {
|
|
608
|
-
this.
|
|
626
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
609
627
|
}
|
|
610
628
|
}
|
|
611
629
|
|