@switchbot/homebridge-switchbot 1.7.1-beta.9 → 1.8.1-beta.2

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 (92) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/config.schema.json +3 -3
  3. package/dist/devices/bots.d.ts +15 -14
  4. package/dist/devices/bots.d.ts.map +1 -1
  5. package/dist/devices/bots.js +163 -154
  6. package/dist/devices/bots.js.map +1 -1
  7. package/dist/devices/colorbulb.d.ts +5 -4
  8. package/dist/devices/colorbulb.d.ts.map +1 -1
  9. package/dist/devices/colorbulb.js +70 -61
  10. package/dist/devices/colorbulb.js.map +1 -1
  11. package/dist/devices/contact.d.ts +8 -7
  12. package/dist/devices/contact.d.ts.map +1 -1
  13. package/dist/devices/contact.js +82 -74
  14. package/dist/devices/contact.js.map +1 -1
  15. package/dist/devices/curtains.d.ts +8 -7
  16. package/dist/devices/curtains.d.ts.map +1 -1
  17. package/dist/devices/curtains.js +104 -101
  18. package/dist/devices/curtains.js.map +1 -1
  19. package/dist/devices/humidifiers.d.ts +5 -4
  20. package/dist/devices/humidifiers.d.ts.map +1 -1
  21. package/dist/devices/humidifiers.js +74 -62
  22. package/dist/devices/humidifiers.js.map +1 -1
  23. package/dist/devices/meters.d.ts +4 -3
  24. package/dist/devices/meters.d.ts.map +1 -1
  25. package/dist/devices/meters.js +68 -56
  26. package/dist/devices/meters.js.map +1 -1
  27. package/dist/devices/motion.d.ts +6 -5
  28. package/dist/devices/motion.d.ts.map +1 -1
  29. package/dist/devices/motion.js +82 -70
  30. package/dist/devices/motion.js.map +1 -1
  31. package/dist/devices/plugs.d.ts +4 -3
  32. package/dist/devices/plugs.d.ts.map +1 -1
  33. package/dist/devices/plugs.js +64 -52
  34. package/dist/devices/plugs.js.map +1 -1
  35. package/dist/irdevices/airconditioners.d.ts +2 -1
  36. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  37. package/dist/irdevices/airconditioners.js +29 -22
  38. package/dist/irdevices/airconditioners.js.map +1 -1
  39. package/dist/irdevices/airpurifiers.d.ts +4 -3
  40. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  41. package/dist/irdevices/airpurifiers.js +33 -26
  42. package/dist/irdevices/airpurifiers.js.map +1 -1
  43. package/dist/irdevices/cameras.d.ts +2 -1
  44. package/dist/irdevices/cameras.d.ts.map +1 -1
  45. package/dist/irdevices/cameras.js +29 -22
  46. package/dist/irdevices/cameras.js.map +1 -1
  47. package/dist/irdevices/fans.d.ts +2 -1
  48. package/dist/irdevices/fans.d.ts.map +1 -1
  49. package/dist/irdevices/fans.js +29 -22
  50. package/dist/irdevices/fans.js.map +1 -1
  51. package/dist/irdevices/lights.d.ts +2 -1
  52. package/dist/irdevices/lights.d.ts.map +1 -1
  53. package/dist/irdevices/lights.js +29 -22
  54. package/dist/irdevices/lights.js.map +1 -1
  55. package/dist/irdevices/others.d.ts +3 -2
  56. package/dist/irdevices/others.d.ts.map +1 -1
  57. package/dist/irdevices/others.js +41 -34
  58. package/dist/irdevices/others.js.map +1 -1
  59. package/dist/irdevices/tvs.d.ts +2 -1
  60. package/dist/irdevices/tvs.d.ts.map +1 -1
  61. package/dist/irdevices/tvs.js +29 -22
  62. package/dist/irdevices/tvs.js.map +1 -1
  63. package/dist/irdevices/vacuumcleaners.d.ts +2 -1
  64. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  65. package/dist/irdevices/vacuumcleaners.js +29 -22
  66. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  67. package/dist/irdevices/waterheaters.d.ts +2 -1
  68. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  69. package/dist/irdevices/waterheaters.js +29 -22
  70. package/dist/irdevices/waterheaters.js.map +1 -1
  71. package/dist/settings.d.ts +7 -1
  72. package/dist/settings.d.ts.map +1 -1
  73. package/dist/settings.js.map +1 -1
  74. package/package.json +1 -1
  75. package/src/devices/bots.ts +170 -162
  76. package/src/devices/colorbulb.ts +69 -61
  77. package/src/devices/contact.ts +83 -75
  78. package/src/devices/curtains.ts +103 -100
  79. package/src/devices/humidifiers.ts +73 -60
  80. package/src/devices/meters.ts +67 -54
  81. package/src/devices/motion.ts +81 -68
  82. package/src/devices/plugs.ts +63 -50
  83. package/src/irdevices/airconditioners.ts +28 -20
  84. package/src/irdevices/airpurifiers.ts +32 -24
  85. package/src/irdevices/cameras.ts +28 -20
  86. package/src/irdevices/fans.ts +28 -20
  87. package/src/irdevices/lights.ts +28 -20
  88. package/src/irdevices/others.ts +40 -32
  89. package/src/irdevices/tvs.ts +28 -20
  90. package/src/irdevices/vacuumcleaners.ts +28 -20
  91. package/src/irdevices/waterheaters.ts +28 -20
  92. package/src/settings.ts +7 -1
@@ -56,16 +56,12 @@ export class Contact {
56
56
  public device: device & devicesConfig,
57
57
  ) {
58
58
  // default placeholders
59
- this.logs();
60
- this.scan();
61
- this.refreshRate();
59
+ this.logs(device);
60
+ this.scan(device);
61
+ this.refreshRate(device);
62
+ this.config(device);
62
63
  this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED;
63
64
 
64
- // Contact Config
65
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} Config: (ble: ${device.ble}, offline: ${device.offline},`
66
- + ` hide_lightsensor: ${device.contact?.hide_lightsensor}, hide_motionsensor: ${device.contact?.hide_motionsensor},`
67
- + ` set_minLux: ${this.device.contact?.set_minLux}, set_maxLux: ${this.device.contact?.set_maxLux})`);
68
-
69
65
  // this is subject we use to track when we need to POST changes to the SwitchBot API
70
66
  this.doContactUpdate = new Subject();
71
67
  this.contactUbpdateInProgress = false;
@@ -159,71 +155,6 @@ export class Contact {
159
155
  });
160
156
  }
161
157
 
162
- refreshRate() {
163
- if (this.device.refreshRate) {
164
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
165
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
166
- this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
167
- }
168
- } else if (this.platform.config.options!.refreshRate) {
169
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
170
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
171
- this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
172
- }
173
- }
174
- }
175
-
176
- scan() {
177
- if (this.device.scanDuration) {
178
- this.scanDuration = this.accessory.context.scanDuration = this.device.scanDuration;
179
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
180
- this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
181
- }
182
- } else {
183
- this.scanDuration = this.accessory.context.scanDuration = 1;
184
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
185
- this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
186
- }
187
- }
188
- }
189
-
190
- logs() {
191
- if (this.platform.debugMode) {
192
- this.deviceLogging = this.accessory.context.logging = 'debug';
193
- this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
194
- } else if (this.device.logging) {
195
- this.deviceLogging = this.accessory.context.logging = this.device.logging;
196
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
197
- this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
198
- }
199
- } else if (this.platform.config.options?.logging) {
200
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
201
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
202
- this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
203
- }
204
- } else {
205
- this.deviceLogging = this.accessory.context.logging = 'standard';
206
- }
207
- }
208
-
209
- private minLux(): number {
210
- if (this.device.contact?.set_minLux) {
211
- this.set_minLux = this.device.contact!.set_minLux!;
212
- } else {
213
- this.set_minLux = 1;
214
- }
215
- return this.set_minLux;
216
- }
217
-
218
- private maxLux(): number {
219
- if (this.device.contact?.set_maxLux) {
220
- this.set_maxLux = this.device.contact!.set_maxLux!;
221
- } else {
222
- this.set_maxLux = 6001;
223
- }
224
- return this.set_maxLux;
225
- }
226
-
227
158
  /**
228
159
  * Parse the device status from the SwitchBot api
229
160
  */
@@ -235,7 +166,7 @@ export class Contact {
235
166
  }
236
167
  }
237
168
 
238
- private async BLEparseStatus() {
169
+ async BLEparseStatus() {
239
170
  this.debugLog(`Contact Sensor: ${this.accessory.displayName} BLE parseStatus`);
240
171
  // Door State
241
172
  switch (this.doorState) {
@@ -283,7 +214,7 @@ export class Contact {
283
214
  this.debugLog(`Contact Sensor: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, StatusLowBattery: ${this.StatusLowBattery}`);
284
215
  }
285
216
 
286
- private async openAPIparseStatus() {
217
+ async openAPIparseStatus() {
287
218
  if (this.device.ble) {
288
219
  this.SwitchToOpenAPI = false;
289
220
  }
@@ -493,6 +424,83 @@ export class Contact {
493
424
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
494
425
  }
495
426
 
427
+ config(device: device & devicesConfig) {
428
+ const config: any = device.contact;
429
+ if (device.ble) {
430
+ config['ble'] = device.ble;
431
+ }
432
+ if (device.logging !== undefined) {
433
+ config['logging'] = device.logging;
434
+ }
435
+ if (device.refreshRate !== undefined) {
436
+ config['refreshRate'] = device.refreshRate;
437
+ }
438
+ if (device.scanDuration !== undefined) {
439
+ config['scanDuration'] = device.scanDuration;
440
+ }
441
+ if (config !== undefined) {
442
+ this.warnLog(`Contact Sensor: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
443
+ }
444
+ }
445
+
446
+ refreshRate(device: device & devicesConfig) {
447
+ if (device.refreshRate) {
448
+ this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
449
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
450
+ } else if (this.platform.config.options!.refreshRate) {
451
+ this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
452
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
453
+ }
454
+ }
455
+
456
+ scan(device: device & devicesConfig) {
457
+ if (device.scanDuration) {
458
+ this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
459
+ if (device.ble) {
460
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
461
+ }
462
+ } else {
463
+ this.scanDuration = this.accessory.context.scanDuration = 1;
464
+ if (this.device.ble) {
465
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
466
+ }
467
+ }
468
+ }
469
+
470
+ logs(device: device & devicesConfig) {
471
+ if (this.platform.debugMode) {
472
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
473
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
474
+ } else if (device.logging) {
475
+ this.deviceLogging = this.accessory.context.logging = device.logging;
476
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
477
+ } else if (this.platform.config.options?.logging) {
478
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
479
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
480
+ } else {
481
+ this.deviceLogging = this.accessory.context.logging = 'standard';
482
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
483
+ }
484
+ }
485
+
486
+ private minLux(): number {
487
+ if (this.device.contact?.set_minLux) {
488
+ this.set_minLux = this.device.contact!.set_minLux!;
489
+ } else {
490
+ this.set_minLux = 1;
491
+ }
492
+ return this.set_minLux;
493
+ }
494
+
495
+ private maxLux(): number {
496
+ if (this.device.contact?.set_maxLux) {
497
+ this.set_maxLux = this.device.contact!.set_maxLux!;
498
+ } else {
499
+ this.set_maxLux = 6001;
500
+ }
501
+ return this.set_maxLux;
502
+ }
503
+
496
504
  /**
497
505
  * Logging for Device
498
506
  */
@@ -43,7 +43,7 @@ export class Curtain {
43
43
 
44
44
  // Config
45
45
  set_minStep!: number;
46
- curtainRefreshRate!: number;
46
+ updateRate!: number;
47
47
  set_minLux!: number;
48
48
  set_maxLux!: number;
49
49
  scanDuration!: number;
@@ -60,20 +60,15 @@ export class Curtain {
60
60
  public device: device & devicesConfig,
61
61
  ) {
62
62
  // default placeholders
63
- this.logs();
64
- this.scan();
63
+ this.logs(device);
64
+ this.scan(device);
65
65
  this.setMinMax();
66
- this.refreshRate();
66
+ this.refreshRate(device);
67
+ this.config(device);
67
68
  this.CurrentPosition = 0;
68
69
  this.TargetPosition = 0;
69
70
  this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
70
71
 
71
- // Curtain Config
72
- this.debugLog(`Curtain: ${this.accessory.displayName} Config: (ble: ${device.ble}, disable_group: ${device.curtain?.disable_group},`
73
- + ` hide_lightsensor: ${device.curtain?.hide_lightsensor}, set_minLux: ${device.curtain?.set_minLux}, set_maxLux: `
74
- + `${device.curtain?.set_maxLux}, refreshRate: ${device.curtain?.refreshRate}, set_max: ${device.curtain?.set_max}, set_min: `
75
- + `${device.curtain?.set_min}, set_minStep: ${device.curtain?.set_minStep})`);
76
-
77
72
  // this is subject we use to track when we need to POST changes to the SwitchBot API
78
73
  this.doCurtainUpdate = new Subject();
79
74
  this.curtainUpdateInProgress = false;
@@ -112,7 +107,7 @@ export class Curtain {
112
107
  this.service
113
108
  .getCharacteristic(this.platform.Characteristic.CurrentPosition)
114
109
  .setProps({
115
- minStep: this.minStep(),
110
+ minStep: this.minStep(device),
116
111
  minValue: 0,
117
112
  maxValue: 100,
118
113
  validValueRanges: [0, 100],
@@ -124,7 +119,7 @@ export class Curtain {
124
119
  this.service
125
120
  .getCharacteristic(this.platform.Characteristic.TargetPosition)
126
121
  .setProps({
127
- minStep: this.minStep(),
122
+ minStep: this.minStep(device),
128
123
  validValueRanges: [0, 100],
129
124
  })
130
125
  .onSet(this.TargetPositionSet.bind(this));
@@ -175,7 +170,7 @@ export class Curtain {
175
170
  });
176
171
 
177
172
  // update slide progress
178
- interval(this.curtainRefreshRate * 1000)
173
+ interval(this.updateRate * 1000)
179
174
  .pipe(skipWhile(() => this.curtainUpdateInProgress))
180
175
  .subscribe(() => {
181
176
  if (this.PositionState === this.platform.Characteristic.PositionState.STOPPED) {
@@ -214,93 +209,6 @@ export class Curtain {
214
209
  });
215
210
  }
216
211
 
217
- refreshRate() {
218
- // refreshRate
219
- if (this.device.refreshRate) {
220
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
221
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
222
- this.warnLog(`Curtain: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
223
- }
224
- } else if (this.platform.config.options!.refreshRate) {
225
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
226
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
227
- this.warnLog(`Curtain: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
228
- }
229
- }
230
- // curtainRefreshRate
231
- if (this.device?.curtain?.refreshRate) {
232
- this.curtainRefreshRate = this.device?.curtain?.refreshRate;
233
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
234
- this.warnLog(`Curtain: ${this.accessory.displayName} Using Device Config Curtain refreshRate: ${this.deviceRefreshRate}`);
235
- }
236
- } else {
237
- this.curtainRefreshRate = 5;
238
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
239
- this.warnLog(`Curtain: ${this.accessory.displayName} Using Default Curtain Refresh Rate.`);
240
- }
241
- }
242
- }
243
-
244
- scan() {
245
- if (this.device.scanDuration) {
246
- this.scanDuration = this.accessory.context.scanDuration = this.device.scanDuration;
247
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
248
- this.warnLog(`Curtain: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
249
- }
250
- } else {
251
- this.scanDuration = this.accessory.context.scanDuration = 1;
252
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
253
- this.warnLog(`Curtain: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
254
- }
255
- }
256
- }
257
-
258
- logs() {
259
- if (this.platform.debugMode) {
260
- this.deviceLogging = this.accessory.context.logging = 'debug';
261
- this.warnLog(`Curtain: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
262
- } else if (this.device.logging) {
263
- this.deviceLogging = this.accessory.context.logging = this.device.logging;
264
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
265
- this.warnLog(`Curtain: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
266
- }
267
- } else if (this.platform.config.options?.logging) {
268
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
269
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
270
- this.warnLog(`Curtain: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
271
- }
272
- } else {
273
- this.deviceLogging = this.accessory.context.logging = 'standard';
274
- }
275
- }
276
-
277
- private minStep(): number {
278
- if (this.device.curtain?.set_minStep) {
279
- this.set_minStep = this.device.curtain?.set_minStep;
280
- } else {
281
- this.set_minStep = 1;
282
- }
283
- return this.set_minStep;
284
- }
285
-
286
- private minLux(): number {
287
- if (this.device.curtain?.set_minLux) {
288
- this.set_minLux = this.device.curtain?.set_minLux;
289
- } else {
290
- this.set_minLux = 1;
291
- }
292
- return this.set_minLux;
293
- }
294
-
295
- private maxLux(): number {
296
- if (this.device.curtain?.set_maxLux) {
297
- this.set_maxLux = this.device.curtain?.set_maxLux;
298
- } else {
299
- this.set_maxLux = 6001;
300
- }
301
- return this.set_maxLux;
302
- }
303
-
304
212
  /**
305
213
  * Parse the device status from the SwitchBot api
306
214
  */
@@ -809,6 +717,101 @@ export class Curtain {
809
717
  }
810
718
  }
811
719
 
720
+ config(device: device & devicesConfig) {
721
+ const config: any = device.curtain;
722
+ if (device.ble) {
723
+ config['ble'] = device.ble;
724
+ }
725
+ if (device.logging !== undefined) {
726
+ config['logging'] = device.logging;
727
+ }
728
+ if (device.refreshRate !== undefined) {
729
+ config['refreshRate'] = device.refreshRate;
730
+ }
731
+ if (device.scanDuration !== undefined) {
732
+ config['scanDuration'] = device.scanDuration;
733
+ }
734
+ if (config !== undefined) {
735
+ this.warnLog(`Curtain: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
736
+ }
737
+ }
738
+
739
+ refreshRate(device: device & devicesConfig) {
740
+ // refreshRate
741
+ if (device.refreshRate) {
742
+ this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
743
+ this.debugLog(`Curtain: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
744
+ } else if (this.platform.config.options!.refreshRate) {
745
+ this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
746
+ this.debugLog(`Curtain: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
747
+ }
748
+ // updateRate
749
+ if (device?.curtain?.updateRate) {
750
+ this.updateRate = device?.curtain?.updateRate;
751
+ this.debugLog(`Curtain: ${this.accessory.displayName} Using Device Config Curtain refreshRate: ${this.deviceRefreshRate}`);
752
+ } else {
753
+ this.updateRate = 5;
754
+ this.debugLog(`Curtain: ${this.accessory.displayName} Using Default Curtain Refresh Rate.`);
755
+ }
756
+ }
757
+
758
+ scan(device: device & devicesConfig) {
759
+ if (device.scanDuration) {
760
+ this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
761
+ if (device.ble) {
762
+ this.debugLog(`Curtain: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
763
+ }
764
+ } else {
765
+ this.scanDuration = this.accessory.context.scanDuration = 1;
766
+ if (this.device.ble) {
767
+ this.debugLog(`Curtain: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
768
+ }
769
+ }
770
+ }
771
+
772
+ logs(device: device & devicesConfig) {
773
+ if (this.platform.debugMode) {
774
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
775
+ this.debugLog(`Curtain: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
776
+ } else if (device.logging) {
777
+ this.deviceLogging = this.accessory.context.logging = device.logging;
778
+ this.debugLog(`Curtain: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
779
+ } else if (this.platform.config.options?.logging) {
780
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
781
+ this.debugLog(`Curtain: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
782
+ } else {
783
+ this.deviceLogging = this.accessory.context.logging = 'standard';
784
+ this.debugLog(`Curtain: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
785
+ }
786
+ }
787
+
788
+ private minStep(device: device & devicesConfig): number {
789
+ if (device.curtain?.set_minStep) {
790
+ this.set_minStep = device.curtain?.set_minStep;
791
+ } else {
792
+ this.set_minStep = 1;
793
+ }
794
+ return this.set_minStep;
795
+ }
796
+
797
+ private minLux(): number {
798
+ if (this.device.curtain?.set_minLux) {
799
+ this.set_minLux = this.device.curtain?.set_minLux;
800
+ } else {
801
+ this.set_minLux = 1;
802
+ }
803
+ return this.set_minLux;
804
+ }
805
+
806
+ private maxLux(): number {
807
+ if (this.device.curtain?.set_maxLux) {
808
+ this.set_maxLux = this.device.curtain?.set_maxLux;
809
+ } else {
810
+ this.set_maxLux = 6001;
811
+ }
812
+ return this.set_maxLux;
813
+ }
814
+
812
815
  /**
813
816
  * Logging for Device
814
817
  */
@@ -56,9 +56,10 @@ export class Humidifier {
56
56
  public device: device & devicesConfig,
57
57
  ) {
58
58
  // default placeholders
59
- this.logs();
60
- this.scan();
61
- this.refreshRate();
59
+ this.logs(device);
60
+ this.scan(device);
61
+ this.refreshRate(device);
62
+ this.config(device);
62
63
  this.CurrentRelativeHumidity = 0;
63
64
  this.TargetHumidifierDehumidifierState = this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
64
65
  this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
@@ -153,7 +154,7 @@ export class Humidifier {
153
154
  minStep: 0.1,
154
155
  })
155
156
  .onGet(() => {
156
- return Number.isNaN(this.CurrentTemperature);
157
+ return this.CurrentTemperature;
157
158
  });
158
159
  } else {
159
160
  this.debugLog(`Humidifier: ${accessory.displayName} Temperature Sensor Service Not Added`);
@@ -197,62 +198,6 @@ export class Humidifier {
197
198
  });
198
199
  }
199
200
 
200
- refreshRate() {
201
- if (this.device.refreshRate) {
202
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
203
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
204
- this.warnLog(`Humidifier: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
205
- }
206
- } else if (this.platform.config.options!.refreshRate) {
207
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
208
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
209
- this.warnLog(`Humidifier: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
210
- }
211
- }
212
- }
213
-
214
- scan() {
215
- if (this.device.scanDuration) {
216
- this.scanDuration = this.accessory.context.scanDuration = this.device.scanDuration;
217
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
218
- this.warnLog(`Humidifier: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
219
- }
220
- } else {
221
- this.scanDuration = this.accessory.context.scanDuration = 1;
222
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
223
- this.warnLog(`Humidifier: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
224
- }
225
- }
226
- }
227
-
228
- logs() {
229
- if (this.platform.debugMode) {
230
- this.deviceLogging = this.accessory.context.logging = 'debug';
231
- this.warnLog(`Humidifier: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
232
- } else if (this.device.logging) {
233
- this.deviceLogging = this.accessory.context.logging = this.device.logging;
234
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
235
- this.warnLog(`Humidifier: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
236
- }
237
- } else if (this.platform.config.options?.logging) {
238
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
239
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
240
- this.warnLog(`Humidifier: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
241
- }
242
- } else {
243
- this.deviceLogging = this.accessory.context.logging = 'standard';
244
- }
245
- }
246
-
247
- private minStep(): number | undefined {
248
- if (this.device.humidifier?.set_minStep) {
249
- this.set_minStep = this.device.humidifier?.set_minStep;
250
- } else {
251
- this.set_minStep = 1;
252
- }
253
- return this.set_minStep;
254
- }
255
-
256
201
  /**
257
202
  * Parse the device status from the SwitchBot api
258
203
  */
@@ -766,6 +711,74 @@ export class Humidifier {
766
711
  this.doHumidifierUpdate.next();
767
712
  }
768
713
 
714
+ config(device: device & devicesConfig) {
715
+ const config: any = device.humidifier;
716
+ if (device.ble !== undefined) {
717
+ config['ble'] = device.ble;
718
+ }
719
+ if (device.logging !== undefined) {
720
+ config['logging'] = device.logging;
721
+ }
722
+ if (device.refreshRate !== undefined) {
723
+ config['refreshRate'] = device.refreshRate;
724
+ }
725
+ if (device.scanDuration !== undefined) {
726
+ config['scanDuration'] = device.scanDuration;
727
+ }
728
+ if (config !== undefined) {
729
+ this.warnLog(`Humidifier: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
730
+ }
731
+ }
732
+
733
+ refreshRate(device: device & devicesConfig) {
734
+ if (device.refreshRate) {
735
+ this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
736
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
737
+ } else if (this.platform.config.options!.refreshRate) {
738
+ this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
739
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
740
+ }
741
+ }
742
+
743
+ scan(device: device & devicesConfig) {
744
+ if (device.scanDuration) {
745
+ this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
746
+ if (device.ble) {
747
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
748
+ }
749
+ } else {
750
+ this.scanDuration = this.accessory.context.scanDuration = 1;
751
+ if (this.device.ble) {
752
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
753
+ }
754
+ }
755
+ }
756
+
757
+ logs(device: device & devicesConfig) {
758
+ if (this.platform.debugMode) {
759
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
760
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
761
+ } else if (device.logging) {
762
+ this.deviceLogging = this.accessory.context.logging = device.logging;
763
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
764
+ } else if (this.platform.config.options?.logging) {
765
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
766
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
767
+ } else {
768
+ this.deviceLogging = this.accessory.context.logging = 'standard';
769
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
770
+ }
771
+ }
772
+
773
+ private minStep(): number | undefined {
774
+ if (this.device.humidifier?.set_minStep) {
775
+ this.set_minStep = this.device.humidifier?.set_minStep;
776
+ } else {
777
+ this.set_minStep = 1;
778
+ }
779
+ return this.set_minStep;
780
+ }
781
+
769
782
  /**
770
783
  * Logging for Device
771
784
  */