@switchbot/homebridge-switchbot 1.4.1-beta.4 → 1.4.1-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/dist/devices/bots.d.ts +1 -1
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +17 -17
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +1 -1
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +13 -8
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +1 -1
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +15 -4
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +1 -1
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +17 -7
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +1 -1
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +20 -9
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +1 -1
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +12 -4
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +1 -1
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +10 -4
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +1 -1
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +5 -4
- package/dist/devices/plugs.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +1 -4
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +19 -53
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +1 -1
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +7 -3
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +1 -1
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +4 -3
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +1 -1
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +6 -3
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +1 -1
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +4 -3
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +1 -1
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +4 -3
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +1 -1
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +5 -3
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +4 -3
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +1 -1
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +4 -3
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/package.json +1 -1
- package/src/devices/bots.ts +17 -18
- package/src/devices/colorbulb.ts +14 -9
- package/src/devices/contact.ts +16 -5
- package/src/devices/curtains.ts +17 -7
- package/src/devices/humidifiers.ts +21 -10
- package/src/devices/meters.ts +13 -5
- package/src/devices/motion.ts +11 -5
- package/src/devices/plugs.ts +6 -5
- package/src/irdevices/airconditioners.ts +20 -58
- package/src/irdevices/airpurifiers.ts +8 -4
- package/src/irdevices/cameras.ts +5 -4
- package/src/irdevices/fans.ts +7 -4
- package/src/irdevices/lights.ts +5 -4
- package/src/irdevices/others.ts +4 -3
- package/src/irdevices/tvs.ts +6 -4
- package/src/irdevices/vacuumcleaners.ts +5 -4
- package/src/irdevices/waterheaters.ts +5 -4
package/src/devices/colorbulb.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { AxiosResponse } from 'axios';
|
|
|
2
2
|
import { interval, Subject } from 'rxjs';
|
|
3
3
|
import { SwitchBotPlatform } from '../platform';
|
|
4
4
|
import { debounceTime, skipWhile, tap } from 'rxjs/operators';
|
|
5
|
-
import { Service, PlatformAccessory, CharacteristicValue, ControllerConstructor, Controller, ControllerServiceMap
|
|
5
|
+
import { Service, PlatformAccessory, CharacteristicValue, ControllerConstructor, Controller, ControllerServiceMap } from 'homebridge';
|
|
6
6
|
import { DeviceURL, device, devicesConfig, switchbot, deviceStatusResponse, payload, hs2rgb, rgb2hs, m2hs } from '../settings';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -191,7 +191,7 @@ export class ColorBulb {
|
|
|
191
191
|
this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges,`
|
|
192
192
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
193
193
|
}
|
|
194
|
-
this.apiError();
|
|
194
|
+
this.apiError(e);
|
|
195
195
|
}
|
|
196
196
|
this.colorBulbUpdateInProgress = false;
|
|
197
197
|
});
|
|
@@ -301,7 +301,7 @@ export class ColorBulb {
|
|
|
301
301
|
this.errorLog(`Color Bulb: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
302
302
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
303
303
|
}
|
|
304
|
-
this.apiError();
|
|
304
|
+
this.apiError(e);
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
|
|
@@ -365,7 +365,7 @@ export class ColorBulb {
|
|
|
365
365
|
this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
366
366
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
367
367
|
}
|
|
368
|
-
this.apiError();
|
|
368
|
+
this.apiError(e);
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
371
|
|
|
@@ -407,7 +407,7 @@ export class ColorBulb {
|
|
|
407
407
|
this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
408
408
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
409
409
|
}
|
|
410
|
-
this.apiError();
|
|
410
|
+
this.apiError(e);
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
413
|
|
|
@@ -445,7 +445,7 @@ export class ColorBulb {
|
|
|
445
445
|
this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
446
446
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
447
447
|
}
|
|
448
|
-
this.apiError();
|
|
448
|
+
this.apiError(e);
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
451
|
|
|
@@ -480,7 +480,7 @@ export class ColorBulb {
|
|
|
480
480
|
this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
481
481
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
482
482
|
}
|
|
483
|
-
this.apiError();
|
|
483
|
+
this.apiError(e);
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
486
|
|
|
@@ -517,8 +517,13 @@ export class ColorBulb {
|
|
|
517
517
|
}
|
|
518
518
|
}
|
|
519
519
|
|
|
520
|
-
public apiError() {
|
|
521
|
-
|
|
520
|
+
public apiError(e: any) {
|
|
521
|
+
this.service.updateCharacteristic(this.platform.Characteristic.On, e);
|
|
522
|
+
this.service.updateCharacteristic(this.platform.Characteristic.Hue, e);
|
|
523
|
+
this.service.updateCharacteristic(this.platform.Characteristic.Brightness, e);
|
|
524
|
+
this.service.updateCharacteristic(this.platform.Characteristic.Saturation, e);
|
|
525
|
+
this.service.updateCharacteristic(this.platform.Characteristic.ColorTemperature, e);
|
|
526
|
+
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
522
527
|
}
|
|
523
528
|
|
|
524
529
|
private statusCode(push: AxiosResponse<{ statusCode: number; }>) {
|
package/src/devices/contact.ts
CHANGED
|
@@ -2,7 +2,7 @@ import Switchbot from 'node-switchbot';
|
|
|
2
2
|
import { interval, Subject } from 'rxjs';
|
|
3
3
|
import { skipWhile } from 'rxjs/operators';
|
|
4
4
|
import { SwitchBotPlatform } from '../platform';
|
|
5
|
-
import { Service, PlatformAccessory, CharacteristicValue
|
|
5
|
+
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
6
6
|
import { DeviceURL, device, devicesConfig, serviceData, switchbot, deviceStatusResponse } from '../settings';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -322,7 +322,7 @@ export class Contact {
|
|
|
322
322
|
this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
323
323
|
await this.openAPIRefreshStatus();
|
|
324
324
|
}
|
|
325
|
-
this.apiError();
|
|
325
|
+
this.apiError(e);
|
|
326
326
|
});
|
|
327
327
|
}
|
|
328
328
|
|
|
@@ -344,7 +344,7 @@ export class Contact {
|
|
|
344
344
|
this.errorLog(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
345
345
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
346
346
|
}
|
|
347
|
-
this.apiError();
|
|
347
|
+
this.apiError(e);
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
}
|
|
@@ -392,8 +392,19 @@ export class Contact {
|
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
-
public apiError() {
|
|
396
|
-
|
|
395
|
+
public apiError(e: any) {
|
|
396
|
+
this.service.updateCharacteristic(this.platform.Characteristic.ContactSensorState, e);
|
|
397
|
+
if (!this.device.contact?.hide_motionsensor) {
|
|
398
|
+
this.motionService?.updateCharacteristic(this.platform.Characteristic.MotionDetected, e);
|
|
399
|
+
}
|
|
400
|
+
if (!this.device.contact?.hide_lightsensor) {
|
|
401
|
+
this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e);
|
|
402
|
+
}
|
|
403
|
+
if (this.device.ble) {
|
|
404
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
|
|
405
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
406
|
+
}
|
|
407
|
+
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
397
408
|
}
|
|
398
409
|
|
|
399
410
|
/**
|
package/src/devices/curtains.ts
CHANGED
|
@@ -186,7 +186,7 @@ export class Curtain {
|
|
|
186
186
|
this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges,`
|
|
187
187
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
188
188
|
}
|
|
189
|
-
this.apiError();
|
|
189
|
+
this.apiError(e);
|
|
190
190
|
}
|
|
191
191
|
this.curtainUpdateInProgress = false;
|
|
192
192
|
});
|
|
@@ -490,7 +490,7 @@ export class Curtain {
|
|
|
490
490
|
this.warnLog(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
491
491
|
await this.openAPIRefreshStatus();
|
|
492
492
|
}
|
|
493
|
-
this.apiError();
|
|
493
|
+
this.apiError(e);
|
|
494
494
|
});
|
|
495
495
|
}
|
|
496
496
|
|
|
@@ -512,7 +512,7 @@ export class Curtain {
|
|
|
512
512
|
this.errorLog(`Curtain: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
513
513
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
514
514
|
}
|
|
515
|
-
this.apiError();
|
|
515
|
+
this.apiError(e);
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
518
|
}
|
|
@@ -554,7 +554,7 @@ export class Curtain {
|
|
|
554
554
|
this.warnLog(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
555
555
|
await this.OpenAPIpushChanges();
|
|
556
556
|
}
|
|
557
|
-
this.apiError();
|
|
557
|
+
this.apiError(e);
|
|
558
558
|
});
|
|
559
559
|
} else {
|
|
560
560
|
this.debugLog(`Curtain: ${this.accessory.displayName} No BLE Changes, CurrentPosition & TargetPosition Are the Same.`
|
|
@@ -596,7 +596,7 @@ export class Curtain {
|
|
|
596
596
|
this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
597
597
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
598
598
|
}
|
|
599
|
-
this.apiError();
|
|
599
|
+
this.apiError(e);
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
602
|
}
|
|
@@ -645,8 +645,18 @@ export class Curtain {
|
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
647
|
|
|
648
|
-
public apiError() {
|
|
649
|
-
|
|
648
|
+
public apiError(e: any) {
|
|
649
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
|
|
650
|
+
this.service.updateCharacteristic(this.platform.Characteristic.PositionState, e);
|
|
651
|
+
this.service.updateCharacteristic(this.platform.Characteristic.TargetPosition, e);
|
|
652
|
+
if (!this.device.curtain?.hide_lightsensor) {
|
|
653
|
+
this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e);
|
|
654
|
+
}
|
|
655
|
+
if (this.device.ble) {
|
|
656
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
|
|
657
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
658
|
+
}
|
|
659
|
+
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
650
660
|
}
|
|
651
661
|
|
|
652
662
|
private statusCode(push: AxiosResponse<{ statusCode: number; }>) {
|
|
@@ -3,7 +3,7 @@ import Switchbot from 'node-switchbot';
|
|
|
3
3
|
import { interval, Subject } from 'rxjs';
|
|
4
4
|
import { SwitchBotPlatform } from '../platform';
|
|
5
5
|
import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
|
|
6
|
-
import { Service, PlatformAccessory, CharacteristicValue
|
|
6
|
+
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
7
7
|
import { DeviceURL, device, devicesConfig, serviceData, ad, deviceStatusResponse, payload } from '../settings';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -184,7 +184,7 @@ export class Humidifier {
|
|
|
184
184
|
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges,`
|
|
185
185
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
186
186
|
}
|
|
187
|
-
this.apiError();
|
|
187
|
+
this.apiError(e);
|
|
188
188
|
}
|
|
189
189
|
this.humidifierUpdateInProgress = false;
|
|
190
190
|
});
|
|
@@ -387,7 +387,7 @@ export class Humidifier {
|
|
|
387
387
|
this.warnLog(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
388
388
|
await this.openAPIRefreshStatus();
|
|
389
389
|
}
|
|
390
|
-
this.apiError();
|
|
390
|
+
this.apiError(e);
|
|
391
391
|
});
|
|
392
392
|
}
|
|
393
393
|
|
|
@@ -413,7 +413,7 @@ export class Humidifier {
|
|
|
413
413
|
this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
414
414
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
415
415
|
}
|
|
416
|
-
this.apiError();
|
|
416
|
+
this.apiError(e);
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
}
|
|
@@ -457,7 +457,7 @@ export class Humidifier {
|
|
|
457
457
|
this.warnLog(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
458
458
|
await this.OpenAPIpushChanges();
|
|
459
459
|
}
|
|
460
|
-
this.apiError();
|
|
460
|
+
this.apiError(e);
|
|
461
461
|
});
|
|
462
462
|
}
|
|
463
463
|
|
|
@@ -494,7 +494,7 @@ export class Humidifier {
|
|
|
494
494
|
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
495
495
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
496
496
|
}
|
|
497
|
-
this.apiError();
|
|
497
|
+
this.apiError(e);
|
|
498
498
|
}
|
|
499
499
|
} else if (
|
|
500
500
|
this.TargetHumidifierDehumidifierState ===
|
|
@@ -543,7 +543,7 @@ export class Humidifier {
|
|
|
543
543
|
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushAutoChanges with OpenAPI Connection,`
|
|
544
544
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
545
545
|
}
|
|
546
|
-
this.apiError();
|
|
546
|
+
this.apiError(e);
|
|
547
547
|
}
|
|
548
548
|
}
|
|
549
549
|
|
|
@@ -578,7 +578,7 @@ export class Humidifier {
|
|
|
578
578
|
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushActiveChanges with OpenAPI Connection,`
|
|
579
579
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
580
580
|
}
|
|
581
|
-
this.apiError();
|
|
581
|
+
this.apiError(e);
|
|
582
582
|
}
|
|
583
583
|
}
|
|
584
584
|
|
|
@@ -639,8 +639,19 @@ export class Humidifier {
|
|
|
639
639
|
}
|
|
640
640
|
}
|
|
641
641
|
|
|
642
|
-
public apiError() {
|
|
643
|
-
|
|
642
|
+
public apiError(e: any) {
|
|
643
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, e);
|
|
644
|
+
if (!this.device.ble) {
|
|
645
|
+
this.service.updateCharacteristic(this.platform.Characteristic.WaterLevel, e);
|
|
646
|
+
}
|
|
647
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState, e);
|
|
648
|
+
this.service.updateCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState, e);
|
|
649
|
+
this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
650
|
+
this.service.updateCharacteristic(this.platform.Characteristic.RelativeHumidityHumidifierThreshold, e);
|
|
651
|
+
if (!this.device.humidifier?.hide_temperature && !this.device.ble) {
|
|
652
|
+
this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
|
|
653
|
+
}
|
|
654
|
+
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
644
655
|
}
|
|
645
656
|
|
|
646
657
|
private statusCode(push: AxiosResponse<{ statusCode: number; }>) {
|
package/src/devices/meters.ts
CHANGED
|
@@ -2,7 +2,7 @@ import Switchbot from 'node-switchbot';
|
|
|
2
2
|
import { interval, Subject } from 'rxjs';
|
|
3
3
|
import { skipWhile } from 'rxjs/operators';
|
|
4
4
|
import { SwitchBotPlatform } from '../platform';
|
|
5
|
-
import { Service, PlatformAccessory, Units, CharacteristicValue
|
|
5
|
+
import { Service, PlatformAccessory, Units, CharacteristicValue } from 'homebridge';
|
|
6
6
|
import { DeviceURL, device, devicesConfig, serviceData, ad, switchbot, deviceStatusResponse, temperature } from '../settings';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -358,7 +358,7 @@ export class Meter {
|
|
|
358
358
|
this.warnLog(`Meter: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
359
359
|
this.openAPIRefreshStatus();
|
|
360
360
|
}
|
|
361
|
-
this.apiError();
|
|
361
|
+
this.apiError(e);
|
|
362
362
|
});
|
|
363
363
|
}
|
|
364
364
|
|
|
@@ -386,7 +386,7 @@ export class Meter {
|
|
|
386
386
|
this.errorLog(`Meter: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
387
387
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
388
388
|
}
|
|
389
|
-
this.apiError();
|
|
389
|
+
this.apiError(e);
|
|
390
390
|
}
|
|
391
391
|
}
|
|
392
392
|
}
|
|
@@ -425,8 +425,16 @@ export class Meter {
|
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
|
|
428
|
-
public apiError() {
|
|
429
|
-
|
|
428
|
+
public apiError(e: any) {
|
|
429
|
+
this.service.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
430
|
+
this.service.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
|
|
431
|
+
if (!this.device.meter?.hide_humidity) {
|
|
432
|
+
this.humidityservice?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, e);
|
|
433
|
+
}
|
|
434
|
+
if (!this.device.meter?.hide_temperature) {
|
|
435
|
+
this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
|
|
436
|
+
}
|
|
437
|
+
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
430
438
|
}
|
|
431
439
|
|
|
432
440
|
/**
|
package/src/devices/motion.ts
CHANGED
|
@@ -2,7 +2,7 @@ import Switchbot from 'node-switchbot';
|
|
|
2
2
|
import { interval, Subject } from 'rxjs';
|
|
3
3
|
import { skipWhile } from 'rxjs/operators';
|
|
4
4
|
import { SwitchBotPlatform } from '../platform';
|
|
5
|
-
import { Service, PlatformAccessory, CharacteristicValue
|
|
5
|
+
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
6
6
|
import { DeviceURL, device, devicesConfig, serviceData, switchbot, deviceStatusResponse } from '../settings';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -259,7 +259,7 @@ export class Motion {
|
|
|
259
259
|
this.warnLog(`Motion Sensor: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
260
260
|
await this.openAPIRefreshStatus();
|
|
261
261
|
}
|
|
262
|
-
this.apiError();
|
|
262
|
+
this.apiError(e);
|
|
263
263
|
});
|
|
264
264
|
}
|
|
265
265
|
|
|
@@ -281,7 +281,7 @@ export class Motion {
|
|
|
281
281
|
this.errorLog(`Motion Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
282
282
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
283
283
|
}
|
|
284
|
-
this.apiError();
|
|
284
|
+
this.apiError(e);
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
}
|
|
@@ -319,8 +319,14 @@ export class Motion {
|
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
-
public apiError() {
|
|
323
|
-
|
|
322
|
+
public apiError(e: any) {
|
|
323
|
+
this.service.updateCharacteristic(this.platform.Characteristic.MotionDetected, e);
|
|
324
|
+
if (this.device.ble) {
|
|
325
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
|
|
326
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
327
|
+
this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e);
|
|
328
|
+
}
|
|
329
|
+
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
324
330
|
}
|
|
325
331
|
|
|
326
332
|
/**
|
package/src/devices/plugs.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { AxiosResponse } from 'axios';
|
|
|
3
3
|
import { interval, Subject } from 'rxjs';
|
|
4
4
|
import { SwitchBotPlatform } from '../platform';
|
|
5
5
|
import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
|
|
6
|
-
import { Service, PlatformAccessory, CharacteristicValue
|
|
6
|
+
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
7
7
|
import { DeviceURL, device, devicesConfig, deviceStatusResponse, payload } from '../settings';
|
|
8
8
|
|
|
9
9
|
export class Plug {
|
|
@@ -108,7 +108,7 @@ export class Plug {
|
|
|
108
108
|
this.errorLog(`Plug: ${this.accessory.displayName} failed pushChanges,`
|
|
109
109
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
110
110
|
}
|
|
111
|
-
this.apiError();
|
|
111
|
+
this.apiError(e);
|
|
112
112
|
}
|
|
113
113
|
this.plugUpdateInProgress = false;
|
|
114
114
|
});
|
|
@@ -174,7 +174,7 @@ export class Plug {
|
|
|
174
174
|
this.errorLog(`Plug: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
175
175
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
176
176
|
}
|
|
177
|
-
this.apiError();
|
|
177
|
+
this.apiError(e);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
|
|
@@ -224,8 +224,9 @@ export class Plug {
|
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
public apiError() {
|
|
228
|
-
|
|
227
|
+
public apiError(e: any) {
|
|
228
|
+
this.service.updateCharacteristic(this.platform.Characteristic.On, e);
|
|
229
|
+
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
229
230
|
}
|
|
230
231
|
|
|
231
232
|
private statusCode(push: AxiosResponse<{ statusCode: number; }>) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { SwitchBotPlatform } from '../platform';
|
|
3
3
|
import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
|
|
4
|
-
import { CharacteristicValue,
|
|
4
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -21,7 +21,6 @@ export class AirConditioner {
|
|
|
21
21
|
CurrentTemperatureCached!: CharacteristicValue;
|
|
22
22
|
TargetHeaterCoolerState?: CharacteristicValue;
|
|
23
23
|
CurrentHeaterCoolerState!: CharacteristicValue;
|
|
24
|
-
HeatingThresholdTemperature?: CharacteristicValue;
|
|
25
24
|
|
|
26
25
|
// Others
|
|
27
26
|
state!: string;
|
|
@@ -106,30 +105,6 @@ export class AirConditioner {
|
|
|
106
105
|
return this.CurrentHeaterCoolerStateGet();
|
|
107
106
|
});
|
|
108
107
|
|
|
109
|
-
this.service
|
|
110
|
-
.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
|
|
111
|
-
.setProps({
|
|
112
|
-
minValue: 16,
|
|
113
|
-
maxValue: 30,
|
|
114
|
-
minStep: 1,
|
|
115
|
-
})
|
|
116
|
-
.onGet(() => {
|
|
117
|
-
return this.HeatingThresholdTemperatureGet();
|
|
118
|
-
})
|
|
119
|
-
.onSet(this.HeatingThresholdTemperatureSet.bind(this));
|
|
120
|
-
|
|
121
|
-
this.service
|
|
122
|
-
.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature)
|
|
123
|
-
.setProps({
|
|
124
|
-
minValue: 16,
|
|
125
|
-
maxValue: 30,
|
|
126
|
-
minStep: 1,
|
|
127
|
-
})
|
|
128
|
-
.onGet(() => {
|
|
129
|
-
return this.HeatingThresholdTemperatureGet();
|
|
130
|
-
})
|
|
131
|
-
.onSet(this.HeatingThresholdTemperatureSet.bind(this));
|
|
132
|
-
|
|
133
108
|
this.service
|
|
134
109
|
.getCharacteristic(this.platform.Characteristic.RotationSpeed)
|
|
135
110
|
.setProps({
|
|
@@ -220,13 +195,6 @@ export class AirConditioner {
|
|
|
220
195
|
this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
|
|
221
196
|
+ ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
222
197
|
}
|
|
223
|
-
if (this.HeatingThresholdTemperature === undefined) {
|
|
224
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
225
|
-
} else {
|
|
226
|
-
this.service?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.HeatingThresholdTemperature);
|
|
227
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
|
|
228
|
-
+ ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
229
|
-
}
|
|
230
198
|
}
|
|
231
199
|
|
|
232
200
|
private CurrentTemperatureGet(value: CharacteristicValue) {
|
|
@@ -242,17 +210,17 @@ export class AirConditioner {
|
|
|
242
210
|
|
|
243
211
|
private TargetHeaterCoolerStateSet(value: CharacteristicValue) {
|
|
244
212
|
switch (value) {
|
|
245
|
-
case this.platform.Characteristic.TargetHeaterCoolerState.AUTO:
|
|
246
|
-
this.CurrentMode = AirConditioner.MODE_AUTO;
|
|
247
|
-
break;
|
|
248
|
-
case this.platform.Characteristic.TargetHeaterCoolerState.COOL:
|
|
249
|
-
this.CurrentMode = AirConditioner.MODE_COOL;
|
|
250
|
-
break;
|
|
251
213
|
case this.platform.Characteristic.TargetHeaterCoolerState.HEAT:
|
|
252
214
|
this.CurrentMode = AirConditioner.MODE_HEAT;
|
|
215
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} (Set) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
253
216
|
break;
|
|
254
|
-
|
|
217
|
+
case this.platform.Characteristic.TargetHeaterCoolerState.COOL:
|
|
218
|
+
this.CurrentMode = AirConditioner.MODE_COOL;
|
|
219
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} (Set) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
255
220
|
break;
|
|
221
|
+
case this.platform.Characteristic.TargetHeaterCoolerState.AUTO:
|
|
222
|
+
this.CurrentMode = AirConditioner.MODE_AUTO;
|
|
223
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} (Set) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
256
224
|
}
|
|
257
225
|
this.pushAirConditionerStatusChanges();
|
|
258
226
|
}
|
|
@@ -261,30 +229,18 @@ export class AirConditioner {
|
|
|
261
229
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
262
230
|
if ((this.CurrentTemperature || 24) < (this.LastTemperature || 30)) {
|
|
263
231
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
232
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} (Get) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
264
233
|
} else {
|
|
265
234
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
235
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} (Get) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
266
236
|
}
|
|
267
237
|
} else {
|
|
268
238
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
239
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} (Get) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
269
240
|
}
|
|
270
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
271
241
|
return this.CurrentHeaterCoolerState;
|
|
272
242
|
}
|
|
273
243
|
|
|
274
|
-
private HeatingThresholdTemperatureGet() {
|
|
275
|
-
this.CurrentTemperature = this.CurrentTemperature || 24;
|
|
276
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
|
|
277
|
-
return this.CurrentTemperature;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
private HeatingThresholdTemperatureSet(value: CharacteristicValue) {
|
|
281
|
-
this.pushAirConditionerStatusChanges();
|
|
282
|
-
this.LastTemperature = Number(this.CurrentTemperature);
|
|
283
|
-
this.CurrentTemperature = Number(value);
|
|
284
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature},`
|
|
285
|
-
+ ` LastTemperature: ${this.LastTemperature}`);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
244
|
/**
|
|
289
245
|
* Pushes the requested changes to the SwitchBot API
|
|
290
246
|
* deviceType commandType Command command parameter Description
|
|
@@ -386,7 +342,7 @@ export class AirConditioner {
|
|
|
386
342
|
this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,`
|
|
387
343
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
388
344
|
}
|
|
389
|
-
this.apiError();
|
|
345
|
+
this.apiError(e);
|
|
390
346
|
}
|
|
391
347
|
}
|
|
392
348
|
|
|
@@ -419,8 +375,14 @@ export class AirConditioner {
|
|
|
419
375
|
}
|
|
420
376
|
}
|
|
421
377
|
|
|
422
|
-
public apiError() {
|
|
423
|
-
|
|
378
|
+
public apiError(e: any) {
|
|
379
|
+
this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
380
|
+
this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, e);
|
|
381
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
|
|
382
|
+
this.service.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, e);
|
|
383
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, e);
|
|
384
|
+
this.service.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, e);
|
|
385
|
+
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
424
386
|
}
|
|
425
387
|
|
|
426
388
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { SwitchBotPlatform } from '../platform';
|
|
3
3
|
import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
|
|
4
|
-
import { CharacteristicValue,
|
|
4
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -248,7 +248,7 @@ export class AirPurifier {
|
|
|
248
248
|
this.errorLog(`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
249
249
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
250
250
|
}
|
|
251
|
-
this.apiError();
|
|
251
|
+
this.apiError(e);
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
|
|
@@ -281,8 +281,12 @@ export class AirPurifier {
|
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
public apiError() {
|
|
285
|
-
|
|
284
|
+
public apiError(e: any) {
|
|
285
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, e);
|
|
286
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentAirPurifierState, e);
|
|
287
|
+
this.service.updateCharacteristic(this.platform.Characteristic.TargetAirPurifierState, e);
|
|
288
|
+
this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
289
|
+
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
286
290
|
}
|
|
287
291
|
|
|
288
292
|
/**
|
package/src/irdevices/cameras.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { SwitchBotPlatform } from '../platform';
|
|
3
3
|
import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
|
|
4
|
-
import { CharacteristicValue,
|
|
4
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -140,7 +140,7 @@ export class Camera {
|
|
|
140
140
|
this.errorLog(`Camera: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
141
141
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
142
142
|
}
|
|
143
|
-
this.apiError();
|
|
143
|
+
this.apiError(e);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
|
|
@@ -173,8 +173,9 @@ export class Camera {
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
public apiError() {
|
|
177
|
-
|
|
176
|
+
public apiError(e: any) {
|
|
177
|
+
this.service.updateCharacteristic(this.platform.Characteristic.On, e);
|
|
178
|
+
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
178
179
|
}
|
|
179
180
|
|
|
180
181
|
/**
|
package/src/irdevices/fans.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { SwitchBotPlatform } from '../platform';
|
|
3
|
-
import { CharacteristicValue,
|
|
3
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
4
4
|
import { DeviceURL, irdevice, deviceStatusResponse, irDevicesConfig, payload } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -262,7 +262,7 @@ export class Fan {
|
|
|
262
262
|
this.errorLog(`Fan: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
263
263
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
264
264
|
}
|
|
265
|
-
this.apiError();
|
|
265
|
+
this.apiError(e);
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
268
|
|
|
@@ -295,8 +295,11 @@ export class Fan {
|
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
public apiError() {
|
|
299
|
-
|
|
298
|
+
public apiError(e: any) {
|
|
299
|
+
this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
300
|
+
this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, e);
|
|
301
|
+
this.service.updateCharacteristic(this.platform.Characteristic.SwingMode, e);
|
|
302
|
+
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
300
303
|
}
|
|
301
304
|
|
|
302
305
|
/**
|