@switchbot/homebridge-switchbot 2.8.0 → 2.8.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.
Files changed (112) hide show
  1. package/.github/npm-version-script.js +81 -0
  2. package/dist/device/blindtilt.d.ts +21 -23
  3. package/dist/device/blindtilt.d.ts.map +1 -1
  4. package/dist/device/blindtilt.js +71 -73
  5. package/dist/device/blindtilt.js.map +1 -1
  6. package/dist/device/bot.d.ts +11 -15
  7. package/dist/device/bot.d.ts.map +1 -1
  8. package/dist/device/bot.js +38 -34
  9. package/dist/device/bot.js.map +1 -1
  10. package/dist/device/ceilinglight.d.ts +10 -14
  11. package/dist/device/ceilinglight.d.ts.map +1 -1
  12. package/dist/device/ceilinglight.js +33 -23
  13. package/dist/device/ceilinglight.js.map +1 -1
  14. package/dist/device/colorbulb.d.ts +16 -24
  15. package/dist/device/colorbulb.d.ts.map +1 -1
  16. package/dist/device/colorbulb.js +49 -43
  17. package/dist/device/colorbulb.js.map +1 -1
  18. package/dist/device/contact.d.ts +16 -24
  19. package/dist/device/contact.d.ts.map +1 -1
  20. package/dist/device/contact.js +49 -51
  21. package/dist/device/contact.js.map +1 -1
  22. package/dist/device/curtain.d.ts +21 -26
  23. package/dist/device/curtain.d.ts.map +1 -1
  24. package/dist/device/curtain.js +49 -47
  25. package/dist/device/curtain.js.map +1 -1
  26. package/dist/device/hub.d.ts +9 -8
  27. package/dist/device/hub.d.ts.map +1 -1
  28. package/dist/device/hub.js +42 -30
  29. package/dist/device/hub.js.map +1 -1
  30. package/dist/device/humidifier.d.ts +8 -10
  31. package/dist/device/humidifier.d.ts.map +1 -1
  32. package/dist/device/humidifier.js +27 -17
  33. package/dist/device/humidifier.js.map +1 -1
  34. package/dist/device/iosensor.d.ts +16 -21
  35. package/dist/device/iosensor.d.ts.map +1 -1
  36. package/dist/device/iosensor.js +35 -26
  37. package/dist/device/iosensor.js.map +1 -1
  38. package/dist/device/lightstrip.d.ts +8 -13
  39. package/dist/device/lightstrip.d.ts.map +1 -1
  40. package/dist/device/lightstrip.js +28 -25
  41. package/dist/device/lightstrip.js.map +1 -1
  42. package/dist/device/lock.d.ts +15 -21
  43. package/dist/device/lock.d.ts.map +1 -1
  44. package/dist/device/lock.js +75 -26
  45. package/dist/device/lock.js.map +1 -1
  46. package/dist/device/meter.d.ts +16 -21
  47. package/dist/device/meter.d.ts.map +1 -1
  48. package/dist/device/meter.js +40 -37
  49. package/dist/device/meter.js.map +1 -1
  50. package/dist/device/meterplus.d.ts +16 -21
  51. package/dist/device/meterplus.d.ts.map +1 -1
  52. package/dist/device/meterplus.js +40 -37
  53. package/dist/device/meterplus.js.map +1 -1
  54. package/dist/device/motion.d.ts +12 -21
  55. package/dist/device/motion.d.ts.map +1 -1
  56. package/dist/device/motion.js +44 -46
  57. package/dist/device/motion.js.map +1 -1
  58. package/dist/device/plug.d.ts +5 -15
  59. package/dist/device/plug.d.ts.map +1 -1
  60. package/dist/device/plug.js +22 -19
  61. package/dist/device/plug.js.map +1 -1
  62. package/dist/device/robotvacuumcleaner.d.ts +9 -13
  63. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  64. package/dist/device/robotvacuumcleaner.js +30 -28
  65. package/dist/device/robotvacuumcleaner.js.map +1 -1
  66. package/dist/irdevice/airconditioner.d.ts +4 -4
  67. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  68. package/dist/irdevice/camera.d.ts +1 -1
  69. package/dist/irdevice/camera.d.ts.map +1 -1
  70. package/dist/irdevice/fan.d.ts +3 -4
  71. package/dist/irdevice/fan.d.ts.map +1 -1
  72. package/dist/irdevice/fan.js.map +1 -1
  73. package/dist/irdevice/light.d.ts +1 -1
  74. package/dist/irdevice/light.d.ts.map +1 -1
  75. package/dist/irdevice/other.d.ts +2 -2
  76. package/dist/irdevice/other.d.ts.map +1 -1
  77. package/dist/irdevice/tv.d.ts +1 -2
  78. package/dist/irdevice/tv.d.ts.map +1 -1
  79. package/dist/irdevice/tv.js.map +1 -1
  80. package/dist/irdevice/vacuumcleaner.d.ts +1 -1
  81. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  82. package/dist/irdevice/waterheater.d.ts +1 -1
  83. package/dist/irdevice/waterheater.d.ts.map +1 -1
  84. package/dist/settings.d.ts +3 -1
  85. package/dist/settings.d.ts.map +1 -1
  86. package/dist/settings.js.map +1 -1
  87. package/package.json +5 -5
  88. package/src/device/blindtilt.ts +96 -95
  89. package/src/device/bot.ts +54 -54
  90. package/src/device/ceilinglight.ts +46 -39
  91. package/src/device/colorbulb.ts +68 -69
  92. package/src/device/contact.ts +69 -77
  93. package/src/device/curtain.ts +75 -74
  94. package/src/device/hub.ts +53 -38
  95. package/src/device/humidifier.ts +33 -26
  96. package/src/device/iosensor.ts +53 -48
  97. package/src/device/lightstrip.ts +39 -40
  98. package/src/device/lock.ts +94 -49
  99. package/src/device/meter.ts +59 -59
  100. package/src/device/meterplus.ts +59 -60
  101. package/src/device/motion.ts +61 -65
  102. package/src/device/plug.ts +27 -35
  103. package/src/device/robotvacuumcleaner.ts +43 -43
  104. package/src/irdevice/airconditioner.ts +4 -4
  105. package/src/irdevice/camera.ts +1 -1
  106. package/src/irdevice/fan.ts +3 -6
  107. package/src/irdevice/light.ts +1 -1
  108. package/src/irdevice/other.ts +2 -2
  109. package/src/irdevice/tv.ts +1 -4
  110. package/src/irdevice/vacuumcleaner.ts +1 -1
  111. package/src/irdevice/waterheater.ts +1 -1
  112. package/src/settings.ts +5 -1
@@ -6,31 +6,29 @@ import { interval, Subject } from 'rxjs';
6
6
  import { SwitchBotPlatform } from '../platform';
7
7
  import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
8
8
  import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
9
- import { device, devicesConfig, deviceStatus, ad, serviceData, switchbot, Devices } from '../settings';
9
+ import { device, devicesConfig, deviceStatus, ad, serviceData, Devices } from '../settings';
10
10
 
11
11
  export class RobotVacuumCleaner {
12
12
  // Services
13
+ batteryService: Service;
13
14
  robotVacuumCleanerService: Service;
14
- batteryService?: Service;
15
15
 
16
16
  // Characteristic Values
17
17
  On!: CharacteristicValue;
18
18
  Brightness!: CharacteristicValue;
19
- BatteryLevel?: CharacteristicValue;
20
- StatusLowBattery?: CharacteristicValue;
19
+ BatteryLevel!: CharacteristicValue;
20
+ StatusLowBattery!: CharacteristicValue;
21
21
 
22
- // OpenAPI Others
23
- Version: deviceStatus['version'];
24
- Battery: deviceStatus['battery'];
25
- power: deviceStatus['power'];
26
- deviceStatus!: any; //deviceStatusResponse;
22
+ // OpenAPI Status
23
+ OpenAPI_On: deviceStatus['power'];
24
+ OpenAPI_BatteryLevel: deviceStatus['battery'];
25
+ OpenAPI_FirmwareRevision: deviceStatus['version'];
26
+
27
+ // BLE Status
28
+ BLE_On: serviceData['state'];
27
29
 
28
30
  // BLE Others
29
- connected?: boolean;
30
- switchbot!: switchbot;
31
- address!: ad['address'];
32
- serviceData!: serviceData;
33
- state: serviceData['state'];
31
+ BLE_IsConnected?: boolean;
34
32
 
35
33
  // Config
36
34
  scanDuration!: number;
@@ -111,18 +109,12 @@ export class RobotVacuumCleaner {
111
109
  .onSet(this.BrightnessSet.bind(this));
112
110
 
113
111
  // Battery Service
114
- if (!this.batteryService) {
115
- this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Battery Service`);
116
- (this.batteryService = this.accessory.getService(this.platform.Service.Battery) || this.accessory.addService(this.platform.Service.Battery)),
117
- `${accessory.displayName} Battery`;
118
-
119
- this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
120
- if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
121
- this.batteryService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
122
- }
123
- this.batteryService.setCharacteristic(this.platform.Characteristic.ChargingState, this.platform.Characteristic.ChargingState.NOT_CHARGEABLE);
124
- } else {
125
- this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Battery Service Not Added`);
112
+ (this.batteryService = this.accessory.getService(this.platform.Service.Battery) || accessory.addService(this.platform.Service.Battery)),
113
+ `${accessory.displayName} Battery`;
114
+
115
+ this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
116
+ if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
117
+ this.batteryService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
126
118
  }
127
119
 
128
120
  // Update Homekit
@@ -184,7 +176,7 @@ export class RobotVacuumCleaner {
184
176
  async BLEparseStatus(): Promise<void> {
185
177
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLEparseStatus`);
186
178
  // State
187
- switch (this.state) {
179
+ switch (this.BLE_On) {
188
180
  case 'on':
189
181
  this.On = true;
190
182
  break;
@@ -196,7 +188,7 @@ export class RobotVacuumCleaner {
196
188
 
197
189
  async openAPIparseStatus() {
198
190
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIparseStatus`);
199
- switch (this.power) {
191
+ switch (this.OpenAPI_On) {
200
192
  case 'on':
201
193
  this.On = true;
202
194
  break;
@@ -206,7 +198,7 @@ export class RobotVacuumCleaner {
206
198
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
207
199
 
208
200
  // Battery
209
- this.BatteryLevel = Number(this.Battery);
201
+ this.BatteryLevel = Number(this.OpenAPI_BatteryLevel);
210
202
  if (this.BatteryLevel < 15) {
211
203
  this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
212
204
  } else {
@@ -253,14 +245,12 @@ export class RobotVacuumCleaner {
253
245
  })
254
246
  .then(async () => {
255
247
  // Set an event hander
256
- switchbot.onadvertisement = async (ad: any) => {
257
- this.address = ad.address;
248
+ switchbot.onadvertisement = async (ad: ad) => {
258
249
  this.debugLog(
259
250
  `${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
260
- ` BLE Address Found: ${this.address}`,
251
+ ` BLE Address Found: ${ad.address}`,
261
252
  );
262
- this.serviceData = ad.serviceData;
263
- this.state = ad.serviceData.state;
253
+ this.BLE_On = ad.serviceData.state;
264
254
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
265
255
  this.debugLog(
266
256
  `${this.device.deviceType}: ${this.accessory.displayName} state: ${ad.serviceData.state}, ` +
@@ -268,13 +258,13 @@ export class RobotVacuumCleaner {
268
258
  `wifiRssi: ${ad.serviceData.wifiRssi}, overload: ${ad.serviceData.overload}, currentPower: ${ad.serviceData.currentPower}`,
269
259
  );
270
260
 
271
- if (this.serviceData) {
272
- this.connected = true;
273
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
261
+ if (ad.serviceData) {
262
+ this.BLE_IsConnected = true;
263
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.BLE_IsConnected}`);
274
264
  await this.stopScanning(switchbot);
275
265
  } else {
276
- this.connected = false;
277
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
266
+ this.BLE_IsConnected = false;
267
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.BLE_IsConnected}`);
278
268
  }
279
269
  };
280
270
  // Wait
@@ -308,9 +298,9 @@ export class RobotVacuumCleaner {
308
298
  this.statusCode(statusCode);
309
299
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
310
300
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
311
- this.power = deviceStatus.body.power;
312
- this.Battery = deviceStatus.body.battery;
313
- this.Version = deviceStatus.body.version;
301
+ this.OpenAPI_On = deviceStatus.body.power;
302
+ this.OpenAPI_BatteryLevel = deviceStatus.body.battery;
303
+ this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
314
304
  this.openAPIparseStatus();
315
305
  this.updateHomeKitCharacteristics();
316
306
  } catch (e: any) {
@@ -568,11 +558,21 @@ export class RobotVacuumCleaner {
568
558
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
569
559
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
570
560
  }
561
+ // FirmwareRevision
562
+ if (this.OpenAPI_FirmwareRevision === undefined) {
563
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
564
+ } else {
565
+ this.accessory.context.OpenAPI_FirmwareRevision = this.OpenAPI_FirmwareRevision;
566
+ this.accessory.getService(this.platform.Service.AccessoryInformation)!
567
+ .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
568
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
569
+ + `updateCharacteristic CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
570
+ }
571
571
  }
572
572
 
573
573
  async stopScanning(switchbot: any) {
574
574
  await switchbot.stopScan();
575
- if (this.connected) {
575
+ if (this.BLE_IsConnected) {
576
576
  await this.BLEparseStatus();
577
577
  await this.updateHomeKitCharacteristics();
578
578
  } else {
@@ -16,10 +16,10 @@ export class AirConditioner {
16
16
  Active!: CharacteristicValue;
17
17
  RotationSpeed!: CharacteristicValue;
18
18
  CurrentTemperature!: CharacteristicValue;
19
+ ThresholdTemperature!: CharacteristicValue;
19
20
  CurrentRelativeHumidity?: CharacteristicValue;
20
21
  TargetHeaterCoolerState!: CharacteristicValue;
21
22
  CurrentHeaterCoolerState!: CharacteristicValue;
22
- ThresholdTemperature!: CharacteristicValue;
23
23
 
24
24
  // Others
25
25
  state!: string;
@@ -33,12 +33,12 @@ export class AirConditioner {
33
33
  static MODE_HEAT: number;
34
34
 
35
35
  // Config
36
- disablePushOn?: boolean;
37
- disablePushOff?: boolean;
38
- disablePushDetail?: boolean;
39
36
  deviceLogging!: string;
40
37
  hide_automode?: boolean;
38
+ disablePushOn?: boolean;
39
+ disablePushOff?: boolean;
41
40
  meter?: PlatformAccessory;
41
+ disablePushDetail?: boolean;
42
42
 
43
43
  private readonly valid12 = [1, 2];
44
44
  private readonly valid012 = [0, 1, 2];
@@ -16,9 +16,9 @@ export class Camera {
16
16
  On!: CharacteristicValue;
17
17
 
18
18
  // Config
19
+ deviceLogging!: string;
19
20
  disablePushOn?: boolean;
20
21
  disablePushOff?: boolean;
21
- deviceLogging!: string;
22
22
 
23
23
  constructor(
24
24
  private readonly platform: SwitchBotPlatform,
@@ -14,21 +14,18 @@ export class Fan {
14
14
 
15
15
  // Characteristic Values
16
16
  Active!: CharacteristicValue;
17
- ActiveIdentifier!: CharacteristicValue;
18
- RotationSpeed!: CharacteristicValue;
19
17
  SwingMode!: CharacteristicValue;
18
+ RotationSpeed!: CharacteristicValue;
19
+ ActiveIdentifier!: CharacteristicValue;
20
20
  RotationDirection!: CharacteristicValue;
21
21
 
22
- // Others
23
- deviceStatus!: any;
24
-
25
22
  // Config
26
23
  minStep?: number;
27
24
  minValue?: number;
28
25
  maxValue?: number;
26
+ deviceLogging!: string;
29
27
  disablePushOn?: boolean;
30
28
  disablePushOff?: boolean;
31
- deviceLogging!: string;
32
29
 
33
30
  constructor(
34
31
  private readonly platform: SwitchBotPlatform,
@@ -16,9 +16,9 @@ export class Light {
16
16
  On!: CharacteristicValue;
17
17
 
18
18
  // Config
19
+ deviceLogging!: string;
19
20
  disablePushOn?: boolean;
20
21
  disablePushOff?: boolean;
21
- deviceLogging!: string;
22
22
 
23
23
  constructor(
24
24
  private readonly platform: SwitchBotPlatform,
@@ -16,10 +16,10 @@ export class Others {
16
16
  Active!: CharacteristicValue;
17
17
 
18
18
  // Config
19
- disablePushOn?: boolean;
20
- disablePushOff?: boolean;
21
19
  deviceLogging!: string;
20
+ disablePushOn?: boolean;
22
21
  otherDeviceType?: string;
22
+ disablePushOff?: boolean;
23
23
 
24
24
  constructor(
25
25
  private readonly platform: SwitchBotPlatform,
@@ -17,14 +17,11 @@ export class TV {
17
17
  Active!: CharacteristicValue;
18
18
  ActiveIdentifier!: CharacteristicValue;
19
19
 
20
- // Others
21
- deviceStatus!: any;
22
-
23
20
  // Config
21
+ deviceLogging!: string;
24
22
  disablePushOn?: boolean;
25
23
  disablePushOff?: boolean;
26
24
  disablePushDetail?: boolean;
27
- deviceLogging!: string;
28
25
 
29
26
  constructor(
30
27
  private readonly platform: SwitchBotPlatform,
@@ -16,9 +16,9 @@ export class VacuumCleaner {
16
16
  On!: CharacteristicValue;
17
17
 
18
18
  // Config
19
+ deviceLogging!: string;
19
20
  disablePushOn?: boolean;
20
21
  disablePushOff?: boolean;
21
- deviceLogging!: string;
22
22
 
23
23
  constructor(
24
24
  private readonly platform: SwitchBotPlatform,
@@ -16,9 +16,9 @@ export class WaterHeater {
16
16
  Active!: CharacteristicValue;
17
17
 
18
18
  // Config
19
+ deviceLogging!: string;
19
20
  disablePushOn?: boolean;
20
21
  disablePushOff?: boolean;
21
- deviceLogging!: string;
22
22
 
23
23
  constructor(
24
24
  private readonly platform: SwitchBotPlatform,
package/src/settings.ts CHANGED
@@ -312,6 +312,10 @@ export type serviceData = {
312
312
  mode?: boolean;
313
313
  //Bot/ColorBulb State
314
314
  state?: string | boolean;
315
+ //Lock door open
316
+ door_open?: string;
317
+ //Lock Status
318
+ status?: string;
315
319
  //ColorBulb Power
316
320
  power?: boolean;
317
321
  //ColorBulb R
@@ -342,7 +346,7 @@ export type serviceData = {
342
346
  //Contact ((lightLevel == 0) ? 'dark' : 'bright')
343
347
  //Curtain (light sensor level (1-10))
344
348
  //Light Level
345
- lightLevel?: number | string;
349
+ lightLevel?: number | string | boolean;
346
350
  //Contact DoorState
347
351
  doorState?: number | string;
348
352
  //Is Curtain Calibrated