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