@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
@@ -64,11 +64,11 @@ export class Bot {
64
64
  public device: device & devicesConfig,
65
65
  ) {
66
66
  // default placeholders
67
- this.logs();
68
- this.scan();
69
- this.refreshRate();
70
- this.PressOrSwitch();
71
-
67
+ this.logs(device);
68
+ this.scan(device);
69
+ this.refreshRate(device);
70
+ this.PressOrSwitch(device);
71
+ this.config(device);
72
72
  if (this.On === undefined) {
73
73
  this.On = false;
74
74
  this.accessory.context.On = this.On;
@@ -84,10 +84,6 @@ export class Bot {
84
84
  this.BatteryLevel = 100;
85
85
  this.StatusLowBattery = 0;
86
86
 
87
- // Bot Config
88
- this.debugLog(`Bot: ${this.accessory.displayName} Config: (ble: ${device.ble}, offline: ${device.offline}, mode: ${device.bot?.mode},`
89
- + ` deviceType: ${device.bot?.deviceType}, doublePress: ${this.doublePress})`);
90
-
91
87
  // this is subject we use to track when we need to POST changes to the SwitchBot API
92
88
  this.doBotUpdate = new Subject();
93
89
  this.botUpdateInProgress = false;
@@ -377,159 +373,6 @@ export class Bot {
377
373
  });
378
374
  }
379
375
 
380
- public removeOutletService(accessory: PlatformAccessory) {
381
- // If outletService still pressent, then remove first
382
- this.outletService = this.accessory.getService(this.platform.Service.Outlet);
383
- if (this.outletService) {
384
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Outlet Service`);
385
- }
386
- accessory.removeService(this.outletService!);
387
- }
388
-
389
- public removeGarageDoorService(accessory: PlatformAccessory) {
390
- // If garageDoorService still pressent, then remove first
391
- this.garageDoorService = this.accessory.getService(this.platform.Service.GarageDoorOpener);
392
- if (this.garageDoorService) {
393
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Garage Door Service`);
394
- }
395
- accessory.removeService(this.garageDoorService!);
396
- }
397
-
398
- public removeDoorService(accessory: PlatformAccessory) {
399
- // If doorService still pressent, then remove first
400
- this.doorService = this.accessory.getService(this.platform.Service.Door);
401
- if (this.doorService) {
402
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Door Service`);
403
- }
404
- accessory.removeService(this.doorService!);
405
- }
406
-
407
- public removeLockService(accessory: PlatformAccessory) {
408
- // If lockService still pressent, then remove first
409
- this.lockService = this.accessory.getService(this.platform.Service.LockMechanism);
410
- if (this.lockService) {
411
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Lock Service`);
412
- }
413
- accessory.removeService(this.lockService!);
414
- }
415
-
416
- public removeFaucetService(accessory: PlatformAccessory) {
417
- // If faucetService still pressent, then remove first
418
- this.faucetService = this.accessory.getService(this.platform.Service.Faucet);
419
- if (this.faucetService) {
420
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Faucet Service`);
421
- }
422
- accessory.removeService(this.faucetService!);
423
- }
424
-
425
- public removeFanService(accessory: PlatformAccessory) {
426
- // If fanService still pressent, then remove first
427
- this.fanService = this.accessory.getService(this.platform.Service.Fan);
428
- if (this.fanService) {
429
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Fan Service`);
430
- }
431
- accessory.removeService(this.fanService!);
432
- }
433
-
434
- public removeWindowService(accessory: PlatformAccessory) {
435
- // If windowService still pressent, then remove first
436
- this.windowService = this.accessory.getService(this.platform.Service.Window);
437
- if (this.windowService) {
438
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Service`);
439
- }
440
- accessory.removeService(this.windowService!);
441
- }
442
-
443
- public removeWindowCoveringService(accessory: PlatformAccessory) {
444
- // If windowCoveringService still pressent, then remove first
445
- this.windowCoveringService = this.accessory.getService(this.platform.Service.WindowCovering);
446
- if (this.windowCoveringService) {
447
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Covering Service`);
448
- }
449
- accessory.removeService(this.windowCoveringService!);
450
- }
451
-
452
- public removeStatefulProgrammableSwitchService(accessory: PlatformAccessory) {
453
- // If statefulProgrammableSwitchService still pressent, then remove first
454
- this.statefulProgrammableSwitchService = this.accessory.getService(this.platform.Service.StatefulProgrammableSwitch);
455
- if (this.statefulProgrammableSwitchService) {
456
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
457
- }
458
- accessory.removeService(this.statefulProgrammableSwitchService!);
459
- }
460
-
461
- public removeSwitchService(accessory: PlatformAccessory) {
462
- // If switchService still pressent, then remove first
463
- this.switchService = this.accessory.getService(this.platform.Service.Switch);
464
- if (this.switchService) {
465
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Switch Service`);
466
- }
467
- accessory.removeService(this.switchService!);
468
- }
469
-
470
- refreshRate() {
471
- if (this.device.refreshRate) {
472
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
473
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
474
- this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
475
- }
476
- } else if (this.platform.config.options!.refreshRate) {
477
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
478
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
479
- this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
480
- }
481
- }
482
- }
483
-
484
- scan() {
485
- if (this.device.scanDuration) {
486
- this.scanDuration = this.accessory.context.scanDuration = this.device.scanDuration;
487
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
488
- this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
489
- }
490
- } else {
491
- this.scanDuration = this.accessory.context.scanDuration = 1;
492
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
493
- this.warnLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
494
- }
495
- }
496
- }
497
-
498
- logs() {
499
- if (this.platform.debugMode) {
500
- this.deviceLogging = this.accessory.context.logging = 'debug';
501
- this.warnLog(`Bot: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
502
- } else if (this.device.logging) {
503
- this.deviceLogging = this.accessory.context.logging = this.device.logging;
504
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
505
- this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
506
- }
507
- } else if (this.platform.config.options?.logging) {
508
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
509
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
510
- this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
511
- }
512
- } else {
513
- this.deviceLogging = this.accessory.context.logging = 'standard';
514
- }
515
- }
516
-
517
- PressOrSwitch() {
518
- if (!this.device.bot?.mode) {
519
- this.botMode = 'switch';
520
- this.warnLog(`Bot: ${this.accessory.displayName} does not have bot mode set in the Plugin's SwitchBot Device Settings,`);
521
- this.warnLog(`Bot: ${this.accessory.displayName} is defaulting to "${this.botMode}" mode, you may experience issues.`);
522
- } else if (this.device.bot?.mode === 'switch') {
523
- this.botMode = 'switch';
524
- this.infoLog(`Bot: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
525
- } else if (this.device.bot?.mode === 'press') {
526
- this.botMode = 'press';
527
- this.infoLog(`Bot: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
528
- } else {
529
- throw new Error(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
530
- }
531
- }
532
-
533
376
  /**
534
377
  * Parse the device status from the SwitchBot api
535
378
  */
@@ -1170,6 +1013,171 @@ export class Bot {
1170
1013
  this.doBotUpdate.next();
1171
1014
  }
1172
1015
 
1016
+ config(device: device & devicesConfig) {
1017
+ const config: any = device.bot;
1018
+ if (device.ble) {
1019
+ config['ble'] = device.ble;
1020
+ }
1021
+ if (device.logging !== undefined) {
1022
+ config['logging'] = device.logging;
1023
+ }
1024
+ if (device.refreshRate !== undefined) {
1025
+ config['refreshRate'] = device.refreshRate;
1026
+ }
1027
+ if (device.scanDuration !== undefined) {
1028
+ config['scanDuration'] = device.scanDuration;
1029
+ }
1030
+ if (config !== undefined) {
1031
+ this.warnLog(`Bot: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
1032
+ }
1033
+ }
1034
+
1035
+ refreshRate(device: device & devicesConfig) {
1036
+ if (device.refreshRate) {
1037
+ this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
1038
+ this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
1039
+ } else if (this.platform.config.options!.refreshRate) {
1040
+ this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
1041
+ this.debugLog(`Bot: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
1042
+ }
1043
+ }
1044
+
1045
+ scan(device: device & devicesConfig) {
1046
+ if (device.scanDuration) {
1047
+ this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
1048
+ if (device.ble) {
1049
+ this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
1050
+ }
1051
+ } else {
1052
+ this.scanDuration = this.accessory.context.scanDuration = 1;
1053
+ if (this.device.ble) {
1054
+ this.debugLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
1055
+ }
1056
+ }
1057
+ }
1058
+
1059
+ logs(device: device & devicesConfig) {
1060
+ if (this.platform.debugMode) {
1061
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
1062
+ this.debugLog(`Bot: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
1063
+ } else if (device.logging) {
1064
+ this.deviceLogging = this.accessory.context.logging = device.logging;
1065
+ this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
1066
+ } else if (this.platform.config.options?.logging) {
1067
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
1068
+ this.debugLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
1069
+ } else {
1070
+ this.deviceLogging = this.accessory.context.logging = 'standard';
1071
+ this.debugLog(`Bot: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
1072
+ }
1073
+ }
1074
+
1075
+ PressOrSwitch(device: device & devicesConfig) {
1076
+ if (!device.bot?.mode) {
1077
+ this.botMode = 'switch';
1078
+ this.warnLog(`Bot: ${this.accessory.displayName} does not have bot mode set in the Plugin's SwitchBot Device Settings,`);
1079
+ this.warnLog(`Bot: ${this.accessory.displayName} is defaulting to "${this.botMode}" mode, you may experience issues.`);
1080
+ } else if (device.bot?.mode === 'switch') {
1081
+ this.botMode = 'switch';
1082
+ this.debugLog(`Bot: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
1083
+ } else if (device.bot?.mode === 'press') {
1084
+ this.botMode = 'press';
1085
+ this.debugLog(`Bot: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
1086
+ } else {
1087
+ throw new Error(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
1088
+ }
1089
+ }
1090
+
1091
+ public removeOutletService(accessory: PlatformAccessory) {
1092
+ // If outletService still pressent, then remove first
1093
+ this.outletService = this.accessory.getService(this.platform.Service.Outlet);
1094
+ if (this.outletService) {
1095
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Outlet Service`);
1096
+ }
1097
+ accessory.removeService(this.outletService!);
1098
+ }
1099
+
1100
+ public removeGarageDoorService(accessory: PlatformAccessory) {
1101
+ // If garageDoorService still pressent, then remove first
1102
+ this.garageDoorService = this.accessory.getService(this.platform.Service.GarageDoorOpener);
1103
+ if (this.garageDoorService) {
1104
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Garage Door Service`);
1105
+ }
1106
+ accessory.removeService(this.garageDoorService!);
1107
+ }
1108
+
1109
+ public removeDoorService(accessory: PlatformAccessory) {
1110
+ // If doorService still pressent, then remove first
1111
+ this.doorService = this.accessory.getService(this.platform.Service.Door);
1112
+ if (this.doorService) {
1113
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Door Service`);
1114
+ }
1115
+ accessory.removeService(this.doorService!);
1116
+ }
1117
+
1118
+ public removeLockService(accessory: PlatformAccessory) {
1119
+ // If lockService still pressent, then remove first
1120
+ this.lockService = this.accessory.getService(this.platform.Service.LockMechanism);
1121
+ if (this.lockService) {
1122
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Lock Service`);
1123
+ }
1124
+ accessory.removeService(this.lockService!);
1125
+ }
1126
+
1127
+ public removeFaucetService(accessory: PlatformAccessory) {
1128
+ // If faucetService still pressent, then remove first
1129
+ this.faucetService = this.accessory.getService(this.platform.Service.Faucet);
1130
+ if (this.faucetService) {
1131
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Faucet Service`);
1132
+ }
1133
+ accessory.removeService(this.faucetService!);
1134
+ }
1135
+
1136
+ public removeFanService(accessory: PlatformAccessory) {
1137
+ // If fanService still pressent, then remove first
1138
+ this.fanService = this.accessory.getService(this.platform.Service.Fan);
1139
+ if (this.fanService) {
1140
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Fan Service`);
1141
+ }
1142
+ accessory.removeService(this.fanService!);
1143
+ }
1144
+
1145
+ public removeWindowService(accessory: PlatformAccessory) {
1146
+ // If windowService still pressent, then remove first
1147
+ this.windowService = this.accessory.getService(this.platform.Service.Window);
1148
+ if (this.windowService) {
1149
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Service`);
1150
+ }
1151
+ accessory.removeService(this.windowService!);
1152
+ }
1153
+
1154
+ public removeWindowCoveringService(accessory: PlatformAccessory) {
1155
+ // If windowCoveringService still pressent, then remove first
1156
+ this.windowCoveringService = this.accessory.getService(this.platform.Service.WindowCovering);
1157
+ if (this.windowCoveringService) {
1158
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Covering Service`);
1159
+ }
1160
+ accessory.removeService(this.windowCoveringService!);
1161
+ }
1162
+
1163
+ public removeStatefulProgrammableSwitchService(accessory: PlatformAccessory) {
1164
+ // If statefulProgrammableSwitchService still pressent, then remove first
1165
+ this.statefulProgrammableSwitchService = this.accessory.getService(this.platform.Service.StatefulProgrammableSwitch);
1166
+ if (this.statefulProgrammableSwitchService) {
1167
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
1168
+ }
1169
+ accessory.removeService(this.statefulProgrammableSwitchService!);
1170
+ }
1171
+
1172
+ public removeSwitchService(accessory: PlatformAccessory) {
1173
+ // If switchService still pressent, then remove first
1174
+ this.switchService = this.accessory.getService(this.platform.Service.Switch);
1175
+ if (this.switchService) {
1176
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Switch Service`);
1177
+ }
1178
+ accessory.removeService(this.switchService!);
1179
+ }
1180
+
1173
1181
  /**
1174
1182
  * Logging for Device
1175
1183
  */
@@ -58,9 +58,10 @@ export class ColorBulb {
58
58
  public device: device & devicesConfig,
59
59
  ) {
60
60
  // default placeholders
61
- this.logs();
62
- this.refreshRate();
63
- this.adaptiveLighting();
61
+ this.logs(device);
62
+ this.refreshRate(device);
63
+ this.adaptiveLighting(device);
64
+ this.config(device);
64
65
  if (this.On === undefined) {
65
66
  this.On = false;
66
67
  } else {
@@ -72,11 +73,6 @@ export class ColorBulb {
72
73
  this.ColorTemperature = 140;
73
74
  this.minKelvin = 2000;
74
75
  this.maxKelvin = 9000;
75
-
76
- // ColorBulb Config
77
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Config: (ble: ${device.ble}, set_minStep: ${device.colorbulb?.set_minStep},`
78
- + ` adaptiveLighting: ${device.colorbulb?.adaptiveLightingShift})`);
79
-
80
76
  // this is subject we use to track when we need to POST changes to the SwitchBot API
81
77
  this.doColorBulbUpdate = new Subject();
82
78
  this.colorBulbUpdateInProgress = false;
@@ -121,7 +117,7 @@ export class ColorBulb {
121
117
  // handle Brightness events using the Brightness characteristic
122
118
  this.service.getCharacteristic(this.platform.Characteristic.Brightness)
123
119
  .setProps({
124
- minStep: this.minStep(),
120
+ minStep: this.minStep(device),
125
121
  minValue: 0,
126
122
  maxValue: 100,
127
123
  validValueRanges: [0, 100],
@@ -218,58 +214,6 @@ export class ColorBulb {
218
214
  });
219
215
  }
220
216
 
221
- refreshRate() {
222
- if (this.device.refreshRate) {
223
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
224
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
225
- this.warnLog(`Color Bulb: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
226
- }
227
- } else if (this.platform.config.options!.refreshRate) {
228
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
229
- if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
230
- this.warnLog(`Color Bulb: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
231
- }
232
- }
233
- }
234
-
235
- logs() {
236
- if (this.platform.debugMode) {
237
- this.deviceLogging = this.accessory.context.logging = 'debug';
238
- this.warnLog(`Color Bulb: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
239
- } else if (this.device.logging) {
240
- this.deviceLogging = this.accessory.context.logging = this.device.logging;
241
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
242
- this.warnLog(`Color Bulb: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
243
- }
244
- } else if (this.platform.config.options?.logging) {
245
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
246
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
247
- this.warnLog(`Color Bulb: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
248
- }
249
- } else {
250
- this.deviceLogging = this.accessory.context.logging = 'standard';
251
- }
252
- }
253
-
254
- adaptiveLighting() {
255
- if (this.device.colorbulb?.adaptiveLightingShift) {
256
- this.adaptiveLightingShift = this.device.colorbulb.adaptiveLightingShift;
257
- this.debugLog(`Color Bulb: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
258
- } else {
259
- this.adaptiveLightingShift = 0;
260
- this.debugLog(`Color Bulb: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
261
- }
262
- }
263
-
264
- private minStep(): number {
265
- if (this.device.colorbulb?.set_minStep) {
266
- this.set_minStep = this.device.colorbulb?.set_minStep;
267
- } else {
268
- this.set_minStep = 1;
269
- }
270
- return this.set_minStep;
271
- }
272
-
273
217
  parseStatus() {
274
218
  switch (this.power) {
275
219
  case 'on':
@@ -673,6 +617,70 @@ export class ColorBulb {
673
617
  this.doColorBulbUpdate.next();
674
618
  }
675
619
 
620
+ config(device: device & devicesConfig) {
621
+ const config: any = device.colorbulb;
622
+ if (device.ble) {
623
+ config['ble'] = device.ble;
624
+ }
625
+ if (device.logging !== undefined) {
626
+ config['logging'] = device.logging;
627
+ }
628
+ if (device.refreshRate !== undefined) {
629
+ config['refreshRate'] = device.refreshRate;
630
+ }
631
+ if (device.scanDuration !== undefined) {
632
+ config['scanDuration'] = device.scanDuration;
633
+ }
634
+ if (config !== undefined) {
635
+ this.warnLog(`Color Bulb: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
636
+ }
637
+ }
638
+
639
+ refreshRate(device: device & devicesConfig) {
640
+ if (device.refreshRate) {
641
+ this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
642
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
643
+ } else if (this.platform.config.options!.refreshRate) {
644
+ this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
645
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
646
+ }
647
+ }
648
+
649
+ logs(device: device & devicesConfig) {
650
+ if (this.platform.debugMode) {
651
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
652
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
653
+ } else if (device.logging) {
654
+ this.deviceLogging = this.accessory.context.logging = device.logging;
655
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
656
+ } else if (this.platform.config.options?.logging) {
657
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
658
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
659
+ } else {
660
+ this.deviceLogging = this.accessory.context.logging = 'standard';
661
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
662
+ }
663
+ }
664
+
665
+ adaptiveLighting(device: device & devicesConfig) {
666
+ if (device.colorbulb?.adaptiveLightingShift) {
667
+ this.adaptiveLightingShift = device.colorbulb.adaptiveLightingShift;
668
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
669
+ } else {
670
+ this.adaptiveLightingShift = 0;
671
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
672
+ }
673
+ }
674
+
675
+ minStep(device: device & devicesConfig): number {
676
+ if (device.colorbulb?.set_minStep) {
677
+ this.set_minStep = device.colorbulb?.set_minStep;
678
+ } else {
679
+ this.set_minStep = 1;
680
+ }
681
+ return this.set_minStep;
682
+ }
683
+
676
684
  /**
677
685
  * Logging for Device
678
686
  */