@switchbot/homebridge-switchbot 1.8.1-beta.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/devices/bots.d.ts +15 -15
  3. package/dist/devices/bots.d.ts.map +1 -1
  4. package/dist/devices/bots.js +162 -159
  5. package/dist/devices/bots.js.map +1 -1
  6. package/dist/devices/colorbulb.d.ts +5 -5
  7. package/dist/devices/colorbulb.d.ts.map +1 -1
  8. package/dist/devices/colorbulb.js +69 -66
  9. package/dist/devices/colorbulb.js.map +1 -1
  10. package/dist/devices/contact.d.ts +8 -8
  11. package/dist/devices/contact.d.ts.map +1 -1
  12. package/dist/devices/contact.js +81 -78
  13. package/dist/devices/contact.js.map +1 -1
  14. package/dist/devices/curtains.d.ts +7 -7
  15. package/dist/devices/curtains.d.ts.map +1 -1
  16. package/dist/devices/curtains.js +105 -113
  17. package/dist/devices/curtains.js.map +1 -1
  18. package/dist/devices/humidifiers.d.ts +5 -5
  19. package/dist/devices/humidifiers.d.ts.map +1 -1
  20. package/dist/devices/humidifiers.js +72 -69
  21. package/dist/devices/humidifiers.js.map +1 -1
  22. package/dist/devices/meters.d.ts +4 -4
  23. package/dist/devices/meters.d.ts.map +1 -1
  24. package/dist/devices/meters.js +63 -60
  25. package/dist/devices/meters.js.map +1 -1
  26. package/dist/devices/motion.d.ts +6 -6
  27. package/dist/devices/motion.d.ts.map +1 -1
  28. package/dist/devices/motion.js +81 -78
  29. package/dist/devices/motion.js.map +1 -1
  30. package/dist/devices/plugs.d.ts +4 -4
  31. package/dist/devices/plugs.d.ts.map +1 -1
  32. package/dist/devices/plugs.js +63 -60
  33. package/dist/devices/plugs.js.map +1 -1
  34. package/dist/irdevices/airconditioners.d.ts +2 -2
  35. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  36. package/dist/irdevices/airconditioners.js +30 -27
  37. package/dist/irdevices/airconditioners.js.map +1 -1
  38. package/dist/irdevices/airpurifiers.d.ts +2 -2
  39. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  40. package/dist/irdevices/airpurifiers.js +30 -27
  41. package/dist/irdevices/airpurifiers.js.map +1 -1
  42. package/dist/irdevices/cameras.d.ts +2 -2
  43. package/dist/irdevices/cameras.d.ts.map +1 -1
  44. package/dist/irdevices/cameras.js +30 -27
  45. package/dist/irdevices/cameras.js.map +1 -1
  46. package/dist/irdevices/fans.d.ts +2 -2
  47. package/dist/irdevices/fans.d.ts.map +1 -1
  48. package/dist/irdevices/fans.js +30 -27
  49. package/dist/irdevices/fans.js.map +1 -1
  50. package/dist/irdevices/lights.d.ts +2 -2
  51. package/dist/irdevices/lights.d.ts.map +1 -1
  52. package/dist/irdevices/lights.js +30 -27
  53. package/dist/irdevices/lights.js.map +1 -1
  54. package/dist/irdevices/others.d.ts +3 -3
  55. package/dist/irdevices/others.d.ts.map +1 -1
  56. package/dist/irdevices/others.js +41 -38
  57. package/dist/irdevices/others.js.map +1 -1
  58. package/dist/irdevices/tvs.d.ts +2 -2
  59. package/dist/irdevices/tvs.d.ts.map +1 -1
  60. package/dist/irdevices/tvs.js +30 -27
  61. package/dist/irdevices/tvs.js.map +1 -1
  62. package/dist/irdevices/vacuumcleaners.d.ts +2 -2
  63. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  64. package/dist/irdevices/vacuumcleaners.js +30 -27
  65. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  66. package/dist/irdevices/waterheaters.d.ts +2 -2
  67. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  68. package/dist/irdevices/waterheaters.js +30 -27
  69. package/dist/irdevices/waterheaters.js.map +1 -1
  70. package/package.json +71 -71
  71. package/src/devices/bots.ts +169 -166
  72. package/src/devices/colorbulb.ts +68 -65
  73. package/src/devices/contact.ts +82 -79
  74. package/src/devices/curtains.ts +103 -111
  75. package/src/devices/humidifiers.ts +71 -68
  76. package/src/devices/meters.ts +62 -59
  77. package/src/devices/motion.ts +80 -77
  78. package/src/devices/plugs.ts +62 -59
  79. package/src/irdevices/airconditioners.ts +29 -26
  80. package/src/irdevices/airpurifiers.ts +29 -26
  81. package/src/irdevices/cameras.ts +29 -26
  82. package/src/irdevices/fans.ts +29 -26
  83. package/src/irdevices/lights.ts +29 -26
  84. package/src/irdevices/others.ts +40 -37
  85. package/src/irdevices/tvs.ts +29 -26
  86. package/src/irdevices/vacuumcleaners.ts +29 -26
  87. package/src/irdevices/waterheaters.ts +29 -26
@@ -67,7 +67,7 @@ export class Bot {
67
67
  this.logs(device);
68
68
  this.scan(device);
69
69
  this.refreshRate(device);
70
- this.PressOrSwitch();
70
+ this.PressOrSwitch(device);
71
71
  this.config(device);
72
72
  if (this.On === undefined) {
73
73
  this.On = false;
@@ -373,171 +373,6 @@ export class Bot {
373
373
  });
374
374
  }
375
375
 
376
- public removeOutletService(accessory: PlatformAccessory) {
377
- // If outletService still pressent, then remove first
378
- this.outletService = this.accessory.getService(this.platform.Service.Outlet);
379
- if (this.outletService) {
380
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Outlet Service`);
381
- }
382
- accessory.removeService(this.outletService!);
383
- }
384
-
385
- public removeGarageDoorService(accessory: PlatformAccessory) {
386
- // If garageDoorService still pressent, then remove first
387
- this.garageDoorService = this.accessory.getService(this.platform.Service.GarageDoorOpener);
388
- if (this.garageDoorService) {
389
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Garage Door Service`);
390
- }
391
- accessory.removeService(this.garageDoorService!);
392
- }
393
-
394
- public removeDoorService(accessory: PlatformAccessory) {
395
- // If doorService still pressent, then remove first
396
- this.doorService = this.accessory.getService(this.platform.Service.Door);
397
- if (this.doorService) {
398
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Door Service`);
399
- }
400
- accessory.removeService(this.doorService!);
401
- }
402
-
403
- public removeLockService(accessory: PlatformAccessory) {
404
- // If lockService still pressent, then remove first
405
- this.lockService = this.accessory.getService(this.platform.Service.LockMechanism);
406
- if (this.lockService) {
407
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Lock Service`);
408
- }
409
- accessory.removeService(this.lockService!);
410
- }
411
-
412
- public removeFaucetService(accessory: PlatformAccessory) {
413
- // If faucetService still pressent, then remove first
414
- this.faucetService = this.accessory.getService(this.platform.Service.Faucet);
415
- if (this.faucetService) {
416
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Faucet Service`);
417
- }
418
- accessory.removeService(this.faucetService!);
419
- }
420
-
421
- public removeFanService(accessory: PlatformAccessory) {
422
- // If fanService still pressent, then remove first
423
- this.fanService = this.accessory.getService(this.platform.Service.Fan);
424
- if (this.fanService) {
425
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Fan Service`);
426
- }
427
- accessory.removeService(this.fanService!);
428
- }
429
-
430
- public removeWindowService(accessory: PlatformAccessory) {
431
- // If windowService still pressent, then remove first
432
- this.windowService = this.accessory.getService(this.platform.Service.Window);
433
- if (this.windowService) {
434
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Service`);
435
- }
436
- accessory.removeService(this.windowService!);
437
- }
438
-
439
- public removeWindowCoveringService(accessory: PlatformAccessory) {
440
- // If windowCoveringService still pressent, then remove first
441
- this.windowCoveringService = this.accessory.getService(this.platform.Service.WindowCovering);
442
- if (this.windowCoveringService) {
443
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Covering Service`);
444
- }
445
- accessory.removeService(this.windowCoveringService!);
446
- }
447
-
448
- public removeStatefulProgrammableSwitchService(accessory: PlatformAccessory) {
449
- // If statefulProgrammableSwitchService still pressent, then remove first
450
- this.statefulProgrammableSwitchService = this.accessory.getService(this.platform.Service.StatefulProgrammableSwitch);
451
- if (this.statefulProgrammableSwitchService) {
452
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
453
- }
454
- accessory.removeService(this.statefulProgrammableSwitchService!);
455
- }
456
-
457
- public removeSwitchService(accessory: PlatformAccessory) {
458
- // If switchService still pressent, then remove first
459
- this.switchService = this.accessory.getService(this.platform.Service.Switch);
460
- if (this.switchService) {
461
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Switch Service`);
462
- }
463
- accessory.removeService(this.switchService!);
464
- }
465
-
466
- config(device: device & devicesConfig) {
467
- const config: any = device.bot;
468
- if (device.ble !== undefined) {
469
- config['ble'] = device.ble;
470
- }
471
- if (device.logging !== undefined) {
472
- config['logging'] = device.logging;
473
- }
474
- if (device.refreshRate !== undefined) {
475
- config['refreshRate'] = device.refreshRate;
476
- }
477
- if (device.scanDuration !== undefined) {
478
- config['scanDuration'] = device.scanDuration;
479
- }
480
- if (config !== undefined) {
481
- this.warnLog(`Bot: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
482
- }
483
- }
484
-
485
- refreshRate(device: device & devicesConfig) {
486
- if (device.refreshRate) {
487
- this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
488
- this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
489
- } else if (this.platform.config.options!.refreshRate) {
490
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
491
- this.debugLog(`Bot: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
492
- }
493
- }
494
-
495
- scan(device: device & devicesConfig) {
496
- if (device.scanDuration) {
497
- this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
498
- if (device.ble) {
499
- this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
500
- }
501
- } else {
502
- this.scanDuration = this.accessory.context.scanDuration = 1;
503
- if (this.device.ble) {
504
- this.debugLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
505
- }
506
- }
507
- }
508
-
509
- logs(device: device & devicesConfig) {
510
- if (this.platform.debugMode) {
511
- this.deviceLogging = this.accessory.context.logging = 'debugMode';
512
- this.debugLog(`Bot: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
513
- } else if (device.logging) {
514
- this.deviceLogging = this.accessory.context.logging = device.logging;
515
- this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
516
- } else if (this.platform.config.options?.logging) {
517
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
518
- this.debugLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
519
- } else {
520
- this.deviceLogging = this.accessory.context.logging = 'standard';
521
- this.debugLog(`Bot: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
522
- }
523
- }
524
-
525
- PressOrSwitch() {
526
- if (!this.device.bot?.mode) {
527
- this.botMode = 'switch';
528
- this.warnLog(`Bot: ${this.accessory.displayName} does not have bot mode set in the Plugin's SwitchBot Device Settings,`);
529
- this.warnLog(`Bot: ${this.accessory.displayName} is defaulting to "${this.botMode}" mode, you may experience issues.`);
530
- } else if (this.device.bot?.mode === 'switch') {
531
- this.botMode = 'switch';
532
- this.infoLog(`Bot: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
533
- } else if (this.device.bot?.mode === 'press') {
534
- this.botMode = 'press';
535
- this.infoLog(`Bot: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
536
- } else {
537
- throw new Error(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
538
- }
539
- }
540
-
541
376
  /**
542
377
  * Parse the device status from the SwitchBot api
543
378
  */
@@ -1178,6 +1013,174 @@ export class Bot {
1178
1013
  this.doBotUpdate.next();
1179
1014
  }
1180
1015
 
1016
+ config(device: device & devicesConfig) {
1017
+ let config = {};
1018
+ if (device.bot) {
1019
+ config = device.bot;
1020
+ }
1021
+ if (device.ble) {
1022
+ config['ble'] = device.ble;
1023
+ }
1024
+ if (device.logging !== undefined) {
1025
+ config['logging'] = device.logging;
1026
+ }
1027
+ if (device.refreshRate !== undefined) {
1028
+ config['refreshRate'] = device.refreshRate;
1029
+ }
1030
+ if (device.scanDuration !== undefined) {
1031
+ config['scanDuration'] = device.scanDuration;
1032
+ }
1033
+ if (config !== undefined) {
1034
+ this.warnLog(`Bot: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
1035
+ }
1036
+ }
1037
+
1038
+ refreshRate(device: device & devicesConfig) {
1039
+ if (device.refreshRate) {
1040
+ this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
1041
+ this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
1042
+ } else if (this.platform.config.options!.refreshRate) {
1043
+ this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
1044
+ this.debugLog(`Bot: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
1045
+ }
1046
+ }
1047
+
1048
+ scan(device: device & devicesConfig) {
1049
+ if (device.scanDuration) {
1050
+ this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
1051
+ if (device.ble) {
1052
+ this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
1053
+ }
1054
+ } else {
1055
+ this.scanDuration = this.accessory.context.scanDuration = 1;
1056
+ if (this.device.ble) {
1057
+ this.debugLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
1058
+ }
1059
+ }
1060
+ }
1061
+
1062
+ logs(device: device & devicesConfig) {
1063
+ if (this.platform.debugMode) {
1064
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
1065
+ this.debugLog(`Bot: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
1066
+ } else if (device.logging) {
1067
+ this.deviceLogging = this.accessory.context.logging = device.logging;
1068
+ this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
1069
+ } else if (this.platform.config.options?.logging) {
1070
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
1071
+ this.debugLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
1072
+ } else {
1073
+ this.deviceLogging = this.accessory.context.logging = 'standard';
1074
+ this.debugLog(`Bot: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
1075
+ }
1076
+ }
1077
+
1078
+ PressOrSwitch(device: device & devicesConfig) {
1079
+ if (!device.bot?.mode) {
1080
+ this.botMode = 'switch';
1081
+ this.warnLog(`Bot: ${this.accessory.displayName} does not have bot mode set in the Plugin's SwitchBot Device Settings,`);
1082
+ this.warnLog(`Bot: ${this.accessory.displayName} is defaulting to "${this.botMode}" mode, you may experience issues.`);
1083
+ } else if (device.bot?.mode === 'switch') {
1084
+ this.botMode = 'switch';
1085
+ this.debugLog(`Bot: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
1086
+ } else if (device.bot?.mode === 'press') {
1087
+ this.botMode = 'press';
1088
+ this.debugLog(`Bot: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
1089
+ } else {
1090
+ throw new Error(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
1091
+ }
1092
+ }
1093
+
1094
+ public removeOutletService(accessory: PlatformAccessory) {
1095
+ // If outletService still pressent, then remove first
1096
+ this.outletService = this.accessory.getService(this.platform.Service.Outlet);
1097
+ if (this.outletService) {
1098
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Outlet Service`);
1099
+ }
1100
+ accessory.removeService(this.outletService!);
1101
+ }
1102
+
1103
+ public removeGarageDoorService(accessory: PlatformAccessory) {
1104
+ // If garageDoorService still pressent, then remove first
1105
+ this.garageDoorService = this.accessory.getService(this.platform.Service.GarageDoorOpener);
1106
+ if (this.garageDoorService) {
1107
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Garage Door Service`);
1108
+ }
1109
+ accessory.removeService(this.garageDoorService!);
1110
+ }
1111
+
1112
+ public removeDoorService(accessory: PlatformAccessory) {
1113
+ // If doorService still pressent, then remove first
1114
+ this.doorService = this.accessory.getService(this.platform.Service.Door);
1115
+ if (this.doorService) {
1116
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Door Service`);
1117
+ }
1118
+ accessory.removeService(this.doorService!);
1119
+ }
1120
+
1121
+ public removeLockService(accessory: PlatformAccessory) {
1122
+ // If lockService still pressent, then remove first
1123
+ this.lockService = this.accessory.getService(this.platform.Service.LockMechanism);
1124
+ if (this.lockService) {
1125
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Lock Service`);
1126
+ }
1127
+ accessory.removeService(this.lockService!);
1128
+ }
1129
+
1130
+ public removeFaucetService(accessory: PlatformAccessory) {
1131
+ // If faucetService still pressent, then remove first
1132
+ this.faucetService = this.accessory.getService(this.platform.Service.Faucet);
1133
+ if (this.faucetService) {
1134
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Faucet Service`);
1135
+ }
1136
+ accessory.removeService(this.faucetService!);
1137
+ }
1138
+
1139
+ public removeFanService(accessory: PlatformAccessory) {
1140
+ // If fanService still pressent, then remove first
1141
+ this.fanService = this.accessory.getService(this.platform.Service.Fan);
1142
+ if (this.fanService) {
1143
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Fan Service`);
1144
+ }
1145
+ accessory.removeService(this.fanService!);
1146
+ }
1147
+
1148
+ public removeWindowService(accessory: PlatformAccessory) {
1149
+ // If windowService still pressent, then remove first
1150
+ this.windowService = this.accessory.getService(this.platform.Service.Window);
1151
+ if (this.windowService) {
1152
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Service`);
1153
+ }
1154
+ accessory.removeService(this.windowService!);
1155
+ }
1156
+
1157
+ public removeWindowCoveringService(accessory: PlatformAccessory) {
1158
+ // If windowCoveringService still pressent, then remove first
1159
+ this.windowCoveringService = this.accessory.getService(this.platform.Service.WindowCovering);
1160
+ if (this.windowCoveringService) {
1161
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Covering Service`);
1162
+ }
1163
+ accessory.removeService(this.windowCoveringService!);
1164
+ }
1165
+
1166
+ public removeStatefulProgrammableSwitchService(accessory: PlatformAccessory) {
1167
+ // If statefulProgrammableSwitchService still pressent, then remove first
1168
+ this.statefulProgrammableSwitchService = this.accessory.getService(this.platform.Service.StatefulProgrammableSwitch);
1169
+ if (this.statefulProgrammableSwitchService) {
1170
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
1171
+ }
1172
+ accessory.removeService(this.statefulProgrammableSwitchService!);
1173
+ }
1174
+
1175
+ public removeSwitchService(accessory: PlatformAccessory) {
1176
+ // If switchService still pressent, then remove first
1177
+ this.switchService = this.accessory.getService(this.platform.Service.Switch);
1178
+ if (this.switchService) {
1179
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Switch Service`);
1180
+ }
1181
+ accessory.removeService(this.switchService!);
1182
+ }
1183
+
1181
1184
  /**
1182
1185
  * Logging for Device
1183
1186
  */
@@ -117,7 +117,7 @@ export class ColorBulb {
117
117
  // handle Brightness events using the Brightness characteristic
118
118
  this.service.getCharacteristic(this.platform.Characteristic.Brightness)
119
119
  .setProps({
120
- minStep: this.minStep(),
120
+ minStep: this.minStep(device),
121
121
  minValue: 0,
122
122
  maxValue: 100,
123
123
  validValueRanges: [0, 100],
@@ -214,70 +214,6 @@ export class ColorBulb {
214
214
  });
215
215
  }
216
216
 
217
- config(device: device & devicesConfig) {
218
- const config: any = device.colorbulb;
219
- if (device.ble !== undefined) {
220
- config['ble'] = device.ble;
221
- }
222
- if (device.logging !== undefined) {
223
- config['logging'] = device.logging;
224
- }
225
- if (device.refreshRate !== undefined) {
226
- config['refreshRate'] = device.refreshRate;
227
- }
228
- if (device.scanDuration !== undefined) {
229
- config['scanDuration'] = device.scanDuration;
230
- }
231
- if (config !== undefined) {
232
- this.warnLog(`Color Bulb: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
233
- }
234
- }
235
-
236
- refreshRate(device: device & devicesConfig) {
237
- if (device.refreshRate) {
238
- this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
239
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
240
- } else if (this.platform.config.options!.refreshRate) {
241
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
242
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
243
- }
244
- }
245
-
246
- logs(device: device & devicesConfig) {
247
- if (this.platform.debugMode) {
248
- this.deviceLogging = this.accessory.context.logging = 'debugMode';
249
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
250
- } else if (device.logging) {
251
- this.deviceLogging = this.accessory.context.logging = device.logging;
252
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
253
- } else if (this.platform.config.options?.logging) {
254
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
255
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
256
- } else {
257
- this.deviceLogging = this.accessory.context.logging = 'standard';
258
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
259
- }
260
- }
261
-
262
- adaptiveLighting(device: device & devicesConfig) {
263
- if (device.colorbulb?.adaptiveLightingShift) {
264
- this.adaptiveLightingShift = device.colorbulb.adaptiveLightingShift;
265
- this.debugLog(`Color Bulb: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
266
- } else {
267
- this.adaptiveLightingShift = 0;
268
- this.debugLog(`Color Bulb: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
269
- }
270
- }
271
-
272
- private minStep(): number {
273
- if (this.device.colorbulb?.set_minStep) {
274
- this.set_minStep = this.device.colorbulb?.set_minStep;
275
- } else {
276
- this.set_minStep = 1;
277
- }
278
- return this.set_minStep;
279
- }
280
-
281
217
  parseStatus() {
282
218
  switch (this.power) {
283
219
  case 'on':
@@ -681,6 +617,73 @@ export class ColorBulb {
681
617
  this.doColorBulbUpdate.next();
682
618
  }
683
619
 
620
+ config(device: device & devicesConfig) {
621
+ let config = {};
622
+ if (device.colorbulb) {
623
+ config = device.colorbulb;
624
+ }
625
+ if (device.ble) {
626
+ config['ble'] = device.ble;
627
+ }
628
+ if (device.logging !== undefined) {
629
+ config['logging'] = device.logging;
630
+ }
631
+ if (device.refreshRate !== undefined) {
632
+ config['refreshRate'] = device.refreshRate;
633
+ }
634
+ if (device.scanDuration !== undefined) {
635
+ config['scanDuration'] = device.scanDuration;
636
+ }
637
+ if (config !== undefined) {
638
+ this.warnLog(`Color Bulb: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
639
+ }
640
+ }
641
+
642
+ refreshRate(device: device & devicesConfig) {
643
+ if (device.refreshRate) {
644
+ this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
645
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
646
+ } else if (this.platform.config.options!.refreshRate) {
647
+ this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
648
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
649
+ }
650
+ }
651
+
652
+ logs(device: device & devicesConfig) {
653
+ if (this.platform.debugMode) {
654
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
655
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
656
+ } else if (device.logging) {
657
+ this.deviceLogging = this.accessory.context.logging = device.logging;
658
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
659
+ } else if (this.platform.config.options?.logging) {
660
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
661
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
662
+ } else {
663
+ this.deviceLogging = this.accessory.context.logging = 'standard';
664
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
665
+ }
666
+ }
667
+
668
+ adaptiveLighting(device: device & devicesConfig) {
669
+ if (device.colorbulb?.adaptiveLightingShift) {
670
+ this.adaptiveLightingShift = device.colorbulb.adaptiveLightingShift;
671
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
672
+ } else {
673
+ this.adaptiveLightingShift = 0;
674
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
675
+ }
676
+ }
677
+
678
+ minStep(device: device & devicesConfig): number {
679
+ if (device.colorbulb?.set_minStep) {
680
+ this.set_minStep = device.colorbulb?.set_minStep;
681
+ } else {
682
+ this.set_minStep = 1;
683
+ }
684
+ return this.set_minStep;
685
+ }
686
+
684
687
  /**
685
688
  * Logging for Device
686
689
  */
@@ -155,83 +155,6 @@ export class Contact {
155
155
  });
156
156
  }
157
157
 
158
- config(device: device & devicesConfig) {
159
- const config: any = device.contact;
160
- if (device.ble !== undefined) {
161
- config['ble'] = device.ble;
162
- }
163
- if (device.logging !== undefined) {
164
- config['logging'] = device.logging;
165
- }
166
- if (device.refreshRate !== undefined) {
167
- config['refreshRate'] = device.refreshRate;
168
- }
169
- if (device.scanDuration !== undefined) {
170
- config['scanDuration'] = device.scanDuration;
171
- }
172
- if (config !== undefined) {
173
- this.warnLog(`Contact Sensor: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
174
- }
175
- }
176
-
177
- refreshRate(device: device & devicesConfig) {
178
- if (device.refreshRate) {
179
- this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
180
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
181
- } else if (this.platform.config.options!.refreshRate) {
182
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
183
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
184
- }
185
- }
186
-
187
- scan(device: device & devicesConfig) {
188
- if (device.scanDuration) {
189
- this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
190
- if (device.ble) {
191
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
192
- }
193
- } else {
194
- this.scanDuration = this.accessory.context.scanDuration = 1;
195
- if (this.device.ble) {
196
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
197
- }
198
- }
199
- }
200
-
201
- logs(device: device & devicesConfig) {
202
- if (this.platform.debugMode) {
203
- this.deviceLogging = this.accessory.context.logging = 'debugMode';
204
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
205
- } else if (device.logging) {
206
- this.deviceLogging = this.accessory.context.logging = device.logging;
207
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
208
- } else if (this.platform.config.options?.logging) {
209
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
210
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
211
- } else {
212
- this.deviceLogging = this.accessory.context.logging = 'standard';
213
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
214
- }
215
- }
216
-
217
- private minLux(): number {
218
- if (this.device.contact?.set_minLux) {
219
- this.set_minLux = this.device.contact!.set_minLux!;
220
- } else {
221
- this.set_minLux = 1;
222
- }
223
- return this.set_minLux;
224
- }
225
-
226
- private maxLux(): number {
227
- if (this.device.contact?.set_maxLux) {
228
- this.set_maxLux = this.device.contact!.set_maxLux!;
229
- } else {
230
- this.set_maxLux = 6001;
231
- }
232
- return this.set_maxLux;
233
- }
234
-
235
158
  /**
236
159
  * Parse the device status from the SwitchBot api
237
160
  */
@@ -243,7 +166,7 @@ export class Contact {
243
166
  }
244
167
  }
245
168
 
246
- private async BLEparseStatus() {
169
+ async BLEparseStatus() {
247
170
  this.debugLog(`Contact Sensor: ${this.accessory.displayName} BLE parseStatus`);
248
171
  // Door State
249
172
  switch (this.doorState) {
@@ -291,7 +214,7 @@ export class Contact {
291
214
  this.debugLog(`Contact Sensor: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, StatusLowBattery: ${this.StatusLowBattery}`);
292
215
  }
293
216
 
294
- private async openAPIparseStatus() {
217
+ async openAPIparseStatus() {
295
218
  if (this.device.ble) {
296
219
  this.SwitchToOpenAPI = false;
297
220
  }
@@ -501,6 +424,86 @@ export class Contact {
501
424
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
502
425
  }
503
426
 
427
+ config(device: device & devicesConfig) {
428
+ let config = {};
429
+ if (device.contact) {
430
+ config = device.contact;
431
+ }
432
+ if (device.ble) {
433
+ config['ble'] = device.ble;
434
+ }
435
+ if (device.logging !== undefined) {
436
+ config['logging'] = device.logging;
437
+ }
438
+ if (device.refreshRate !== undefined) {
439
+ config['refreshRate'] = device.refreshRate;
440
+ }
441
+ if (device.scanDuration !== undefined) {
442
+ config['scanDuration'] = device.scanDuration;
443
+ }
444
+ if (config !== undefined) {
445
+ this.warnLog(`Contact Sensor: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
446
+ }
447
+ }
448
+
449
+ refreshRate(device: device & devicesConfig) {
450
+ if (device.refreshRate) {
451
+ this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
452
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
453
+ } else if (this.platform.config.options!.refreshRate) {
454
+ this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
455
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
456
+ }
457
+ }
458
+
459
+ scan(device: device & devicesConfig) {
460
+ if (device.scanDuration) {
461
+ this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
462
+ if (device.ble) {
463
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
464
+ }
465
+ } else {
466
+ this.scanDuration = this.accessory.context.scanDuration = 1;
467
+ if (this.device.ble) {
468
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
469
+ }
470
+ }
471
+ }
472
+
473
+ logs(device: device & devicesConfig) {
474
+ if (this.platform.debugMode) {
475
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
476
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
477
+ } else if (device.logging) {
478
+ this.deviceLogging = this.accessory.context.logging = device.logging;
479
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
480
+ } else if (this.platform.config.options?.logging) {
481
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
482
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
483
+ } else {
484
+ this.deviceLogging = this.accessory.context.logging = 'standard';
485
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
486
+ }
487
+ }
488
+
489
+ private minLux(): number {
490
+ if (this.device.contact?.set_minLux) {
491
+ this.set_minLux = this.device.contact!.set_minLux!;
492
+ } else {
493
+ this.set_minLux = 1;
494
+ }
495
+ return this.set_minLux;
496
+ }
497
+
498
+ private maxLux(): number {
499
+ if (this.device.contact?.set_maxLux) {
500
+ this.set_maxLux = this.device.contact!.set_maxLux!;
501
+ } else {
502
+ this.set_maxLux = 6001;
503
+ }
504
+ return this.set_maxLux;
505
+ }
506
+
504
507
  /**
505
508
  * Logging for Device
506
509
  */