@switchbot/homebridge-switchbot 2.8.0-beta.9 → 2.8.1-beta.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 +4 -2
- package/README.md +1 -1
- package/dist/device/blindtilt.d.ts +21 -22
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +78 -77
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +11 -13
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +93 -75
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +10 -13
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +40 -27
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +16 -23
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +55 -46
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +16 -22
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +82 -73
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +21 -24
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +76 -77
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +10 -8
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +50 -35
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +8 -10
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +34 -21
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +16 -20
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +42 -29
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +2 -5
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +9 -8
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +15 -19
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +71 -28
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +5 -9
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +16 -20
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +6 -10
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +16 -20
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +6 -8
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +49 -47
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +2 -5
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +9 -8
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +6 -8
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +20 -4
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +2 -0
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +67 -86
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +0 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +0 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +64 -63
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +3 -1
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +12 -12
- package/src/device/blindtilt.ts +103 -100
- package/src/device/bot.ts +105 -89
- package/src/device/ceilinglight.ts +56 -46
- package/src/device/colorbulb.ts +78 -76
- package/src/device/contact.ts +100 -94
- package/src/device/curtain.ts +101 -101
- package/src/device/hub.ts +61 -43
- package/src/device/humidifier.ts +42 -33
- package/src/device/iosensor.ts +59 -50
- package/src/device/lightstrip.ts +14 -17
- package/src/device/lock.ts +91 -50
- package/src/device/meter.ts +22 -30
- package/src/device/meterplus.ts +23 -32
- package/src/device/motion.ts +55 -53
- package/src/device/plug.ts +12 -15
- package/src/device/robotvacuumcleaner.ts +33 -16
- package/src/irdevice/airconditioner.ts +80 -94
- package/src/irdevice/airpurifier.ts +1 -1
- package/src/irdevice/camera.ts +1 -1
- package/src/irdevice/fan.ts +1 -4
- package/src/irdevice/light.ts +1 -1
- package/src/irdevice/other.ts +1 -1
- package/src/irdevice/tv.ts +1 -4
- package/src/irdevice/vacuumcleaner.ts +1 -1
- package/src/irdevice/waterheater.ts +1 -1
- package/src/platform.ts +73 -73
- package/src/settings.ts +6 -2
package/src/device/curtain.ts
CHANGED
|
@@ -7,43 +7,44 @@ import { connectAsync } from 'async-mqtt';
|
|
|
7
7
|
import { SwitchBotPlatform } from '../platform';
|
|
8
8
|
import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
|
|
9
9
|
import { Service, PlatformAccessory, CharacteristicValue, CharacteristicChange } from 'homebridge';
|
|
10
|
-
import { device, devicesConfig, serviceData,
|
|
10
|
+
import { device, devicesConfig, serviceData, deviceStatus, ad, Devices } from '../settings';
|
|
11
11
|
import { hostname } from 'os';
|
|
12
12
|
|
|
13
13
|
export class Curtain {
|
|
14
14
|
// Services
|
|
15
|
-
|
|
15
|
+
batteryService: Service;
|
|
16
16
|
lightSensorService?: Service;
|
|
17
|
-
|
|
17
|
+
windowCoveringService: Service;
|
|
18
18
|
|
|
19
19
|
// Characteristic Values
|
|
20
|
-
|
|
20
|
+
BatteryLevel!: CharacteristicValue;
|
|
21
21
|
PositionState!: CharacteristicValue;
|
|
22
22
|
TargetPosition!: CharacteristicValue;
|
|
23
|
+
CurrentPosition!: CharacteristicValue;
|
|
24
|
+
StatusLowBattery!: CharacteristicValue;
|
|
23
25
|
CurrentAmbientLightLevel?: CharacteristicValue;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
// OpenAPI Status
|
|
28
|
+
OpenAPI_InMotion: deviceStatus['moving'];
|
|
29
|
+
OpenAPI_BatterLevel: deviceStatus['battery'];
|
|
30
|
+
OpenAPI_FirmwareRevision: deviceStatus['version'];
|
|
31
|
+
OpenAPI_CurrentPosition: deviceStatus['slidePosition'];
|
|
32
|
+
OpenAPI_CurrentAmbientLightLevel: deviceStatus['brightness'];
|
|
27
33
|
|
|
28
34
|
// OpenAPI Others
|
|
29
|
-
deviceStatus!: any; //deviceStatusResponse;
|
|
30
|
-
slidePosition: deviceStatus['slidePosition'];
|
|
31
|
-
moving: deviceStatus['moving'];
|
|
32
|
-
brightness: deviceStatus['brightness'];
|
|
33
|
-
setPositionMode?: string | number;
|
|
34
35
|
Mode!: string;
|
|
36
|
+
setPositionMode?: string | number;
|
|
37
|
+
|
|
38
|
+
// BLE Status
|
|
39
|
+
BLE_Battery: serviceData['battery'];
|
|
40
|
+
BLE_InMotion: serviceData['inMotion'];
|
|
41
|
+
BLE_Calibration: serviceData['calibration'];
|
|
42
|
+
BLE_CurrentPosition: serviceData['position'];
|
|
43
|
+
BLE_CurrentAmbientLightLevel: serviceData['lightLevel'];
|
|
35
44
|
|
|
36
45
|
// BLE Others
|
|
37
|
-
|
|
38
|
-
switchbot!: switchbot;
|
|
39
|
-
serviceData!: serviceData;
|
|
46
|
+
BLE_IsConnected?: boolean;
|
|
40
47
|
spaceBetweenLevels!: number;
|
|
41
|
-
address!: ad['address'];
|
|
42
|
-
calibration: serviceData['calibration'];
|
|
43
|
-
battery: serviceData['battery'];
|
|
44
|
-
position: serviceData['position'];
|
|
45
|
-
inMotion: serviceData['inMotion'];
|
|
46
|
-
lightLevel: serviceData['lightLevel'];
|
|
47
48
|
|
|
48
49
|
// Target
|
|
49
50
|
setNewTarget!: boolean;
|
|
@@ -53,15 +54,15 @@ export class Curtain {
|
|
|
53
54
|
mqttClient: MqttClient | null = null;
|
|
54
55
|
|
|
55
56
|
// Config
|
|
56
|
-
set_minStep!: number;
|
|
57
57
|
updateRate!: number;
|
|
58
58
|
set_minLux!: number;
|
|
59
59
|
set_maxLux!: number;
|
|
60
|
+
set_minStep!: number;
|
|
61
|
+
setOpenMode!: string;
|
|
62
|
+
setCloseMode!: string;
|
|
60
63
|
scanDuration!: number;
|
|
61
64
|
deviceLogging!: string;
|
|
62
65
|
deviceRefreshRate!: number;
|
|
63
|
-
setCloseMode!: string;
|
|
64
|
-
setOpenMode!: string;
|
|
65
66
|
|
|
66
67
|
// Updates
|
|
67
68
|
curtainUpdateInProgress!: boolean;
|
|
@@ -170,21 +171,12 @@ export class Curtain {
|
|
|
170
171
|
}
|
|
171
172
|
|
|
172
173
|
// Battery Service
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
this.
|
|
179
|
-
(this.batteryService = this.accessory.getService(this.platform.Service.Battery) || this.accessory.addService(this.platform.Service.Battery)),
|
|
180
|
-
`${accessory.displayName} Battery`;
|
|
181
|
-
|
|
182
|
-
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
183
|
-
if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
184
|
-
this.batteryService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
|
|
185
|
-
}
|
|
186
|
-
} else {
|
|
187
|
-
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Battery Service Not Added`);
|
|
174
|
+
(this.batteryService = this.accessory.getService(this.platform.Service.Battery) || accessory.addService(this.platform.Service.Battery)),
|
|
175
|
+
`${accessory.displayName} Battery`;
|
|
176
|
+
|
|
177
|
+
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
178
|
+
if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
179
|
+
this.batteryService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
|
|
188
180
|
}
|
|
189
181
|
|
|
190
182
|
// Update Homekit
|
|
@@ -315,7 +307,7 @@ export class Curtain {
|
|
|
315
307
|
async BLEparseStatus(): Promise<void> {
|
|
316
308
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLEparseStatus`);
|
|
317
309
|
// CurrentPosition
|
|
318
|
-
this.CurrentPosition = 100 - Number(this.
|
|
310
|
+
this.CurrentPosition = 100 - Number(this.BLE_CurrentPosition);
|
|
319
311
|
await this.setMinMax();
|
|
320
312
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentPosition ${this.CurrentPosition}`);
|
|
321
313
|
if (this.setNewTarget) {
|
|
@@ -354,45 +346,45 @@ export class Curtain {
|
|
|
354
346
|
this.spaceBetweenLevels = 9;
|
|
355
347
|
|
|
356
348
|
// Brightness
|
|
357
|
-
switch (this.
|
|
349
|
+
switch (this.BLE_CurrentAmbientLightLevel) {
|
|
358
350
|
case 1:
|
|
359
351
|
this.CurrentAmbientLightLevel = this.set_minLux;
|
|
360
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
352
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel}`);
|
|
361
353
|
break;
|
|
362
354
|
case 2:
|
|
363
355
|
this.CurrentAmbientLightLevel = (this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels;
|
|
364
356
|
this.debugLog(
|
|
365
|
-
`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
357
|
+
`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel},` +
|
|
366
358
|
` Calculation: ${(this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels}`,
|
|
367
359
|
);
|
|
368
360
|
break;
|
|
369
361
|
case 3:
|
|
370
362
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 2;
|
|
371
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
363
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel}`);
|
|
372
364
|
break;
|
|
373
365
|
case 4:
|
|
374
366
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 3;
|
|
375
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
367
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel}`);
|
|
376
368
|
break;
|
|
377
369
|
case 5:
|
|
378
370
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 4;
|
|
379
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
371
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel}`);
|
|
380
372
|
break;
|
|
381
373
|
case 6:
|
|
382
374
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 5;
|
|
383
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
375
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel}`);
|
|
384
376
|
break;
|
|
385
377
|
case 7:
|
|
386
378
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 6;
|
|
387
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
379
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel}`);
|
|
388
380
|
break;
|
|
389
381
|
case 8:
|
|
390
382
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 7;
|
|
391
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
383
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel}`);
|
|
392
384
|
break;
|
|
393
385
|
case 9:
|
|
394
386
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 8;
|
|
395
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
387
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel}`);
|
|
396
388
|
break;
|
|
397
389
|
case 10:
|
|
398
390
|
default:
|
|
@@ -400,12 +392,12 @@ export class Curtain {
|
|
|
400
392
|
this.debugLog();
|
|
401
393
|
}
|
|
402
394
|
this.debugLog(
|
|
403
|
-
`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
395
|
+
`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel},` +
|
|
404
396
|
` CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
|
|
405
397
|
);
|
|
406
398
|
}
|
|
407
399
|
// Battery
|
|
408
|
-
this.BatteryLevel = Number(this.
|
|
400
|
+
this.BatteryLevel = Number(this.BLE_Battery);
|
|
409
401
|
if (this.BatteryLevel < 10) {
|
|
410
402
|
this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
|
|
411
403
|
} else {
|
|
@@ -419,14 +411,14 @@ export class Curtain {
|
|
|
419
411
|
async openAPIparseStatus(): Promise<void> {
|
|
420
412
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIparseStatus`);
|
|
421
413
|
// CurrentPosition
|
|
422
|
-
this.CurrentPosition = 100 - Number(this.
|
|
414
|
+
this.CurrentPosition = 100 - Number(this.OpenAPI_CurrentPosition);
|
|
423
415
|
await this.setMinMax();
|
|
424
416
|
this.debugLog(`Curtain ${this.accessory.displayName} CurrentPosition: ${this.CurrentPosition}`);
|
|
425
417
|
if (this.setNewTarget) {
|
|
426
418
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Checking Status ...`);
|
|
427
419
|
}
|
|
428
420
|
|
|
429
|
-
if (this.setNewTarget && this.
|
|
421
|
+
if (this.setNewTarget && this.OpenAPI_InMotion) {
|
|
430
422
|
await this.setMinMax();
|
|
431
423
|
if (Number(this.TargetPosition) > this.CurrentPosition) {
|
|
432
424
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Closing, CurrentPosition: ${this.CurrentPosition} `);
|
|
@@ -459,7 +451,7 @@ export class Curtain {
|
|
|
459
451
|
this.set_minLux = this.minLux();
|
|
460
452
|
this.set_maxLux = this.maxLux();
|
|
461
453
|
// Brightness
|
|
462
|
-
switch (this.
|
|
454
|
+
switch (this.OpenAPI_CurrentAmbientLightLevel) {
|
|
463
455
|
case 'dim':
|
|
464
456
|
this.CurrentAmbientLightLevel = this.set_minLux;
|
|
465
457
|
break;
|
|
@@ -506,18 +498,16 @@ export class Curtain {
|
|
|
506
498
|
})
|
|
507
499
|
.then(async () => {
|
|
508
500
|
// Set an event hander
|
|
509
|
-
switchbot.onadvertisement = async (ad:
|
|
510
|
-
this.address = ad.address;
|
|
501
|
+
switchbot.onadvertisement = async (ad: ad) => {
|
|
511
502
|
this.debugLog(
|
|
512
503
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
|
513
|
-
` BLE Address Found: ${
|
|
504
|
+
` BLE Address Found: ${ad.address}`,
|
|
514
505
|
);
|
|
515
|
-
this.
|
|
516
|
-
this.
|
|
517
|
-
this.
|
|
518
|
-
this.
|
|
519
|
-
this.
|
|
520
|
-
this.lightLevel = ad.serviceData.lightLevel;
|
|
506
|
+
this.BLE_Calibration = ad.serviceData.calibration;
|
|
507
|
+
this.BLE_Battery = ad.serviceData.battery;
|
|
508
|
+
this.BLE_InMotion = ad.serviceData.inMotion;
|
|
509
|
+
this.BLE_CurrentPosition = ad.serviceData.position;
|
|
510
|
+
this.BLE_CurrentAmbientLightLevel = ad.serviceData.lightLevel;
|
|
521
511
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
|
|
522
512
|
this.debugLog(
|
|
523
513
|
`${this.device.deviceType}: ${this.accessory.displayName} calibration: ${ad.serviceData.calibration}, ` +
|
|
@@ -525,13 +515,13 @@ export class Curtain {
|
|
|
525
515
|
`inMotion: ${ad.serviceData.inMotion}`,
|
|
526
516
|
);
|
|
527
517
|
|
|
528
|
-
if (
|
|
529
|
-
this.
|
|
530
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.
|
|
518
|
+
if (ad.serviceData) {
|
|
519
|
+
this.BLE_IsConnected = true;
|
|
520
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.BLE_IsConnected}`);
|
|
531
521
|
await this.stopScanning(switchbot);
|
|
532
522
|
} else {
|
|
533
|
-
this.
|
|
534
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.
|
|
523
|
+
this.BLE_IsConnected = false;
|
|
524
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.BLE_IsConnected}`);
|
|
535
525
|
}
|
|
536
526
|
};
|
|
537
527
|
// Wait
|
|
@@ -560,14 +550,16 @@ export class Curtain {
|
|
|
560
550
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
561
551
|
headers: this.platform.generateHeaders(),
|
|
562
552
|
});
|
|
563
|
-
const deviceStatus = await body.json();
|
|
553
|
+
const deviceStatus: any = await body.json();
|
|
564
554
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
|
|
565
555
|
this.statusCode(statusCode);
|
|
566
556
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
|
|
567
557
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
|
|
568
|
-
this.
|
|
569
|
-
this.
|
|
570
|
-
this.
|
|
558
|
+
this.OpenAPI_CurrentPosition = deviceStatus.body.slidePosition;
|
|
559
|
+
this.OpenAPI_InMotion = deviceStatus.body.moving;
|
|
560
|
+
this.OpenAPI_CurrentAmbientLightLevel = deviceStatus.body.brightness;
|
|
561
|
+
this.OpenAPI_BatterLevel = deviceStatus.body.battery;
|
|
562
|
+
this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
|
|
571
563
|
this.openAPIparseStatus();
|
|
572
564
|
this.updateHomeKitCharacteristics();
|
|
573
565
|
} catch (e: any) {
|
|
@@ -704,7 +696,7 @@ export class Curtain {
|
|
|
704
696
|
method: 'POST',
|
|
705
697
|
headers: this.platform.generateHeaders(),
|
|
706
698
|
});
|
|
707
|
-
const deviceStatus = await body.json();
|
|
699
|
+
const deviceStatus: any = await body.json();
|
|
708
700
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
|
|
709
701
|
this.statusCode(statusCode);
|
|
710
702
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
|
|
@@ -823,27 +815,35 @@ export class Curtain {
|
|
|
823
815
|
}
|
|
824
816
|
}
|
|
825
817
|
}
|
|
826
|
-
if (this.
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
this.mqttPublish('BatteryLevel', this.BatteryLevel);
|
|
832
|
-
}
|
|
833
|
-
this.accessory.context.BatteryLevel = this.BatteryLevel;
|
|
834
|
-
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
|
|
835
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
|
|
818
|
+
if (this.BatteryLevel === undefined) {
|
|
819
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
|
|
820
|
+
} else {
|
|
821
|
+
if (this.device.mqttURL) {
|
|
822
|
+
this.mqttPublish('BatteryLevel', this.BatteryLevel);
|
|
836
823
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
this.
|
|
824
|
+
this.accessory.context.BatteryLevel = this.BatteryLevel;
|
|
825
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
|
|
826
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
|
|
827
|
+
}
|
|
828
|
+
if (this.StatusLowBattery === undefined) {
|
|
829
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
|
|
830
|
+
} else {
|
|
831
|
+
if (this.device.mqttURL) {
|
|
832
|
+
this.mqttPublish('StatusLowBattery', this.StatusLowBattery);
|
|
846
833
|
}
|
|
834
|
+
this.accessory.context.StatusLowBattery = this.StatusLowBattery;
|
|
835
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
|
|
836
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
|
|
837
|
+
}
|
|
838
|
+
// FirmwareRevision
|
|
839
|
+
if (this.OpenAPI_FirmwareRevision === undefined) {
|
|
840
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
|
|
841
|
+
} else {
|
|
842
|
+
this.accessory.context.OpenAPI_FirmwareRevision = this.OpenAPI_FirmwareRevision;
|
|
843
|
+
this.accessory.getService(this.platform.Service.AccessoryInformation)!
|
|
844
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
|
|
845
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
846
|
+
+ `updateCharacteristic CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
|
|
847
847
|
}
|
|
848
848
|
}
|
|
849
849
|
|
|
@@ -881,7 +881,7 @@ export class Curtain {
|
|
|
881
881
|
|
|
882
882
|
async stopScanning(switchbot: any) {
|
|
883
883
|
await switchbot.stopScan();
|
|
884
|
-
if (this.
|
|
884
|
+
if (this.BLE_IsConnected) {
|
|
885
885
|
await this.BLEparseStatus();
|
|
886
886
|
await this.updateHomeKitCharacteristics();
|
|
887
887
|
} else {
|
|
@@ -1071,10 +1071,8 @@ export class Curtain {
|
|
|
1071
1071
|
if (!this.device.curtain?.hide_lightsensor) {
|
|
1072
1072
|
this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e);
|
|
1073
1073
|
}
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
1077
|
-
}
|
|
1074
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
|
|
1075
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
1078
1076
|
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
1079
1077
|
}
|
|
1080
1078
|
|
|
@@ -1085,10 +1083,12 @@ export class Curtain {
|
|
|
1085
1083
|
);
|
|
1086
1084
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
1087
1085
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
1088
|
-
if (
|
|
1089
|
-
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
1090
|
-
} else if (device.firmware) {
|
|
1086
|
+
if (device.firmware) {
|
|
1091
1087
|
FirmwareRevision = device.firmware;
|
|
1088
|
+
} else if (device.version) {
|
|
1089
|
+
FirmwareRevision = JSON.stringify(device.version);
|
|
1090
|
+
} if (accessory.context.FirmwareRevision) {
|
|
1091
|
+
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
1092
1092
|
} else {
|
|
1093
1093
|
FirmwareRevision = this.platform.version;
|
|
1094
1094
|
}
|
package/src/device/hub.ts
CHANGED
|
@@ -3,23 +3,27 @@ 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 {
|
|
10
10
|
// Services
|
|
11
|
-
hubTemperatureSensor: Service;
|
|
12
|
-
hubHumiditySensor: Service;
|
|
13
11
|
hubLightSensor: Service;
|
|
12
|
+
hubHumiditySensor: Service;
|
|
13
|
+
hubTemperatureSensor: Service;
|
|
14
14
|
|
|
15
15
|
// Characteristic Values
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
CurrentAmbientLightLevel!:
|
|
16
|
+
CurrentTemperature!: CharacteristicValue;
|
|
17
|
+
CurrentRelativeHumidity!: CharacteristicValue;
|
|
18
|
+
CurrentAmbientLightLevel!: CharacteristicValue;
|
|
19
|
+
|
|
20
|
+
// OpenAPI Status
|
|
21
|
+
OpenAPI_FirmwareRevision: deviceStatus['version'];
|
|
22
|
+
OpenAPI_CurrentTemperature: deviceStatus['temperature'];
|
|
23
|
+
OpenAPI_CurrentRelativeHumidity: deviceStatus['humidity'];
|
|
24
|
+
OpenAPI_CurrentAmbientLightLevel!: deviceStatus['brightness'];
|
|
19
25
|
|
|
20
26
|
// OpenAPI Others
|
|
21
|
-
deviceStatus!: any; //deviceStatusResponse;
|
|
22
|
-
lightLevel!: number;
|
|
23
27
|
spaceBetweenLevels!: number;
|
|
24
28
|
|
|
25
29
|
// Config
|
|
@@ -173,10 +177,11 @@ export class Hub {
|
|
|
173
177
|
|
|
174
178
|
async openAPIparseStatus(): Promise<void> {
|
|
175
179
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIparseStatus`);
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
// Temperature
|
|
181
|
+
this.CurrentTemperature = Number(this.OpenAPI_CurrentTemperature);
|
|
182
|
+
|
|
183
|
+
// Humidity
|
|
184
|
+
this.CurrentRelativeHumidity = Number(this.OpenAPI_CurrentRelativeHumidity);
|
|
180
185
|
|
|
181
186
|
if (!this.device.curtain?.hide_lightsensor) {
|
|
182
187
|
this.set_minLux = this.minLux();
|
|
@@ -184,85 +189,85 @@ export class Hub {
|
|
|
184
189
|
this.spaceBetweenLevels = 19;
|
|
185
190
|
|
|
186
191
|
// Brightness
|
|
187
|
-
switch (this.
|
|
192
|
+
switch (this.OpenAPI_CurrentAmbientLightLevel) {
|
|
188
193
|
case 1:
|
|
189
194
|
this.CurrentAmbientLightLevel = this.set_minLux;
|
|
190
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
195
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
|
|
191
196
|
break;
|
|
192
197
|
case 2:
|
|
193
198
|
this.CurrentAmbientLightLevel = (this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels;
|
|
194
199
|
this.debugLog(
|
|
195
|
-
`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
200
|
+
`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel},` +
|
|
196
201
|
` Calculation: ${(this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels}`,
|
|
197
202
|
);
|
|
198
203
|
break;
|
|
199
204
|
case 3:
|
|
200
205
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 2;
|
|
201
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
206
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
|
|
202
207
|
break;
|
|
203
208
|
case 4:
|
|
204
209
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 3;
|
|
205
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
210
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
|
|
206
211
|
break;
|
|
207
212
|
case 5:
|
|
208
213
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 4;
|
|
209
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
214
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
|
|
210
215
|
break;
|
|
211
216
|
case 6:
|
|
212
217
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 5;
|
|
213
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
218
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
|
|
214
219
|
break;
|
|
215
220
|
case 7:
|
|
216
221
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 6;
|
|
217
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
222
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
|
|
218
223
|
break;
|
|
219
224
|
case 8:
|
|
220
225
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 7;
|
|
221
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
226
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
|
|
222
227
|
break;
|
|
223
228
|
case 9:
|
|
224
229
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 8;
|
|
225
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
230
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
|
|
226
231
|
break;
|
|
227
232
|
case 10:
|
|
228
233
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 9;
|
|
229
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
234
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
|
|
230
235
|
break;
|
|
231
236
|
case 11:
|
|
232
237
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 10;
|
|
233
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
238
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
|
|
234
239
|
break;
|
|
235
240
|
case 12:
|
|
236
241
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 11;
|
|
237
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
242
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
|
|
238
243
|
break;
|
|
239
244
|
case 13:
|
|
240
245
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 12;
|
|
241
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
246
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
|
|
242
247
|
break;
|
|
243
248
|
case 14:
|
|
244
249
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 13;
|
|
245
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
250
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
|
|
246
251
|
break;
|
|
247
252
|
case 15:
|
|
248
253
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 14;
|
|
249
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
254
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
|
|
250
255
|
break;
|
|
251
256
|
case 16:
|
|
252
257
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 15;
|
|
253
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
258
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
|
|
254
259
|
break;
|
|
255
260
|
case 17:
|
|
256
261
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 16;
|
|
257
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
262
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
|
|
258
263
|
break;
|
|
259
264
|
case 18:
|
|
260
265
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 17;
|
|
261
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
266
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
|
|
262
267
|
break;
|
|
263
268
|
case 19:
|
|
264
269
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 18;
|
|
265
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
270
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
|
|
266
271
|
break;
|
|
267
272
|
case 20:
|
|
268
273
|
default:
|
|
@@ -270,7 +275,7 @@ export class Hub {
|
|
|
270
275
|
this.debugLog();
|
|
271
276
|
}
|
|
272
277
|
this.debugLog(
|
|
273
|
-
`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
278
|
+
`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel},` +
|
|
274
279
|
` CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
|
|
275
280
|
);
|
|
276
281
|
}
|
|
@@ -293,14 +298,15 @@ export class Hub {
|
|
|
293
298
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
294
299
|
headers: this.platform.generateHeaders(),
|
|
295
300
|
});
|
|
296
|
-
const deviceStatus = await body.json();
|
|
301
|
+
const deviceStatus: any = await body.json();
|
|
297
302
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
|
|
298
303
|
this.statusCode(statusCode);
|
|
299
304
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
|
|
300
305
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
|
|
301
|
-
this.
|
|
302
|
-
this.
|
|
303
|
-
this.
|
|
306
|
+
this.OpenAPI_CurrentTemperature = deviceStatus.body.temperature;
|
|
307
|
+
this.OpenAPI_CurrentRelativeHumidity = deviceStatus.body.humidity;
|
|
308
|
+
this.OpenAPI_CurrentAmbientLightLevel = deviceStatus.body.lightLevel;
|
|
309
|
+
this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
|
|
304
310
|
this.openAPIparseStatus();
|
|
305
311
|
this.updateHomeKitCharacteristics();
|
|
306
312
|
} catch (e: any) {
|
|
@@ -357,12 +363,22 @@ export class Hub {
|
|
|
357
363
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
|
|
358
364
|
} else {
|
|
359
365
|
this.accessory.context.CurrentAmbientLightLevel = this.CurrentAmbientLightLevel;
|
|
360
|
-
this.
|
|
366
|
+
this.hubLightSensor?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.CurrentAmbientLightLevel);
|
|
361
367
|
this.debugLog(
|
|
362
|
-
`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
363
|
-
`updateCharacteristic CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
|
|
368
|
+
`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
369
|
+
+ `updateCharacteristic CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
|
|
364
370
|
);
|
|
365
371
|
}
|
|
372
|
+
// FirmwareRevision
|
|
373
|
+
if (this.OpenAPI_FirmwareRevision === undefined) {
|
|
374
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
|
|
375
|
+
} else {
|
|
376
|
+
this.accessory.context.OpenAPI_FirmwareRevision = this.OpenAPI_FirmwareRevision;
|
|
377
|
+
this.accessory.getService(this.platform.Service.AccessoryInformation)!
|
|
378
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
|
|
379
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
380
|
+
+ `updateCharacteristic CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
|
|
381
|
+
}
|
|
366
382
|
}
|
|
367
383
|
|
|
368
384
|
async statusCode(statusCode: number): Promise<void> {
|
|
@@ -444,10 +460,12 @@ export class Hub {
|
|
|
444
460
|
);
|
|
445
461
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
446
462
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
447
|
-
if (
|
|
448
|
-
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
449
|
-
} else if (device.firmware) {
|
|
463
|
+
if (device.firmware) {
|
|
450
464
|
FirmwareRevision = device.firmware;
|
|
465
|
+
} else if (device.version) {
|
|
466
|
+
FirmwareRevision = JSON.stringify(device.version);
|
|
467
|
+
} else if (accessory.context.FirmwareRevision) {
|
|
468
|
+
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
451
469
|
} else {
|
|
452
470
|
FirmwareRevision = this.platform.version;
|
|
453
471
|
}
|