@switchbot/homebridge-switchbot 1.4.0 → 1.4.1-beta.3

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 (103) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/config.schema.json +83 -11
  3. package/dist/devices/bots.d.ts +13 -3
  4. package/dist/devices/bots.d.ts.map +1 -1
  5. package/dist/devices/bots.js +162 -105
  6. package/dist/devices/bots.js.map +1 -1
  7. package/dist/devices/colorbulb.d.ts +13 -3
  8. package/dist/devices/colorbulb.d.ts.map +1 -1
  9. package/dist/devices/colorbulb.js +161 -96
  10. package/dist/devices/colorbulb.js.map +1 -1
  11. package/dist/devices/contact.d.ts +13 -3
  12. package/dist/devices/contact.d.ts.map +1 -1
  13. package/dist/devices/contact.js +117 -63
  14. package/dist/devices/contact.js.map +1 -1
  15. package/dist/devices/curtains.d.ts +14 -5
  16. package/dist/devices/curtains.d.ts.map +1 -1
  17. package/dist/devices/curtains.js +198 -140
  18. package/dist/devices/curtains.js.map +1 -1
  19. package/dist/devices/humidifiers.d.ts +13 -3
  20. package/dist/devices/humidifiers.d.ts.map +1 -1
  21. package/dist/devices/humidifiers.js +180 -127
  22. package/dist/devices/humidifiers.js.map +1 -1
  23. package/dist/devices/meters.d.ts +13 -3
  24. package/dist/devices/meters.d.ts.map +1 -1
  25. package/dist/devices/meters.js +121 -63
  26. package/dist/devices/meters.js.map +1 -1
  27. package/dist/devices/motion.d.ts +13 -3
  28. package/dist/devices/motion.d.ts.map +1 -1
  29. package/dist/devices/motion.js +104 -45
  30. package/dist/devices/motion.js.map +1 -1
  31. package/dist/devices/plugs.d.ts +13 -3
  32. package/dist/devices/plugs.d.ts.map +1 -1
  33. package/dist/devices/plugs.js +99 -35
  34. package/dist/devices/plugs.js.map +1 -1
  35. package/dist/irdevices/airconditioners.d.ts +11 -3
  36. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  37. package/dist/irdevices/airconditioners.js +80 -45
  38. package/dist/irdevices/airconditioners.js.map +1 -1
  39. package/dist/irdevices/airpurifiers.d.ts +11 -3
  40. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  41. package/dist/irdevices/airpurifiers.js +68 -31
  42. package/dist/irdevices/airpurifiers.js.map +1 -1
  43. package/dist/irdevices/cameras.d.ts +11 -3
  44. package/dist/irdevices/cameras.d.ts.map +1 -1
  45. package/dist/irdevices/cameras.js +64 -24
  46. package/dist/irdevices/cameras.js.map +1 -1
  47. package/dist/irdevices/fans.d.ts +11 -3
  48. package/dist/irdevices/fans.d.ts.map +1 -1
  49. package/dist/irdevices/fans.js +74 -35
  50. package/dist/irdevices/fans.js.map +1 -1
  51. package/dist/irdevices/lights.d.ts +11 -3
  52. package/dist/irdevices/lights.d.ts.map +1 -1
  53. package/dist/irdevices/lights.js +65 -25
  54. package/dist/irdevices/lights.js.map +1 -1
  55. package/dist/irdevices/others.d.ts +11 -3
  56. package/dist/irdevices/others.d.ts.map +1 -1
  57. package/dist/irdevices/others.js +71 -31
  58. package/dist/irdevices/others.js.map +1 -1
  59. package/dist/irdevices/tvs.d.ts +11 -3
  60. package/dist/irdevices/tvs.d.ts.map +1 -1
  61. package/dist/irdevices/tvs.js +81 -42
  62. package/dist/irdevices/tvs.js.map +1 -1
  63. package/dist/irdevices/vacuumcleaners.d.ts +11 -3
  64. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  65. package/dist/irdevices/vacuumcleaners.js +64 -24
  66. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  67. package/dist/irdevices/waterheaters.d.ts +11 -3
  68. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  69. package/dist/irdevices/waterheaters.js +64 -24
  70. package/dist/irdevices/waterheaters.js.map +1 -1
  71. package/dist/platform.d.ts +10 -10
  72. package/dist/platform.d.ts.map +1 -1
  73. package/dist/platform.js +290 -307
  74. package/dist/platform.js.map +1 -1
  75. package/dist/settings.d.ts +4 -1
  76. package/dist/settings.d.ts.map +1 -1
  77. package/dist/settings.js.map +1 -1
  78. package/nodemon.json +1 -1
  79. package/package.json +70 -66
  80. package/src/devices/bots.ts +169 -105
  81. package/src/devices/colorbulb.ts +170 -99
  82. package/src/devices/contact.ts +124 -64
  83. package/src/devices/curtains.ts +207 -145
  84. package/src/devices/humidifiers.ts +187 -129
  85. package/src/devices/meters.ts +128 -64
  86. package/src/devices/motion.ts +110 -45
  87. package/src/devices/plugs.ts +104 -36
  88. package/src/irdevices/airconditioners.ts +85 -45
  89. package/src/irdevices/airpurifiers.ts +73 -31
  90. package/src/irdevices/cameras.ts +69 -24
  91. package/src/irdevices/fans.ts +79 -36
  92. package/src/irdevices/lights.ts +70 -25
  93. package/src/irdevices/others.ts +76 -31
  94. package/src/irdevices/tvs.ts +86 -42
  95. package/src/irdevices/vacuumcleaners.ts +69 -24
  96. package/src/irdevices/waterheaters.ts +69 -24
  97. package/src/platform.ts +285 -302
  98. package/src/settings.ts +4 -1
  99. package/dist/devices/indoorcam.d.ts +0 -64
  100. package/dist/devices/indoorcam.d.ts.map +0 -1
  101. package/dist/devices/indoorcam.js +0 -249
  102. package/dist/devices/indoorcam.js.map +0 -1
  103. package/src/devices/indoorcam.ts +0 -309
package/dist/platform.js CHANGED
@@ -11,7 +11,6 @@ const motion_1 = require("./devices/motion");
11
11
  const contact_1 = require("./devices/contact");
12
12
  const curtains_1 = require("./devices/curtains");
13
13
  const colorbulb_1 = require("./devices/colorbulb");
14
- const indoorcam_1 = require("./devices/indoorcam");
15
14
  const humidifiers_1 = require("./devices/humidifiers");
16
15
  const tvs_1 = require("./irdevices/tvs");
17
16
  const fans_1 = require("./irdevices/fans");
@@ -41,9 +40,9 @@ class SwitchBotPlatform {
41
40
  this.axios = axios_1.default.create({
42
41
  responseType: 'json',
43
42
  });
44
- // debugMode!: boolean;
45
43
  this.version = require('../package.json').version; // eslint-disable-line @typescript-eslint/no-var-requires
46
- this.log.debug('Finished initializing platform:', this.config.name);
44
+ this.logs();
45
+ this.debugLog('Finished initializing platform:', this.config.name);
47
46
  // only load if configured
48
47
  if (!this.config) {
49
48
  return;
@@ -56,14 +55,15 @@ class SwitchBotPlatform {
56
55
  // verify the config
57
56
  try {
58
57
  this.verifyConfig();
59
- this.log.debug('Config OK');
58
+ this.debugLog('Config OK');
60
59
  }
61
60
  catch (e) {
62
- this.log.error(JSON.stringify(e.message));
63
- this.log.debug(JSON.stringify(e));
61
+ this.errorLog(JSON.stringify(e.message));
62
+ if (this.platformLogging === 'debugMode') {
63
+ this.errorLog(JSON.stringify(e));
64
+ }
64
65
  return;
65
66
  }
66
- this.debugMode = process.argv.includes('-D') || process.argv.includes('--debug');
67
67
  // setup axios interceptor to add headers / api key to each request
68
68
  this.axios.interceptors.request.use((request) => {
69
69
  request.headers.Authorization = this.config.credentials?.openToken;
@@ -75,23 +75,44 @@ class SwitchBotPlatform {
75
75
  // in order to ensure they weren't added to homebridge already. This event can also be used
76
76
  // to start discovery of new accessories.
77
77
  this.api.on('didFinishLaunching', async () => {
78
- log.debug('Executed didFinishLaunching callback');
78
+ this.debugLog('Executed didFinishLaunching callback');
79
79
  // run the method to discover / register your devices as accessories
80
80
  try {
81
81
  this.discoverDevices();
82
82
  }
83
83
  catch (e) {
84
- this.log.error('Failed to Discover Devices.', JSON.stringify(e.message));
85
- this.log.debug(JSON.stringify(e));
84
+ this.errorLog('Failed to Discover Devices.', JSON.stringify(e.message));
85
+ if (this.platformLogging === 'debugMode') {
86
+ this.errorLog(JSON.stringify(e));
87
+ }
86
88
  }
87
89
  });
88
90
  }
91
+ logs() {
92
+ this.debugMode = process.argv.includes('-D') || process.argv.includes('--debug');
93
+ if (this.config.options?.logging === 'debug' || this.config.options?.logging === 'standard' || this.config.options?.logging === 'none') {
94
+ this.platformLogging = this.config.options.logging;
95
+ if (this.debugMode) {
96
+ this.log.warn(`Using Config Logging: ${this.platformLogging}`);
97
+ }
98
+ }
99
+ else if (this.debugMode) {
100
+ if (this.debugMode) {
101
+ this.log.warn('Using debugMode Logging');
102
+ }
103
+ this.platformLogging = 'debugMode';
104
+ }
105
+ else {
106
+ this.log.warn('Using Standard Logging');
107
+ this.platformLogging = 'standard';
108
+ }
109
+ }
89
110
  /**
90
111
  * This function is invoked when homebridge restores cached accessories from disk at startup.
91
112
  * It should be used to setup event handlers for characteristics and update respective values.
92
113
  */
93
114
  configureAccessory(accessory) {
94
- this.log.info('Loading accessory from cache:', accessory.displayName);
115
+ this.infoLog(`Loading accessory from cache: ${accessory.displayName}`);
95
116
  // add the restored accessory to the accessories cache so we can track if it has already been registered
96
117
  this.accessories.push(accessory);
97
118
  }
@@ -104,7 +125,6 @@ class SwitchBotPlatform {
104
125
  * This will disable adding any device and will just output info.
105
126
  */
106
127
  this.config.options = this.config.options || {};
107
- this.config.options.debug;
108
128
  if (this.config.options) {
109
129
  // Device Config
110
130
  if (this.config.options.devices) {
@@ -118,7 +138,7 @@ class SwitchBotPlatform {
118
138
  }
119
139
  if (deviceConfig.bot) {
120
140
  if (!deviceConfig.bot?.mode) {
121
- this.log.error('You must set your Bot to Press or Switch Mode');
141
+ this.errorLog('You must set your Bot to Press or Switch Mode');
122
142
  }
123
143
  }
124
144
  }
@@ -129,10 +149,10 @@ class SwitchBotPlatform {
129
149
  for (const irDeviceConfig of this.config.options.irdevices) {
130
150
  if (!irDeviceConfig.hide_device) {
131
151
  if (!irDeviceConfig.deviceId) {
132
- this.log.error('The devices config section is missing the *Device ID* in the config, Check Your Conifg.');
152
+ this.errorLog('The devices config section is missing the *Device ID* in the config, Check Your Conifg.');
133
153
  }
134
154
  if (!irDeviceConfig.deviceId && !irDeviceConfig.configRemoteType) {
135
- this.log.error('The devices config section is missing the *Device Type* in the config, Check Your Conifg.');
155
+ this.errorLog('The devices config section is missing the *Device Type* in the config, Check Your Conifg.');
136
156
  }
137
157
  }
138
158
  }
@@ -144,19 +164,23 @@ class SwitchBotPlatform {
144
164
  if (!this.config.options.refreshRate) {
145
165
  // default 120 seconds (2 minutes)
146
166
  this.config.options.refreshRate = 120;
147
- this.log.warn('Using Default Refresh Rate (2 minutes).');
148
- }
149
- if (!this.config.options.pushRate) {
150
- // default 100 milliseconds
151
- this.config.options.pushRate = 0.1;
152
- this.log.warn('Using Default Push Rate.');
153
- }
154
- if (!this.config.credentials) {
155
- this.debug('Missing Credentials');
156
- }
157
- if (!this.config.credentials?.openToken) {
158
- this.log.error('Missing openToken');
159
- this.log.warn('Cloud Enabled SwitchBot Devices & IR Devices will not work');
167
+ if (this.debugMode) {
168
+ this.warnLog('Using Default Refresh Rate (2 minutes).');
169
+ }
170
+ if (!this.config.options.pushRate) {
171
+ // default 100 milliseconds
172
+ this.config.options.pushRate = 0.1;
173
+ if (this.debugMode) {
174
+ this.warnLog('Using Default Push Rate.');
175
+ }
176
+ }
177
+ if (!this.config.credentials) {
178
+ this.debugLog('Missing Credentials');
179
+ }
180
+ if (!this.config.credentials?.openToken) {
181
+ this.errorLog('Missing openToken');
182
+ this.warnLog('Cloud Enabled SwitchBot Devices & IR Devices will not work');
183
+ }
160
184
  }
161
185
  }
162
186
  /**
@@ -167,12 +191,12 @@ class SwitchBotPlatform {
167
191
  if (this.config.credentials?.openToken) {
168
192
  const devicesAPI = (await this.axios.get(settings_1.DeviceURL)).data;
169
193
  this.deviceListInfo(devicesAPI);
170
- this.debug(JSON.stringify(devicesAPI));
194
+ this.debugLog(JSON.stringify(devicesAPI));
171
195
  // SwitchBot Devices
172
- this.log.info('Total SwitchBot Devices Found:', devicesAPI.body.deviceList.length);
196
+ this.infoLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
173
197
  const deviceLists = devicesAPI.body.deviceList;
174
198
  if (!this.config.options?.devices) {
175
- this.debug(`SwitchBot Device Config Not Set: ${JSON.stringify(this.config.options?.devices)}`);
199
+ this.debugLog(`SwitchBot Device Config Not Set: ${JSON.stringify(this.config.options?.devices)}`);
176
200
  const devices = deviceLists.map((v) => v);
177
201
  for (const device of devices) {
178
202
  if (device.deviceType) {
@@ -184,14 +208,14 @@ class SwitchBotPlatform {
184
208
  }
185
209
  }
186
210
  else if (this.config.credentials?.openToken && this.config.options.devices) {
187
- this.debug(`SwitchBot Device Config Set: ${JSON.stringify(this.config.options?.devices)}`);
211
+ this.debugLog(`SwitchBot Device Config Set: ${JSON.stringify(this.config.options?.devices)}`);
188
212
  const deviceConfigs = this.config.options?.devices;
189
213
  const mergeBydeviceId = (a1, a2) => a1.map((itm) => ({
190
214
  ...a2.find((item) => (item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '')) && item),
191
215
  ...itm,
192
216
  }));
193
217
  const devices = mergeBydeviceId(deviceLists, deviceConfigs);
194
- this.debug(`SwitchBot Devices: ${JSON.stringify(devices)}`);
218
+ this.debugLog(`SwitchBot Devices: ${JSON.stringify(devices)}`);
195
219
  for (const device of devices) {
196
220
  if (device.deviceType) {
197
221
  if (device.configDeviceName) {
@@ -202,13 +226,13 @@ class SwitchBotPlatform {
202
226
  }
203
227
  }
204
228
  else {
205
- this.log.error('Neither SwitchBot OpenToken or Device Config are not set.');
229
+ this.errorLog('Neither SwitchBot OpenToken or Device Config are not set.');
206
230
  }
207
231
  // IR Devices
208
- this.log.info('Total IR Devices Found:', devicesAPI.body.infraredRemoteList.length);
232
+ this.infoLog(`Total IR Devices Found: ${devicesAPI.body.infraredRemoteList.length}`);
209
233
  const irDeviceLists = devicesAPI.body.infraredRemoteList;
210
234
  if (!this.config.options?.irdevices) {
211
- this.debug(`IR Device Config Not Set: ${JSON.stringify(this.config.options?.irdevices)}`);
235
+ this.debugLog(`IR Device Config Not Set: ${JSON.stringify(this.config.options?.irdevices)}`);
212
236
  const devices = irDeviceLists.map((v) => v);
213
237
  for (const device of devices) {
214
238
  if (device.remoteType) {
@@ -217,14 +241,14 @@ class SwitchBotPlatform {
217
241
  }
218
242
  }
219
243
  else {
220
- this.debug(`IR Device Config Set: ${JSON.stringify(this.config.options?.irdevices)}`);
244
+ this.debugLog(`IR Device Config Set: ${JSON.stringify(this.config.options?.irdevices)}`);
221
245
  const irDeviceConfig = this.config.options?.irdevices;
222
246
  const mergeIRBydeviceId = (a1, a2) => a1.map((itm) => ({
223
247
  ...a2.find((item) => (item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '')) && item),
224
248
  ...itm,
225
249
  }));
226
250
  const devices = mergeIRBydeviceId(irDeviceLists, irDeviceConfig);
227
- this.debug(`IR Devices: ${JSON.stringify(devices)}`);
251
+ this.debugLog(`IR Devices: ${JSON.stringify(devices)}`);
228
252
  for (const device of devices) {
229
253
  if (device.remoteType) {
230
254
  this.createIRDevice(device);
@@ -233,7 +257,7 @@ class SwitchBotPlatform {
233
257
  }
234
258
  }
235
259
  else if (!this.config.credentials?.openToken && this.config.options?.devices) {
236
- this.debug(`SwitchBot Device Manual Config Set: ${JSON.stringify(this.config.options?.devices)}`);
260
+ this.debugLog(`SwitchBot Device Manual Config Set: ${JSON.stringify(this.config.options?.devices)}`);
237
261
  const deviceConfigs = this.config.options?.devices;
238
262
  const devices = deviceConfigs.map((v) => v);
239
263
  for (const device of devices) {
@@ -245,108 +269,113 @@ class SwitchBotPlatform {
245
269
  }
246
270
  }
247
271
  else {
248
- this.log.error('Neither SwitchBot OpenToken or Device Config are not set.');
272
+ this.errorLog('Neither SwitchBot OpenToken or Device Config are not set.');
249
273
  }
250
274
  }
251
275
  catch (e) {
252
- if (e.message.includes('400')) {
253
- this.log.error('Failed to Discover Devices: Bad Request');
254
- this.debug('The client has issued an invalid request. This is commonly used to specify validation errors in a request payload.');
255
- }
256
- else if (e.message.includes('401')) {
257
- this.log.error('Failed to Discover Devices: Unauthorized Request');
258
- this.debug('Authorization for the API is required, but the request has not been authenticated.');
259
- }
260
- else if (e.message.includes('403')) {
261
- this.log.error('Failed to Discover Devices: Forbidden Request');
262
- this.debug('The request has been authenticated but does not have appropriate permissions, or a requested resource is not found.');
263
- }
264
- else if (e.message.includes('404')) {
265
- this.log.error('Failed to Discover Devices: Requst Not Found');
266
- this.debug('Specifies the requested path does not exist.');
267
- }
268
- else if (e.message.includes('406')) {
269
- this.log.error('Failed to Discover Devices: Request Not Acceptable');
270
- this.debug('The client has requested a MIME type via the Accept header for a value not supported by the server.');
271
- }
272
- else if (e.message.includes('415')) {
273
- this.log.error('Failed to Discover Devices: Unsupported Requst Header');
274
- this.debug('The client has defined a contentType header that is not supported by the server.');
275
- }
276
- else if (e.message.includes('422')) {
277
- this.log.error('Failed to Discover Devices: Unprocessable Entity');
278
- this.debug('The client has made a valid request, but the server cannot process it.'
279
- + ' This is often used for APIs for which certain limits have been exceeded.');
280
- }
281
- else if (e.message.includes('429')) {
282
- this.log.error('Failed to Discover Devices: Too Many Requests');
283
- this.debug('The client has exceeded the number of requests allowed for a given time window.');
284
- }
285
- else if (e.message.includes('500')) {
286
- this.log.error('Failed to Discover Devices: Internal Server Error');
287
- this.debug('An unexpected error on the SmartThings servers has occurred. These errors should be rare.');
288
- }
289
- else {
290
- this.log.error('Failed to Discover Devices');
291
- }
292
- if (this.config.options?.debug === 'device') {
293
- this.log.error(`Failed to Discover Devices, Error Message: ${JSON.stringify(e.message)}`);
294
- }
295
- if (this.config.options?.debug === 'debug' || this.debugMode) {
296
- this.log.error(`Failed to Discover Devices, Error: ${JSON.stringify(e)}`);
297
- }
276
+ this.deviceError(e);
277
+ }
278
+ }
279
+ deviceError(e) {
280
+ if (e.message.includes('400')) {
281
+ this.errorLog('Failed to Discover Devices: Bad Request');
282
+ this.debugLog('The client has issued an invalid request. This is commonly used to specify validation errors in a request payload.');
283
+ }
284
+ else if (e.message.includes('401')) {
285
+ this.errorLog('Failed to Discover Devices: Unauthorized Request');
286
+ this.debugLog('Authorization for the API is required, but the request has not been authenticated.');
287
+ }
288
+ else if (e.message.includes('403')) {
289
+ this.errorLog('Failed to Discover Devices: Forbidden Request');
290
+ this.debugLog('The request has been authenticated but does not have appropriate permissions, or a requested resource is not found.');
291
+ }
292
+ else if (e.message.includes('404')) {
293
+ this.errorLog('Failed to Discover Devices: Requst Not Found');
294
+ this.debugLog('Specifies the requested path does not exist.');
295
+ }
296
+ else if (e.message.includes('406')) {
297
+ this.errorLog('Failed to Discover Devices: Request Not Acceptable');
298
+ this.debugLog('The client has requested a MIME type via the Accept header for a value not supported by the server.');
299
+ }
300
+ else if (e.message.includes('415')) {
301
+ this.errorLog('Failed to Discover Devices: Unsupported Requst Header');
302
+ this.debugLog('The client has defined a contentType header that is not supported by the server.');
303
+ }
304
+ else if (e.message.includes('422')) {
305
+ this.errorLog('Failed to Discover Devices: Unprocessable Entity');
306
+ this.debugLog('The client has made a valid request, but the server cannot process it.'
307
+ + ' This is often used for APIs for which certain limits have been exceeded.');
308
+ }
309
+ else if (e.message.includes('429')) {
310
+ this.errorLog('Failed to Discover Devices: Too Many Requests');
311
+ this.debugLog('The client has exceeded the number of requests allowed for a given time window.');
312
+ }
313
+ else if (e.message.includes('500')) {
314
+ this.errorLog('Failed to Discover Devices: Internal Server Error');
315
+ this.debugLog('An unexpected error on the SmartThings servers has occurred. These errors should be rare.');
316
+ }
317
+ else {
318
+ this.errorLog('Failed to Discover Devices');
319
+ }
320
+ if (this.platformLogging === 'debug') {
321
+ this.errorLog(`Failed to Discover Devices, Error Message: ${JSON.stringify(e.message)}`);
322
+ }
323
+ if (this.platformLogging === 'debugMode') {
324
+ this.errorLog(`Failed to Discover Devices, Error: ${JSON.stringify(e)}`);
298
325
  }
299
326
  }
300
327
  createDevice(device) {
301
328
  switch (device.deviceType) {
302
329
  case 'Humidifier':
303
- this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
330
+ this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
304
331
  this.createHumidifier(device);
305
332
  break;
306
333
  case 'Hub Mini':
307
- this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
334
+ this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
308
335
  break;
309
336
  case 'Hub Plus':
310
- this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
337
+ this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
311
338
  break;
312
339
  case 'Bot':
313
- this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
340
+ this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
314
341
  this.createBot(device);
315
342
  break;
316
343
  case 'Meter':
317
- this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
344
+ this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
318
345
  this.createMeter(device);
319
346
  break;
320
347
  case 'Motion Sensor':
321
- this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
348
+ this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
322
349
  this.createMotion(device);
323
350
  break;
324
351
  case 'Contact Sensor':
325
- this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
352
+ this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
326
353
  this.createContact(device);
327
354
  break;
328
355
  case 'Curtain':
329
- this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
356
+ this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
330
357
  this.createCurtain(device);
331
358
  break;
332
359
  case 'Plug':
333
- this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
360
+ this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
334
361
  this.createPlug(device);
335
362
  break;
336
363
  case 'Color Bulb':
337
- this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
364
+ this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
338
365
  this.createColorBulb(device);
339
366
  break;
340
367
  case 'Indoor Cam':
341
- this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
342
- this.createIndoorCam(device);
368
+ this.deviceInfo(device);
369
+ this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
370
+ this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.deviceType}, is currently not supported.`);
343
371
  break;
344
372
  case 'Remote':
345
- this.debug(`Discovered ${device.deviceType}: ${device.deviceId} is Not Supported.`);
373
+ this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId} is Not Supported.`);
346
374
  break;
347
375
  default:
348
- this.log.info(`Device: ${device.deviceName} with Device Type: ${device.deviceType}, is currently not supported.`);
349
- this.log.info('Submit Feature Requests Here: https://git.io/JL14Z');
376
+ this.deviceInfo(device);
377
+ this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.deviceType}, is currently not supported.`);
378
+ this.warnLog('Submit Feature Requests Here: https://git.io/JL14Z');
350
379
  }
351
380
  }
352
381
  createIRDevice(device) {
@@ -363,69 +392,70 @@ class SwitchBotPlatform {
363
392
  case 'DIY DVD':
364
393
  case 'Speaker':
365
394
  case 'DIY Speaker':
366
- this.debug(`Discovered ${device.remoteType}: ${device.deviceId}`);
395
+ this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
367
396
  this.createTV(device);
368
397
  break;
369
398
  case 'Fan':
370
399
  case 'DIY Fan':
371
- this.debug(`Discovered ${device.remoteType}: ${device.deviceId}`);
400
+ this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
372
401
  this.createFan(device);
373
402
  break;
374
403
  case 'Air Conditioner':
375
404
  case 'DIY Air Conditioner':
376
- this.debug(`Discovered ${device.remoteType}: ${device.deviceId}`);
405
+ this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
377
406
  this.createAirConditioner(device);
378
407
  break;
379
408
  case 'Light':
380
409
  case 'DIY Light':
381
- this.debug(`Discovered ${device.remoteType}: ${device.deviceId}`);
410
+ this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
382
411
  this.createLight(device);
383
412
  break;
384
413
  case 'Air Purifier':
385
414
  case 'DIY Air Purifier':
386
- this.debug(`Discovered ${device.remoteType}: ${device.deviceId}`);
415
+ this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
387
416
  this.createAirPurifier(device);
388
417
  break;
389
418
  case 'Water Heater':
390
419
  case 'DIY Water Heater':
391
- this.debug(`Discovered ${device.remoteType}: ${device.deviceId}`);
420
+ this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
392
421
  this.createWaterHeater(device);
393
422
  break;
394
423
  case 'Vacuum Cleaner':
395
424
  case 'DIY Vacuum Cleaner':
396
- this.debug(`Discovered ${device.remoteType}: ${device.deviceId}`);
425
+ this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
397
426
  this.createVacuumCleaner(device);
398
427
  break;
399
428
  case 'Camera':
400
429
  case 'DIY Camera':
401
- this.debug(`Discovered ${device.remoteType}: ${device.deviceId}`);
430
+ this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
402
431
  this.createCamera(device);
403
432
  break;
404
433
  case 'Others':
405
- this.debug(`Discovered ${device.remoteType}: ${device.deviceId}`);
434
+ this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
406
435
  this.createOthers(device);
407
436
  break;
408
437
  default:
409
- this.log.info(`Device: ${device.deviceName} with Device Type: ${device.remoteType}, is currently not supported.`);
410
- this.log.info('Submit Feature Requests Here: https://git.io/JL14Z');
438
+ this.deviceInfo(device);
439
+ this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.remoteType}, is currently not supported.`);
440
+ this.warnLog('Submit Feature Requests Here: https://git.io/JL14Z');
411
441
  }
412
442
  }
413
443
  registerDevice(device) {
414
444
  if (!device.hide_device && device.enableCloudService && device.ble) {
415
445
  this.registeringDevice = true;
416
- this.device(`Device: ${device.deviceName} Both OpenAPI and BLE Connections Enabled`);
446
+ this.debugLog(`Device: ${device.deviceName} Both OpenAPI and BLE Connections Enabled`);
417
447
  }
418
448
  else if (!device.hide_device && device.deviceId && device.configDeviceType && device.configDeviceName && !device.enableCloudService) {
419
449
  this.registeringDevice = true;
420
- this.device(`Device: ${device.deviceName} BLE Connection Enabled`);
450
+ this.debugLog(`Device: ${device.deviceName} BLE Connection Enabled`);
421
451
  }
422
452
  else if (!device.hide_device && device.enableCloudService && !device.ble) {
423
453
  this.registeringDevice = true;
424
- this.device(`Device: ${device.deviceName} OpenAPI Connection Enabled`);
454
+ this.debugLog(`Device: ${device.deviceName} OpenAPI Connection Enabled`);
425
455
  }
426
456
  else {
427
457
  this.registeringDevice = false;
428
- this.device(`Device: ${device.deviceName} Neither OpenAPI and BLE Enabled`);
458
+ this.debugLog(`Device: ${device.deviceName} Neither OpenAPI and BLE Enabled`);
429
459
  }
430
460
  return this.registeringDevice;
431
461
  }
@@ -437,7 +467,7 @@ class SwitchBotPlatform {
437
467
  if (existingAccessory) {
438
468
  // the accessory already exists
439
469
  if (this.registerDevice(device)) {
440
- this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
470
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
441
471
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
442
472
  //existingAccessory.context.firmwareRevision = firmware;
443
473
  existingAccessory.context.model = device.deviceType;
@@ -450,7 +480,7 @@ class SwitchBotPlatform {
450
480
  // create the accessory handler for the restored accessory
451
481
  // this is imported from `platformAccessory.ts`
452
482
  new humidifiers_1.Humidifier(this, existingAccessory, device);
453
- this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
483
+ this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
454
484
  }
455
485
  else {
456
486
  this.unregisterPlatformAccessories(existingAccessory);
@@ -458,7 +488,7 @@ class SwitchBotPlatform {
458
488
  }
459
489
  else if (this.registerDevice(device)) {
460
490
  // the accessory does not yet exist, so we need to create it
461
- this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
491
+ this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
462
492
  // create a new accessory
463
493
  const accessory = new this.api.platformAccessory(device.deviceName, uuid);
464
494
  // store a copy of the device object in the `accessory.context`
@@ -472,13 +502,13 @@ class SwitchBotPlatform {
472
502
  // create the accessory handler for the newly create accessory
473
503
  // this is imported from `platformAccessory.ts`
474
504
  new humidifiers_1.Humidifier(this, accessory, device);
475
- this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
505
+ this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
476
506
  // link the accessory to your platform
477
507
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
478
508
  this.accessories.push(accessory);
479
509
  }
480
510
  else {
481
- this.device(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
511
+ this.debugLog(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
482
512
  }
483
513
  }
484
514
  async createBot(device) {
@@ -489,8 +519,8 @@ class SwitchBotPlatform {
489
519
  if (existingAccessory) {
490
520
  // the accessory already exists
491
521
  if (this.registerDevice(device)) {
492
- this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
493
- this.debug(JSON.stringify(device.bot?.mode));
522
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
523
+ this.debugLog(JSON.stringify(device.bot?.mode));
494
524
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
495
525
  existingAccessory.context.model = device.deviceType;
496
526
  existingAccessory.context.deviceID = device.deviceId;
@@ -502,7 +532,7 @@ class SwitchBotPlatform {
502
532
  // create the accessory handler for the restored accessory
503
533
  // this is imported from `platformAccessory.ts`
504
534
  new bots_1.Bot(this, existingAccessory, device);
505
- this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
535
+ this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
506
536
  }
507
537
  else {
508
538
  this.unregisterPlatformAccessories(existingAccessory);
@@ -510,8 +540,8 @@ class SwitchBotPlatform {
510
540
  }
511
541
  else if (this.registerDevice(device)) {
512
542
  // the accessory does not yet exist, so we need to create it
513
- this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
514
- this.debug(JSON.stringify(device.bot?.mode));
543
+ this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
544
+ this.debugLog(JSON.stringify(device.bot?.mode));
515
545
  // create a new accessory
516
546
  const accessory = new this.api.platformAccessory(device.deviceName, uuid);
517
547
  // store a copy of the device object in the `accessory.context`
@@ -526,13 +556,13 @@ class SwitchBotPlatform {
526
556
  // create the accessory handler for the newly create accessory
527
557
  // this is imported from `platformAccessory.ts`
528
558
  new bots_1.Bot(this, accessory, device);
529
- this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
559
+ this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
530
560
  // link the accessory to your platform
531
561
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
532
562
  this.accessories.push(accessory);
533
563
  }
534
564
  else {
535
- this.device(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
565
+ this.debugLog(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
536
566
  }
537
567
  }
538
568
  async createMeter(device) {
@@ -543,7 +573,7 @@ class SwitchBotPlatform {
543
573
  if (existingAccessory) {
544
574
  // the accessory already exists
545
575
  if (this.registerDevice(device)) {
546
- this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
576
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
547
577
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
548
578
  existingAccessory.context.model = device.deviceType;
549
579
  existingAccessory.context.deviceID = device.deviceId;
@@ -555,7 +585,7 @@ class SwitchBotPlatform {
555
585
  // create the accessory handler for the restored accessory
556
586
  // this is imported from `platformAccessory.ts`
557
587
  new meters_1.Meter(this, existingAccessory, device);
558
- this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
588
+ this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
559
589
  }
560
590
  else {
561
591
  this.unregisterPlatformAccessories(existingAccessory);
@@ -563,7 +593,7 @@ class SwitchBotPlatform {
563
593
  }
564
594
  else if (this.registerDevice(device)) {
565
595
  // the accessory does not yet exist, so we need to create it
566
- this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
596
+ this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
567
597
  // create a new accessory
568
598
  const accessory = new this.api.platformAccessory(device.deviceName, uuid);
569
599
  // store a copy of the device object in the `accessory.context`
@@ -577,13 +607,13 @@ class SwitchBotPlatform {
577
607
  // create the accessory handler for the newly create accessory
578
608
  // this is imported from `platformAccessory.ts`
579
609
  new meters_1.Meter(this, accessory, device);
580
- this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
610
+ this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
581
611
  // link the accessory to your platform
582
612
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
583
613
  this.accessories.push(accessory);
584
614
  }
585
615
  else {
586
- this.device(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
616
+ this.debugLog(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
587
617
  }
588
618
  }
589
619
  async createMotion(device) {
@@ -594,7 +624,7 @@ class SwitchBotPlatform {
594
624
  if (existingAccessory) {
595
625
  // the accessory already exists
596
626
  if (this.registerDevice(device)) {
597
- this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
627
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
598
628
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
599
629
  existingAccessory.context.model = device.deviceType;
600
630
  existingAccessory.context.deviceID = device.deviceId;
@@ -606,7 +636,7 @@ class SwitchBotPlatform {
606
636
  // create the accessory handler for the restored accessory
607
637
  // this is imported from `platformAccessory.ts`
608
638
  new motion_1.Motion(this, existingAccessory, device);
609
- this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
639
+ this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
610
640
  }
611
641
  else {
612
642
  this.unregisterPlatformAccessories(existingAccessory);
@@ -614,7 +644,7 @@ class SwitchBotPlatform {
614
644
  }
615
645
  else if (this.registerDevice(device)) {
616
646
  // the accessory does not yet exist, so we need to create it
617
- this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
647
+ this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
618
648
  // create a new accessory
619
649
  const accessory = new this.api.platformAccessory(device.deviceName, uuid);
620
650
  // store a copy of the device object in the `accessory.context`
@@ -628,13 +658,13 @@ class SwitchBotPlatform {
628
658
  // create the accessory handler for the newly create accessory
629
659
  // this is imported from `platformAccessory.ts`
630
660
  new motion_1.Motion(this, accessory, device);
631
- this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
661
+ this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
632
662
  // link the accessory to your platform
633
663
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
634
664
  this.accessories.push(accessory);
635
665
  }
636
666
  else {
637
- this.device(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
667
+ this.debugLog(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
638
668
  }
639
669
  }
640
670
  async createContact(device) {
@@ -645,7 +675,7 @@ class SwitchBotPlatform {
645
675
  if (existingAccessory) {
646
676
  // the accessory already exists
647
677
  if (this.registerDevice(device)) {
648
- this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
678
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
649
679
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
650
680
  existingAccessory.context.model = device.deviceType;
651
681
  existingAccessory.context.deviceID = device.deviceId;
@@ -657,7 +687,7 @@ class SwitchBotPlatform {
657
687
  // create the accessory handler for the restored accessory
658
688
  // this is imported from `platformAccessory.ts`
659
689
  new contact_1.Contact(this, existingAccessory, device);
660
- this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
690
+ this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
661
691
  }
662
692
  else {
663
693
  this.unregisterPlatformAccessories(existingAccessory);
@@ -665,7 +695,7 @@ class SwitchBotPlatform {
665
695
  }
666
696
  else if (this.registerDevice(device)) {
667
697
  // the accessory does not yet exist, so we need to create it
668
- this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
698
+ this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
669
699
  // create a new accessory
670
700
  const accessory = new this.api.platformAccessory(device.deviceName, uuid);
671
701
  // store a copy of the device object in the `accessory.context`
@@ -679,13 +709,13 @@ class SwitchBotPlatform {
679
709
  // create the accessory handler for the newly create accessory
680
710
  // this is imported from `platformAccessory.ts`
681
711
  new contact_1.Contact(this, accessory, device);
682
- this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
712
+ this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
683
713
  // link the accessory to your platform
684
714
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
685
715
  this.accessories.push(accessory);
686
716
  }
687
717
  else {
688
- this.device(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
718
+ this.debugLog(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
689
719
  }
690
720
  }
691
721
  async createCurtain(device) {
@@ -696,7 +726,7 @@ class SwitchBotPlatform {
696
726
  if (existingAccessory) {
697
727
  // the accessory already exists
698
728
  if (this.isCurtainGrouped(device)) {
699
- this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
729
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
700
730
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
701
731
  existingAccessory.context.model = device.deviceType;
702
732
  existingAccessory.context.deviceID = device.deviceId;
@@ -708,7 +738,7 @@ class SwitchBotPlatform {
708
738
  // create the accessory handler for the restored accessory
709
739
  // this is imported from `platformAccessory.ts`
710
740
  new curtains_1.Curtain(this, existingAccessory, device);
711
- this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
741
+ this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
712
742
  }
713
743
  else {
714
744
  this.unregisterPlatformAccessories(existingAccessory);
@@ -716,17 +746,17 @@ class SwitchBotPlatform {
716
746
  }
717
747
  else if (this.isCurtainGrouped(device)) {
718
748
  // the accessory does not yet exist, so we need to create it
719
- this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
749
+ this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
720
750
  if (device.group && !device.curtain?.disable_group) {
721
- this.device(`Your Curtains are grouped
751
+ this.debugLog(`Your Curtains are grouped
722
752
  , Secondary curtain automatically hidden. Main Curtain: ${device.deviceName}, DeviceID: ${device.deviceId}`);
723
753
  }
724
754
  else {
725
755
  if (device.master) {
726
- this.device(`Main Curtain: ${device.deviceName}, DeviceID: ${device.deviceId}`);
756
+ this.debugLog(`Main Curtain: ${device.deviceName}, DeviceID: ${device.deviceId}`);
727
757
  }
728
758
  else {
729
- this.device(`Secondary Curtain: ${device.deviceName}, DeviceID: ${device.deviceId}`);
759
+ this.debugLog(`Secondary Curtain: ${device.deviceName}, DeviceID: ${device.deviceId}`);
730
760
  }
731
761
  }
732
762
  // create a new accessory
@@ -742,24 +772,24 @@ class SwitchBotPlatform {
742
772
  // create the accessory handler for the newly create accessory
743
773
  // this is imported from `platformAccessory.ts`
744
774
  new curtains_1.Curtain(this, accessory, device);
745
- this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
775
+ this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
746
776
  // link the accessory to your platform
747
777
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
748
778
  this.accessories.push(accessory);
749
779
  }
750
780
  else {
751
- this.device(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
781
+ this.debugLog(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
752
782
  }
753
783
  }
754
784
  isCurtainGrouped(device) {
755
- this.debug(`deviceId: ${device.deviceId}, curtainDevicesIds: ${device.curtainDevicesIds},`
785
+ this.debugLog(`deviceId: ${device.deviceId}, curtainDevicesIds: ${device.curtainDevicesIds},`
756
786
  + ` master: ${device.master}, group: ${device.group}, disable_group: ${device.curtain?.disable_group}`);
757
787
  if (device.group && !device.curtain?.disable_group) {
758
- this.debug(`[Curtain Config] disable_group: ${device.curtain?.disable_group}`);
788
+ this.debugLog(`[Curtain Config] disable_group: ${device.curtain?.disable_group}`);
759
789
  return device.master && this.registerDevice(device);
760
790
  }
761
791
  else {
762
- this.debug(`[Curtain Config] disable_group: ${device.curtain?.disable_group}, UnGrouping ${device.master}`);
792
+ this.debugLog(`[Curtain Config] disable_group: ${device.curtain?.disable_group}, UnGrouping ${device.master}`);
763
793
  return this.registerDevice(device);
764
794
  }
765
795
  }
@@ -771,7 +801,7 @@ class SwitchBotPlatform {
771
801
  if (existingAccessory) {
772
802
  // the accessory already exists
773
803
  if (!device.hide_device && device.enableCloudService) {
774
- this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
804
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
775
805
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
776
806
  existingAccessory.context.model = device.deviceType;
777
807
  existingAccessory.context.deviceID = device.deviceId;
@@ -783,7 +813,7 @@ class SwitchBotPlatform {
783
813
  // create the accessory handler for the restored accessory
784
814
  // this is imported from `platformAccessory.ts`
785
815
  new plugs_1.Plug(this, existingAccessory, device);
786
- this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
816
+ this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
787
817
  }
788
818
  else {
789
819
  this.unregisterPlatformAccessories(existingAccessory);
@@ -791,7 +821,7 @@ class SwitchBotPlatform {
791
821
  }
792
822
  else if (!device.hide_device && device.enableCloudService) {
793
823
  // the accessory does not yet exist, so we need to create it
794
- this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
824
+ this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
795
825
  // create a new accessory
796
826
  const accessory = new this.api.platformAccessory(device.deviceName, uuid);
797
827
  // store a copy of the device object in the `accessory.context`
@@ -805,13 +835,13 @@ class SwitchBotPlatform {
805
835
  // create the accessory handler for the newly create accessory
806
836
  // this is imported from `platformAccessory.ts`
807
837
  new plugs_1.Plug(this, accessory, device);
808
- this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
838
+ this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
809
839
  // link the accessory to your platform
810
840
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
811
841
  this.accessories.push(accessory);
812
842
  }
813
843
  else {
814
- this.device(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
844
+ this.debugLog(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
815
845
  }
816
846
  }
817
847
  async createColorBulb(device) {
@@ -822,7 +852,7 @@ class SwitchBotPlatform {
822
852
  if (existingAccessory) {
823
853
  // the accessory already exists
824
854
  if (!device.hide_device && device.enableCloudService) {
825
- this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
855
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
826
856
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
827
857
  existingAccessory.context.model = device.deviceType;
828
858
  existingAccessory.context.deviceID = device.deviceId;
@@ -834,7 +864,7 @@ class SwitchBotPlatform {
834
864
  // create the accessory handler for the restored accessory
835
865
  // this is imported from `platformAccessory.ts`
836
866
  new colorbulb_1.ColorBulb(this, existingAccessory, device);
837
- this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
867
+ this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
838
868
  }
839
869
  else {
840
870
  this.unregisterPlatformAccessories(existingAccessory);
@@ -842,7 +872,7 @@ class SwitchBotPlatform {
842
872
  }
843
873
  else if (!device.hide_device && device.enableCloudService) {
844
874
  // the accessory does not yet exist, so we need to create it
845
- this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
875
+ this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
846
876
  // create a new accessory
847
877
  const accessory = new this.api.platformAccessory(device.deviceName, uuid);
848
878
  // store a copy of the device object in the `accessory.context`
@@ -856,64 +886,13 @@ class SwitchBotPlatform {
856
886
  // create the accessory handler for the newly create accessory
857
887
  // this is imported from `platformAccessory.ts`
858
888
  new colorbulb_1.ColorBulb(this, accessory, device);
859
- this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
860
- // link the accessory to your platform
861
- this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
862
- this.accessories.push(accessory);
863
- }
864
- else {
865
- this.device(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
866
- }
867
- }
868
- async createIndoorCam(device) {
869
- const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
870
- // see if an accessory with the same uuid has already been registered and restored from
871
- // the cached devices we stored in the `configureAccessory` method above
872
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
873
- if (existingAccessory) {
874
- // the accessory already exists
875
- if (!device.hide_device && device.enableCloudService) {
876
- this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
877
- // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
878
- existingAccessory.context.model = device.deviceType;
879
- existingAccessory.context.deviceID = device.deviceId;
880
- existingAccessory.displayName = device.deviceName;
881
- existingAccessory.context.firmwareRevision = this.version;
882
- existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
883
- await this.connectionTypeExistingAccessory(device, existingAccessory);
884
- this.api.updatePlatformAccessories([existingAccessory]);
885
- // create the accessory handler for the restored accessory
886
- // this is imported from `platformAccessory.ts`
887
- new indoorcam_1.IndoorCam(this, existingAccessory, device);
888
- this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
889
- }
890
- else {
891
- this.unregisterPlatformAccessories(existingAccessory);
892
- }
893
- }
894
- else if (!device.hide_device && device.enableCloudService) {
895
- // the accessory does not yet exist, so we need to create it
896
- this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
897
- // create a new accessory
898
- const accessory = new this.api.platformAccessory(device.deviceName, uuid);
899
- // store a copy of the device object in the `accessory.context`
900
- // the `context` property can be used to store any data about the accessory you may need
901
- accessory.context.device = device;
902
- accessory.context.model = device.deviceType;
903
- accessory.context.deviceID = device.deviceId;
904
- accessory.context.firmwareRevision = this.version;
905
- accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
906
- await this.connectionTypeNewAccessory(device, accessory);
907
- // create the accessory handler for the newly create accessory
908
- // this is imported from `platformAccessory.ts`
909
- new indoorcam_1.IndoorCam(this, accessory, device);
910
- this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
889
+ this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
911
890
  // link the accessory to your platform
912
891
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
913
892
  this.accessories.push(accessory);
914
893
  }
915
894
  else {
916
- this.device(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
895
+ this.debugLog(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
917
896
  }
918
897
  }
919
898
  async createTV(device) {
@@ -922,23 +901,23 @@ class SwitchBotPlatform {
922
901
  // the cached devices we stored in the `configureAccessory` method above
923
902
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
924
903
  if (!device.hide_device && existingAccessory) {
925
- this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
904
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
926
905
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
927
906
  existingAccessory.context.model = device.remoteType;
928
907
  existingAccessory.context.deviceID = device.deviceId;
929
908
  existingAccessory.displayName = device.deviceName;
930
909
  existingAccessory.context.firmwareRevision = this.version;
931
910
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
932
- await this.connectionTypeExistingIRAccessory(device, existingAccessory);
911
+ await this.connectionTypeExistingIRAccessory(existingAccessory);
933
912
  this.api.updatePlatformAccessories([existingAccessory]);
934
913
  // create the accessory handler for the restored accessory
935
914
  // this is imported from `platformAccessory.ts`
936
915
  new tvs_1.TV(this, existingAccessory, device);
937
- this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
916
+ this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
938
917
  }
939
918
  else if (!device.hide_device && device.hubDeviceId) {
940
919
  // the accessory does not yet exist, so we need to create it
941
- this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
920
+ this.infoLog(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
942
921
  // create a new accessory
943
922
  const accessory = new this.api.platformAccessory(device.deviceName, uuid);
944
923
  // store a copy of the device object in the `accessory.context`
@@ -948,11 +927,11 @@ class SwitchBotPlatform {
948
927
  accessory.context.deviceID = device.deviceId;
949
928
  accessory.context.firmwareRevision = this.version;
950
929
  accessory.context.deviceType = `IR: ${device.remoteType}`;
951
- await this.connectionTypeNewIRAccessory(device, accessory);
930
+ await this.connectionTypeNewIRAccessory(accessory);
952
931
  // create the accessory handler for the newly create accessory
953
932
  // this is imported from `platformAccessory.ts`
954
933
  new tvs_1.TV(this, accessory, device);
955
- this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
934
+ this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
956
935
  /**
957
936
  * Publish as external accessory
958
937
  * Only one TV can exist per bridge, to bypass this limitation, you should
@@ -962,7 +941,7 @@ class SwitchBotPlatform {
962
941
  this.accessories.push(accessory);
963
942
  }
964
943
  else {
965
- this.device(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
944
+ this.debugLog(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
966
945
  }
967
946
  }
968
947
  async createFan(device) {
@@ -973,19 +952,19 @@ class SwitchBotPlatform {
973
952
  if (existingAccessory) {
974
953
  // the accessory already exists
975
954
  if (!device.hide_device && device.hubDeviceId) {
976
- this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
955
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
977
956
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
978
957
  existingAccessory.context.model = device.remoteType;
979
958
  existingAccessory.context.deviceID = device.deviceId;
980
959
  existingAccessory.displayName = device.deviceName;
981
960
  existingAccessory.context.firmwareRevision = this.version;
982
961
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
983
- await this.connectionTypeExistingIRAccessory(device, existingAccessory);
962
+ await this.connectionTypeExistingIRAccessory(existingAccessory);
984
963
  this.api.updatePlatformAccessories([existingAccessory]);
985
964
  // create the accessory handler for the restored accessory
986
965
  // this is imported from `platformAccessory.ts`
987
966
  new fans_1.Fan(this, existingAccessory, device);
988
- this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
967
+ this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
989
968
  }
990
969
  else {
991
970
  this.unregisterPlatformAccessories(existingAccessory);
@@ -993,7 +972,7 @@ class SwitchBotPlatform {
993
972
  }
994
973
  else if (!device.hide_device && device.hubDeviceId) {
995
974
  // the accessory does not yet exist, so we need to create it
996
- this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
975
+ this.infoLog(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
997
976
  // create a new accessory
998
977
  const accessory = new this.api.platformAccessory(device.deviceName, uuid);
999
978
  // store a copy of the device object in the `accessory.context`
@@ -1003,17 +982,17 @@ class SwitchBotPlatform {
1003
982
  accessory.context.deviceID = device.deviceId;
1004
983
  accessory.context.firmwareRevision = this.version;
1005
984
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1006
- await this.connectionTypeNewIRAccessory(device, accessory);
985
+ await this.connectionTypeNewIRAccessory(accessory);
1007
986
  // create the accessory handler for the newly create accessory
1008
987
  // this is imported from `platformAccessory.ts`
1009
988
  new fans_1.Fan(this, accessory, device);
1010
- this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
989
+ this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1011
990
  // link the accessory to your platform
1012
991
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
1013
992
  this.accessories.push(accessory);
1014
993
  }
1015
994
  else {
1016
- this.device(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
995
+ this.debugLog(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
1017
996
  }
1018
997
  }
1019
998
  async createLight(device) {
@@ -1024,19 +1003,19 @@ class SwitchBotPlatform {
1024
1003
  if (existingAccessory) {
1025
1004
  // the accessory already exists
1026
1005
  if (!device.hide_device && device.hubDeviceId) {
1027
- this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1006
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1028
1007
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1029
1008
  existingAccessory.context.model = device.remoteType;
1030
1009
  existingAccessory.context.deviceID = device.deviceId;
1031
1010
  existingAccessory.displayName = device.deviceName;
1032
1011
  existingAccessory.context.firmwareRevision = this.version;
1033
1012
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1034
- await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1013
+ await this.connectionTypeExistingIRAccessory(existingAccessory);
1035
1014
  this.api.updatePlatformAccessories([existingAccessory]);
1036
1015
  // create the accessory handler for the restored accessory
1037
1016
  // this is imported from `platformAccessory.ts`
1038
1017
  new lights_1.Light(this, existingAccessory, device);
1039
- this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1018
+ this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1040
1019
  }
1041
1020
  else {
1042
1021
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1044,7 +1023,7 @@ class SwitchBotPlatform {
1044
1023
  }
1045
1024
  else if (!device.hide_device && device.hubDeviceId) {
1046
1025
  // the accessory does not yet exist, so we need to create it
1047
- this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1026
+ this.infoLog(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1048
1027
  // create a new accessory
1049
1028
  const accessory = new this.api.platformAccessory(device.deviceName, uuid);
1050
1029
  // store a copy of the device object in the `accessory.context`
@@ -1054,17 +1033,17 @@ class SwitchBotPlatform {
1054
1033
  accessory.context.deviceID = device.deviceId;
1055
1034
  accessory.context.firmwareRevision = this.version;
1056
1035
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1057
- await this.connectionTypeNewIRAccessory(device, accessory);
1036
+ await this.connectionTypeNewIRAccessory(accessory);
1058
1037
  // create the accessory handler for the newly create accessory
1059
1038
  // this is imported from `platformAccessory.ts`
1060
1039
  new lights_1.Light(this, accessory, device);
1061
- this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1040
+ this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1062
1041
  // link the accessory to your platform
1063
1042
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
1064
1043
  this.accessories.push(accessory);
1065
1044
  }
1066
1045
  else {
1067
- this.device(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
1046
+ this.debugLog(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
1068
1047
  }
1069
1048
  }
1070
1049
  async createAirConditioner(device) {
@@ -1075,19 +1054,19 @@ class SwitchBotPlatform {
1075
1054
  if (existingAccessory) {
1076
1055
  // the accessory already exists
1077
1056
  if (!device.hide_device && device.hubDeviceId) {
1078
- this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1057
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1079
1058
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1080
1059
  existingAccessory.context.model = device.remoteType;
1081
1060
  existingAccessory.context.deviceID = device.deviceId;
1082
1061
  existingAccessory.displayName = device.deviceName;
1083
1062
  existingAccessory.context.firmwareRevision = this.version;
1084
1063
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1085
- await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1064
+ await this.connectionTypeExistingIRAccessory(existingAccessory);
1086
1065
  this.api.updatePlatformAccessories([existingAccessory]);
1087
1066
  // create the accessory handler for the restored accessory
1088
1067
  // this is imported from `platformAccessory.ts`
1089
1068
  new airconditioners_1.AirConditioner(this, existingAccessory, device);
1090
- this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1069
+ this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1091
1070
  }
1092
1071
  else {
1093
1072
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1095,7 +1074,7 @@ class SwitchBotPlatform {
1095
1074
  }
1096
1075
  else if (!device.hide_device && device.hubDeviceId) {
1097
1076
  // the accessory does not yet exist, so we need to create it
1098
- this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1077
+ this.infoLog(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1099
1078
  // create a new accessory
1100
1079
  const accessory = new this.api.platformAccessory(device.deviceName, uuid);
1101
1080
  // store a copy of the device object in the `accessory.context`
@@ -1105,17 +1084,17 @@ class SwitchBotPlatform {
1105
1084
  accessory.context.deviceID = device.deviceId;
1106
1085
  accessory.context.firmwareRevision = this.version;
1107
1086
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1108
- await this.connectionTypeNewIRAccessory(device, accessory);
1087
+ await this.connectionTypeNewIRAccessory(accessory);
1109
1088
  // create the accessory handler for the newly create accessory
1110
1089
  // this is imported from `platformAccessory.ts`
1111
1090
  new airconditioners_1.AirConditioner(this, accessory, device);
1112
- this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1091
+ this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1113
1092
  // link the accessory to your platform
1114
1093
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
1115
1094
  this.accessories.push(accessory);
1116
1095
  }
1117
1096
  else {
1118
- this.device(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
1097
+ this.debugLog(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
1119
1098
  }
1120
1099
  }
1121
1100
  async createAirPurifier(device) {
@@ -1126,19 +1105,19 @@ class SwitchBotPlatform {
1126
1105
  if (existingAccessory) {
1127
1106
  // the accessory already exists
1128
1107
  if (!device.hide_device && device.hubDeviceId) {
1129
- this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1108
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1130
1109
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1131
1110
  existingAccessory.context.model = device.remoteType;
1132
1111
  existingAccessory.context.deviceID = device.deviceId;
1133
1112
  existingAccessory.displayName = device.deviceName;
1134
1113
  existingAccessory.context.firmwareRevision = this.version;
1135
1114
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1136
- await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1115
+ await this.connectionTypeExistingIRAccessory(existingAccessory);
1137
1116
  this.api.updatePlatformAccessories([existingAccessory]);
1138
1117
  // create the accessory handler for the restored accessory
1139
1118
  // this is imported from `platformAccessory.ts`
1140
1119
  new airpurifiers_1.AirPurifier(this, existingAccessory, device);
1141
- this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1120
+ this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1142
1121
  }
1143
1122
  else {
1144
1123
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1146,7 +1125,7 @@ class SwitchBotPlatform {
1146
1125
  }
1147
1126
  else if (!device.hide_device && device.hubDeviceId) {
1148
1127
  // the accessory does not yet exist, so we need to create it
1149
- this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1128
+ this.infoLog(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1150
1129
  // create a new accessory
1151
1130
  const accessory = new this.api.platformAccessory(device.deviceName, uuid);
1152
1131
  // store a copy of the device object in the `accessory.context`
@@ -1156,17 +1135,17 @@ class SwitchBotPlatform {
1156
1135
  accessory.context.deviceID = device.deviceId;
1157
1136
  accessory.context.firmwareRevision = this.version;
1158
1137
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1159
- await this.connectionTypeNewIRAccessory(device, accessory);
1138
+ await this.connectionTypeNewIRAccessory(accessory);
1160
1139
  // create the accessory handler for the newly create accessory
1161
1140
  // this is imported from `platformAccessory.ts`
1162
1141
  new airpurifiers_1.AirPurifier(this, accessory, device);
1163
- this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1142
+ this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1164
1143
  // link the accessory to your platform
1165
1144
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
1166
1145
  this.accessories.push(accessory);
1167
1146
  }
1168
1147
  else {
1169
- this.device(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
1148
+ this.debugLog(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
1170
1149
  }
1171
1150
  }
1172
1151
  async createWaterHeater(device) {
@@ -1177,19 +1156,19 @@ class SwitchBotPlatform {
1177
1156
  if (existingAccessory) {
1178
1157
  // the accessory already exists
1179
1158
  if (!device.hide_device && device.hubDeviceId) {
1180
- this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1159
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1181
1160
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1182
1161
  existingAccessory.context.model = device.remoteType;
1183
1162
  existingAccessory.context.deviceID = device.deviceId;
1184
1163
  existingAccessory.displayName = device.deviceName;
1185
1164
  existingAccessory.context.firmwareRevision = this.version;
1186
1165
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1187
- await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1166
+ await this.connectionTypeExistingIRAccessory(existingAccessory);
1188
1167
  this.api.updatePlatformAccessories([existingAccessory]);
1189
1168
  // create the accessory handler for the restored accessory
1190
1169
  // this is imported from `platformAccessory.ts`
1191
1170
  new waterheaters_1.WaterHeater(this, existingAccessory, device);
1192
- this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1171
+ this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1193
1172
  }
1194
1173
  else {
1195
1174
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1197,7 +1176,7 @@ class SwitchBotPlatform {
1197
1176
  }
1198
1177
  else if (!device.hide_device && device.hubDeviceId) {
1199
1178
  // the accessory does not yet exist, so we need to create it
1200
- this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1179
+ this.infoLog(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1201
1180
  // create a new accessory
1202
1181
  const accessory = new this.api.platformAccessory(device.deviceName, uuid);
1203
1182
  // store a copy of the device object in the `accessory.context`
@@ -1207,17 +1186,17 @@ class SwitchBotPlatform {
1207
1186
  accessory.context.deviceID = device.deviceId;
1208
1187
  accessory.context.firmwareRevision = this.version;
1209
1188
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1210
- await this.connectionTypeNewIRAccessory(device, accessory);
1189
+ await this.connectionTypeNewIRAccessory(accessory);
1211
1190
  // create the accessory handler for the newly create accessory
1212
1191
  // this is imported from `platformAccessory.ts`
1213
1192
  new waterheaters_1.WaterHeater(this, accessory, device);
1214
- this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1193
+ this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1215
1194
  // link the accessory to your platform
1216
1195
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
1217
1196
  this.accessories.push(accessory);
1218
1197
  }
1219
1198
  else {
1220
- this.device(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
1199
+ this.debugLog(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
1221
1200
  }
1222
1201
  }
1223
1202
  async createVacuumCleaner(device) {
@@ -1228,19 +1207,19 @@ class SwitchBotPlatform {
1228
1207
  if (existingAccessory) {
1229
1208
  // the accessory already exists
1230
1209
  if (!device.hide_device && device.hubDeviceId) {
1231
- this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1210
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1232
1211
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1233
1212
  existingAccessory.context.model = device.remoteType;
1234
1213
  existingAccessory.context.deviceID = device.deviceId;
1235
1214
  existingAccessory.displayName = device.deviceName;
1236
1215
  existingAccessory.context.firmwareRevision = this.version;
1237
1216
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1238
- await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1217
+ await this.connectionTypeExistingIRAccessory(existingAccessory);
1239
1218
  this.api.updatePlatformAccessories([existingAccessory]);
1240
1219
  // create the accessory handler for the restored accessory
1241
1220
  // this is imported from `platformAccessory.ts`
1242
1221
  new vacuumcleaners_1.VacuumCleaner(this, existingAccessory, device);
1243
- this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1222
+ this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1244
1223
  }
1245
1224
  else {
1246
1225
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1248,7 +1227,7 @@ class SwitchBotPlatform {
1248
1227
  }
1249
1228
  else if (!device.hide_device && device.hubDeviceId) {
1250
1229
  // the accessory does not yet exist, so we need to create it
1251
- this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1230
+ this.infoLog(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1252
1231
  // create a new accessory
1253
1232
  const accessory = new this.api.platformAccessory(device.deviceName, uuid);
1254
1233
  // store a copy of the device object in the `accessory.context`
@@ -1258,17 +1237,17 @@ class SwitchBotPlatform {
1258
1237
  accessory.context.deviceID = device.deviceId;
1259
1238
  accessory.context.firmwareRevision = this.version;
1260
1239
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1261
- await this.connectionTypeNewIRAccessory(device, accessory);
1240
+ await this.connectionTypeNewIRAccessory(accessory);
1262
1241
  // create the accessory handler for the newly create accessory
1263
1242
  // this is imported from `platformAccessory.ts`
1264
1243
  new vacuumcleaners_1.VacuumCleaner(this, accessory, device);
1265
- this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1244
+ this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1266
1245
  // link the accessory to your platform
1267
1246
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
1268
1247
  this.accessories.push(accessory);
1269
1248
  }
1270
1249
  else {
1271
- this.device(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
1250
+ this.debugLog(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
1272
1251
  }
1273
1252
  }
1274
1253
  async createCamera(device) {
@@ -1279,19 +1258,19 @@ class SwitchBotPlatform {
1279
1258
  if (existingAccessory) {
1280
1259
  // the accessory already exists
1281
1260
  if (!device.hide_device && device.hubDeviceId) {
1282
- this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1261
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1283
1262
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1284
1263
  existingAccessory.context.model = device.remoteType;
1285
1264
  existingAccessory.context.deviceID = device.deviceId;
1286
1265
  existingAccessory.displayName = device.deviceName;
1287
1266
  existingAccessory.context.firmwareRevision = this.version;
1288
1267
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1289
- await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1268
+ await this.connectionTypeExistingIRAccessory(existingAccessory);
1290
1269
  this.api.updatePlatformAccessories([existingAccessory]);
1291
1270
  // create the accessory handler for the restored accessory
1292
1271
  // this is imported from `platformAccessory.ts`
1293
1272
  new cameras_1.Camera(this, existingAccessory, device);
1294
- this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1273
+ this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1295
1274
  }
1296
1275
  else {
1297
1276
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1299,7 +1278,7 @@ class SwitchBotPlatform {
1299
1278
  }
1300
1279
  else if (!device.hide_device && device.hubDeviceId) {
1301
1280
  // the accessory does not yet exist, so we need to create it
1302
- this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1281
+ this.infoLog(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1303
1282
  // create a new accessory
1304
1283
  const accessory = new this.api.platformAccessory(device.deviceName, uuid);
1305
1284
  // store a copy of the device object in the `accessory.context`
@@ -1309,17 +1288,17 @@ class SwitchBotPlatform {
1309
1288
  accessory.context.deviceID = device.deviceId;
1310
1289
  accessory.context.firmwareRevision = this.version;
1311
1290
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1312
- await this.connectionTypeNewIRAccessory(device, accessory);
1291
+ await this.connectionTypeNewIRAccessory(accessory);
1313
1292
  // create the accessory handler for the newly create accessory
1314
1293
  // this is imported from `platformAccessory.ts`
1315
1294
  new cameras_1.Camera(this, accessory, device);
1316
- this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1295
+ this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1317
1296
  // link the accessory to your platform
1318
1297
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
1319
1298
  this.accessories.push(accessory);
1320
1299
  }
1321
1300
  else {
1322
- this.device(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
1301
+ this.debugLog(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
1323
1302
  }
1324
1303
  }
1325
1304
  async createOthers(device) {
@@ -1330,19 +1309,19 @@ class SwitchBotPlatform {
1330
1309
  if (existingAccessory) {
1331
1310
  // the accessory already exists
1332
1311
  if (!device.hide_device && device.hubDeviceId) {
1333
- this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1312
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1334
1313
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1335
1314
  existingAccessory.context.model = device.remoteType;
1336
1315
  existingAccessory.context.deviceID = device.deviceId;
1337
1316
  existingAccessory.displayName = device.deviceName;
1338
1317
  existingAccessory.context.firmwareRevision = this.version;
1339
1318
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1340
- await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1319
+ await this.connectionTypeExistingIRAccessory(existingAccessory);
1341
1320
  this.api.updatePlatformAccessories([existingAccessory]);
1342
1321
  // create the accessory handler for the restored accessory
1343
1322
  // this is imported from `platformAccessory.ts`
1344
1323
  new others_1.Others(this, existingAccessory, device);
1345
- this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1324
+ this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1346
1325
  }
1347
1326
  else {
1348
1327
  this.unregisterPlatformAccessories(existingAccessory);
@@ -1350,7 +1329,7 @@ class SwitchBotPlatform {
1350
1329
  }
1351
1330
  else if (!device.hide_device && device.hubDeviceId) {
1352
1331
  // the accessory does not yet exist, so we need to create it
1353
- this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1332
+ this.infoLog(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1354
1333
  // create a new accessory
1355
1334
  const accessory = new this.api.platformAccessory(device.deviceName, uuid);
1356
1335
  // store a copy of the device object in the `accessory.context`
@@ -1360,17 +1339,17 @@ class SwitchBotPlatform {
1360
1339
  accessory.context.deviceID = device.deviceId;
1361
1340
  accessory.context.firmwareRevision = this.version;
1362
1341
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1363
- await this.connectionTypeNewIRAccessory(device, accessory);
1342
+ await this.connectionTypeNewIRAccessory(accessory);
1364
1343
  // create the accessory handler for the newly create accessory
1365
1344
  // this is imported from `platformAccessory.ts`
1366
1345
  new others_1.Others(this, accessory, device);
1367
- this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1346
+ this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1368
1347
  // link the accessory to your platform
1369
1348
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
1370
1349
  this.accessories.push(accessory);
1371
1350
  }
1372
1351
  else {
1373
- this.device(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
1352
+ this.debugLog(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
1374
1353
  }
1375
1354
  }
1376
1355
  async connectionTypeNewAccessory(device, accessory) {
@@ -1389,63 +1368,67 @@ class SwitchBotPlatform {
1389
1368
  existingAccessory.context.connectionType = 'OpenAPI';
1390
1369
  }
1391
1370
  }
1392
- async connectionTypeNewIRAccessory(device, accessory) {
1371
+ async connectionTypeNewIRAccessory(accessory) {
1393
1372
  accessory.context.connectionType = 'IR wirth OpenAPI';
1394
1373
  }
1395
- async connectionTypeExistingIRAccessory(device, existingAccessory) {
1374
+ async connectionTypeExistingIRAccessory(existingAccessory) {
1396
1375
  existingAccessory.context.connectionType = 'IR with OpenAPI';
1397
1376
  }
1398
1377
  unregisterPlatformAccessories(existingAccessory) {
1399
1378
  // remove platform accessories when no longer present
1400
1379
  this.api.unregisterPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [existingAccessory]);
1401
- this.log.info('Removing existing accessory from cache:', existingAccessory.displayName);
1380
+ this.infoLog('Removing existing accessory from cache:', existingAccessory.displayName);
1402
1381
  }
1403
1382
  deviceListInfo(devices) {
1404
- if (this.config.options?.debug === 'device') {
1405
- this.device(`deviceListInfoStatus: ${JSON.stringify(devices)}`);
1383
+ if (this.platformLogging === 'debug') {
1384
+ this.warnLog(`deviceListInfoStatus: ${JSON.stringify(devices)}`);
1406
1385
  }
1407
1386
  }
1408
1387
  async deviceInfo(device) {
1409
- if (this.config.options?.debug === 'device') {
1410
- this.device(JSON.stringify(device));
1388
+ if (this.platformLogging === 'debug') {
1389
+ this.warnLog(JSON.stringify(device));
1411
1390
  this.deviceStatus = (await this.axios.get(`${settings_1.DeviceURL}/${device.deviceId}/status`)).data;
1412
1391
  if (this.deviceStatus.message === 'success') {
1413
- this.device(`${device.deviceName} deviceInfoStatus: ${JSON.stringify(this.deviceStatus)}`);
1392
+ this.warnLog(`${device.deviceName} deviceInfoStatus: ${JSON.stringify(this.deviceStatus)}`);
1414
1393
  }
1415
1394
  else {
1416
- this.device(`${device.deviceName} deviceInfoStatus: ${JSON.stringify(this.deviceStatus.message)}`);
1417
- this.device('Unable to retreive deviceInfoStatus.');
1395
+ this.warnLog(`${device.deviceName} deviceInfoStatus: ${JSON.stringify(this.deviceStatus.message)}`);
1396
+ this.warnLog('Unable to retreive deviceInfoStatus.');
1418
1397
  }
1419
1398
  }
1420
1399
  }
1421
1400
  /**
1422
- * If debug level logging is turned on, log to log.info
1401
+ * If device level logging is turned on, log to log.warn
1423
1402
  * Otherwise send debug logs to log.debug
1424
- * this.debugMode = process.argv.includes('-D') || process.argv.includes('--debug');
1425
1403
  */
1426
- debug(...log) {
1427
- if (this.config.options.debug === 'debug') {
1428
- this.log.info('[DEBUG]', String(...log));
1429
- }
1430
- else {
1431
- this.log.debug(String(...log));
1404
+ infoLog(...log) {
1405
+ if (this.enablingPlatfromLogging()) {
1406
+ this.log.info(String(...log));
1432
1407
  }
1433
1408
  }
1434
- /**
1435
- * If device level logging is turned on, log to log.warn
1436
- * Otherwise send debug logs to log.debug
1437
- */
1438
- device(...log) {
1439
- if (this.config.options.debug === 'device') {
1440
- this.log.warn('[DEVICE]', String(...log));
1409
+ warnLog(...log) {
1410
+ if (this.enablingPlatfromLogging()) {
1411
+ this.log.warn(String(...log));
1441
1412
  }
1442
- else if (this.config.options.debug === 'debug') {
1443
- this.log.info('[DEBUG]', String(...log));
1413
+ }
1414
+ errorLog(...log) {
1415
+ if (this.enablingPlatfromLogging()) {
1416
+ this.log.error(String(...log));
1444
1417
  }
1445
- else {
1446
- this.log.debug(String(...log));
1418
+ }
1419
+ debugLog(...log) {
1420
+ if (this.enablingPlatfromLogging()) {
1421
+ if (this.platformLogging === 'debugMode') {
1422
+ this.log.debug(String(...log));
1423
+ }
1424
+ else if (this.platformLogging === 'debug') {
1425
+ this.log.info('[DEBUG]', String(...log));
1426
+ }
1447
1427
  }
1448
1428
  }
1429
+ enablingPlatfromLogging() {
1430
+ return this.platformLogging?.includes('debug') || this.platformLogging === 'standard';
1431
+ }
1449
1432
  }
1450
1433
  exports.SwitchBotPlatform = SwitchBotPlatform;
1451
1434
  //# sourceMappingURL=platform.js.map