@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
@@ -55,9 +55,10 @@ export class Meter {
55
55
  public device: device & devicesConfig,
56
56
  ) {
57
57
  // default placeholders
58
- this.logs();
59
- this.scan();
60
- this.refreshRate();
58
+ this.logs(device);
59
+ this.scan(device);
60
+ this.refreshRate(device);
61
+ this.config(device);
61
62
  if (this.CurrentRelativeHumidity === undefined) {
62
63
  this.CurrentRelativeHumidity = 0;
63
64
  } else {
@@ -173,53 +174,6 @@ export class Meter {
173
174
  });
174
175
  }
175
176
 
176
- refreshRate() {
177
- if (this.device.refreshRate) {
178
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
179
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
180
- this.warnLog(`Meter: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
181
- }
182
- } else if (this.platform.config.options!.refreshRate) {
183
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
184
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
185
- this.warnLog(`Meter: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
186
- }
187
- }
188
- }
189
-
190
- scan() {
191
- if (this.device.scanDuration) {
192
- this.scanDuration = this.accessory.context.scanDuration = this.device.scanDuration;
193
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
194
- this.warnLog(`Meter: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
195
- }
196
- } else {
197
- this.scanDuration = this.accessory.context.scanDuration = 1;
198
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
199
- this.warnLog(`Meter: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
200
- }
201
- }
202
- }
203
-
204
- logs() {
205
- if (this.platform.debugMode) {
206
- this.deviceLogging = this.accessory.context.logging = 'debug';
207
- this.warnLog(`Meter: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
208
- } else if (this.device.logging) {
209
- this.deviceLogging = this.accessory.context.logging = this.device.logging;
210
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
211
- this.warnLog(`Meter: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
212
- }
213
- } else if (this.platform.config.options?.logging) {
214
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
215
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
216
- this.warnLog(`Meter: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
217
- }
218
- } else {
219
- this.deviceLogging = this.accessory.context.logging = 'standard';
220
- }
221
- }
222
-
223
177
  /**
224
178
  * Parse the device status from the SwitchBot api
225
179
  */
@@ -408,16 +362,16 @@ export class Meter {
408
362
  }
409
363
  if (this.device.ble) {
410
364
  if (this.BatteryLevel === undefined) {
411
- this.debugLog(`Bot: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
365
+ this.debugLog(`Meter: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
412
366
  } else {
413
367
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
414
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
368
+ this.debugLog(`Meter: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
415
369
  }
416
370
  if (this.StatusLowBattery === undefined) {
417
- this.debugLog(`Bot: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
371
+ this.debugLog(`Meter: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
418
372
  } else {
419
373
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
420
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
374
+ this.debugLog(`Meter: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
421
375
  }
422
376
  }
423
377
  }
@@ -436,6 +390,65 @@ export class Meter {
436
390
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
437
391
  }
438
392
 
393
+ config(device: device & devicesConfig) {
394
+ const config: any = device.meter;
395
+ if (device.ble !== undefined) {
396
+ config['ble'] = device.ble;
397
+ }
398
+ if (device.logging !== undefined) {
399
+ config['logging'] = device.logging;
400
+ }
401
+ if (device.refreshRate !== undefined) {
402
+ config['refreshRate'] = device.refreshRate;
403
+ }
404
+ if (device.scanDuration !== undefined) {
405
+ config['scanDuration'] = device.scanDuration;
406
+ }
407
+ if (config !== undefined) {
408
+ this.warnLog(`Meter: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
409
+ }
410
+ }
411
+
412
+ refreshRate(device: device & devicesConfig) {
413
+ if (device.refreshRate) {
414
+ this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
415
+ this.debugLog(`Meter: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
416
+ } else if (this.platform.config.options!.refreshRate) {
417
+ this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
418
+ this.debugLog(`Meter: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
419
+ }
420
+ }
421
+
422
+ scan(device: device & devicesConfig) {
423
+ if (device.scanDuration) {
424
+ this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
425
+ if (device.ble) {
426
+ this.debugLog(`Meter: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
427
+ }
428
+ } else {
429
+ this.scanDuration = this.accessory.context.scanDuration = 1;
430
+ if (this.device.ble) {
431
+ this.debugLog(`Meter: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
432
+ }
433
+ }
434
+ }
435
+
436
+ logs(device: device & devicesConfig) {
437
+ if (this.platform.debugMode) {
438
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
439
+ this.debugLog(`Meter: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
440
+ } else if (device.logging) {
441
+ this.deviceLogging = this.accessory.context.logging = device.logging;
442
+ this.debugLog(`Meter: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
443
+ } else if (this.platform.config.options?.logging) {
444
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
445
+ this.debugLog(`Meter: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
446
+ } else {
447
+ this.deviceLogging = this.accessory.context.logging = 'standard';
448
+ this.debugLog(`Meter: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
449
+ }
450
+ }
451
+
439
452
  /**
440
453
  * Logging for Device
441
454
  */
@@ -52,9 +52,10 @@ export class Motion {
52
52
  public device: device & devicesConfig,
53
53
  ) {
54
54
  // default placeholders
55
- this.logs();
56
- this.scan();
57
- this.refreshRate();
55
+ this.logs(device);
56
+ this.scan(device);
57
+ this.refreshRate(device);
58
+ this.config(device);
58
59
  this.MotionDetected = false;
59
60
 
60
61
  // Motion Config
@@ -138,71 +139,6 @@ export class Motion {
138
139
  });
139
140
  }
140
141
 
141
- refreshRate() {
142
- if (this.device.refreshRate) {
143
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
144
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
145
- this.warnLog(`Motion Sensor: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
146
- }
147
- } else if (this.platform.config.options!.refreshRate) {
148
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
149
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
150
- this.warnLog(`Motion Sensor: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
151
- }
152
- }
153
- }
154
-
155
- scan() {
156
- if (this.device.scanDuration) {
157
- this.scanDuration = this.accessory.context.scanDuration = this.device.scanDuration;
158
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
159
- this.warnLog(`Motion Sensor: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
160
- }
161
- } else {
162
- this.scanDuration = this.accessory.context.scanDuration = 1;
163
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
164
- this.warnLog(`Motion Sensor: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
165
- }
166
- }
167
- }
168
-
169
- logs() {
170
- if (this.platform.debugMode) {
171
- this.deviceLogging = this.accessory.context.logging = 'debug';
172
- this.warnLog(`Motion Sensor: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
173
- } else if (this.device.logging) {
174
- this.deviceLogging = this.accessory.context.logging = this.device.logging;
175
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
176
- this.warnLog(`Motion Sensor: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
177
- }
178
- } else if (this.platform.config.options?.logging) {
179
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
180
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
181
- this.warnLog(`Motion Sensor: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
182
- }
183
- } else {
184
- this.deviceLogging = this.accessory.context.logging = 'standard';
185
- }
186
- }
187
-
188
- private minLux(): number {
189
- if (this.device.motion?.set_minLux) {
190
- this.set_minLux = this.device.motion!.set_minLux!;
191
- } else {
192
- this.set_minLux = 1;
193
- }
194
- return this.set_minLux;
195
- }
196
-
197
- private maxLux(): number {
198
- if (this.device.motion?.set_maxLux) {
199
- this.set_maxLux = this.device.motion!.set_maxLux!;
200
- } else {
201
- this.set_maxLux = 6001;
202
- }
203
- return this.set_maxLux;
204
- }
205
-
206
142
  /**
207
143
  * Parse the device status from the SwitchBot api
208
144
  */
@@ -428,6 +364,83 @@ export class Motion {
428
364
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
429
365
  }
430
366
 
367
+ config(device: device & devicesConfig) {
368
+ const config: any = device.motion;
369
+ if (device.ble !== undefined) {
370
+ config['ble'] = device.ble;
371
+ }
372
+ if (device.logging !== undefined) {
373
+ config['logging'] = device.logging;
374
+ }
375
+ if (device.refreshRate !== undefined) {
376
+ config['refreshRate'] = device.refreshRate;
377
+ }
378
+ if (device.scanDuration !== undefined) {
379
+ config['scanDuration'] = device.scanDuration;
380
+ }
381
+ if (config !== undefined) {
382
+ this.warnLog(`Motion Sensor: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
383
+ }
384
+ }
385
+
386
+ refreshRate(device: device & devicesConfig) {
387
+ if (device.refreshRate) {
388
+ this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
389
+ this.debugLog(`Motion Sensor: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
390
+ } else if (this.platform.config.options!.refreshRate) {
391
+ this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
392
+ this.debugLog(`Motion Sensor: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
393
+ }
394
+ }
395
+
396
+ scan(device: device & devicesConfig) {
397
+ if (device.scanDuration) {
398
+ this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
399
+ if (device.ble) {
400
+ this.debugLog(`Motion Sensor: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
401
+ }
402
+ } else {
403
+ this.scanDuration = this.accessory.context.scanDuration = 1;
404
+ if (this.device.ble) {
405
+ this.debugLog(`Motion Sensor: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
406
+ }
407
+ }
408
+ }
409
+
410
+ logs(device: device & devicesConfig) {
411
+ if (this.platform.debugMode) {
412
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
413
+ this.debugLog(`Motion Sensor: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
414
+ } else if (device.logging) {
415
+ this.deviceLogging = this.accessory.context.logging = device.logging;
416
+ this.debugLog(`Motion Sensor: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
417
+ } else if (this.platform.config.options?.logging) {
418
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
419
+ this.debugLog(`Motion Sensor: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
420
+ } else {
421
+ this.deviceLogging = this.accessory.context.logging = 'standard';
422
+ this.debugLog(`Motion Sensor: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
423
+ }
424
+ }
425
+
426
+ private minLux(): number {
427
+ if (this.device.motion?.set_minLux) {
428
+ this.set_minLux = this.device.motion!.set_minLux!;
429
+ } else {
430
+ this.set_minLux = 1;
431
+ }
432
+ return this.set_minLux;
433
+ }
434
+
435
+ private maxLux(): number {
436
+ if (this.device.motion?.set_maxLux) {
437
+ this.set_maxLux = this.device.motion!.set_maxLux!;
438
+ } else {
439
+ this.set_maxLux = 6001;
440
+ }
441
+ return this.set_maxLux;
442
+ }
443
+
431
444
  /**
432
445
  * Logging for Device
433
446
  */
@@ -33,9 +33,10 @@ export class Plug {
33
33
  public device: device & devicesConfig,
34
34
  ) {
35
35
  // default placeholders
36
- this.logs();
37
- this.scan();
38
- this.refreshRate();
36
+ this.logs(device);
37
+ this.scan(device);
38
+ this.refreshRate(device);
39
+ this.config(device);
39
40
  if (this.On === undefined) {
40
41
  this.On = false;
41
42
  } else {
@@ -117,53 +118,6 @@ export class Plug {
117
118
  });
118
119
  }
119
120
 
120
- refreshRate() {
121
- if (this.device.refreshRate) {
122
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
123
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
124
- this.warnLog(`Plug: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
125
- }
126
- } else if (this.platform.config.options!.refreshRate) {
127
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
128
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
129
- this.warnLog(`Plug: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
130
- }
131
- }
132
- }
133
-
134
- scan() {
135
- if (this.device.scanDuration) {
136
- this.scanDuration = this.accessory.context.scanDuration = this.device.scanDuration;
137
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
138
- this.warnLog(`Plug: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
139
- }
140
- } else {
141
- this.scanDuration = this.accessory.context.scanDuration = 1;
142
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
143
- this.warnLog(`Plug: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
144
- }
145
- }
146
- }
147
-
148
- logs() {
149
- if (this.platform.debugMode) {
150
- this.deviceLogging = this.accessory.context.logging = 'debug';
151
- this.warnLog(`Plug: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
152
- } else if (this.device.logging) {
153
- this.deviceLogging = this.accessory.context.logging = this.device.logging;
154
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
155
- this.warnLog(`Plug: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
156
- }
157
- } else if (this.platform.config.options?.logging) {
158
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
159
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
160
- this.warnLog(`Plug: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
161
- }
162
- } else {
163
- this.deviceLogging = this.accessory.context.logging = 'standard';
164
- }
165
- }
166
-
167
121
  parseStatus() {
168
122
  switch (this.power) {
169
123
  case 'on':
@@ -295,6 +249,65 @@ export class Plug {
295
249
  this.doPlugUpdate.next();
296
250
  }
297
251
 
252
+ config(device: device & devicesConfig) {
253
+ const config: any = device.plug;
254
+ if (device.ble !== undefined) {
255
+ config['ble'] = device.ble;
256
+ }
257
+ if (device.logging !== undefined) {
258
+ config['logging'] = device.logging;
259
+ }
260
+ if (device.refreshRate !== undefined) {
261
+ config['refreshRate'] = device.refreshRate;
262
+ }
263
+ if (device.scanDuration !== undefined) {
264
+ config['scanDuration'] = device.scanDuration;
265
+ }
266
+ if (config !== undefined) {
267
+ this.warnLog(`Plug: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
268
+ }
269
+ }
270
+
271
+ refreshRate(device: device & devicesConfig) {
272
+ if (device.refreshRate) {
273
+ this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
274
+ this.debugLog(`Plug: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
275
+ } else if (this.platform.config.options!.refreshRate) {
276
+ this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
277
+ this.debugLog(`Plug: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
278
+ }
279
+ }
280
+
281
+ scan(device: device & devicesConfig) {
282
+ if (device.scanDuration) {
283
+ this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
284
+ if (device.ble) {
285
+ this.debugLog(`Plug: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
286
+ }
287
+ } else {
288
+ this.scanDuration = this.accessory.context.scanDuration = 1;
289
+ if (this.device.ble) {
290
+ this.debugLog(`Plug: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
291
+ }
292
+ }
293
+ }
294
+
295
+ logs(device: device & devicesConfig) {
296
+ if (this.platform.debugMode) {
297
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
298
+ this.debugLog(`Plug: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
299
+ } else if (device.logging) {
300
+ this.deviceLogging = this.accessory.context.logging = device.logging;
301
+ this.debugLog(`Plug: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
302
+ } else if (this.platform.config.options?.logging) {
303
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
304
+ this.debugLog(`Plug: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
305
+ } else {
306
+ this.deviceLogging = this.accessory.context.logging = 'standard';
307
+ this.debugLog(`Plug: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
308
+ }
309
+ }
310
+
298
311
  /**
299
312
  * Logging for Device
300
313
  */
@@ -49,7 +49,8 @@ export class AirConditioner {
49
49
  public device: irdevice & irDevicesConfig,
50
50
  ) {
51
51
  // default placeholders
52
- this.logs();
52
+ this.logs(device);
53
+ this.config(device);
53
54
  if (this.Active === undefined) {
54
55
  this.Active = this.platform.Characteristic.Active.INACTIVE;
55
56
  } else {
@@ -166,25 +167,6 @@ export class AirConditioner {
166
167
  .onSet(this.RotationSpeedSet.bind(this));
167
168
  }
168
169
 
169
- logs() {
170
- if (this.platform.debugMode) {
171
- this.deviceLogging = this.accessory.context.logging = 'debug';
172
- this.warnLog(`Air Conditioner: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
173
- } else if (this.device.logging) {
174
- this.deviceLogging = this.accessory.context.logging = this.device.logging;
175
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
176
- this.warnLog(`Air Conditioner: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
177
- }
178
- } else if (this.platform.config.options?.logging) {
179
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
180
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
181
- this.warnLog(`Air Conditioner: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
182
- }
183
- } else {
184
- this.deviceLogging = this.accessory.context.logging = 'standard';
185
- }
186
- }
187
-
188
170
  /**
189
171
  * Pushes the requested changes to the SwitchBot API
190
172
  * deviceType commandType Command command parameter Description
@@ -576,6 +558,32 @@ export class AirConditioner {
576
558
  }
577
559
  }
578
560
 
561
+ config(device: irdevice & irDevicesConfig) {
562
+ const config: any = device.irair;
563
+ if (device.logging !== undefined) {
564
+ config['logging'] = device.logging;
565
+ }
566
+ if (config !== undefined) {
567
+ this.warnLog(`Air Conditioner: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
568
+ }
569
+ }
570
+
571
+ logs(device: irdevice & irDevicesConfig) {
572
+ if (this.platform.debugMode) {
573
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
574
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
575
+ } else if (device.logging) {
576
+ this.deviceLogging = this.accessory.context.logging = device.logging;
577
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
578
+ } else if (this.platform.config.options?.logging) {
579
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
580
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
581
+ } else {
582
+ this.deviceLogging = this.accessory.context.logging = 'standard';
583
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
584
+ }
585
+ }
586
+
579
587
  /**
580
588
  * Logging for Device
581
589
  */
@@ -44,7 +44,8 @@ export class AirPurifier {
44
44
  public device: irdevice & irDevicesConfig,
45
45
  ) {
46
46
  // default placeholders
47
- this.logs();
47
+ this.logs(device);
48
+ this.config(device);
48
49
  if (this.Active === undefined) {
49
50
  this.Active = this.platform.Characteristic.Active.INACTIVE;
50
51
  } else {
@@ -87,31 +88,12 @@ export class AirPurifier {
87
88
  this.service.getCharacteristic(this.platform.Characteristic.TargetAirPurifierState).onSet(this.TargetAirPurifierStateSet.bind(this));
88
89
  }
89
90
 
90
- logs() {
91
- if (this.platform.debugMode) {
92
- this.deviceLogging = this.accessory.context.logging = 'debug';
93
- this.warnLog(`Air Purifier: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
94
- } else if (this.device.logging) {
95
- this.deviceLogging = this.accessory.context.logging = this.device.logging;
96
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
97
- this.warnLog(`Air Purifier: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
98
- }
99
- } else if (this.platform.config.options?.logging) {
100
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
101
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
102
- this.warnLog(`Air Purifier: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
103
- }
104
- } else {
105
- this.deviceLogging = this.accessory.context.logging = 'standard';
106
- }
107
- }
108
-
109
91
  private ActiveSet(value: CharacteristicValue) {
110
92
  this.debugLog(`Air Purifier: ${this.accessory.displayName} Set Active: ${value}`);
111
93
  if (value === this.platform.Characteristic.Active.INACTIVE) {
112
- this.pushAirConditionerOffChanges();
94
+ this.pushAirPurifierOffChanges();
113
95
  } else {
114
- this.pushAirConditionerOnChanges();
96
+ this.pushAirPurifierOnChanges();
115
97
  }
116
98
  this.Active = value;
117
99
  this.ActiveCached = this.Active;
@@ -177,7 +159,7 @@ export class AirPurifier {
177
159
  * AirPurifier: "command" "middleSpeed" "default" = fan speed to medium
178
160
  * AirPurifier: "command" "highSpeed" "default" = fan speed to high
179
161
  */
180
- async pushAirConditionerOnChanges() {
162
+ async pushAirPurifierOnChanges() {
181
163
  if (this.Active !== 1) {
182
164
  const payload = {
183
165
  commandType: 'command',
@@ -188,7 +170,7 @@ export class AirPurifier {
188
170
  }
189
171
  }
190
172
 
191
- async pushAirConditionerOffChanges() {
173
+ async pushAirPurifierOffChanges() {
192
174
  if (this.Active !== 0) {
193
175
  const payload = {
194
176
  commandType: 'command',
@@ -298,6 +280,32 @@ export class AirPurifier {
298
280
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
299
281
  }
300
282
 
283
+ config(device: irdevice & irDevicesConfig) {
284
+ const config: any = device.irpur;
285
+ if (device.logging !== undefined) {
286
+ config['logging'] = device.logging;
287
+ }
288
+ if (config !== undefined) {
289
+ this.warnLog(`Air Purifier: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
290
+ }
291
+ }
292
+
293
+ logs(device: irdevice & irDevicesConfig) {
294
+ if (this.platform.debugMode) {
295
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
296
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
297
+ } else if (device.logging) {
298
+ this.deviceLogging = this.accessory.context.logging = device.logging;
299
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
300
+ } else if (this.platform.config.options?.logging) {
301
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
302
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
303
+ } else {
304
+ this.deviceLogging = this.accessory.context.logging = 'standard';
305
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
306
+ }
307
+ }
308
+
301
309
  /**
302
310
  * Logging for Device
303
311
  */
@@ -25,7 +25,8 @@ export class Camera {
25
25
  public device: irdevice & irDevicesConfig,
26
26
  ) {
27
27
  // default placeholders
28
- this.logs();
28
+ this.logs(device);
29
+ this.config(device);
29
30
  if (this.On === undefined) {
30
31
  this.On = false;
31
32
  } else {
@@ -57,25 +58,6 @@ export class Camera {
57
58
  this.service.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
58
59
  }
59
60
 
60
- logs() {
61
- if (this.platform.debugMode) {
62
- this.deviceLogging = this.accessory.context.logging = 'debug';
63
- this.warnLog(`Camera: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
64
- } else if (this.device.logging) {
65
- this.deviceLogging = this.accessory.context.logging = this.device.logging;
66
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
67
- this.warnLog(`Camera: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
68
- }
69
- } else if (this.platform.config.options?.logging) {
70
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
71
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
72
- this.warnLog(`Camera: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
73
- }
74
- } else {
75
- this.deviceLogging = this.accessory.context.logging = 'standard';
76
- }
77
- }
78
-
79
61
  private OnSet(value: CharacteristicValue) {
80
62
  this.debugLog(`Camera: ${this.accessory.displayName} On: ${value}`);
81
63
  this.On = value;
@@ -187,6 +169,32 @@ export class Camera {
187
169
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
188
170
  }
189
171
 
172
+ config(device: irdevice & irDevicesConfig) {
173
+ const config: any = device.ircam;
174
+ if (device.logging !== undefined) {
175
+ config['logging'] = device.logging;
176
+ }
177
+ if (config !== undefined) {
178
+ this.warnLog(`Camera: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
179
+ }
180
+ }
181
+
182
+ logs(device: irdevice & irDevicesConfig) {
183
+ if (this.platform.debugMode) {
184
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
185
+ this.debugLog(`Camera: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
186
+ } else if (device.logging) {
187
+ this.deviceLogging = this.accessory.context.logging = device.logging;
188
+ this.debugLog(`Camera: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
189
+ } else if (this.platform.config.options?.logging) {
190
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
191
+ this.debugLog(`Camera: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
192
+ } else {
193
+ this.deviceLogging = this.accessory.context.logging = 'standard';
194
+ this.debugLog(`Camera: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
195
+ }
196
+ }
197
+
190
198
  /**
191
199
  * Logging for Device
192
200
  */