@switchbot/homebridge-switchbot 1.8.1-beta.3 → 1.8.2-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 (61) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/devices/bots.js +1 -1
  3. package/dist/devices/bots.js.map +1 -1
  4. package/dist/devices/colorbulb.js +1 -1
  5. package/dist/devices/colorbulb.js.map +1 -1
  6. package/dist/devices/contact.js +1 -1
  7. package/dist/devices/contact.js.map +1 -1
  8. package/dist/devices/curtains.js +1 -1
  9. package/dist/devices/curtains.js.map +1 -1
  10. package/dist/devices/humidifiers.js +1 -1
  11. package/dist/devices/humidifiers.js.map +1 -1
  12. package/dist/devices/meters.js +1 -1
  13. package/dist/devices/meters.js.map +1 -1
  14. package/dist/devices/motion.js +1 -1
  15. package/dist/devices/motion.js.map +1 -1
  16. package/dist/devices/plugs.js +1 -1
  17. package/dist/devices/plugs.js.map +1 -1
  18. package/dist/irdevices/airconditioners.js +1 -1
  19. package/dist/irdevices/airconditioners.js.map +1 -1
  20. package/dist/irdevices/airpurifiers.js +1 -1
  21. package/dist/irdevices/airpurifiers.js.map +1 -1
  22. package/dist/irdevices/cameras.js +1 -1
  23. package/dist/irdevices/cameras.js.map +1 -1
  24. package/dist/irdevices/fans.js +1 -1
  25. package/dist/irdevices/fans.js.map +1 -1
  26. package/dist/irdevices/lights.js +1 -1
  27. package/dist/irdevices/lights.js.map +1 -1
  28. package/dist/irdevices/others.js +1 -1
  29. package/dist/irdevices/others.js.map +1 -1
  30. package/dist/irdevices/tvs.js +1 -1
  31. package/dist/irdevices/tvs.js.map +1 -1
  32. package/dist/irdevices/vacuumcleaners.js +1 -1
  33. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  34. package/dist/irdevices/waterheaters.js +1 -1
  35. package/dist/irdevices/waterheaters.js.map +1 -1
  36. package/dist/platform.d.ts +1 -1
  37. package/dist/platform.d.ts.map +1 -1
  38. package/dist/platform.js +44 -28
  39. package/dist/platform.js.map +1 -1
  40. package/dist/settings.d.ts +1 -1
  41. package/dist/settings.d.ts.map +1 -1
  42. package/package.json +1 -1
  43. package/src/devices/bots.ts +1 -1
  44. package/src/devices/colorbulb.ts +1 -1
  45. package/src/devices/contact.ts +1 -1
  46. package/src/devices/curtains.ts +1 -1
  47. package/src/devices/humidifiers.ts +1 -1
  48. package/src/devices/meters.ts +1 -1
  49. package/src/devices/motion.ts +1 -1
  50. package/src/devices/plugs.ts +1 -1
  51. package/src/irdevices/airconditioners.ts +1 -1
  52. package/src/irdevices/airpurifiers.ts +1 -1
  53. package/src/irdevices/cameras.ts +1 -1
  54. package/src/irdevices/fans.ts +1 -1
  55. package/src/irdevices/lights.ts +1 -1
  56. package/src/irdevices/others.ts +1 -1
  57. package/src/irdevices/tvs.ts +1 -1
  58. package/src/irdevices/vacuumcleaners.ts +1 -1
  59. package/src/irdevices/waterheaters.ts +1 -1
  60. package/src/platform.ts +45 -29
  61. package/src/settings.ts +1 -1
@@ -191,7 +191,7 @@ export class WaterHeater {
191
191
  if (device.logging !== undefined) {
192
192
  config['logging'] = device.logging;
193
193
  }
194
- if (config !== undefined) {
194
+ if (Object.entries(config).length !== 0) {
195
195
  this.warnLog(`Water Heater: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
196
196
  }
197
197
  }
package/src/platform.ts CHANGED
@@ -97,17 +97,19 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
97
97
  this.debugMode = process.argv.includes('-D') || process.argv.includes('--debug');
98
98
  if (this.config.options?.logging === 'debug' || this.config.options?.logging === 'standard' || this.config.options?.logging === 'none') {
99
99
  this.platformLogging = this.config.options!.logging;
100
- if (this.debugMode) {
100
+ if (this.platformLogging.includes('debug')) {
101
101
  this.log.warn(`Using Config Logging: ${this.platformLogging}`);
102
102
  }
103
103
  } else if (this.debugMode) {
104
- if (this.debugMode) {
105
- this.log.warn('Using debugMode Logging');
106
- }
107
104
  this.platformLogging = 'debugMode';
105
+ if (this.platformLogging?.includes('debug')) {
106
+ this.log.warn(`Using ${this.platformLogging} Logging`);
107
+ }
108
108
  } else {
109
- this.log.warn('Using Standard Logging');
110
109
  this.platformLogging = 'standard';
110
+ if (this.platformLogging?.includes('debug')) {
111
+ this.log.warn(`Using ${this.platformLogging} Logging`);
112
+ }
111
113
  }
112
114
  }
113
115
 
@@ -126,14 +128,23 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
126
128
  * Verify the config passed to the plugin is valid
127
129
  */
128
130
  verifyConfig() {
129
- /**
130
- * Hidden Device Discovery Option
131
- * This will disable adding any device and will just output info.
132
- */
133
131
  this.config.options = this.config.options || {};
134
132
 
135
- if (this.config.options) {
133
+ const platformConfig = {};
134
+ if (this.config.options?.logging) {
135
+ platformConfig['logging'] = this.config.options?.logging;
136
+ }
137
+ if (this.config.options?.logging) {
138
+ platformConfig['refreshRate'] = this.config.options?.refreshRate;
139
+ }
140
+ if (this.config.options?.logging) {
141
+ platformConfig['pushRate'] = this.config.options?.pushRate;
142
+ }
143
+ if (Object.entries(platformConfig).length !== 0) {
144
+ this.warnLog(`Platform Config: ${JSON.stringify(platformConfig)}`);
145
+ }
136
146
 
147
+ if (this.config.options) {
137
148
  // Device Config
138
149
  if (this.config.options.devices) {
139
150
  for (const deviceConfig of this.config.options.devices) {
@@ -170,41 +181,32 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
170
181
  if (!this.config.options.refreshRate) {
171
182
  // default 120 seconds (2 minutes)
172
183
  this.config.options!.refreshRate! = 120;
173
- if (this.debugMode) {
174
- this.warnLog('Using Default Refresh Rate (2 minutes).');
184
+ if (this.platformLogging?.includes('debug')) {
185
+ this.debugLog('Using Default Refresh Rate (2 minutes).');
175
186
  }
176
187
 
177
188
  if (!this.config.options.pushRate) {
178
189
  // default 100 milliseconds
179
190
  this.config.options!.pushRate! = 0.1;
180
- if (this.debugMode) {
191
+ if (this.platformLogging?.includes('debug')) {
181
192
  this.warnLog('Using Default Push Rate.');
182
193
  }
183
194
  }
184
195
 
185
196
  if (!this.config.credentials) {
186
- this.debugLog('Missing Credentials');
197
+ if (this.platformLogging?.includes('debug')) {
198
+ this.debugLog('Missing Credentials');
199
+ }
187
200
  }
188
201
  if (!this.config.credentials?.openToken) {
189
- this.errorLog('Missing openToken');
190
- this.warnLog('Cloud Enabled SwitchBot Devices & IR Devices will not work');
202
+ if (this.platformLogging?.includes('debug')) {
203
+ this.errorLog('Missing openToken');
204
+ this.warnLog('Cloud Enabled SwitchBot Devices & IR Devices will not work');
205
+ }
191
206
  }
192
207
  }
193
208
  }
194
209
 
195
- connectBLE() {
196
- let Switchbot: new () => any;
197
- let switchbot: any;
198
- try {
199
- Switchbot = require('node-switchbot');
200
- switchbot = new Switchbot();
201
- } catch (e) {
202
- switchbot = false;
203
- this.errorLog(`Was 'node-switchbot' found: ${switchbot}`);
204
- }
205
- return switchbot;
206
- }
207
-
208
210
  /**
209
211
  * this method discovers devices
210
212
  */
@@ -1499,6 +1501,20 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1499
1501
  }
1500
1502
  }
1501
1503
 
1504
+ // BLE Connection
1505
+ connectBLE() {
1506
+ let Switchbot: new () => any;
1507
+ let switchbot: any;
1508
+ try {
1509
+ Switchbot = require('node-switchbot');
1510
+ switchbot = new Switchbot();
1511
+ } catch (e) {
1512
+ switchbot = false;
1513
+ this.errorLog(`Was 'node-switchbot' found: ${switchbot}`);
1514
+ }
1515
+ return switchbot;
1516
+ }
1517
+
1502
1518
  /**
1503
1519
  * If device level logging is turned on, log to log.warn
1504
1520
  * Otherwise send debug logs to log.debug
package/src/settings.ts CHANGED
@@ -51,7 +51,7 @@ export interface devicesConfig extends device {
51
51
  motion?: motion;
52
52
  colorbulb?: colorbulb;
53
53
  plug?: Record<any, any>;
54
- ble?: string;
54
+ ble?: boolean;
55
55
  scanDuration?: number;
56
56
  hide_device?: boolean;
57
57
  offline?: boolean;