@switchbot/homebridge-switchbot 0.1.2-beta.7 → 0.2.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/.github/ISSUE_TEMPLATE/feature-request.yml +1 -1
  2. package/.github/dependabot.yml +2 -0
  3. package/.github/workflows/codeql-analysis.yml +71 -0
  4. package/CHANGELOG.md +5 -1
  5. package/README.md +2 -1
  6. package/config.schema.json +420 -471
  7. package/dist/devices/bots.d.ts +19 -5
  8. package/dist/devices/bots.d.ts.map +1 -1
  9. package/dist/devices/bots.js +172 -148
  10. package/dist/devices/bots.js.map +1 -1
  11. package/dist/devices/bulb.d.ts +8 -6
  12. package/dist/devices/bulb.d.ts.map +1 -1
  13. package/dist/devices/bulb.js +45 -28
  14. package/dist/devices/bulb.js.map +1 -1
  15. package/dist/devices/contact.d.ts +10 -5
  16. package/dist/devices/contact.d.ts.map +1 -1
  17. package/dist/devices/contact.js +94 -63
  18. package/dist/devices/contact.js.map +1 -1
  19. package/dist/devices/curtains.d.ts +14 -5
  20. package/dist/devices/curtains.d.ts.map +1 -1
  21. package/dist/devices/curtains.js +174 -120
  22. package/dist/devices/curtains.js.map +1 -1
  23. package/dist/devices/humidifiers.d.ts +6 -6
  24. package/dist/devices/humidifiers.d.ts.map +1 -1
  25. package/dist/devices/humidifiers.js +78 -94
  26. package/dist/devices/humidifiers.js.map +1 -1
  27. package/dist/devices/indoorcam.d.ts +43 -0
  28. package/dist/devices/indoorcam.d.ts.map +1 -0
  29. package/dist/devices/indoorcam.js +241 -0
  30. package/dist/devices/indoorcam.js.map +1 -0
  31. package/dist/devices/meters.d.ts +8 -5
  32. package/dist/devices/meters.d.ts.map +1 -1
  33. package/dist/devices/meters.js +126 -92
  34. package/dist/devices/meters.js.map +1 -1
  35. package/dist/devices/motion.d.ts +9 -5
  36. package/dist/devices/motion.d.ts.map +1 -1
  37. package/dist/devices/motion.js +74 -59
  38. package/dist/devices/motion.js.map +1 -1
  39. package/dist/devices/plugs.d.ts +5 -4
  40. package/dist/devices/plugs.d.ts.map +1 -1
  41. package/dist/devices/plugs.js +65 -56
  42. package/dist/devices/plugs.js.map +1 -1
  43. package/dist/irdevices/airconditioners.d.ts +3 -3
  44. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  45. package/dist/irdevices/airconditioners.js +12 -7
  46. package/dist/irdevices/airconditioners.js.map +1 -1
  47. package/dist/irdevices/airpurifiers.d.ts +3 -3
  48. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  49. package/dist/irdevices/airpurifiers.js +1 -1
  50. package/dist/irdevices/airpurifiers.js.map +1 -1
  51. package/dist/irdevices/cameras.d.ts +3 -3
  52. package/dist/irdevices/cameras.d.ts.map +1 -1
  53. package/dist/irdevices/cameras.js +1 -1
  54. package/dist/irdevices/cameras.js.map +1 -1
  55. package/dist/irdevices/fans.d.ts +3 -3
  56. package/dist/irdevices/fans.d.ts.map +1 -1
  57. package/dist/irdevices/fans.js +11 -12
  58. package/dist/irdevices/fans.js.map +1 -1
  59. package/dist/irdevices/lights.d.ts +3 -3
  60. package/dist/irdevices/lights.d.ts.map +1 -1
  61. package/dist/irdevices/lights.js +1 -1
  62. package/dist/irdevices/lights.js.map +1 -1
  63. package/dist/irdevices/others.d.ts +3 -3
  64. package/dist/irdevices/others.d.ts.map +1 -1
  65. package/dist/irdevices/others.js +8 -8
  66. package/dist/irdevices/others.js.map +1 -1
  67. package/dist/irdevices/tvs.d.ts +3 -3
  68. package/dist/irdevices/tvs.d.ts.map +1 -1
  69. package/dist/irdevices/tvs.js +16 -6
  70. package/dist/irdevices/tvs.js.map +1 -1
  71. package/dist/irdevices/vacuumcleaners.d.ts +3 -3
  72. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  73. package/dist/irdevices/vacuumcleaners.js +2 -3
  74. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  75. package/dist/irdevices/waterheaters.d.ts +3 -3
  76. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  77. package/dist/irdevices/waterheaters.js +2 -2
  78. package/dist/irdevices/waterheaters.js.map +1 -1
  79. package/dist/platform.d.ts +14 -5
  80. package/dist/platform.d.ts.map +1 -1
  81. package/dist/platform.js +420 -418
  82. package/dist/platform.js.map +1 -1
  83. package/dist/settings.d.ts +18 -15
  84. package/dist/settings.d.ts.map +1 -1
  85. package/package.json +65 -65
  86. package/src/devices/bots.ts +188 -165
  87. package/src/devices/bulb.ts +48 -40
  88. package/src/devices/contact.ts +100 -73
  89. package/src/devices/curtains.ts +192 -140
  90. package/src/devices/humidifiers.ts +82 -124
  91. package/src/devices/indoorcam.ts +303 -0
  92. package/src/devices/meters.ts +130 -110
  93. package/src/devices/motion.ts +80 -69
  94. package/src/devices/plugs.ts +67 -65
  95. package/src/irdevices/airconditioners.ts +14 -10
  96. package/src/irdevices/airpurifiers.ts +4 -4
  97. package/src/irdevices/cameras.ts +4 -4
  98. package/src/irdevices/fans.ts +14 -18
  99. package/src/irdevices/lights.ts +4 -4
  100. package/src/irdevices/others.ts +12 -14
  101. package/src/irdevices/tvs.ts +21 -10
  102. package/src/irdevices/vacuumcleaners.ts +5 -9
  103. package/src/irdevices/waterheaters.ts +5 -5
  104. package/src/platform.ts +455 -619
  105. package/src/settings.ts +19 -15
  106. package/.github/workflows/issue-validate.yml +0 -18
package/dist/platform.js CHANGED
@@ -12,6 +12,7 @@ const meters_1 = require("./devices/meters");
12
12
  const motion_1 = require("./devices/motion");
13
13
  const contact_1 = require("./devices/contact");
14
14
  const curtains_1 = require("./devices/curtains");
15
+ const indoorcam_1 = require("./devices/indoorcam");
15
16
  const humidifiers_1 = require("./devices/humidifiers");
16
17
  const tvs_1 = require("./irdevices/tvs");
17
18
  const fans_1 = require("./irdevices/fans");
@@ -90,13 +91,9 @@ class SwitchBotPlatform {
90
91
  */
91
92
  configureAccessory(accessory) {
92
93
  this.log.info('Loading accessory from cache:', accessory.displayName);
93
- //accessory.context.timeout = this.apiError(accessory);
94
94
  // add the restored accessory to the accessories cache so we can track if it has already been registered
95
95
  this.accessories.push(accessory);
96
96
  }
97
- apiError(accessory) {
98
- this.log.debug('API Error:', accessory.displayName);
99
- }
100
97
  /**
101
98
  * Verify the config passed to the plugin is valid
102
99
  */
@@ -105,58 +102,26 @@ class SwitchBotPlatform {
105
102
  * Hidden Device Discovery Option
106
103
  * This will disable adding any device and will just output info.
107
104
  */
108
- this.config.devicediscovery;
109
105
  this.config.options = this.config.options || {};
110
- //Enable BLE for Device
111
- this.config.options.ble;
112
- // Hide Devices by DeviceID
113
- this.config.options.hide_device = this.config.options.hide_device || [];
114
- // Meter Config Options
115
- this.config.options.bot = this.config.options.bot || {};
116
- this.config.options.bot.device_press;
117
- this.config.options.bot.device_switch;
118
- // Meter Config Options
119
- this.config.options.meter = this.config.options.meter || {};
120
- this.config.options.meter.hide_temperature;
121
- this.config.options.meter.hide_humidity;
122
- // Humidifier Config Options
123
- this.config.options.humidifier = this.config.options.humidifier || {};
124
- this.config.options.humidifier.set_minStep;
125
- this.config.options.humidifier.hide_temperature;
126
- // Curtain Config Options
127
- this.config.options.curtain = this.config.options.curtain || {};
128
- this.config.options.curtain.disable_group;
129
- if (!this.config.options.curtain.refreshRate) {
130
- this.config.options.curtain.refreshRate = 5;
131
- if (this.config.options.debug) {
132
- this.log.warn('Using Default Curtain Refresh Rate.');
106
+ this.config.options.debug;
107
+ // Device Config
108
+ if (this.config.options.devices) {
109
+ for (const deviceConfig of this.config.options.devices) {
110
+ if (!deviceConfig.type) {
111
+ this.log.error('The devices config section is missing the "Type" in the config, Check Your Conifg.');
112
+ }
113
+ if (!deviceConfig.deviceId) {
114
+ this.log.error('The devices config section is missing the "Device ID" in the config, Check Your Conifg.');
115
+ }
133
116
  }
134
117
  }
135
- this.config.options.curtain.set_minStep;
136
- this.config.options.curtain.set_min;
137
- this.config.options.curtain.set_max;
138
- // Fan Config Options
139
- this.config.options.fan = this.config.options.fan || {};
140
- this.config.options.fan.swing_mode;
141
- this.config.options.fan.rotation_speed;
142
- this.config.options.fan.set_minStep;
143
- this.config.options.fan.set_min;
144
- this.config.options.fan.set_max;
145
- // AirConditioner Config Options
146
- this.config.options.irair = this.config.options.irair || {};
147
- this.config.options.irair.hide_automode;
148
- // Others Config Options
149
- this.config.options.other = this.config.options.other || {};
150
- this.config.options.other.deviceType;
151
- this.config.options.other.commandOn;
152
- this.config.options.other.commandOff;
153
- if (this.config.options.refreshRate < 120) {
154
- throw new Error('Refresh Rate must be above 120 (2 minutes).');
118
+ if (this.config.options.refreshRate < 30) {
119
+ throw new Error('Refresh Rate must be above 30 (30 seconds).');
155
120
  }
156
121
  if (!this.config.options.refreshRate) {
157
- // default 600 seconds (15 minutes)
158
- this.config.options.refreshRate = 1000;
159
- this.log.warn('Using Default Refresh Rate.');
122
+ // default 120 seconds (2 minutes)
123
+ this.config.options.refreshRate = 120;
124
+ this.log.warn('Using Default Refresh Rate (2 minutes).');
160
125
  }
161
126
  if (!this.config.options.pushRate) {
162
127
  // default 100 milliseconds
@@ -175,168 +140,40 @@ class SwitchBotPlatform {
175
140
  */
176
141
  async discoverDevices() {
177
142
  try {
178
- const devices = (await this.axios.get(settings_1.DeviceURL)).data;
179
- if (this.config.devicediscovery) {
180
- this.deviceListInfo(devices);
181
- }
182
- else {
183
- this.log.debug(JSON.stringify(devices));
184
- }
185
- this.log.info('Total SwitchBot Devices Found:', devices.body.deviceList.length);
186
- this.log.info('Total IR Devices Found:', devices.body.infraredRemoteList.length);
187
- for (const device of devices.body.deviceList) {
188
- if (this.config.devicediscovery) {
189
- this.deviceInfo(device);
190
- }
191
- else {
192
- this.debug(JSON.stringify(device));
193
- }
194
- // For Future Devices
195
- switch (device.deviceType) {
196
- case 'Humidifier':
197
- if (this.config.devicediscovery) {
198
- this.log.info('Discovered %s %s', device.deviceName, device.deviceType);
199
- }
200
- this.createHumidifier(device);
201
- break;
202
- case 'Hub Mini':
203
- if (this.config.devicediscovery) {
204
- this.log.info('Discovered a %s', device.deviceType);
205
- }
206
- break;
207
- case 'Hub Plus':
208
- if (this.config.devicediscovery) {
209
- this.log.info('Discovered a %s', device.deviceType);
210
- }
211
- break;
212
- case 'Bot':
213
- if (this.config.devicediscovery) {
214
- this.log.info('Discovered %s %s', device.deviceName, device.deviceType);
215
- }
216
- this.createBot(device);
217
- break;
218
- case 'Meter':
219
- if (this.config.devicediscovery) {
220
- this.log.info('Discovered %s %s', device.deviceName, device.deviceType);
221
- }
222
- this.createMeter(device);
223
- break;
224
- case 'Motion Sensor':
225
- if (this.config.devicediscovery) {
226
- this.log.info('Discovered %s %s', device.deviceName, device.deviceType);
227
- }
228
- this.createMotion(device);
229
- break;
230
- case 'Contact Sensor':
231
- if (this.config.devicediscovery) {
232
- this.log.info('Discovered %s %s', device.deviceName, device.deviceType);
233
- }
234
- this.createContact(device);
235
- break;
236
- case 'Curtain':
237
- if (this.config.devicediscovery) {
238
- this.log.info('Discovered %s %s', device.deviceName, device.deviceType);
239
- }
240
- this.createCurtain(device);
241
- break;
242
- case 'Plug':
243
- if (this.config.devicediscovery) {
244
- this.log.info('Discovered %s %s', device.deviceName, device.deviceType);
245
- }
246
- this.createPlug(device);
247
- break;
248
- case 'Remote':
249
- if (this.config.devicediscovery) {
250
- this.debug(`Discovered ${device.deviceName}, ${device.deviceType} is Not Supported.`);
251
- }
252
- break;
253
- default:
254
- this.log.info('Device: %s with Device Type: %s, is currently not supported.', device.deviceName, device.deviceType, 'Submit Feature Requests Here: https://git.io/JL14Z');
143
+ const devicesAPI = (await this.axios.get(settings_1.DeviceURL)).data;
144
+ this.deviceListInfo(devicesAPI);
145
+ this.debug(JSON.stringify(devicesAPI));
146
+ this.log.info('Total SwitchBot Devices Found:', devicesAPI.body.deviceList.length);
147
+ this.log.info('Total IR Devices Found:', devicesAPI.body.infraredRemoteList.length);
148
+ const deviceLists = devicesAPI.body.deviceList;
149
+ if (!this.config.options?.devices) {
150
+ this.debug(`Config Not Set: ${JSON.stringify(this.config.options?.devices)}`);
151
+ const devices = deviceLists.map((v) => v);
152
+ for (const device of devices) {
153
+ if (device.deviceType) {
154
+ this.createDevice(device);
155
+ }
156
+ else {
157
+ this.createIRDevice(device);
158
+ }
255
159
  }
256
160
  }
257
- for (const device of devices.body.infraredRemoteList) {
258
- if (this.config.devicediscovery) {
259
- this.deviceInfo(device);
260
- }
261
- else {
262
- this.debug(JSON.stringify(device));
263
- }
264
- // For Future Devices
265
- switch (device.remoteType) {
266
- case 'TV':
267
- case 'DIY TV':
268
- case 'Projector':
269
- case 'DIY Projector':
270
- case 'Set Top Box':
271
- case 'DIY Set Top Box':
272
- case 'IPTV':
273
- case 'DIY IPTV':
274
- case 'DVD':
275
- case 'DIY DVD':
276
- case 'Speaker':
277
- case 'DIY Speaker':
278
- if (this.config.devicediscovery) {
279
- this.log.info('Discovered %s %s', device.deviceName, device.remoteType);
280
- }
281
- this.createTV(device);
282
- break;
283
- case 'Fan':
284
- case 'DIY Fan':
285
- if (this.config.devicediscovery) {
286
- this.log.info('Discovered %s %s', device.deviceName, device.remoteType);
287
- }
288
- this.createFan(device);
289
- break;
290
- case 'Air Conditioner':
291
- case 'DIY Air Conditioner':
292
- if (this.config.devicediscovery) {
293
- this.log.info('Discovered %s %s', device.deviceName, device.remoteType);
294
- }
295
- this.createAirConditioner(device);
296
- break;
297
- case 'Light':
298
- case 'DIY Light':
299
- if (this.config.devicediscovery) {
300
- this.log.info('Discovered %s %s', device.deviceName, device.remoteType);
301
- }
302
- this.createLight(device);
303
- break;
304
- case 'Air Purifier':
305
- case 'DIY Air Purifier':
306
- if (this.config.devicediscovery) {
307
- this.log.info('Discovered %s %s', device.deviceName, device.remoteType);
308
- }
309
- this.createAirPurifier(device);
310
- break;
311
- case 'Water Heater':
312
- case 'DIY Water Heater':
313
- if (this.config.devicediscovery) {
314
- this.log.info('Discovered %s %s', device.deviceName, device.remoteType);
315
- }
316
- this.createWaterHeater(device);
317
- break;
318
- case 'Vacuum Cleaner':
319
- case 'DIY Vacuum Cleaner':
320
- if (this.config.devicediscovery) {
321
- this.log.info('Discovered %s %s', device.deviceName, device.remoteType);
322
- }
323
- this.createVacuumCleaner(device);
324
- break;
325
- case 'Camera':
326
- case 'DIY Camera':
327
- if (this.config.devicediscovery) {
328
- this.log.info('Discovered %s %s', device.deviceName, device.remoteType);
329
- }
330
- this.createCamera(device);
331
- break;
332
- case 'Others':
333
- if (this.config.devicediscovery) {
334
- this.log.info('Discovered %s %s', device.deviceName, device.remoteType);
335
- }
336
- this.createOthers(device);
337
- break;
338
- default:
339
- this.log.info('Device: %s with Device Type: %s, is currently not supported.', device.deviceName, device.remoteType, 'Submit Feature Requests Here: https://git.io/JL14Z');
161
+ else {
162
+ this.debug(`Config Set: ${JSON.stringify(this.config.options?.devices)}`);
163
+ const deviceConfigs = this.config.options?.devices;
164
+ const mergeBydeviceId = (a1, a2) => a1.map((itm) => ({
165
+ ...a2.find((item) => (item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId) && item),
166
+ ...itm,
167
+ }));
168
+ const devices = mergeBydeviceId(deviceLists, deviceConfigs);
169
+ this.debug(JSON.stringify(devices));
170
+ for (const device of devices) {
171
+ if (device.deviceType) {
172
+ this.createDevice(device);
173
+ }
174
+ else {
175
+ this.createIRDevice(device);
176
+ }
340
177
  }
341
178
  }
342
179
  }
@@ -345,189 +182,301 @@ class SwitchBotPlatform {
345
182
  this.debug(JSON.stringify(e));
346
183
  }
347
184
  }
185
+ createDevice(device) {
186
+ switch (device.deviceType) {
187
+ case 'Humidifier':
188
+ this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
189
+ this.createHumidifier(device);
190
+ break;
191
+ case 'Hub Mini':
192
+ this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
193
+ break;
194
+ case 'Hub Plus':
195
+ this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
196
+ break;
197
+ case 'Bot':
198
+ this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
199
+ this.createBot(device);
200
+ break;
201
+ case 'Meter':
202
+ this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
203
+ this.createMeter(device);
204
+ break;
205
+ case 'Motion Sensor':
206
+ this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
207
+ this.createMotion(device);
208
+ break;
209
+ case 'Contact Sensor':
210
+ this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
211
+ this.createContact(device);
212
+ break;
213
+ case 'Curtain':
214
+ this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
215
+ this.createCurtain(device);
216
+ break;
217
+ case 'Plug':
218
+ this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
219
+ this.createPlug(device);
220
+ break;
221
+ case 'IndoorCam':
222
+ this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
223
+ this.createIndoorCam(device);
224
+ break;
225
+ case 'Remote':
226
+ this.debug(`Discovered ${device.deviceType}: ${device.deviceId} is Not Supported.`);
227
+ break;
228
+ default:
229
+ this.log.info(`Device: ${device.deviceName} with Device Type: ${device.deviceType}, is currently not supported.`);
230
+ this.log.info('Submit Feature Requests Here: https://git.io/JL14Z');
231
+ }
232
+ }
233
+ createIRDevice(device) {
234
+ switch (device.remoteType) {
235
+ case 'TV':
236
+ case 'DIY TV':
237
+ case 'Projector':
238
+ case 'DIY Projector':
239
+ case 'Set Top Box':
240
+ case 'DIY Set Top Box':
241
+ case 'IPTV':
242
+ case 'DIY IPTV':
243
+ case 'DVD':
244
+ case 'DIY DVD':
245
+ case 'Speaker':
246
+ case 'DIY Speaker':
247
+ this.debug(`Discovered ${device.remoteType}: ${device.deviceId}`);
248
+ this.createTV(device);
249
+ break;
250
+ case 'Fan':
251
+ case 'DIY Fan':
252
+ this.debug(`Discovered ${device.remoteType}: ${device.deviceId}`);
253
+ this.createFan(device);
254
+ break;
255
+ case 'Air Conditioner':
256
+ case 'DIY Air Conditioner':
257
+ this.debug(`Discovered ${device.remoteType}: ${device.deviceId}`);
258
+ this.createAirConditioner(device);
259
+ break;
260
+ case 'Light':
261
+ case 'DIY Light':
262
+ this.debug(`Discovered ${device.remoteType}: ${device.deviceId}`);
263
+ this.createLight(device);
264
+ break;
265
+ case 'Air Purifier':
266
+ case 'DIY Air Purifier':
267
+ this.debug(`Discovered ${device.remoteType}: ${device.deviceId}`);
268
+ this.createAirPurifier(device);
269
+ break;
270
+ case 'Water Heater':
271
+ case 'DIY Water Heater':
272
+ this.debug(`Discovered ${device.remoteType}: ${device.deviceId}`);
273
+ this.createWaterHeater(device);
274
+ break;
275
+ case 'Vacuum Cleaner':
276
+ case 'DIY Vacuum Cleaner':
277
+ this.debug(`Discovered ${device.remoteType}: ${device.deviceId}`);
278
+ this.createVacuumCleaner(device);
279
+ break;
280
+ case 'Camera':
281
+ case 'DIY Camera':
282
+ this.debug(`Discovered ${device.remoteType}: ${device.deviceId}`);
283
+ this.createCamera(device);
284
+ break;
285
+ case 'Others':
286
+ this.debug(`Discovered ${device.remoteType}: ${device.deviceId}`);
287
+ this.createOthers(device);
288
+ break;
289
+ default:
290
+ this.log.info(`Device: ${device.deviceName} with Device Type: ${device.remoteType}, is currently not supported.`);
291
+ this.log.info('Submit Feature Requests Here: https://git.io/JL14Z');
292
+ }
293
+ }
348
294
  async createHumidifier(device) {
349
- const uuid = this.api.hap.uuid.generate(`${device.deviceName}-${device.deviceId}-${device.deviceType}`);
295
+ const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
350
296
  // see if an accessory with the same uuid has already been registered and restored from
351
297
  // the cached devices we stored in the `configureAccessory` method above
352
298
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
353
299
  if (existingAccessory) {
354
300
  // the accessory already exists
355
- if (!this.config.options?.hide_device.includes(device.deviceId) && device.enableCloudService) {
356
- this.log.info('Restoring existing accessory from cache: %s DeviceID: %s', existingAccessory.displayName, device.deviceId);
301
+ if (!device.hide_device && device.enableCloudService) {
302
+ this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
357
303
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
358
304
  //existingAccessory.context.firmwareRevision = firmware;
359
305
  existingAccessory.context.model = device.deviceType;
360
306
  existingAccessory.context.deviceID = device.deviceId;
307
+ existingAccessory.displayName = device.deviceName;
361
308
  existingAccessory.context.firmwareRevision = this.version;
362
309
  await this.connectionTypeExistingAccessory(device, existingAccessory);
363
310
  this.api.updatePlatformAccessories([existingAccessory]);
364
311
  // create the accessory handler for the restored accessory
365
312
  // this is imported from `platformAccessory.ts`
366
313
  new humidifiers_1.Humidifier(this, existingAccessory, device);
367
- this.debug(`${device.deviceType} UDID: ${device.deviceName}-${device.deviceId}-${device.deviceType}`);
314
+ this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
368
315
  }
369
316
  else {
370
317
  this.unregisterPlatformAccessories(existingAccessory);
371
318
  }
372
319
  }
373
- else if (!this.config.options?.hide_device.includes(device.deviceId) && device.enableCloudService) {
320
+ else if (!device.hide_device && device.enableCloudService) {
374
321
  // the accessory does not yet exist, so we need to create it
375
- this.log.info('Adding new accessory: %s %s DeviceID: %s', device.deviceName, device.deviceType, device.deviceId);
322
+ this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
376
323
  // create a new accessory
377
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
324
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
378
325
  // store a copy of the device object in the `accessory.context`
379
326
  // the `context` property can be used to store any data about the accessory you may need
380
327
  accessory.context.device = device;
381
328
  accessory.context.model = device.deviceType;
382
329
  accessory.context.deviceID = device.deviceId;
383
330
  accessory.context.firmwareRevision = this.version;
384
- await this.connectionTypeNewAccessory(device, accessory);
331
+ await this.connectionTypeExistingAccessory(device, accessory);
385
332
  // create the accessory handler for the newly create accessory
386
333
  // this is imported from `platformAccessory.ts`
387
334
  new humidifiers_1.Humidifier(this, accessory, device);
388
- this.debug(`${device.deviceType} UDID: ${device.deviceName}-${device.deviceId}-${device.deviceType}`);
335
+ this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
389
336
  // link the accessory to your platform
390
337
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
391
338
  this.accessories.push(accessory);
392
339
  }
393
340
  else {
394
- if (this.config.devicediscovery) {
395
- this.log.error('Unable to Register new device: %s %s - %s', device.deviceName, device.deviceType, device.deviceId);
396
- }
341
+ this.device(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
397
342
  }
398
343
  }
399
344
  async createBot(device) {
400
- const uuid = this.api.hap.uuid.generate(`${device.deviceName}-${device.deviceId}-${device.deviceType}`);
345
+ const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
401
346
  // see if an accessory with the same uuid has already been registered and restored from
402
347
  // the cached devices we stored in the `configureAccessory` method above
403
348
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
404
349
  if (existingAccessory) {
405
350
  // the accessory already exists
406
- if (!this.config.options?.hide_device.includes(device.deviceId) && device.enableCloudService) {
407
- this.log.info('Restoring existing accessory from cache: %s DeviceID: %s', existingAccessory.displayName, device.deviceId);
351
+ if (!device.hide_device && device.enableCloudService) {
352
+ this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
353
+ this.log.error(JSON.stringify(device.bot?.mode));
354
+ if (!device.bot?.mode) {
355
+ this.log.error('You must set your Bot to Press or Switch Mode');
356
+ }
408
357
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
409
358
  existingAccessory.context.model = device.deviceType;
410
359
  existingAccessory.context.deviceID = device.deviceId;
360
+ existingAccessory.displayName = device.deviceName;
411
361
  existingAccessory.context.firmwareRevision = this.version;
412
362
  await this.connectionTypeExistingAccessory(device, existingAccessory);
413
363
  this.api.updatePlatformAccessories([existingAccessory]);
414
364
  // create the accessory handler for the restored accessory
415
365
  // this is imported from `platformAccessory.ts`
416
366
  new bots_1.Bot(this, existingAccessory, device);
417
- this.debug(`${device.deviceType} UDID: ${device.deviceName}-${device.deviceId}-${device.deviceType}`);
367
+ this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
418
368
  }
419
369
  else {
420
370
  this.unregisterPlatformAccessories(existingAccessory);
421
371
  }
422
372
  }
423
- else if (!this.config.options?.hide_device.includes(device.deviceId) && device.enableCloudService) {
373
+ else if (!device.hide_device && device.enableCloudService) {
424
374
  // the accessory does not yet exist, so we need to create it
425
- this.log.info('Adding new accessory: %s %s DeviceID: %s', device.deviceName, device.deviceType, device.deviceId);
426
- if (!this.config.options?.bot?.device_press && !this.config.options?.bot?.device_switch) {
375
+ this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
376
+ this.log.error(JSON.stringify(device.bot?.mode));
377
+ if (!device.bot?.mode) {
427
378
  this.log.error('You must set your Bot to Press or Switch Mode');
428
379
  }
429
380
  // create a new accessory
430
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
381
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
431
382
  // store a copy of the device object in the `accessory.context`
432
383
  // the `context` property can be used to store any data about the accessory you may need
433
384
  accessory.context.device = device;
434
385
  accessory.context.model = device.deviceType;
435
386
  accessory.context.deviceID = device.deviceId;
436
387
  accessory.context.firmwareRevision = this.version;
437
- await this.connectionTypeNewAccessory(device, accessory);
388
+ await this.connectionTypeExistingAccessory(device, accessory);
438
389
  // accessory.context.firmwareRevision = findaccessories.accessoryAttribute.softwareRevision;
439
390
  // create the accessory handler for the newly create accessory
440
391
  // this is imported from `platformAccessory.ts`
441
392
  new bots_1.Bot(this, accessory, device);
442
- this.debug(`${device.deviceType} UDID: ${device.deviceName}-${device.deviceId}-${device.deviceType}`);
393
+ this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
443
394
  // link the accessory to your platform
444
395
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
445
396
  this.accessories.push(accessory);
446
397
  }
447
398
  else {
448
- if (this.config.devicediscovery) {
449
- this.log.error('Unable to Register new device: %s %s - %s', device.deviceName, device.deviceType, device.deviceId);
450
- }
399
+ this.device(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
451
400
  }
452
401
  }
453
402
  async createMeter(device) {
454
- const uuid = this.api.hap.uuid.generate(`${device.deviceName}-${device.deviceId}-${device.deviceType}`);
403
+ const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
455
404
  // see if an accessory with the same uuid has already been registered and restored from
456
405
  // the cached devices we stored in the `configureAccessory` method above
457
406
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
458
407
  if (existingAccessory) {
459
408
  // the accessory already exists
460
- if (!this.config.options?.hide_device.includes(device.deviceId) && device.enableCloudService) {
461
- this.log.info('Restoring existing accessory from cache: %s DeviceID: %s', existingAccessory.displayName, device.deviceId);
409
+ if (!device.hide_device && device.enableCloudService) {
410
+ this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
462
411
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
463
412
  existingAccessory.context.model = device.deviceType;
464
413
  existingAccessory.context.deviceID = device.deviceId;
414
+ existingAccessory.displayName = device.deviceName;
465
415
  existingAccessory.context.firmwareRevision = this.version;
466
416
  await this.connectionTypeExistingAccessory(device, existingAccessory);
467
417
  this.api.updatePlatformAccessories([existingAccessory]);
468
418
  // create the accessory handler for the restored accessory
469
419
  // this is imported from `platformAccessory.ts`
470
420
  new meters_1.Meter(this, existingAccessory, device);
471
- this.debug(`${device.deviceType} UDID: ${device.deviceName}-${device.deviceId}-${device.deviceType}`);
421
+ this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
472
422
  }
473
423
  else {
474
424
  this.unregisterPlatformAccessories(existingAccessory);
475
425
  }
476
426
  }
477
- else if (!this.config.options?.hide_device.includes(device.deviceId) && device.enableCloudService) {
427
+ else if (!device.hide_device && device.enableCloudService) {
478
428
  // the accessory does not yet exist, so we need to create it
479
- this.log.info('Adding new accessory: %s %s DeviceID: %s', device.deviceName, device.deviceType, device.deviceId);
429
+ this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
480
430
  // create a new accessory
481
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
431
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
482
432
  // store a copy of the device object in the `accessory.context`
483
433
  // the `context` property can be used to store any data about the accessory you may need
484
434
  accessory.context.device = device;
485
435
  accessory.context.model = device.deviceType;
486
436
  accessory.context.deviceID = device.deviceId;
487
437
  accessory.context.firmwareRevision = this.version;
488
- await this.connectionTypeNewAccessory(device, accessory);
438
+ await this.connectionTypeExistingAccessory(device, accessory);
489
439
  // create the accessory handler for the newly create accessory
490
440
  // this is imported from `platformAccessory.ts`
491
441
  new meters_1.Meter(this, accessory, device);
492
- this.debug(`${device.deviceType} UDID: ${device.deviceName}-${device.deviceId}-${device.deviceType}`);
442
+ this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
493
443
  // link the accessory to your platform
494
444
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
495
445
  this.accessories.push(accessory);
496
446
  }
497
447
  else {
498
- if (this.config.devicediscovery) {
499
- this.log.error('Unable to Register new device: %s %s - %s', device.deviceName, device.deviceType, device.deviceId);
500
- }
448
+ this.device(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
501
449
  }
502
450
  }
503
451
  async createMotion(device) {
504
- const uuid = this.api.hap.uuid.generate(`${device.deviceName}-${device.deviceId}-${device.deviceType}`);
452
+ const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
505
453
  // see if an accessory with the same uuid has already been registered and restored from
506
454
  // the cached devices we stored in the `configureAccessory` method above
507
455
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
508
456
  if (existingAccessory) {
509
457
  // the accessory already exists
510
- if (!this.config.options?.hide_device.includes(device.deviceId) && device.enableCloudService) {
511
- this.log.info('Restoring existing accessory from cache: %s DeviceID: %s', existingAccessory.displayName, device.deviceId);
458
+ if (!device.hide_device && device.enableCloudService) {
459
+ this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
512
460
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
513
461
  existingAccessory.context.model = device.deviceType;
514
462
  existingAccessory.context.deviceID = device.deviceId;
463
+ existingAccessory.displayName = device.deviceName;
515
464
  existingAccessory.context.firmwareRevision = this.version;
516
465
  this.api.updatePlatformAccessories([existingAccessory]);
517
466
  // create the accessory handler for the restored accessory
518
467
  // this is imported from `platformAccessory.ts`
519
468
  new motion_1.Motion(this, existingAccessory, device);
520
- this.debug(`${device.deviceType} UDID: ${device.deviceName}-${device.deviceId}-${device.deviceType}`);
469
+ this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
521
470
  }
522
471
  else {
523
472
  this.unregisterPlatformAccessories(existingAccessory);
524
473
  }
525
474
  }
526
- else if (!this.config.options?.hide_device.includes(device.deviceId) && device.enableCloudService) {
475
+ else if (!device.hide_device && device.enableCloudService) {
527
476
  // the accessory does not yet exist, so we need to create it
528
- this.log.info('Adding new accessory: %s %s DeviceID: %s', device.deviceName, device.deviceType, device.deviceId);
477
+ this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
529
478
  // create a new accessory
530
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
479
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
531
480
  // store a copy of the device object in the `accessory.context`
532
481
  // the `context` property can be used to store any data about the accessory you may need
533
482
  accessory.context.device = device;
@@ -537,45 +486,44 @@ class SwitchBotPlatform {
537
486
  // create the accessory handler for the newly create accessory
538
487
  // this is imported from `platformAccessory.ts`
539
488
  new motion_1.Motion(this, accessory, device);
540
- this.debug(`${device.deviceType} UDID: ${device.deviceName}-${device.deviceId}-${device.deviceType}`);
489
+ this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
541
490
  // link the accessory to your platform
542
491
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
543
492
  this.accessories.push(accessory);
544
493
  }
545
494
  else {
546
- if (this.config.devicediscovery) {
547
- this.log.error('Unable to Register new device: %s %s - %s', device.deviceName, device.deviceType, device.deviceId);
548
- }
495
+ this.device(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
549
496
  }
550
497
  }
551
498
  async createContact(device) {
552
- const uuid = this.api.hap.uuid.generate(`${device.deviceName}-${device.deviceId}-${device.deviceType}`);
499
+ const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
553
500
  // see if an accessory with the same uuid has already been registered and restored from
554
501
  // the cached devices we stored in the `configureAccessory` method above
555
502
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
556
503
  if (existingAccessory) {
557
504
  // the accessory already exists
558
- if (!this.config.options?.hide_device.includes(device.deviceId) && device.enableCloudService) {
559
- this.log.info('Restoring existing accessory from cache: %s DeviceID: %s', existingAccessory.displayName, device.deviceId);
505
+ if (!device.hide_device && device.enableCloudService) {
506
+ this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
560
507
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
561
508
  existingAccessory.context.model = device.deviceType;
562
509
  existingAccessory.context.deviceID = device.deviceId;
510
+ existingAccessory.displayName = device.deviceName;
563
511
  existingAccessory.context.firmwareRevision = this.version;
564
512
  this.api.updatePlatformAccessories([existingAccessory]);
565
513
  // create the accessory handler for the restored accessory
566
514
  // this is imported from `platformAccessory.ts`
567
515
  new contact_1.Contact(this, existingAccessory, device);
568
- this.debug(`${device.deviceType} UDID: ${device.deviceName}-${device.deviceId}-${device.deviceType}`);
516
+ this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
569
517
  }
570
518
  else {
571
519
  this.unregisterPlatformAccessories(existingAccessory);
572
520
  }
573
521
  }
574
- else if (!this.config.options?.hide_device.includes(device.deviceId) && device.enableCloudService) {
522
+ else if (!device.hide_device && device.enableCloudService) {
575
523
  // the accessory does not yet exist, so we need to create it
576
- this.log.info('Adding new accessory: %s %s DeviceID: %s', device.deviceName, device.deviceType, device.deviceId);
524
+ this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
577
525
  // create a new accessory
578
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
526
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
579
527
  // store a copy of the device object in the `accessory.context`
580
528
  // the `context` property can be used to store any data about the accessory you may need
581
529
  accessory.context.device = device;
@@ -585,36 +533,35 @@ class SwitchBotPlatform {
585
533
  // create the accessory handler for the newly create accessory
586
534
  // this is imported from `platformAccessory.ts`
587
535
  new contact_1.Contact(this, accessory, device);
588
- this.debug(`${device.deviceType} UDID: ${device.deviceName}-${device.deviceId}-${device.deviceType}`);
536
+ this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
589
537
  // link the accessory to your platform
590
538
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
591
539
  this.accessories.push(accessory);
592
540
  }
593
541
  else {
594
- if (this.config.devicediscovery) {
595
- this.log.error('Unable to Register new device: %s %s - %s', device.deviceName, device.deviceType, device.deviceId);
596
- }
542
+ this.device(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
597
543
  }
598
544
  }
599
545
  async createCurtain(device) {
600
- const uuid = this.api.hap.uuid.generate(`${device.deviceName}-${device.deviceId}-${device.deviceType}`);
546
+ const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
601
547
  // see if an accessory with the same uuid has already been registered and restored from
602
548
  // the cached devices we stored in the `configureAccessory` method above
603
549
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
604
550
  if (existingAccessory) {
605
551
  // the accessory already exists
606
552
  if (this.isCurtainGrouped(device)) {
607
- this.log.info('Restoring existing accessory from cache: %s DeviceID: %s', existingAccessory.displayName, device.deviceId);
553
+ this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
608
554
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
609
555
  existingAccessory.context.model = device.deviceType;
610
556
  existingAccessory.context.deviceID = device.deviceId;
557
+ existingAccessory.displayName = device.deviceName;
611
558
  existingAccessory.context.firmwareRevision = this.version;
612
559
  await this.connectionTypeExistingAccessory(device, existingAccessory);
613
560
  this.api.updatePlatformAccessories([existingAccessory]);
614
561
  // create the accessory handler for the restored accessory
615
562
  // this is imported from `platformAccessory.ts`
616
563
  new curtains_1.Curtain(this, existingAccessory, device);
617
- this.debug(`${device.deviceType} UDID: ${device.deviceName}-${device.deviceId}-${device.deviceType}`);
564
+ this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
618
565
  }
619
566
  else {
620
567
  this.unregisterPlatformAccessories(existingAccessory);
@@ -622,133 +569,181 @@ class SwitchBotPlatform {
622
569
  }
623
570
  else if (this.isCurtainGrouped(device)) {
624
571
  // the accessory does not yet exist, so we need to create it
625
- this.log.info('Adding new accessory: %s %s DeviceID: %s', device.deviceName, device.deviceType, device.deviceId);
626
- if (device.group && !this.config.options?.curtain?.disable_group) {
627
- this.log.warn('Your Curtains are grouped, Secondary curtain automatically hidden. Main Curtain: %s, DeviceID: %s', device.deviceName, device.deviceId);
572
+ this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
573
+ if (device.group && !device.curtain?.disable_group) {
574
+ this.device(`Your Curtains are grouped
575
+ , Secondary curtain automatically hidden. Main Curtain: ${device.deviceName}, DeviceID: ${device.deviceId}`);
628
576
  }
629
577
  else {
630
578
  if (device.master) {
631
- this.log.warn('Main Curtain: %s, DeviceID: %s', device.deviceName, device.deviceId);
579
+ this.device(`Main Curtain: ${device.deviceName}, DeviceID: ${device.deviceId}`);
632
580
  }
633
581
  else {
634
- this.log.warn('Secondary Curtain: %s, DeviceID: %s', device.deviceName, device.deviceId);
582
+ this.device(`Secondary Curtain: ${device.deviceName}, DeviceID: ${device.deviceId}`);
635
583
  }
636
584
  }
637
585
  // create a new accessory
638
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
586
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
639
587
  // store a copy of the device object in the `accessory.context`
640
588
  // the `context` property can be used to store any data about the accessory you may need
641
589
  accessory.context.device = device;
642
590
  accessory.context.model = device.deviceType;
643
591
  accessory.context.deviceID = device.deviceId;
644
592
  accessory.context.firmwareRevision = this.version;
645
- await this.connectionTypeNewAccessory(device, accessory);
593
+ await this.connectionTypeExistingAccessory(device, accessory);
646
594
  // create the accessory handler for the newly create accessory
647
595
  // this is imported from `platformAccessory.ts`
648
596
  new curtains_1.Curtain(this, accessory, device);
649
- this.debug(`${device.deviceType} UDID: ${device.deviceName}-${device.deviceId}-${device.deviceType}`);
597
+ this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
650
598
  // link the accessory to your platform
651
599
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
652
600
  this.accessories.push(accessory);
653
601
  }
654
602
  else {
655
- if (this.config.devicediscovery) {
656
- this.log.error('Unable to Register new device: %s %s - %s', device.deviceName, device.deviceType, device.deviceId);
657
- }
603
+ this.device(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
658
604
  }
659
605
  }
660
606
  isCurtainGrouped(device) {
661
- if (device.group && !this.config.options?.curtain?.disable_group) {
662
- return device.master && !this.config.options?.hide_device.includes(device.deviceId) && device.enableCloudService;
607
+ if (device.group && !device.curtain?.disable_group) {
608
+ return device.master && !device.hide_device && device.enableCloudService;
663
609
  }
664
610
  else {
665
- return !this.config.options?.hide_device.includes(device.deviceId) && device.enableCloudService;
611
+ return !device.hide_device && device.enableCloudService;
666
612
  }
667
613
  }
668
614
  async createPlug(device) {
669
- const uuid = this.api.hap.uuid.generate(`${device.deviceName}-${device.deviceId}-${device.deviceType}`);
615
+ const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
670
616
  // see if an accessory with the same uuid has already been registered and restored from
671
617
  // the cached devices we stored in the `configureAccessory` method above
672
618
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
673
619
  if (existingAccessory) {
674
620
  // the accessory already exists
675
- if (!this.config.options?.hide_device.includes(device.deviceId) && device.enableCloudService) {
676
- this.log.info('Restoring existing accessory from cache: %s DeviceID: %s', existingAccessory.displayName, device.deviceId);
621
+ if (!device.hide_device && device.enableCloudService) {
622
+ this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
677
623
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
678
624
  existingAccessory.context.model = device.deviceType;
679
625
  existingAccessory.context.deviceID = device.deviceId;
626
+ existingAccessory.displayName = device.deviceName;
680
627
  existingAccessory.context.firmwareRevision = this.version;
681
628
  await this.connectionTypeExistingAccessory(device, existingAccessory);
682
629
  this.api.updatePlatformAccessories([existingAccessory]);
683
630
  // create the accessory handler for the restored accessory
684
631
  // this is imported from `platformAccessory.ts`
685
632
  new plugs_1.Plug(this, existingAccessory, device);
686
- this.debug(`${device.deviceType} UDID: ${device.deviceName}-${device.deviceId}-${device.deviceType}`);
633
+ this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
687
634
  }
688
635
  else {
689
636
  this.unregisterPlatformAccessories(existingAccessory);
690
637
  }
691
638
  }
692
- else if (!this.config.options?.hide_device.includes(device.deviceId) && device.enableCloudService) {
639
+ else if (!device.hide_device && device.enableCloudService) {
693
640
  // the accessory does not yet exist, so we need to create it
694
- this.log.info('Adding new accessory: %s %s DeviceID: %s', device.deviceName, device.deviceType, device.deviceId);
641
+ this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
695
642
  // create a new accessory
696
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
643
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
697
644
  // store a copy of the device object in the `accessory.context`
698
645
  // the `context` property can be used to store any data about the accessory you may need
699
646
  accessory.context.device = device;
700
647
  accessory.context.model = device.deviceType;
701
648
  accessory.context.deviceID = device.deviceId;
702
649
  accessory.context.firmwareRevision = this.version;
703
- await this.connectionTypeNewAccessory(device, accessory);
650
+ await this.connectionTypeExistingAccessory(device, accessory);
704
651
  // create the accessory handler for the newly create accessory
705
652
  // this is imported from `platformAccessory.ts`
706
653
  new plugs_1.Plug(this, accessory, device);
707
- this.debug(`${device.deviceType} UDID: ${device.deviceName}-${device.deviceId}-${device.deviceType}`);
654
+ this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
708
655
  // link the accessory to your platform
709
656
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
710
657
  this.accessories.push(accessory);
711
658
  }
712
659
  else {
713
- if (this.config.devicediscovery) {
714
- this.log.error('Unable to Register new device: %s %s - %s', device.deviceName, device.deviceType, device.deviceId);
660
+ this.device(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
661
+ }
662
+ }
663
+ async createIndoorCam(device) {
664
+ const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
665
+ // see if an accessory with the same uuid has already been registered and restored from
666
+ // the cached devices we stored in the `configureAccessory` method above
667
+ const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
668
+ if (existingAccessory) {
669
+ // the accessory already exists
670
+ if (!device.hide_device && device.enableCloudService) {
671
+ this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
672
+ // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
673
+ existingAccessory.context.model = device.deviceType;
674
+ existingAccessory.context.deviceID = device.deviceId;
675
+ existingAccessory.displayName = device.deviceName;
676
+ existingAccessory.context.firmwareRevision = this.version;
677
+ await this.connectionTypeExistingAccessory(device, existingAccessory);
678
+ this.api.updatePlatformAccessories([existingAccessory]);
679
+ // create the accessory handler for the restored accessory
680
+ // this is imported from `platformAccessory.ts`
681
+ new indoorcam_1.IndoorCam(this, existingAccessory, device);
682
+ this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
683
+ }
684
+ else {
685
+ this.unregisterPlatformAccessories(existingAccessory);
715
686
  }
716
687
  }
688
+ else if (!device.hide_device && device.enableCloudService) {
689
+ // the accessory does not yet exist, so we need to create it
690
+ this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
691
+ // create a new accessory
692
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
693
+ // store a copy of the device object in the `accessory.context`
694
+ // the `context` property can be used to store any data about the accessory you may need
695
+ accessory.context.device = device;
696
+ accessory.context.model = device.deviceType;
697
+ accessory.context.deviceID = device.deviceId;
698
+ accessory.context.firmwareRevision = this.version;
699
+ await this.connectionTypeExistingAccessory(device, accessory);
700
+ // create the accessory handler for the newly create accessory
701
+ // this is imported from `platformAccessory.ts`
702
+ new indoorcam_1.IndoorCam(this, accessory, device);
703
+ this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
704
+ // link the accessory to your platform
705
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
706
+ this.accessories.push(accessory);
707
+ }
708
+ else {
709
+ this.device(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
710
+ }
717
711
  }
718
712
  async createTV(device) {
719
- const uuid = this.api.hap.uuid.generate(`${device.deviceName}-${device.deviceId}-${device.remoteType}-${device.hubDeviceId}`);
713
+ const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
720
714
  // see if an accessory with the same uuid has already been registered and restored from
721
715
  // the cached devices we stored in the `configureAccessory` method above
722
716
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
723
- if (existingAccessory && !this.config.options?.hide_device.includes(device.deviceId)) {
724
- this.log.info('Restoring existing accessory from cache: %s DeviceID: %s', existingAccessory.displayName, device.deviceId);
717
+ if (existingAccessory) {
718
+ this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
725
719
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
726
720
  existingAccessory.context.model = device.remoteType;
727
721
  existingAccessory.context.deviceID = device.deviceId;
722
+ existingAccessory.displayName = device.deviceName;
728
723
  existingAccessory.context.firmwareRevision = this.version;
729
724
  await this.connectionTypeExistingAccessory(device, existingAccessory);
730
725
  this.api.updatePlatformAccessories([existingAccessory]);
731
726
  // create the accessory handler for the restored accessory
732
727
  // this is imported from `platformAccessory.ts`
733
728
  new tvs_1.TV(this, existingAccessory, device);
734
- this.debug(`${device.remoteType} UDID: ${device.deviceName}-${device.deviceId}-${device.remoteType}-${device.hubDeviceId}`);
729
+ this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
735
730
  }
736
- else if (!this.config.options?.hide_device.includes(device.deviceId)) {
731
+ else if (device.hubDeviceId) {
737
732
  // the accessory does not yet exist, so we need to create it
738
- this.log.info('Adding new accessory: %s %s DeviceID: %s', device.deviceName, device.remoteType, device.deviceId);
733
+ this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
739
734
  // create a new accessory
740
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
735
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
741
736
  // store a copy of the device object in the `accessory.context`
742
737
  // the `context` property can be used to store any data about the accessory you may need
743
738
  accessory.context.device = device;
744
739
  accessory.context.model = device.remoteType;
745
740
  accessory.context.deviceID = device.deviceId;
746
741
  accessory.context.firmwareRevision = this.version;
747
- await this.connectionTypeNewAccessory(device, accessory);
742
+ await this.connectionTypeExistingAccessory(device, accessory);
748
743
  // create the accessory handler for the newly create accessory
749
744
  // this is imported from `platformAccessory.ts`
750
745
  new tvs_1.TV(this, accessory, device);
751
- this.debug(`${device.remoteType} UDID: ${device.deviceName}-${device.deviceId}-${device.remoteType}-${device.hubDeviceId}`);
746
+ this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
752
747
  /**
753
748
  * Publish as external accessory
754
749
  * Only one TV can exist per bridge, to bypass this limitation, you should
@@ -758,413 +753,403 @@ class SwitchBotPlatform {
758
753
  this.accessories.push(accessory);
759
754
  }
760
755
  else {
761
- if (this.config.devicediscovery) {
762
- this.log.error('Unable to Register new device: %s %s - %s', device.deviceName, device.remoteType, device.deviceId);
763
- }
756
+ this.device(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
764
757
  }
765
758
  }
766
759
  async createFan(device) {
767
- const uuid = this.api.hap.uuid.generate(`${device.deviceName}-${device.deviceId}-${device.remoteType}`);
760
+ const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
768
761
  // see if an accessory with the same uuid has already been registered and restored from
769
762
  // the cached devices we stored in the `configureAccessory` method above
770
763
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
771
764
  if (existingAccessory) {
772
765
  // the accessory already exists
773
- if (!this.config.options?.hide_device.includes(device.deviceId)) {
774
- this.log.info('Restoring existing accessory from cache: %s DeviceID: %s', existingAccessory.displayName, device.deviceId);
766
+ if (device.hubDeviceId) {
767
+ this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
775
768
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
776
769
  existingAccessory.context.model = device.remoteType;
777
770
  existingAccessory.context.deviceID = device.deviceId;
771
+ existingAccessory.displayName = device.deviceName;
778
772
  existingAccessory.context.firmwareRevision = this.version;
779
773
  await this.connectionTypeExistingAccessory(device, existingAccessory);
780
774
  this.api.updatePlatformAccessories([existingAccessory]);
781
775
  // create the accessory handler for the restored accessory
782
776
  // this is imported from `platformAccessory.ts`
783
777
  new fans_1.Fan(this, existingAccessory, device);
784
- this.debug(`${device.remoteType} UDID: ${device.deviceName}-${device.deviceId}-${device.remoteType}`);
778
+ this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
785
779
  }
786
780
  else {
787
781
  this.unregisterPlatformAccessories(existingAccessory);
788
782
  }
789
783
  }
790
- else if (!this.config.options?.hide_device.includes(device.deviceId)) {
784
+ else if (device.hubDeviceId) {
791
785
  // the accessory does not yet exist, so we need to create it
792
- this.log.info('Adding new accessory: %s %s DeviceID: %s', device.deviceName, device.remoteType, device.deviceId);
786
+ this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
793
787
  // create a new accessory
794
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
788
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
795
789
  // store a copy of the device object in the `accessory.context`
796
790
  // the `context` property can be used to store any data about the accessory you may need
797
791
  accessory.context.device = device;
798
792
  accessory.context.model = device.remoteType;
799
793
  accessory.context.deviceID = device.deviceId;
800
794
  accessory.context.firmwareRevision = this.version;
801
- await this.connectionTypeNewAccessory(device, accessory);
795
+ await this.connectionTypeExistingAccessory(device, accessory);
802
796
  // create the accessory handler for the newly create accessory
803
797
  // this is imported from `platformAccessory.ts`
804
798
  new fans_1.Fan(this, accessory, device);
805
- this.debug(`${device.remoteType} UDID: ${device.deviceName}-${device.deviceId}-${device.remoteType}`);
799
+ this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
806
800
  // link the accessory to your platform
807
801
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
808
802
  this.accessories.push(accessory);
809
803
  }
810
804
  else {
811
- if (this.config.devicediscovery) {
812
- this.log.error('Unable to Register new device: %s %s - %s', device.deviceName, device.remoteType, device.deviceId);
813
- }
805
+ this.device(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
814
806
  }
815
807
  }
816
808
  async createLight(device) {
817
- const uuid = this.api.hap.uuid.generate(`${device.deviceName}-${device.deviceId}-${device.remoteType}`);
809
+ const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
818
810
  // see if an accessory with the same uuid has already been registered and restored from
819
811
  // the cached devices we stored in the `configureAccessory` method above
820
812
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
821
813
  if (existingAccessory) {
822
814
  // the accessory already exists
823
- if (!this.config.options?.hide_device.includes(device.deviceId)) {
824
- this.log.info('Restoring existing accessory from cache: %s DeviceID: %s', existingAccessory.displayName, device.deviceId);
815
+ if (device.hubDeviceId) {
816
+ this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
825
817
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
826
818
  existingAccessory.context.model = device.remoteType;
827
819
  existingAccessory.context.deviceID = device.deviceId;
820
+ existingAccessory.displayName = device.deviceName;
828
821
  existingAccessory.context.firmwareRevision = this.version;
829
822
  await this.connectionTypeExistingAccessory(device, existingAccessory);
830
823
  this.api.updatePlatformAccessories([existingAccessory]);
831
824
  // create the accessory handler for the restored accessory
832
825
  // this is imported from `platformAccessory.ts`
833
826
  new lights_1.Light(this, existingAccessory, device);
834
- this.debug(`${device.remoteType} UDID: ${device.deviceName}-${device.deviceId}-${device.remoteType}`);
827
+ this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
835
828
  }
836
829
  else {
837
830
  this.unregisterPlatformAccessories(existingAccessory);
838
831
  }
839
832
  }
840
- else if (!this.config.options?.hide_device.includes(device.deviceId)) {
833
+ else if (device.hubDeviceId) {
841
834
  // the accessory does not yet exist, so we need to create it
842
- this.log.info('Adding new accessory: %s %s DeviceID: %s', device.deviceName, device.remoteType, device.deviceId);
835
+ this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
843
836
  // create a new accessory
844
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
837
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
845
838
  // store a copy of the device object in the `accessory.context`
846
839
  // the `context` property can be used to store any data about the accessory you may need
847
840
  accessory.context.device = device;
848
841
  accessory.context.model = device.remoteType;
849
842
  accessory.context.deviceID = device.deviceId;
850
843
  accessory.context.firmwareRevision = this.version;
851
- await this.connectionTypeNewAccessory(device, accessory);
844
+ await this.connectionTypeExistingAccessory(device, accessory);
852
845
  // create the accessory handler for the newly create accessory
853
846
  // this is imported from `platformAccessory.ts`
854
847
  new lights_1.Light(this, accessory, device);
855
- this.debug(`${device.remoteType} UDID: ${device.deviceName}-${device.deviceId}-${device.remoteType}`);
848
+ this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
856
849
  // link the accessory to your platform
857
850
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
858
851
  this.accessories.push(accessory);
859
852
  }
860
853
  else {
861
- if (this.config.devicediscovery) {
862
- this.log.error('Unable to Register new device: %s %s - %s', device.deviceName, device.remoteType, device.deviceId);
863
- }
854
+ this.device(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
864
855
  }
865
856
  }
866
857
  async createAirConditioner(device) {
867
- const uuid = this.api.hap.uuid.generate(`${device.deviceName}-${device.deviceId}-${device.remoteType}`);
858
+ const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
868
859
  // see if an accessory with the same uuid has already been registered and restored from
869
860
  // the cached devices we stored in the `configureAccessory` method above
870
861
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
871
862
  if (existingAccessory) {
872
863
  // the accessory already exists
873
- if (!this.config.options?.hide_device.includes(device.deviceId)) {
874
- this.log.info('Restoring existing accessory from cache: %s DeviceID: %s', existingAccessory.displayName, device.deviceId);
864
+ if (device.hubDeviceId) {
865
+ this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
875
866
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
876
867
  existingAccessory.context.model = device.remoteType;
877
868
  existingAccessory.context.deviceID = device.deviceId;
869
+ existingAccessory.displayName = device.deviceName;
878
870
  existingAccessory.context.firmwareRevision = this.version;
879
871
  await this.connectionTypeExistingAccessory(device, existingAccessory);
880
872
  this.api.updatePlatformAccessories([existingAccessory]);
881
873
  // create the accessory handler for the restored accessory
882
874
  // this is imported from `platformAccessory.ts`
883
875
  new airconditioners_1.AirConditioner(this, existingAccessory, device);
884
- this.debug(`Fan UDID: ${device.deviceName}-${device.deviceId}-${device.remoteType}`);
876
+ this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
885
877
  }
886
878
  else {
887
879
  this.unregisterPlatformAccessories(existingAccessory);
888
880
  }
889
881
  }
890
- else if (!this.config.options?.hide_device.includes(device.deviceId)) {
882
+ else if (device.hubDeviceId) {
891
883
  // the accessory does not yet exist, so we need to create it
892
- this.log.info('Adding new accessory: %s %s DeviceID: %s', device.deviceName, device.remoteType, device.deviceId);
884
+ this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
893
885
  // create a new accessory
894
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
886
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
895
887
  // store a copy of the device object in the `accessory.context`
896
888
  // the `context` property can be used to store any data about the accessory you may need
897
889
  accessory.context.device = device;
898
890
  accessory.context.model = device.remoteType;
899
891
  accessory.context.deviceID = device.deviceId;
900
892
  accessory.context.firmwareRevision = this.version;
901
- await this.connectionTypeNewAccessory(device, accessory);
893
+ await this.connectionTypeExistingAccessory(device, accessory);
902
894
  // create the accessory handler for the newly create accessory
903
895
  // this is imported from `platformAccessory.ts`
904
896
  new airconditioners_1.AirConditioner(this, accessory, device);
905
- this.debug(`Fan UDID: ${device.deviceName}-${device.deviceId}-${device.remoteType}`);
897
+ this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
906
898
  // link the accessory to your platform
907
899
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
908
900
  this.accessories.push(accessory);
909
901
  }
910
902
  else {
911
- if (this.config.devicediscovery) {
912
- this.log.error('Unable to Register new device: %s %s - %s', device.deviceName, device.remoteType, device.deviceId);
913
- }
903
+ this.device(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
914
904
  }
915
905
  }
916
906
  async createAirPurifier(device) {
917
- const uuid = this.api.hap.uuid.generate(`${device.deviceName}-${device.deviceId}-${device.remoteType}`);
907
+ const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
918
908
  // see if an accessory with the same uuid has already been registered and restored from
919
909
  // the cached devices we stored in the `configureAccessory` method above
920
910
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
921
911
  if (existingAccessory) {
922
912
  // the accessory already exists
923
- if (!this.config.options?.hide_device.includes(device.deviceId)) {
924
- this.log.info('Restoring existing accessory from cache: %s DeviceID: %s', existingAccessory.displayName, device.deviceId);
913
+ if (device.hubDeviceId) {
914
+ this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
925
915
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
926
916
  existingAccessory.context.model = device.remoteType;
927
917
  existingAccessory.context.deviceID = device.deviceId;
918
+ existingAccessory.displayName = device.deviceName;
928
919
  existingAccessory.context.firmwareRevision = this.version;
929
920
  await this.connectionTypeExistingAccessory(device, existingAccessory);
930
921
  this.api.updatePlatformAccessories([existingAccessory]);
931
922
  // create the accessory handler for the restored accessory
932
923
  // this is imported from `platformAccessory.ts`
933
924
  new airpurifiers_1.AirPurifier(this, existingAccessory, device);
934
- this.debug(`${device.remoteType} UDID: ${device.deviceName}-${device.deviceId}-${device.remoteType}`);
925
+ this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
935
926
  }
936
927
  else {
937
928
  this.unregisterPlatformAccessories(existingAccessory);
938
929
  }
939
930
  }
940
- else if (!this.config.options?.hide_device.includes(device.deviceId)) {
931
+ else if (device.hubDeviceId) {
941
932
  // the accessory does not yet exist, so we need to create it
942
- this.log.info('Adding new accessory: %s %s DeviceID: %s', device.deviceName, device.remoteType, device.deviceId);
933
+ this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
943
934
  // create a new accessory
944
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
935
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
945
936
  // store a copy of the device object in the `accessory.context`
946
937
  // the `context` property can be used to store any data about the accessory you may need
947
938
  accessory.context.device = device;
948
939
  accessory.context.model = device.remoteType;
949
940
  accessory.context.deviceID = device.deviceId;
950
941
  accessory.context.firmwareRevision = this.version;
951
- await this.connectionTypeNewAccessory(device, accessory);
942
+ await this.connectionTypeExistingAccessory(device, accessory);
952
943
  // create the accessory handler for the newly create accessory
953
944
  // this is imported from `platformAccessory.ts`
954
945
  new airpurifiers_1.AirPurifier(this, accessory, device);
955
- this.debug(`${device.remoteType} UDID: ${device.deviceName}-${device.deviceId}-${device.remoteType}`);
946
+ this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
956
947
  // link the accessory to your platform
957
948
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
958
949
  this.accessories.push(accessory);
959
950
  }
960
951
  else {
961
- if (this.config.devicediscovery) {
962
- this.log.error('Unable to Register new device: %s %s - %s', device.deviceName, device.remoteType, device.deviceId);
963
- }
952
+ this.device(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
964
953
  }
965
954
  }
966
955
  async createWaterHeater(device) {
967
- const uuid = this.api.hap.uuid.generate(`${device.deviceName}-${device.deviceId}-${device.remoteType}`);
956
+ const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
968
957
  // see if an accessory with the same uuid has already been registered and restored from
969
958
  // the cached devices we stored in the `configureAccessory` method above
970
959
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
971
960
  if (existingAccessory) {
972
961
  // the accessory already exists
973
- if (!this.config.options?.hide_device.includes(device.deviceId)) {
974
- this.log.info('Restoring existing accessory from cache: %s DeviceID: %s', existingAccessory.displayName, device.deviceId);
962
+ if (device.hubDeviceId) {
963
+ this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
975
964
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
976
965
  existingAccessory.context.model = device.remoteType;
977
966
  existingAccessory.context.deviceID = device.deviceId;
967
+ existingAccessory.displayName = device.deviceName;
978
968
  existingAccessory.context.firmwareRevision = this.version;
979
969
  await this.connectionTypeExistingAccessory(device, existingAccessory);
980
970
  this.api.updatePlatformAccessories([existingAccessory]);
981
971
  // create the accessory handler for the restored accessory
982
972
  // this is imported from `platformAccessory.ts`
983
973
  new waterheaters_1.WaterHeater(this, existingAccessory, device);
984
- this.debug(`${device.remoteType} UDID: ${device.deviceName}-${device.deviceId}-${device.remoteType}`);
974
+ this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
985
975
  }
986
976
  else {
987
977
  this.unregisterPlatformAccessories(existingAccessory);
988
978
  }
989
979
  }
990
- else if (!this.config.options?.hide_device.includes(device.deviceId)) {
980
+ else if (device.hubDeviceId) {
991
981
  // the accessory does not yet exist, so we need to create it
992
- this.log.info('Adding new accessory: %s %s DeviceID: %s', device.deviceName, device.remoteType, device.deviceId);
982
+ this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
993
983
  // create a new accessory
994
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
984
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
995
985
  // store a copy of the device object in the `accessory.context`
996
986
  // the `context` property can be used to store any data about the accessory you may need
997
987
  accessory.context.device = device;
998
988
  accessory.context.model = device.remoteType;
999
989
  accessory.context.deviceID = device.deviceId;
1000
990
  accessory.context.firmwareRevision = this.version;
1001
- await this.connectionTypeNewAccessory(device, accessory);
991
+ await this.connectionTypeExistingAccessory(device, accessory);
1002
992
  // create the accessory handler for the newly create accessory
1003
993
  // this is imported from `platformAccessory.ts`
1004
994
  new waterheaters_1.WaterHeater(this, accessory, device);
1005
- this.debug(`${device.remoteType} UDID: ${device.deviceName}-${device.deviceId}-${device.remoteType}`);
995
+ this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1006
996
  // link the accessory to your platform
1007
997
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
1008
998
  this.accessories.push(accessory);
1009
999
  }
1010
1000
  else {
1011
- if (this.config.devicediscovery) {
1012
- this.log.error('Unable to Register new device: %s %s - %s', device.deviceName, device.remoteType, device.deviceId);
1013
- }
1001
+ this.device(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
1014
1002
  }
1015
1003
  }
1016
1004
  async createVacuumCleaner(device) {
1017
- const uuid = this.api.hap.uuid.generate(`${device.deviceName}-${device.deviceId}-${device.remoteType}`);
1005
+ const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
1018
1006
  // see if an accessory with the same uuid has already been registered and restored from
1019
1007
  // the cached devices we stored in the `configureAccessory` method above
1020
1008
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1021
1009
  if (existingAccessory) {
1022
1010
  // the accessory already exists
1023
- if (!this.config.options?.hide_device.includes(device.deviceId)) {
1024
- this.log.info('Restoring existing accessory from cache: %s DeviceID: %s', existingAccessory.displayName, device.deviceId);
1011
+ if (device.hubDeviceId) {
1012
+ this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1025
1013
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1026
1014
  existingAccessory.context.model = device.remoteType;
1027
1015
  existingAccessory.context.deviceID = device.deviceId;
1016
+ existingAccessory.displayName = device.deviceName;
1028
1017
  existingAccessory.context.firmwareRevision = this.version;
1029
1018
  await this.connectionTypeExistingAccessory(device, existingAccessory);
1030
1019
  this.api.updatePlatformAccessories([existingAccessory]);
1031
1020
  // create the accessory handler for the restored accessory
1032
1021
  // this is imported from `platformAccessory.ts`
1033
1022
  new vacuumcleaners_1.VacuumCleaner(this, existingAccessory, device);
1034
- this.debug(`${device.remoteType} UDID: ${device.deviceName}-${device.deviceId}-${device.remoteType}`);
1023
+ this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1035
1024
  }
1036
1025
  else {
1037
1026
  this.unregisterPlatformAccessories(existingAccessory);
1038
1027
  }
1039
1028
  }
1040
- else if (!this.config.options?.hide_device.includes(device.deviceId)) {
1029
+ else if (device.hubDeviceId) {
1041
1030
  // the accessory does not yet exist, so we need to create it
1042
- this.log.info('Adding new accessory: %s %s DeviceID: %s', device.deviceName, device.remoteType, device.deviceId);
1031
+ this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1043
1032
  // create a new accessory
1044
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
1033
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
1045
1034
  // store a copy of the device object in the `accessory.context`
1046
1035
  // the `context` property can be used to store any data about the accessory you may need
1047
1036
  accessory.context.device = device;
1048
1037
  accessory.context.model = device.remoteType;
1049
1038
  accessory.context.deviceID = device.deviceId;
1050
1039
  accessory.context.firmwareRevision = this.version;
1051
- await this.connectionTypeNewAccessory(device, accessory);
1040
+ await this.connectionTypeExistingAccessory(device, accessory);
1052
1041
  // create the accessory handler for the newly create accessory
1053
1042
  // this is imported from `platformAccessory.ts`
1054
1043
  new vacuumcleaners_1.VacuumCleaner(this, accessory, device);
1055
- this.debug(`${device.remoteType} UDID: ${device.deviceName}-${device.deviceId}-${device.remoteType}`);
1044
+ this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1056
1045
  // link the accessory to your platform
1057
1046
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
1058
1047
  this.accessories.push(accessory);
1059
1048
  }
1060
1049
  else {
1061
- if (this.config.devicediscovery) {
1062
- this.log.error('Unable to Register new device: %s %s - %s', device.deviceName, device.remoteType, device.deviceId);
1063
- }
1050
+ this.device(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
1064
1051
  }
1065
1052
  }
1066
1053
  async createCamera(device) {
1067
- const uuid = this.api.hap.uuid.generate(`${device.deviceName}-${device.deviceId}-${device.remoteType}`);
1054
+ const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
1068
1055
  // see if an accessory with the same uuid has already been registered and restored from
1069
1056
  // the cached devices we stored in the `configureAccessory` method above
1070
1057
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1071
1058
  if (existingAccessory) {
1072
1059
  // the accessory already exists
1073
- if (!this.config.options?.hide_device.includes(device.deviceId)) {
1074
- this.log.info('Restoring existing accessory from cache: %s DeviceID: %s', existingAccessory.displayName, device.deviceId);
1060
+ if (device.hubDeviceId) {
1061
+ this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1075
1062
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1076
1063
  existingAccessory.context.model = device.remoteType;
1077
1064
  existingAccessory.context.deviceID = device.deviceId;
1065
+ existingAccessory.displayName = device.deviceName;
1078
1066
  existingAccessory.context.firmwareRevision = this.version;
1079
1067
  await this.connectionTypeExistingAccessory(device, existingAccessory);
1080
1068
  this.api.updatePlatformAccessories([existingAccessory]);
1081
1069
  // create the accessory handler for the restored accessory
1082
1070
  // this is imported from `platformAccessory.ts`
1083
1071
  new cameras_1.Camera(this, existingAccessory, device);
1084
- this.debug(`${device.remoteType} UDID: ${device.deviceName}-${device.deviceId}-${device.remoteType}`);
1072
+ this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1085
1073
  }
1086
1074
  else {
1087
1075
  this.unregisterPlatformAccessories(existingAccessory);
1088
1076
  }
1089
1077
  }
1090
- else if (!this.config.options?.hide_device.includes(device.deviceId)) {
1078
+ else if (device.hubDeviceId) {
1091
1079
  // the accessory does not yet exist, so we need to create it
1092
- this.log.info('Adding new accessory: %s %s DeviceID: %s', device.deviceName, device.remoteType, device.deviceId);
1080
+ this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1093
1081
  // create a new accessory
1094
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
1082
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
1095
1083
  // store a copy of the device object in the `accessory.context`
1096
1084
  // the `context` property can be used to store any data about the accessory you may need
1097
1085
  accessory.context.device = device;
1098
1086
  accessory.context.model = device.remoteType;
1099
1087
  accessory.context.deviceID = device.deviceId;
1100
1088
  accessory.context.firmwareRevision = this.version;
1101
- await this.connectionTypeNewAccessory(device, accessory);
1089
+ await this.connectionTypeExistingAccessory(device, accessory);
1102
1090
  // create the accessory handler for the newly create accessory
1103
1091
  // this is imported from `platformAccessory.ts`
1104
1092
  new cameras_1.Camera(this, accessory, device);
1105
- this.debug(`${device.remoteType} UDID: ${device.deviceName}-${device.deviceId}-${device.remoteType}`);
1093
+ this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1106
1094
  // link the accessory to your platform
1107
1095
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
1108
1096
  this.accessories.push(accessory);
1109
1097
  }
1110
1098
  else {
1111
- if (this.config.devicediscovery) {
1112
- this.log.error('Unable to Register new device: %s %s - %s', device.deviceName, device.remoteType, device.deviceId);
1113
- }
1099
+ this.device(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
1114
1100
  }
1115
1101
  }
1116
1102
  async createOthers(device) {
1117
- const uuid = this.api.hap.uuid.generate(`${device.deviceName}-${device.deviceId}-${device.remoteType}`);
1103
+ const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
1118
1104
  // see if an accessory with the same uuid has already been registered and restored from
1119
1105
  // the cached devices we stored in the `configureAccessory` method above
1120
1106
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1121
1107
  if (existingAccessory) {
1122
1108
  // the accessory already exists
1123
- if (!this.config.options?.hide_device.includes(device.deviceId)) {
1124
- this.log.info('Restoring existing accessory from cache: %s DeviceID: %s', existingAccessory.displayName, device.deviceId);
1109
+ if (device.hubDeviceId) {
1110
+ this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1125
1111
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1126
1112
  existingAccessory.context.model = device.remoteType;
1127
1113
  existingAccessory.context.deviceID = device.deviceId;
1114
+ existingAccessory.displayName = device.deviceName;
1128
1115
  existingAccessory.context.firmwareRevision = this.version;
1129
1116
  await this.connectionTypeExistingAccessory(device, existingAccessory);
1130
1117
  this.api.updatePlatformAccessories([existingAccessory]);
1131
1118
  // create the accessory handler for the restored accessory
1132
1119
  // this is imported from `platformAccessory.ts`
1133
1120
  new others_1.Others(this, existingAccessory, device);
1134
- this.debug(`${device.remoteType} UDID: ${device.deviceName}-${device.deviceId}-${device.remoteType}`);
1121
+ this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
1135
1122
  }
1136
1123
  else {
1137
1124
  this.unregisterPlatformAccessories(existingAccessory);
1138
1125
  }
1139
1126
  }
1140
- else if (!this.config.options?.hide_device.includes(device.deviceId)) {
1127
+ else if (device.hubDeviceId) {
1141
1128
  // the accessory does not yet exist, so we need to create it
1142
- this.log.info('Adding new accessory: %s %s DeviceID: %s', device.deviceName, device.remoteType, device.deviceId);
1129
+ this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1143
1130
  // create a new accessory
1144
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
1131
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
1145
1132
  // store a copy of the device object in the `accessory.context`
1146
1133
  // the `context` property can be used to store any data about the accessory you may need
1147
1134
  accessory.context.device = device;
1148
1135
  accessory.context.model = device.remoteType;
1149
1136
  accessory.context.deviceID = device.deviceId;
1150
1137
  accessory.context.firmwareRevision = this.version;
1151
- await this.connectionTypeNewAccessory(device, accessory);
1138
+ await this.connectionTypeExistingAccessory(device, accessory);
1152
1139
  // create the accessory handler for the newly create accessory
1153
1140
  // this is imported from `platformAccessory.ts`
1154
1141
  new others_1.Others(this, accessory, device);
1155
- this.debug(`${device.remoteType} UDID: ${device.deviceName}-${device.deviceId}-${device.remoteType}`);
1142
+ this.debug(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1156
1143
  // link the accessory to your platform
1157
1144
  this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
1158
1145
  this.accessories.push(accessory);
1159
1146
  }
1160
1147
  else {
1161
- if (this.config.devicediscovery) {
1162
- this.log.error('Unable to Register new device: %s %s - %s', device.deviceName, device.remoteType, device.deviceId);
1163
- }
1148
+ this.device(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
1164
1149
  }
1165
1150
  }
1166
1151
  async connectionTypeNewAccessory(device, accessory) {
1167
- if (this.config.options?.ble?.includes(device.deviceId)) {
1152
+ if (device.ble) {
1168
1153
  accessory.context.connectionType = 'BLE';
1169
1154
  }
1170
1155
  else {
@@ -1172,7 +1157,7 @@ class SwitchBotPlatform {
1172
1157
  }
1173
1158
  }
1174
1159
  async connectionTypeExistingAccessory(device, existingAccessory) {
1175
- if (this.config.options?.ble?.includes(device.deviceId)) {
1160
+ if (device.ble) {
1176
1161
  existingAccessory.context.connectionType = 'BLE';
1177
1162
  }
1178
1163
  else {
@@ -1185,31 +1170,48 @@ class SwitchBotPlatform {
1185
1170
  this.log.info('Removing existing accessory from cache:', existingAccessory.displayName);
1186
1171
  }
1187
1172
  deviceListInfo(devices) {
1188
- this.log.warn(JSON.stringify(devices));
1173
+ if (this.config.options?.debug === 'device') {
1174
+ this.device(`deviceListInfoStatus: ${JSON.stringify(devices)}`);
1175
+ }
1189
1176
  }
1190
1177
  async deviceInfo(device) {
1191
- this.log.warn(JSON.stringify(device));
1192
- const deviceStatus = (await this.axios.get(`${settings_1.DeviceURL}/${device.deviceId}/status`)).data;
1193
- if (deviceStatus.message === 'success') {
1194
- this.log.warn('deviceStatus -', device.deviceName, JSON.stringify(deviceStatus));
1195
- }
1196
- else {
1197
- this.log.warn('deviceStatus -', device.deviceName, JSON.stringify(deviceStatus.message));
1198
- this.log.error('Unable to retreive device status.');
1178
+ if (this.config.options?.debug === 'device') {
1179
+ this.device(JSON.stringify(device));
1180
+ this.deviceStatus = (await this.axios.get(`${settings_1.DeviceURL}/${device.deviceId}/status`)).data;
1181
+ if (this.deviceStatus.message === 'success') {
1182
+ this.device(`${device.deviceName} deviceInfoStatus: ${JSON.stringify(this.deviceStatus)}`);
1183
+ }
1184
+ else {
1185
+ this.device(`${device.deviceName} deviceInfoStatus: ${JSON.stringify(this.deviceStatus.message)}`);
1186
+ this.device('Unable to retreive deviceInfoStatus.');
1187
+ }
1199
1188
  }
1200
1189
  }
1201
1190
  /**
1202
1191
  * If debug level logging is turned on, log to log.info
1203
1192
  * Otherwise send debug logs to log.debug
1193
+ * this.debugMode = process.argv.includes('-D') || process.argv.includes('--debug');
1204
1194
  */
1205
1195
  debug(...log) {
1206
- if (this.config.options?.debug) {
1196
+ if (this.config.options.debug === 'debug') {
1207
1197
  this.log.info('[DEBUG]', String(...log));
1208
1198
  }
1209
1199
  else {
1210
1200
  this.log.debug(String(...log));
1211
1201
  }
1212
1202
  }
1203
+ /**
1204
+ * If device level logging is turned on, log to log.warn
1205
+ * Otherwise send debug logs to log.debug
1206
+ */
1207
+ device(...log) {
1208
+ if (this.config.options.debug === 'device') {
1209
+ this.log.warn('[DEVICE]', String(...log));
1210
+ }
1211
+ else {
1212
+ this.log.debug(String(...log));
1213
+ }
1214
+ }
1213
1215
  }
1214
1216
  exports.SwitchBotPlatform = SwitchBotPlatform;
1215
1217
  //# sourceMappingURL=platform.js.map