@switchbot/homebridge-switchbot 1.8.1-beta.1 → 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 (86) hide show
  1. package/dist/devices/bots.d.ts +15 -15
  2. package/dist/devices/bots.d.ts.map +1 -1
  3. package/dist/devices/bots.js +159 -159
  4. package/dist/devices/bots.js.map +1 -1
  5. package/dist/devices/colorbulb.d.ts +5 -5
  6. package/dist/devices/colorbulb.d.ts.map +1 -1
  7. package/dist/devices/colorbulb.js +66 -66
  8. package/dist/devices/colorbulb.js.map +1 -1
  9. package/dist/devices/contact.d.ts +8 -8
  10. package/dist/devices/contact.d.ts.map +1 -1
  11. package/dist/devices/contact.js +78 -78
  12. package/dist/devices/contact.js.map +1 -1
  13. package/dist/devices/curtains.d.ts +7 -7
  14. package/dist/devices/curtains.d.ts.map +1 -1
  15. package/dist/devices/curtains.js +97 -97
  16. package/dist/devices/curtains.js.map +1 -1
  17. package/dist/devices/humidifiers.d.ts +5 -5
  18. package/dist/devices/humidifiers.d.ts.map +1 -1
  19. package/dist/devices/humidifiers.js +69 -69
  20. package/dist/devices/humidifiers.js.map +1 -1
  21. package/dist/devices/meters.d.ts +4 -4
  22. package/dist/devices/meters.d.ts.map +1 -1
  23. package/dist/devices/meters.js +60 -60
  24. package/dist/devices/meters.js.map +1 -1
  25. package/dist/devices/motion.d.ts +6 -6
  26. package/dist/devices/motion.d.ts.map +1 -1
  27. package/dist/devices/motion.js +78 -78
  28. package/dist/devices/motion.js.map +1 -1
  29. package/dist/devices/plugs.d.ts +4 -4
  30. package/dist/devices/plugs.d.ts.map +1 -1
  31. package/dist/devices/plugs.js +60 -60
  32. package/dist/devices/plugs.js.map +1 -1
  33. package/dist/irdevices/airconditioners.d.ts +2 -2
  34. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  35. package/dist/irdevices/airconditioners.js +27 -27
  36. package/dist/irdevices/airconditioners.js.map +1 -1
  37. package/dist/irdevices/airpurifiers.d.ts +2 -2
  38. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  39. package/dist/irdevices/airpurifiers.js +27 -27
  40. package/dist/irdevices/airpurifiers.js.map +1 -1
  41. package/dist/irdevices/cameras.d.ts +2 -2
  42. package/dist/irdevices/cameras.d.ts.map +1 -1
  43. package/dist/irdevices/cameras.js +27 -27
  44. package/dist/irdevices/cameras.js.map +1 -1
  45. package/dist/irdevices/fans.d.ts +2 -2
  46. package/dist/irdevices/fans.d.ts.map +1 -1
  47. package/dist/irdevices/fans.js +27 -27
  48. package/dist/irdevices/fans.js.map +1 -1
  49. package/dist/irdevices/lights.d.ts +2 -2
  50. package/dist/irdevices/lights.d.ts.map +1 -1
  51. package/dist/irdevices/lights.js +27 -27
  52. package/dist/irdevices/lights.js.map +1 -1
  53. package/dist/irdevices/others.d.ts +3 -3
  54. package/dist/irdevices/others.d.ts.map +1 -1
  55. package/dist/irdevices/others.js +38 -38
  56. package/dist/irdevices/others.js.map +1 -1
  57. package/dist/irdevices/tvs.d.ts +2 -2
  58. package/dist/irdevices/tvs.d.ts.map +1 -1
  59. package/dist/irdevices/tvs.js +27 -27
  60. package/dist/irdevices/tvs.js.map +1 -1
  61. package/dist/irdevices/vacuumcleaners.d.ts +2 -2
  62. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  63. package/dist/irdevices/vacuumcleaners.js +27 -27
  64. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  65. package/dist/irdevices/waterheaters.d.ts +2 -2
  66. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  67. package/dist/irdevices/waterheaters.js +27 -27
  68. package/dist/irdevices/waterheaters.js.map +1 -1
  69. package/package.json +1 -1
  70. package/src/devices/bots.ts +166 -166
  71. package/src/devices/colorbulb.ts +65 -65
  72. package/src/devices/contact.ts +79 -79
  73. package/src/devices/curtains.ts +95 -95
  74. package/src/devices/humidifiers.ts +68 -68
  75. package/src/devices/meters.ts +59 -59
  76. package/src/devices/motion.ts +77 -77
  77. package/src/devices/plugs.ts +59 -59
  78. package/src/irdevices/airconditioners.ts +26 -26
  79. package/src/irdevices/airpurifiers.ts +26 -26
  80. package/src/irdevices/cameras.ts +26 -26
  81. package/src/irdevices/fans.ts +26 -26
  82. package/src/irdevices/lights.ts +26 -26
  83. package/src/irdevices/others.ts +37 -37
  84. package/src/irdevices/tvs.ts +26 -26
  85. package/src/irdevices/vacuumcleaners.ts +26 -26
  86. package/src/irdevices/waterheaters.ts +26 -26
@@ -209,101 +209,6 @@ export class Curtain {
209
209
  });
210
210
  }
211
211
 
212
- config(device: device & devicesConfig) {
213
- const config: any = device.curtain;
214
- if (device.ble) {
215
- config['ble'] = device.ble;
216
- }
217
- if (device.logging !== undefined) {
218
- config['logging'] = device.logging;
219
- }
220
- if (device.refreshRate !== undefined) {
221
- config['refreshRate'] = device.refreshRate;
222
- }
223
- if (device.scanDuration !== undefined) {
224
- config['scanDuration'] = device.scanDuration;
225
- }
226
- if (config !== undefined) {
227
- this.warnLog(`Curtain: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
228
- }
229
- }
230
-
231
- refreshRate(device: device & devicesConfig) {
232
- // refreshRate
233
- if (device.refreshRate) {
234
- this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
235
- this.debugLog(`Curtain: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
236
- } else if (this.platform.config.options!.refreshRate) {
237
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
238
- this.debugLog(`Curtain: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
239
- }
240
- // updateRate
241
- if (device?.curtain?.updateRate) {
242
- this.updateRate = device?.curtain?.updateRate;
243
- this.debugLog(`Curtain: ${this.accessory.displayName} Using Device Config Curtain refreshRate: ${this.deviceRefreshRate}`);
244
- } else {
245
- this.updateRate = 5;
246
- this.debugLog(`Curtain: ${this.accessory.displayName} Using Default Curtain Refresh Rate.`);
247
- }
248
- }
249
-
250
- scan(device: device & devicesConfig) {
251
- if (device.scanDuration) {
252
- this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
253
- if (device.ble) {
254
- this.debugLog(`Curtain: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
255
- }
256
- } else {
257
- this.scanDuration = this.accessory.context.scanDuration = 1;
258
- if (this.device.ble) {
259
- this.debugLog(`Curtain: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
260
- }
261
- }
262
- }
263
-
264
- logs(device: device & devicesConfig) {
265
- if (this.platform.debugMode) {
266
- this.deviceLogging = this.accessory.context.logging = 'debugMode';
267
- this.debugLog(`Curtain: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
268
- } else if (device.logging) {
269
- this.deviceLogging = this.accessory.context.logging = device.logging;
270
- this.debugLog(`Curtain: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
271
- } else if (this.platform.config.options?.logging) {
272
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
273
- this.debugLog(`Curtain: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
274
- } else {
275
- this.deviceLogging = this.accessory.context.logging = 'standard';
276
- this.debugLog(`Curtain: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
277
- }
278
- }
279
-
280
- private minStep(device: device & devicesConfig): number {
281
- if (device.curtain?.set_minStep) {
282
- this.set_minStep = device.curtain?.set_minStep;
283
- } else {
284
- this.set_minStep = 1;
285
- }
286
- return this.set_minStep;
287
- }
288
-
289
- private minLux(): number {
290
- if (this.device.curtain?.set_minLux) {
291
- this.set_minLux = this.device.curtain?.set_minLux;
292
- } else {
293
- this.set_minLux = 1;
294
- }
295
- return this.set_minLux;
296
- }
297
-
298
- private maxLux(): number {
299
- if (this.device.curtain?.set_maxLux) {
300
- this.set_maxLux = this.device.curtain?.set_maxLux;
301
- } else {
302
- this.set_maxLux = 6001;
303
- }
304
- return this.set_maxLux;
305
- }
306
-
307
212
  /**
308
213
  * Parse the device status from the SwitchBot api
309
214
  */
@@ -812,6 +717,101 @@ export class Curtain {
812
717
  }
813
718
  }
814
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
+
815
815
  /**
816
816
  * Logging for Device
817
817
  */
@@ -198,74 +198,6 @@ export class Humidifier {
198
198
  });
199
199
  }
200
200
 
201
- config(device: device & devicesConfig) {
202
- const config: any = device.humidifier;
203
- if (device.ble !== undefined) {
204
- config['ble'] = device.ble;
205
- }
206
- if (device.logging !== undefined) {
207
- config['logging'] = device.logging;
208
- }
209
- if (device.refreshRate !== undefined) {
210
- config['refreshRate'] = device.refreshRate;
211
- }
212
- if (device.scanDuration !== undefined) {
213
- config['scanDuration'] = device.scanDuration;
214
- }
215
- if (config !== undefined) {
216
- this.warnLog(`Humidifier: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
217
- }
218
- }
219
-
220
- refreshRate(device: device & devicesConfig) {
221
- if (device.refreshRate) {
222
- this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
223
- this.debugLog(`Humidifier: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
224
- } else if (this.platform.config.options!.refreshRate) {
225
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
226
- this.debugLog(`Humidifier: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
227
- }
228
- }
229
-
230
- scan(device: device & devicesConfig) {
231
- if (device.scanDuration) {
232
- this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
233
- if (device.ble) {
234
- this.debugLog(`Humidifier: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
235
- }
236
- } else {
237
- this.scanDuration = this.accessory.context.scanDuration = 1;
238
- if (this.device.ble) {
239
- this.debugLog(`Humidifier: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
240
- }
241
- }
242
- }
243
-
244
- logs(device: device & devicesConfig) {
245
- if (this.platform.debugMode) {
246
- this.deviceLogging = this.accessory.context.logging = 'debugMode';
247
- this.debugLog(`Humidifier: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
248
- } else if (device.logging) {
249
- this.deviceLogging = this.accessory.context.logging = device.logging;
250
- this.debugLog(`Humidifier: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
251
- } else if (this.platform.config.options?.logging) {
252
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
253
- this.debugLog(`Humidifier: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
254
- } else {
255
- this.deviceLogging = this.accessory.context.logging = 'standard';
256
- this.debugLog(`Humidifier: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
257
- }
258
- }
259
-
260
- private minStep(): number | undefined {
261
- if (this.device.humidifier?.set_minStep) {
262
- this.set_minStep = this.device.humidifier?.set_minStep;
263
- } else {
264
- this.set_minStep = 1;
265
- }
266
- return this.set_minStep;
267
- }
268
-
269
201
  /**
270
202
  * Parse the device status from the SwitchBot api
271
203
  */
@@ -779,6 +711,74 @@ export class Humidifier {
779
711
  this.doHumidifierUpdate.next();
780
712
  }
781
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
+
782
782
  /**
783
783
  * Logging for Device
784
784
  */
@@ -174,65 +174,6 @@ export class Meter {
174
174
  });
175
175
  }
176
176
 
177
- config(device: device & devicesConfig) {
178
- const config: any = device.meter;
179
- if (device.ble !== undefined) {
180
- config['ble'] = device.ble;
181
- }
182
- if (device.logging !== undefined) {
183
- config['logging'] = device.logging;
184
- }
185
- if (device.refreshRate !== undefined) {
186
- config['refreshRate'] = device.refreshRate;
187
- }
188
- if (device.scanDuration !== undefined) {
189
- config['scanDuration'] = device.scanDuration;
190
- }
191
- if (config !== undefined) {
192
- this.warnLog(`Meter: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
193
- }
194
- }
195
-
196
- refreshRate(device: device & devicesConfig) {
197
- if (device.refreshRate) {
198
- this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
199
- this.debugLog(`Meter: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
200
- } else if (this.platform.config.options!.refreshRate) {
201
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
202
- this.debugLog(`Meter: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
203
- }
204
- }
205
-
206
- scan(device: device & devicesConfig) {
207
- if (device.scanDuration) {
208
- this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
209
- if (device.ble) {
210
- this.debugLog(`Meter: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
211
- }
212
- } else {
213
- this.scanDuration = this.accessory.context.scanDuration = 1;
214
- if (this.device.ble) {
215
- this.debugLog(`Meter: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
216
- }
217
- }
218
- }
219
-
220
- logs(device: device & devicesConfig) {
221
- if (this.platform.debugMode) {
222
- this.deviceLogging = this.accessory.context.logging = 'debugMode';
223
- this.debugLog(`Meter: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
224
- } else if (device.logging) {
225
- this.deviceLogging = this.accessory.context.logging = device.logging;
226
- this.debugLog(`Meter: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
227
- } else if (this.platform.config.options?.logging) {
228
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
229
- this.debugLog(`Meter: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
230
- } else {
231
- this.deviceLogging = this.accessory.context.logging = 'standard';
232
- this.debugLog(`Meter: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
233
- }
234
- }
235
-
236
177
  /**
237
178
  * Parse the device status from the SwitchBot api
238
179
  */
@@ -449,6 +390,65 @@ export class Meter {
449
390
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
450
391
  }
451
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
+
452
452
  /**
453
453
  * Logging for Device
454
454
  */
@@ -139,83 +139,6 @@ export class Motion {
139
139
  });
140
140
  }
141
141
 
142
- config(device: device & devicesConfig) {
143
- const config: any = device.motion;
144
- if (device.ble !== undefined) {
145
- config['ble'] = device.ble;
146
- }
147
- if (device.logging !== undefined) {
148
- config['logging'] = device.logging;
149
- }
150
- if (device.refreshRate !== undefined) {
151
- config['refreshRate'] = device.refreshRate;
152
- }
153
- if (device.scanDuration !== undefined) {
154
- config['scanDuration'] = device.scanDuration;
155
- }
156
- if (config !== undefined) {
157
- this.warnLog(`Motion Sensor: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
158
- }
159
- }
160
-
161
- refreshRate(device: device & devicesConfig) {
162
- if (device.refreshRate) {
163
- this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
164
- this.debugLog(`Motion Sensor: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
165
- } else if (this.platform.config.options!.refreshRate) {
166
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
167
- this.debugLog(`Motion Sensor: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
168
- }
169
- }
170
-
171
- scan(device: device & devicesConfig) {
172
- if (device.scanDuration) {
173
- this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
174
- if (device.ble) {
175
- this.debugLog(`Motion Sensor: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
176
- }
177
- } else {
178
- this.scanDuration = this.accessory.context.scanDuration = 1;
179
- if (this.device.ble) {
180
- this.debugLog(`Motion Sensor: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
181
- }
182
- }
183
- }
184
-
185
- logs(device: device & devicesConfig) {
186
- if (this.platform.debugMode) {
187
- this.deviceLogging = this.accessory.context.logging = 'debugMode';
188
- this.debugLog(`Motion Sensor: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
189
- } else if (device.logging) {
190
- this.deviceLogging = this.accessory.context.logging = device.logging;
191
- this.debugLog(`Motion Sensor: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
192
- } else if (this.platform.config.options?.logging) {
193
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
194
- this.debugLog(`Motion Sensor: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
195
- } else {
196
- this.deviceLogging = this.accessory.context.logging = 'standard';
197
- this.debugLog(`Motion Sensor: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
198
- }
199
- }
200
-
201
- private minLux(): number {
202
- if (this.device.motion?.set_minLux) {
203
- this.set_minLux = this.device.motion!.set_minLux!;
204
- } else {
205
- this.set_minLux = 1;
206
- }
207
- return this.set_minLux;
208
- }
209
-
210
- private maxLux(): number {
211
- if (this.device.motion?.set_maxLux) {
212
- this.set_maxLux = this.device.motion!.set_maxLux!;
213
- } else {
214
- this.set_maxLux = 6001;
215
- }
216
- return this.set_maxLux;
217
- }
218
-
219
142
  /**
220
143
  * Parse the device status from the SwitchBot api
221
144
  */
@@ -441,6 +364,83 @@ export class Motion {
441
364
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
442
365
  }
443
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
+
444
444
  /**
445
445
  * Logging for Device
446
446
  */