@switchbot/homebridge-switchbot 3.5.0 → 3.5.1-beta.1
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/.github/npm-version-script.cjs +81 -0
- package/config.schema.json +4 -4
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +64 -189
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +34 -68
- 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 +65 -158
- 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 +47 -159
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +42 -105
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +1 -0
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +61 -182
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +41 -2
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +182 -5
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +76 -145
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts +7 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +54 -17
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +55 -104
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +27 -46
- 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 +56 -120
- 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 +36 -66
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +27 -46
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +26 -45
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +24 -43
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +32 -66
- 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 +43 -88
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +23 -43
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +10 -28
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +8 -20
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +8 -20
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +8 -20
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +7 -0
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +28 -0
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +8 -20
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +8 -20
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +8 -20
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +8 -20
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +8 -20
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/settings.d.ts +4 -2
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/dist/utils.d.ts +19 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +20 -1
- package/dist/utils.js.map +1 -1
- package/package.json +8 -8
- package/src/device/blindtilt.ts +71 -186
- package/src/device/bot.ts +32 -68
- package/src/device/ceilinglight.ts +67 -153
- package/src/device/colorbulb.ts +51 -155
- package/src/device/contact.ts +49 -104
- package/src/device/curtain.ts +70 -177
- package/src/device/device.ts +207 -8
- package/src/device/fan.ts +75 -147
- package/src/device/hub.ts +55 -19
- package/src/device/humidifier.ts +52 -104
- package/src/device/iosensor.ts +25 -46
- package/src/device/lightstrip.ts +54 -121
- package/src/device/lock.ts +35 -67
- package/src/device/meter.ts +25 -46
- package/src/device/meterplus.ts +24 -45
- package/src/device/motion.ts +22 -43
- package/src/device/plug.ts +30 -66
- package/src/device/robotvacuumcleaner.ts +40 -89
- package/src/device/waterdetector.ts +22 -43
- package/src/irdevice/airconditioner.ts +10 -26
- package/src/irdevice/airpurifier.ts +8 -20
- package/src/irdevice/camera.ts +8 -20
- package/src/irdevice/fan.ts +8 -20
- package/src/irdevice/irdevice.ts +29 -0
- package/src/irdevice/light.ts +8 -20
- package/src/irdevice/other.ts +8 -20
- package/src/irdevice/tv.ts +8 -20
- package/src/irdevice/vacuumcleaner.ts +8 -20
- package/src/irdevice/waterheater.ts +8 -20
- package/src/settings.ts +4 -2
- package/src/utils.ts +20 -1
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
*
|
|
3
3
|
* ceilinglight.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
|
-
import { request } from 'undici';
|
|
6
5
|
import { deviceBase } from './device.js';
|
|
7
6
|
import { interval, Subject } from 'rxjs';
|
|
8
|
-
import { Devices } from '../settings.js';
|
|
9
7
|
import { hs2rgb, rgb2hs, m2hs } from '../utils.js';
|
|
10
8
|
import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
|
|
11
9
|
|
|
@@ -282,63 +280,42 @@ export class CeilingLight extends deviceBase {
|
|
|
282
280
|
|
|
283
281
|
async BLERefreshStatus(): Promise<void> {
|
|
284
282
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLERefreshStatus`);
|
|
285
|
-
const switchbot = await this.
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
.
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
292
|
-
this.getCustomBLEAddress(switchbot);
|
|
293
|
-
// Start to monitor advertisement packets
|
|
294
|
-
(async () => {
|
|
283
|
+
const switchbot = await this.switchbotBLE();
|
|
284
|
+
|
|
285
|
+
if (switchbot === undefined) {
|
|
286
|
+
await this.BLERefreshConnection(switchbot);
|
|
287
|
+
} else {
|
|
288
|
+
(async () => {
|
|
295
289
|
// Start to monitor advertisement packets
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} address: ${ad.address}, model: ${ad.model}`);
|
|
302
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
|
|
290
|
+
const serviceData: serviceData = await this.monitorAdvertisementPackets(switchbot);
|
|
291
|
+
// Update HomeKit
|
|
292
|
+
if (serviceData.model !== '' && serviceData.modelName !== '') {
|
|
293
|
+
await this.BLEparseStatus(serviceData);
|
|
294
|
+
await this.updateHomeKitCharacteristics();
|
|
303
295
|
} else {
|
|
304
|
-
this.
|
|
296
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed to get serviceData, serviceData: ${serviceData}`);
|
|
297
|
+
await this.BLERefreshConnection(switchbot);
|
|
305
298
|
}
|
|
306
|
-
};
|
|
307
|
-
// Wait 10 seconds
|
|
308
|
-
await switchbot.wait(this.scanDuration * 1000);
|
|
309
|
-
// Stop to monitor
|
|
310
|
-
await switchbot.stopScan();
|
|
311
|
-
// Update HomeKit
|
|
312
|
-
await this.BLEparseStatus(switchbot.onadvertisement.serviceData);
|
|
313
|
-
await this.updateHomeKitCharacteristics();
|
|
314
|
-
})();
|
|
315
|
-
if (switchbot === undefined) {
|
|
316
|
-
await this.BLERefreshConnection(switchbot);
|
|
299
|
+
})();
|
|
317
300
|
}
|
|
318
301
|
}
|
|
319
302
|
|
|
320
303
|
async openAPIRefreshStatus(): Promise<void> {
|
|
321
304
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
|
|
322
305
|
try {
|
|
323
|
-
const { body, statusCode } = await this.
|
|
324
|
-
`${Devices}/${this.device.deviceId}/status`, { headers: this.platform.generateHeaders() });
|
|
325
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
306
|
+
const { body, statusCode } = await this.deviceRefreshStatus();
|
|
326
307
|
const deviceStatus: any = await body.json();
|
|
327
|
-
this.
|
|
328
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
308
|
+
await this.refreshStatusCodes(statusCode, deviceStatus);;
|
|
329
309
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
330
|
-
this.
|
|
331
|
-
|
|
332
|
-
this.
|
|
333
|
-
this.updateHomeKitCharacteristics();
|
|
310
|
+
await this.successfulRefreshStatus(statusCode, deviceStatus);
|
|
311
|
+
await this.openAPIparseStatus(deviceStatus);
|
|
312
|
+
await this.updateHomeKitCharacteristics();
|
|
334
313
|
} else {
|
|
335
|
-
this.
|
|
336
|
-
this.statusCode(deviceStatus.statusCode);
|
|
314
|
+
await this.statusCodes(statusCode, deviceStatus);
|
|
337
315
|
}
|
|
338
316
|
} catch (e: any) {
|
|
339
|
-
this.apiError(e);
|
|
340
|
-
this.
|
|
341
|
-
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
317
|
+
await this.apiError(e);
|
|
318
|
+
await this.openAPIRefreshError(e);
|
|
342
319
|
}
|
|
343
320
|
}
|
|
344
321
|
|
|
@@ -403,14 +380,13 @@ export class CeilingLight extends deviceBase {
|
|
|
403
380
|
async pushChanges(): Promise<void> {
|
|
404
381
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
405
382
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
406
|
-
|
|
407
|
-
|
|
383
|
+
} else if (this.BLE) {
|
|
384
|
+
await this.BLEpushChanges();
|
|
408
385
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
409
386
|
await this.openAPIpushChanges();
|
|
410
387
|
} else {
|
|
411
388
|
await this.offlineOff();
|
|
412
|
-
this.
|
|
413
|
-
+ ` ${this.device.connectionType}, pushChanges will not happen.`);
|
|
389
|
+
await this.pushChangeDisabled();
|
|
414
390
|
}
|
|
415
391
|
// Refresh the status from the API
|
|
416
392
|
interval(15000)
|
|
@@ -428,16 +404,9 @@ export class CeilingLight extends deviceBase {
|
|
|
428
404
|
+ ` BLEpushChanges On: ${this.LightBulb.On} OnCached: ${this.accessory.context.On}`);
|
|
429
405
|
const switchbot = await this.platform.connectBLE();
|
|
430
406
|
// Convert to BLE Address
|
|
431
|
-
|
|
432
|
-
.deviceId!.match(/.{1,2}/g)!
|
|
433
|
-
.join(':')
|
|
434
|
-
.toLowerCase();
|
|
435
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
407
|
+
await this.convertBLEAddress();
|
|
436
408
|
switchbot
|
|
437
|
-
.discover({
|
|
438
|
-
model: 'u',
|
|
439
|
-
id: this.device.bleMac,
|
|
440
|
-
})
|
|
409
|
+
.discover({ model: this.device.bleModel, id: this.device.bleMac })
|
|
441
410
|
.then(async (device_list: any) => {
|
|
442
411
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.LightBulb.On}`);
|
|
443
412
|
return await this.retryBLE({
|
|
@@ -486,24 +455,15 @@ export class CeilingLight extends deviceBase {
|
|
|
486
455
|
});
|
|
487
456
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
488
457
|
try {
|
|
489
|
-
const { body, statusCode } = await
|
|
490
|
-
body: bodyChange,
|
|
491
|
-
method: 'POST',
|
|
492
|
-
headers: this.platform.generateHeaders(),
|
|
493
|
-
});
|
|
494
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
458
|
+
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
495
459
|
const deviceStatus: any = await body.json();
|
|
496
|
-
this.
|
|
497
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
498
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
460
|
+
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
499
461
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
500
|
-
this.
|
|
501
|
-
|
|
502
|
-
this.successLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
503
|
-
+ `request to SwitchBot API, body: ${JSON.stringify(JSON.parse(bodyChange))} sent successfully`);
|
|
462
|
+
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
463
|
+
await this.updateHomeKitCharacteristics();
|
|
504
464
|
} else {
|
|
505
|
-
this.statusCode(statusCode);
|
|
506
|
-
this.statusCode(deviceStatus.statusCode);
|
|
465
|
+
await this.statusCode(statusCode);
|
|
466
|
+
await this.statusCode(deviceStatus.statusCode);
|
|
507
467
|
}
|
|
508
468
|
} catch (e: any) {
|
|
509
469
|
this.apiError(e);
|
|
@@ -543,24 +503,15 @@ export class CeilingLight extends deviceBase {
|
|
|
543
503
|
});
|
|
544
504
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
545
505
|
try {
|
|
546
|
-
const { body, statusCode } = await
|
|
547
|
-
body: bodyChange,
|
|
548
|
-
method: 'POST',
|
|
549
|
-
headers: this.platform.generateHeaders(),
|
|
550
|
-
});
|
|
551
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
506
|
+
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
552
507
|
const deviceStatus: any = await body.json();
|
|
553
|
-
this.
|
|
554
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
555
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
508
|
+
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
556
509
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
557
|
-
this.
|
|
558
|
-
|
|
559
|
-
this.successLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
560
|
-
+ `request to SwitchBot API, body: ${JSON.stringify(JSON.parse(bodyChange))} sent successfully`);
|
|
510
|
+
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
511
|
+
await this.updateHomeKitCharacteristics();
|
|
561
512
|
} else {
|
|
562
|
-
this.statusCode(statusCode);
|
|
563
|
-
this.statusCode(deviceStatus.statusCode);
|
|
513
|
+
await this.statusCode(statusCode);
|
|
514
|
+
await this.statusCode(deviceStatus.statusCode);
|
|
564
515
|
}
|
|
565
516
|
} catch (e: any) {
|
|
566
517
|
this.apiError(e);
|
|
@@ -585,22 +536,15 @@ export class CeilingLight extends deviceBase {
|
|
|
585
536
|
});
|
|
586
537
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
587
538
|
try {
|
|
588
|
-
const { body, statusCode } = await
|
|
589
|
-
body: bodyChange,
|
|
590
|
-
method: 'POST',
|
|
591
|
-
headers: this.platform.generateHeaders(),
|
|
592
|
-
});
|
|
593
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
539
|
+
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
594
540
|
const deviceStatus: any = await body.json();
|
|
595
|
-
this.
|
|
596
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
597
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
541
|
+
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
598
542
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
599
|
-
this.
|
|
600
|
-
|
|
543
|
+
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
544
|
+
await this.updateHomeKitCharacteristics();
|
|
601
545
|
} else {
|
|
602
|
-
this.statusCode(statusCode);
|
|
603
|
-
this.statusCode(deviceStatus.statusCode);
|
|
546
|
+
await this.statusCode(statusCode);
|
|
547
|
+
await this.statusCode(deviceStatus.statusCode);
|
|
604
548
|
}
|
|
605
549
|
} catch (e: any) {
|
|
606
550
|
this.apiError(e);
|
|
@@ -623,24 +567,15 @@ export class CeilingLight extends deviceBase {
|
|
|
623
567
|
});
|
|
624
568
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
625
569
|
try {
|
|
626
|
-
const { body, statusCode } = await
|
|
627
|
-
body: bodyChange,
|
|
628
|
-
method: 'POST',
|
|
629
|
-
headers: this.platform.generateHeaders(),
|
|
630
|
-
});
|
|
631
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
570
|
+
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
632
571
|
const deviceStatus: any = await body.json();
|
|
633
|
-
this.
|
|
634
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
635
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
572
|
+
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
636
573
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
637
|
-
this.
|
|
638
|
-
|
|
639
|
-
this.successLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
640
|
-
+ `request to SwitchBot API, body: ${JSON.stringify(JSON.parse(bodyChange))} sent successfully`);
|
|
574
|
+
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
575
|
+
await this.updateHomeKitCharacteristics();
|
|
641
576
|
} else {
|
|
642
|
-
this.statusCode(statusCode);
|
|
643
|
-
this.statusCode(deviceStatus.statusCode);
|
|
577
|
+
await this.statusCode(statusCode);
|
|
578
|
+
await this.statusCode(deviceStatus.statusCode);
|
|
644
579
|
}
|
|
645
580
|
} catch (e: any) {
|
|
646
581
|
this.apiError(e);
|
|
@@ -754,42 +689,21 @@ export class CeilingLight extends deviceBase {
|
|
|
754
689
|
}
|
|
755
690
|
|
|
756
691
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
this.
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
this.
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
this.LightBulb
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ColorTemperature: ${this.LightBulb.ColorTemperature}`);
|
|
773
|
-
} else {
|
|
774
|
-
this.accessory.context.ColorTemperature = this.LightBulb.ColorTemperature;
|
|
775
|
-
this.LightBulb!.Service.updateCharacteristic(this.hap.Characteristic.ColorTemperature, this.LightBulb.ColorTemperature);
|
|
776
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
777
|
-
+ ` updateCharacteristic ColorTemperature: ${this.LightBulb.ColorTemperature}`);
|
|
778
|
-
}
|
|
779
|
-
if (this.LightBulb.Hue === undefined) {
|
|
780
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${this.LightBulb.Hue}`);
|
|
781
|
-
} else {
|
|
782
|
-
this.accessory.context.Hue = this.LightBulb.Hue;
|
|
783
|
-
this.LightBulb!.Service.updateCharacteristic(this.hap.Characteristic.Hue, this.LightBulb.Hue);
|
|
784
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Hue: ${this.LightBulb.Hue}`);
|
|
785
|
-
}
|
|
786
|
-
if (this.LightBulb.Saturation === undefined) {
|
|
787
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${this.LightBulb.Saturation}`);
|
|
788
|
-
} else {
|
|
789
|
-
this.accessory.context.Saturation = this.LightBulb.Saturation;
|
|
790
|
-
this.LightBulb!.Service.updateCharacteristic(this.hap.Characteristic.Saturation, this.LightBulb.Saturation);
|
|
791
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Saturation: ${this.LightBulb.Saturation}`);
|
|
792
|
-
}
|
|
692
|
+
// On
|
|
693
|
+
await this.updateCharacteristic(this.LightBulb.Service, this.hap.Characteristic.On,
|
|
694
|
+
this.LightBulb.On, 'On');
|
|
695
|
+
// Brightness
|
|
696
|
+
await this.updateCharacteristic(this.LightBulb.Service, this.hap.Characteristic.Brightness,
|
|
697
|
+
this.LightBulb.Brightness, 'Brightness');
|
|
698
|
+
// ColorTemperature
|
|
699
|
+
await this.updateCharacteristic(this.LightBulb.Service, this.hap.Characteristic.ColorTemperature,
|
|
700
|
+
this.LightBulb.ColorTemperature, 'ColorTemperature');
|
|
701
|
+
// Hue
|
|
702
|
+
await this.updateCharacteristic(this.LightBulb.Service, this.hap.Characteristic.Hue,
|
|
703
|
+
this.LightBulb.Hue, 'Hue');
|
|
704
|
+
// Saturation
|
|
705
|
+
await this.updateCharacteristic(this.LightBulb.Service, this.hap.Characteristic.Saturation,
|
|
706
|
+
this.LightBulb.Saturation, 'Saturation');
|
|
793
707
|
}
|
|
794
708
|
|
|
795
709
|
async adaptiveLighting(device: device & devicesConfig): Promise<void> {
|
|
@@ -824,7 +738,7 @@ export class CeilingLight extends deviceBase {
|
|
|
824
738
|
}
|
|
825
739
|
}
|
|
826
740
|
|
|
827
|
-
apiError(e: any): void {
|
|
741
|
+
async apiError(e: any): Promise<void> {
|
|
828
742
|
this.LightBulb!.Service.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
829
743
|
this.LightBulb!.Service.updateCharacteristic(this.hap.Characteristic.Hue, e);
|
|
830
744
|
this.LightBulb!.Service.updateCharacteristic(this.hap.Characteristic.Brightness, e);
|