@switchbot/homebridge-switchbot 1.2.0 → 1.2.1-beta.3

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 (54) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/config.schema.json +39 -36
  3. package/dist/devices/bots.d.ts +1 -1
  4. package/dist/devices/bots.d.ts.map +1 -1
  5. package/dist/devices/bots.js +26 -21
  6. package/dist/devices/bots.js.map +1 -1
  7. package/dist/devices/colorbulb.d.ts.map +1 -1
  8. package/dist/devices/colorbulb.js +1 -0
  9. package/dist/devices/colorbulb.js.map +1 -1
  10. package/dist/devices/contact.d.ts.map +1 -1
  11. package/dist/devices/contact.js +1 -0
  12. package/dist/devices/contact.js.map +1 -1
  13. package/dist/devices/curtains.d.ts +5 -5
  14. package/dist/devices/curtains.d.ts.map +1 -1
  15. package/dist/devices/curtains.js +9 -3
  16. package/dist/devices/curtains.js.map +1 -1
  17. package/dist/devices/humidifiers.d.ts.map +1 -1
  18. package/dist/devices/humidifiers.js +3 -1
  19. package/dist/devices/humidifiers.js.map +1 -1
  20. package/dist/devices/meters.d.ts.map +1 -1
  21. package/dist/devices/meters.js +1 -0
  22. package/dist/devices/meters.js.map +1 -1
  23. package/dist/devices/motion.d.ts.map +1 -1
  24. package/dist/devices/motion.js +1 -0
  25. package/dist/devices/motion.js.map +1 -1
  26. package/dist/irdevices/airconditioners.js +2 -2
  27. package/dist/irdevices/airconditioners.js.map +1 -1
  28. package/dist/irdevices/airpurifiers.js +2 -2
  29. package/dist/irdevices/airpurifiers.js.map +1 -1
  30. package/dist/irdevices/cameras.js +2 -2
  31. package/dist/irdevices/cameras.js.map +1 -1
  32. package/dist/irdevices/fans.js +2 -2
  33. package/dist/irdevices/fans.js.map +1 -1
  34. package/dist/irdevices/lights.js +2 -2
  35. package/dist/irdevices/lights.js.map +1 -1
  36. package/dist/irdevices/others.js +2 -2
  37. package/dist/irdevices/others.js.map +1 -1
  38. package/dist/irdevices/waterheaters.js +2 -2
  39. package/dist/irdevices/waterheaters.js.map +1 -1
  40. package/package.json +66 -66
  41. package/src/devices/bots.ts +28 -22
  42. package/src/devices/colorbulb.ts +1 -0
  43. package/src/devices/contact.ts +1 -0
  44. package/src/devices/curtains.ts +16 -8
  45. package/src/devices/humidifiers.ts +3 -1
  46. package/src/devices/meters.ts +1 -0
  47. package/src/devices/motion.ts +1 -0
  48. package/src/irdevices/airconditioners.ts +2 -2
  49. package/src/irdevices/airpurifiers.ts +2 -2
  50. package/src/irdevices/cameras.ts +2 -2
  51. package/src/irdevices/fans.ts +2 -2
  52. package/src/irdevices/lights.ts +2 -2
  53. package/src/irdevices/others.ts +2 -2
  54. package/src/irdevices/waterheaters.ts +2 -2
@@ -21,13 +21,8 @@ export class Curtain {
21
21
 
22
22
  // OpenAPI Others
23
23
  deviceStatus!: deviceStatusResponse;
24
- setNewTarget!: boolean;
25
- setNewTargetTimer!: NodeJS.Timeout;
26
24
 
27
25
  // BLE Others
28
- set_minLux!: number;
29
- set_maxLux!: number;
30
- spaceBetweenLevels!: number;
31
26
  switchbot!: switchbot;
32
27
  serviceData!: serviceData;
33
28
  calibration: serviceData['calibration'];
@@ -35,9 +30,16 @@ export class Curtain {
35
30
  position: serviceData['position'];
36
31
  lightLevel: serviceData['lightLevel'];
37
32
 
33
+ // Target
34
+ setNewTarget!: boolean;
35
+ setNewTargetTimer!: NodeJS.Timeout;
36
+
38
37
  // Config
39
38
  set_minStep!: number;
40
39
  refreshRate!: number;
40
+ set_minLux!: number;
41
+ set_maxLux!: number;
42
+ spaceBetweenLevels!: number;
41
43
  private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
42
44
  private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
43
45
 
@@ -245,6 +247,7 @@ export class Curtain {
245
247
 
246
248
  private async BLEparseStatus() {
247
249
  this.platform.debug(`Curtain: ${this.accessory.displayName} BLE parseStatus`);
250
+ this.setMinMax();
248
251
  this.CurrentPosition = 100 - Number(this.position);
249
252
  this.platform.debug(`Curtain: ${this.accessory.displayName} CurrentPosition ${this.CurrentPosition}`);
250
253
  if (this.setNewTarget) {
@@ -340,6 +343,7 @@ export class Curtain {
340
343
  if (this.platform.config.credentials?.openToken) {
341
344
  this.platform.debug(`Curtain: ${this.accessory.displayName} OpenAPI parseStatus`);
342
345
  // CurrentPosition
346
+ this.setMinMax();
343
347
  this.CurrentPosition = 100 - this.deviceStatus.body.slidePosition!;
344
348
  this.platform.debug(`Curtain ${this.accessory.displayName} CurrentPosition: ${this.CurrentPosition}`);
345
349
  if (this.setNewTarget) {
@@ -433,6 +437,7 @@ export class Curtain {
433
437
  this.platform.log.warn(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
434
438
  await this.openAPIRefreshStatus();
435
439
  }
440
+ this.apiError(e);
436
441
  });
437
442
  }
438
443
 
@@ -490,6 +495,7 @@ export class Curtain {
490
495
  this.platform.log.warn(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
491
496
  await this.OpenAPIpushChanges();
492
497
  }
498
+ this.apiError(e);
493
499
  });
494
500
  }
495
501
 
@@ -524,6 +530,7 @@ export class Curtain {
524
530
  this.platform.log.error(`Curtain: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
525
531
  + ` Error: ${JSON.stringify(e)}`);
526
532
  }
533
+ this.apiError(e);
527
534
  }
528
535
  }
529
536
  }
@@ -626,17 +633,18 @@ export class Curtain {
626
633
  if (value > this.CurrentPosition) {
627
634
  this.PositionState = this.platform.Characteristic.PositionState.INCREASING;
628
635
  this.setNewTarget = true;
629
- //this.setMinMax();
636
+ this.platform.debug(`Curtain: ${this.accessory.displayName} value: ${value}, CurrentPosition: ${this.CurrentPosition}`);
630
637
  } else if (value < this.CurrentPosition) {
631
638
  this.PositionState = this.platform.Characteristic.PositionState.DECREASING;
632
639
  this.setNewTarget = true;
633
- //this.setMinMax();
640
+ this.platform.debug(`Curtain: ${this.accessory.displayName} value: ${value}, CurrentPosition: ${this.CurrentPosition}`);
634
641
  } else {
635
642
  this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
636
643
  this.setNewTarget = false;
637
- //this.setMinMax();
644
+ this.platform.debug(`Curtain: ${this.accessory.displayName} value: ${value}, CurrentPosition: ${this.CurrentPosition}`);
638
645
  }
639
646
  this.service.setCharacteristic(this.platform.Characteristic.PositionState, this.PositionState);
647
+ this.service.getCharacteristic(this.platform.Characteristic.PositionState).updateValue(this.PositionState);
640
648
 
641
649
  /**
642
650
  * If Curtain movement time is short, the moving flag from backend is always false.
@@ -340,6 +340,7 @@ export class Humidifier {
340
340
  this.platform.log.warn(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
341
341
  await this.openAPIRefreshStatus();
342
342
  }
343
+ this.apiError(e);
343
344
  });
344
345
  }
345
346
 
@@ -387,7 +388,7 @@ export class Humidifier {
387
388
  const switchbot = this.connectBLE();
388
389
  switchbot.discover({ model: 'e', quick: true, id: this.device.bleMac }).then((device_list) => {
389
390
  this.platform.log.info(`${this.accessory.displayName} Target Position: ${this.Active}`);
390
- return device_list[0].runToPos(100 - Number(this.Active));
391
+ return device_list[0].percentage(this.RelativeHumidityHumidifierThreshold);
391
392
  }).then(() => {
392
393
  this.platform.device(`Humidifier: ${this.accessory.displayName} Done.`);
393
394
  }).catch(async (e: any) => {
@@ -404,6 +405,7 @@ export class Humidifier {
404
405
  this.platform.log.warn(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
405
406
  await this.OpenAPIpushChanges();
406
407
  }
408
+ this.apiError(e);
407
409
  });
408
410
  }
409
411
 
@@ -291,6 +291,7 @@ export class Meter {
291
291
  this.platform.log.warn(`Meter: ${this.accessory.displayName} Using OpenAPI Connection`);
292
292
  await this.openAPIRefreshStatus();
293
293
  }
294
+ this.apiError(e);
294
295
  });
295
296
  }
296
297
 
@@ -210,6 +210,7 @@ export class Motion {
210
210
  this.platform.log.warn(`Motion Sensor: ${this.accessory.displayName} Using OpenAPI Connection`);
211
211
  await this.openAPIRefreshStatus();
212
212
  }
213
+ this.apiError(e);
213
214
  });
214
215
  }
215
216
 
@@ -373,8 +373,8 @@ export class AirConditioner {
373
373
  this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} Hub Device is offline.`);
374
374
  break;
375
375
  case 190:
376
- this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
377
- + ` Or command: ${JSON.stringify(push.data)} format is invalid`);
376
+ this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} Device internal error due to device states not synchronized`
377
+ + ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`);
378
378
  break;
379
379
  case 100:
380
380
  this.platform.debug(`Air Conditioner: ${this.accessory.displayName} Command successfully sent.`);
@@ -242,8 +242,8 @@ export class AirPurifier {
242
242
  this.platform.log.error(`Air Purifier: ${this.accessory.displayName} Hub Device is offline.`);
243
243
  break;
244
244
  case 190:
245
- this.platform.log.error(`Air Purifier: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
246
- + ` Or command: ${JSON.stringify(push.data)} format is invalid`);
245
+ this.platform.log.error(`Air Purifier: ${this.accessory.displayName} Device internal error due to device states not synchronized`
246
+ + ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`);
247
247
  break;
248
248
  case 100:
249
249
  this.platform.debug(`Air Purifier: ${this.accessory.displayName} Command successfully sent.`);
@@ -142,8 +142,8 @@ export class Camera {
142
142
  this.platform.log.error(`Camera: ${this.accessory.displayName} Hub Device is offline.`);
143
143
  break;
144
144
  case 190:
145
- this.platform.log.error(`Camera: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
146
- + ` Or command: ${JSON.stringify(push.data)} format is invalid`);
145
+ this.platform.log.error(`Camera: ${this.accessory.displayName} Device internal error due to device states not synchronized`
146
+ + ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`);
147
147
  break;
148
148
  case 100:
149
149
  this.platform.debug(`Camera: ${this.accessory.displayName} Command successfully sent.`);
@@ -264,8 +264,8 @@ export class Fan {
264
264
  this.platform.log.error(`Fan: ${this.accessory.displayName} Hub Device is offline.`);
265
265
  break;
266
266
  case 190:
267
- this.platform.log.error(`Fan: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
268
- + ` Or command: ${JSON.stringify(push.data)} format is invalid`);
267
+ this.platform.log.error(`Fan: ${this.accessory.displayName} Device internal error due to device states not synchronized`
268
+ + ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`);
269
269
  break;
270
270
  case 100:
271
271
  this.platform.debug(`Fan: ${this.accessory.displayName} Command successfully sent.`);
@@ -176,8 +176,8 @@ export class Light {
176
176
  this.platform.log.error(`Light: ${this.accessory.displayName} Hub Device is offline.`);
177
177
  break;
178
178
  case 190:
179
- this.platform.log.error(`Light: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
180
- + ` Or command: ${JSON.stringify(push.data)} format is invalid`);
179
+ this.platform.log.error(`Light: ${this.accessory.displayName} Device internal error due to device states not synchronized`
180
+ + ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`);
181
181
  break;
182
182
  case 100:
183
183
  this.platform.debug(`Light: ${this.accessory.displayName} Command successfully sent.`);
@@ -163,8 +163,8 @@ export class Others {
163
163
  this.platform.log.error(`Other: ${this.accessory.displayName} Hub Device is offline.`);
164
164
  break;
165
165
  case 190:
166
- this.platform.log.error(`Other: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
167
- + ` Or command: ${JSON.stringify(push.data)} format is invalid`);
166
+ this.platform.log.error(`Other: ${this.accessory.displayName} Device internal error due to device states not synchronized`
167
+ + ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`);
168
168
  break;
169
169
  case 100:
170
170
  this.platform.debug(`Other: ${this.accessory.displayName} Command successfully sent.`);
@@ -156,8 +156,8 @@ export class WaterHeater {
156
156
  this.platform.log.error(`Water Heater: ${this.accessory.displayName} Hub Device is offline.`);
157
157
  break;
158
158
  case 190:
159
- this.platform.log.error(`Water Heater: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
160
- + ` Or command: ${JSON.stringify(push.data)} format is invalid`);
159
+ this.platform.log.error(`Water Heater: ${this.accessory.displayName} Device internal error due to device states not synchronized`
160
+ + ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`);
161
161
  break;
162
162
  case 100:
163
163
  this.platform.debug(`Water Heater: ${this.accessory.displayName} Command successfully sent.`);