@switchbot/homebridge-switchbot 3.7.1-beta.11 → 3.7.1-beta.13

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 (190) hide show
  1. package/dist/device/blindtilt.d.ts +8 -8
  2. package/dist/device/blindtilt.d.ts.map +1 -1
  3. package/dist/device/blindtilt.js +34 -66
  4. package/dist/device/blindtilt.js.map +1 -1
  5. package/dist/device/bot.d.ts +9 -9
  6. package/dist/device/bot.d.ts.map +1 -1
  7. package/dist/device/bot.js +61 -97
  8. package/dist/device/bot.js.map +1 -1
  9. package/dist/device/ceilinglight.d.ts +13 -13
  10. package/dist/device/ceilinglight.d.ts.map +1 -1
  11. package/dist/device/ceilinglight.js +38 -73
  12. package/dist/device/ceilinglight.js.map +1 -1
  13. package/dist/device/colorbulb.d.ts +12 -12
  14. package/dist/device/colorbulb.d.ts.map +1 -1
  15. package/dist/device/colorbulb.js +41 -79
  16. package/dist/device/colorbulb.js.map +1 -1
  17. package/dist/device/contact.d.ts +5 -5
  18. package/dist/device/contact.d.ts.map +1 -1
  19. package/dist/device/contact.js +20 -42
  20. package/dist/device/contact.js.map +1 -1
  21. package/dist/device/curtain.d.ts +5 -5
  22. package/dist/device/curtain.d.ts.map +1 -1
  23. package/dist/device/curtain.js +36 -71
  24. package/dist/device/curtain.js.map +1 -1
  25. package/dist/device/device.d.ts +18 -18
  26. package/dist/device/device.d.ts.map +1 -1
  27. package/dist/device/device.js +33 -36
  28. package/dist/device/device.js.map +1 -1
  29. package/dist/device/fan.d.ts +8 -8
  30. package/dist/device/fan.d.ts.map +1 -1
  31. package/dist/device/fan.js +43 -75
  32. package/dist/device/fan.js.map +1 -1
  33. package/dist/device/hub.d.ts +5 -5
  34. package/dist/device/hub.d.ts.map +1 -1
  35. package/dist/device/hub.js +18 -39
  36. package/dist/device/hub.js.map +1 -1
  37. package/dist/device/humidifier.d.ts +5 -5
  38. package/dist/device/humidifier.d.ts.map +1 -1
  39. package/dist/device/humidifier.js +38 -78
  40. package/dist/device/humidifier.js.map +1 -1
  41. package/dist/device/iosensor.d.ts +5 -5
  42. package/dist/device/iosensor.d.ts.map +1 -1
  43. package/dist/device/iosensor.js +21 -40
  44. package/dist/device/iosensor.js.map +1 -1
  45. package/dist/device/lightstrip.d.ts +6 -6
  46. package/dist/device/lightstrip.d.ts.map +1 -1
  47. package/dist/device/lightstrip.js +34 -73
  48. package/dist/device/lightstrip.js.map +1 -1
  49. package/dist/device/lock.d.ts +9 -9
  50. package/dist/device/lock.d.ts.map +1 -1
  51. package/dist/device/lock.js +37 -52
  52. package/dist/device/lock.js.map +1 -1
  53. package/dist/device/meter.d.ts +5 -5
  54. package/dist/device/meter.d.ts.map +1 -1
  55. package/dist/device/meter.js +21 -39
  56. package/dist/device/meter.js.map +1 -1
  57. package/dist/device/meterplus.d.ts +5 -5
  58. package/dist/device/meterplus.d.ts.map +1 -1
  59. package/dist/device/meterplus.js +21 -38
  60. package/dist/device/meterplus.js.map +1 -1
  61. package/dist/device/motion.d.ts +5 -5
  62. package/dist/device/motion.d.ts.map +1 -1
  63. package/dist/device/motion.js +14 -32
  64. package/dist/device/motion.js.map +1 -1
  65. package/dist/device/plug.d.ts +12 -12
  66. package/dist/device/plug.d.ts.map +1 -1
  67. package/dist/device/plug.js +16 -25
  68. package/dist/device/plug.js.map +1 -1
  69. package/dist/device/robotvacuumcleaner.d.ts +11 -11
  70. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  71. package/dist/device/robotvacuumcleaner.js +42 -56
  72. package/dist/device/robotvacuumcleaner.js.map +1 -1
  73. package/dist/device/waterdetector.d.ts +5 -5
  74. package/dist/device/waterdetector.d.ts.map +1 -1
  75. package/dist/device/waterdetector.js +22 -37
  76. package/dist/device/waterdetector.js.map +1 -1
  77. package/dist/homebridge-ui/server.js +2 -2
  78. package/dist/homebridge-ui/server.js.map +1 -1
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +0 -4
  81. package/dist/index.js.map +1 -1
  82. package/dist/irdevice/airconditioner.d.ts +8 -8
  83. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  84. package/dist/irdevice/airconditioner.js +64 -105
  85. package/dist/irdevice/airconditioner.js.map +1 -1
  86. package/dist/irdevice/airpurifier.d.ts +10 -10
  87. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  88. package/dist/irdevice/airpurifier.js +22 -42
  89. package/dist/irdevice/airpurifier.js.map +1 -1
  90. package/dist/irdevice/camera.d.ts +9 -9
  91. package/dist/irdevice/camera.d.ts.map +1 -1
  92. package/dist/irdevice/camera.js +15 -25
  93. package/dist/irdevice/camera.js.map +1 -1
  94. package/dist/irdevice/fan.d.ts +8 -8
  95. package/dist/irdevice/fan.d.ts.map +1 -1
  96. package/dist/irdevice/fan.js +21 -40
  97. package/dist/irdevice/fan.js.map +1 -1
  98. package/dist/irdevice/irdevice.d.ts +11 -11
  99. package/dist/irdevice/irdevice.d.ts.map +1 -1
  100. package/dist/irdevice/irdevice.js +14 -22
  101. package/dist/irdevice/irdevice.js.map +1 -1
  102. package/dist/irdevice/light.d.ts +9 -9
  103. package/dist/irdevice/light.d.ts.map +1 -1
  104. package/dist/irdevice/light.js +24 -47
  105. package/dist/irdevice/light.js.map +1 -1
  106. package/dist/irdevice/other.d.ts +9 -9
  107. package/dist/irdevice/other.d.ts.map +1 -1
  108. package/dist/irdevice/other.js +40 -83
  109. package/dist/irdevice/other.js.map +1 -1
  110. package/dist/irdevice/tv.d.ts +9 -9
  111. package/dist/irdevice/tv.d.ts.map +1 -1
  112. package/dist/irdevice/tv.js +29 -54
  113. package/dist/irdevice/tv.js.map +1 -1
  114. package/dist/irdevice/vacuumcleaner.d.ts +5 -5
  115. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  116. package/dist/irdevice/vacuumcleaner.js +11 -21
  117. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  118. package/dist/irdevice/waterheater.d.ts +5 -5
  119. package/dist/irdevice/waterheater.d.ts.map +1 -1
  120. package/dist/irdevice/waterheater.js +11 -22
  121. package/dist/irdevice/waterheater.js.map +1 -1
  122. package/dist/platform.d.ts +5 -6
  123. package/dist/platform.d.ts.map +1 -1
  124. package/dist/platform.js +142 -146
  125. package/dist/platform.js.map +1 -1
  126. package/dist/settings.d.ts +2 -2
  127. package/dist/settings.d.ts.map +1 -1
  128. package/dist/settings.js.map +1 -1
  129. package/dist/types/bledevicestatus.d.ts +9 -9
  130. package/dist/types/bledevicestatus.d.ts.map +1 -1
  131. package/dist/types/devicelist.d.ts +6 -6
  132. package/dist/types/devicelist.d.ts.map +1 -1
  133. package/dist/types/deviceresponse.d.ts +4 -4
  134. package/dist/types/deviceresponse.d.ts.map +1 -1
  135. package/dist/types/devicestatus.d.ts +2 -2
  136. package/dist/types/devicestatus.d.ts.map +1 -1
  137. package/dist/types/devicewebhookstatus.d.ts +5 -5
  138. package/dist/types/devicewebhookstatus.d.ts.map +1 -1
  139. package/dist/types/irdevicelist.d.ts +4 -4
  140. package/dist/types/irdevicelist.d.ts.map +1 -1
  141. package/dist/types/pushbody.d.ts +2 -2
  142. package/dist/types/pushbody.d.ts.map +1 -1
  143. package/dist/utils.d.ts +4 -4
  144. package/dist/utils.d.ts.map +1 -1
  145. package/dist/utils.js +9 -13
  146. package/dist/utils.js.map +1 -1
  147. package/eslint.config.js +48 -93
  148. package/package.json +54 -47
  149. package/src/device/blindtilt.ts +419 -456
  150. package/src/device/bot.ts +656 -693
  151. package/src/device/ceilinglight.ts +331 -364
  152. package/src/device/colorbulb.ts +412 -448
  153. package/src/device/contact.ts +200 -221
  154. package/src/device/curtain.ts +400 -435
  155. package/src/device/device.ts +206 -208
  156. package/src/device/fan.ts +307 -340
  157. package/src/device/hub.ts +184 -209
  158. package/src/device/humidifier.ts +297 -342
  159. package/src/device/iosensor.ts +182 -204
  160. package/src/device/lightstrip.ts +362 -399
  161. package/src/device/lock.ts +262 -276
  162. package/src/device/meter.ts +183 -205
  163. package/src/device/meterplus.ts +183 -204
  164. package/src/device/motion.ts +169 -185
  165. package/src/device/plug.ts +174 -177
  166. package/src/device/robotvacuumcleaner.ts +256 -269
  167. package/src/device/waterdetector.ts +169 -184
  168. package/src/homebridge-ui/server.ts +16 -15
  169. package/src/index.ts +5 -6
  170. package/src/irdevice/airconditioner.ts +280 -326
  171. package/src/irdevice/airpurifier.ts +124 -143
  172. package/src/irdevice/camera.ts +58 -64
  173. package/src/irdevice/fan.ts +106 -123
  174. package/src/irdevice/irdevice.ts +116 -119
  175. package/src/irdevice/light.ts +119 -143
  176. package/src/irdevice/other.ts +417 -461
  177. package/src/irdevice/tv.ts +155 -177
  178. package/src/irdevice/vacuumcleaner.ts +54 -60
  179. package/src/irdevice/waterheater.ts +56 -63
  180. package/src/platform.ts +1282 -1281
  181. package/src/settings.ts +170 -170
  182. package/src/types/bledevicestatus.ts +255 -255
  183. package/src/types/devicelist.ts +79 -79
  184. package/src/types/deviceresponse.ts +12 -13
  185. package/src/types/devicestatus.ts +124 -124
  186. package/src/types/devicewebhookstatus.ts +126 -127
  187. package/src/types/irdevicelist.ts +10 -10
  188. package/src/types/pushbody.ts +5 -5
  189. package/src/utils.ts +64 -65
  190. package/tsconfig.json +10 -9
package/dist/platform.js CHANGED
@@ -1,50 +1,47 @@
1
- /* Copyright(C) 2017-2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
- *
3
- * platform.ts: @switchbot/homebridge-switchbot platform class.
4
- */
5
- import { Hub } from './device/hub.js';
1
+ import { Buffer } from 'node:buffer';
2
+ import crypto, { randomUUID } from 'node:crypto';
3
+ import { readFileSync, writeFileSync } from 'node:fs';
4
+ import { createServer } from 'node:http';
5
+ import process from 'node:process';
6
+ import asyncmqtt from 'async-mqtt';
7
+ import fakegato from 'fakegato-history';
8
+ import { EveHomeKitTypes } from 'homebridge-lib/EveHomeKitTypes';
9
+ /*
10
+ * For Testing Locally:
11
+ * import { SwitchBotModel } from '/Users/Shared/GitHub/OpenWonderLabs/node-switchbot/dist/index.js';
12
+ */
13
+ import { SwitchBotModel } from 'node-switchbot';
14
+ import { queueScheduler } from 'rxjs';
15
+ import { request } from 'undici';
16
+ import { BlindTilt } from './device/blindtilt.js';
6
17
  import { Bot } from './device/bot.js';
7
- import { Plug } from './device/plug.js';
8
- import { Lock } from './device/lock.js';
9
- import { Meter } from './device/meter.js';
10
- import { Motion } from './device/motion.js';
18
+ import { CeilingLight } from './device/ceilinglight.js';
19
+ import { ColorBulb } from './device/colorbulb.js';
11
20
  import { Contact } from './device/contact.js';
12
21
  import { Curtain } from './device/curtain.js';
22
+ import { Fan } from './device/fan.js';
23
+ import { Hub } from './device/hub.js';
24
+ import { Humidifier } from './device/humidifier.js';
13
25
  import { IOSensor } from './device/iosensor.js';
14
- import { MeterPlus } from './device/meterplus.js';
15
- import { ColorBulb } from './device/colorbulb.js';
16
26
  import { StripLight } from './device/lightstrip.js';
17
- import { Humidifier } from './device/humidifier.js';
18
- import { CeilingLight } from './device/ceilinglight.js';
19
- import { WaterDetector } from './device/waterdetector.js';
27
+ import { Lock } from './device/lock.js';
28
+ import { Meter } from './device/meter.js';
29
+ import { MeterPlus } from './device/meterplus.js';
30
+ import { Motion } from './device/motion.js';
31
+ import { Plug } from './device/plug.js';
20
32
  import { RobotVacuumCleaner } from './device/robotvacuumcleaner.js';
21
- import { Fan } from './device/fan.js';
22
- import { TV } from './irdevice/tv.js';
33
+ import { WaterDetector } from './device/waterdetector.js';
34
+ import { AirConditioner } from './irdevice/airconditioner.js';
35
+ import { AirPurifier } from './irdevice/airpurifier.js';
36
+ import { Camera } from './irdevice/camera.js';
23
37
  import { IRFan } from './irdevice/fan.js';
24
38
  import { Light } from './irdevice/light.js';
25
39
  import { Others } from './irdevice/other.js';
26
- import { Camera } from './irdevice/camera.js';
27
- import { BlindTilt } from './device/blindtilt.js';
28
- import { AirPurifier } from './irdevice/airpurifier.js';
29
- import { WaterHeater } from './irdevice/waterheater.js';
40
+ import { TV } from './irdevice/tv.js';
30
41
  import { VacuumCleaner } from './irdevice/vacuumcleaner.js';
31
- import { AirConditioner } from './irdevice/airconditioner.js';
32
- import { Buffer } from 'buffer';
33
- import { request } from 'undici';
34
- import asyncmqtt from 'async-mqtt';
35
- import { createServer } from 'http';
36
- import { queueScheduler } from 'rxjs';
37
- import fakegato from 'fakegato-history';
38
- import crypto, { randomUUID } from 'crypto';
39
- import { readFileSync, writeFileSync } from 'fs';
40
- import { EveHomeKitTypes } from 'homebridge-lib/EveHomeKitTypes';
41
- import { PLATFORM_NAME, PLUGIN_NAME, Devices, deleteWebhook, queryWebhook, setupWebhook, updateWebhook } from './settings.js';
42
+ import { WaterHeater } from './irdevice/waterheater.js';
43
+ import { deleteWebhook, Devices, PLATFORM_NAME, PLUGIN_NAME, queryWebhook, setupWebhook, updateWebhook } from './settings.js';
42
44
  import { isBlindTiltDevice, isCurtainDevice, sleep } from './utils.js';
43
- /*
44
- * For Testing Locally:
45
- * import { SwitchBotModel } from '/Users/Shared/GitHub/OpenWonderLabs/node-switchbot/dist/index.js';
46
- */
47
- import { SwitchBotModel } from 'node-switchbot';
48
45
  /**
49
46
  * HomebridgePlatform
50
47
  * This class is the main constructor for your plugin, this is where you should
@@ -180,7 +177,7 @@ export class SwitchBotPlatform {
180
177
  }
181
178
  }
182
179
  async setupwebhook() {
183
- //webhook configuration
180
+ // webhook configuration
184
181
  if (this.config.options?.webhookURL) {
185
182
  const url = this.config.options?.webhookURL;
186
183
  try {
@@ -216,7 +213,7 @@ export class SwitchBotPlatform {
216
213
  catch (e) {
217
214
  this.errorLog(`Failed to handle webhook event. Error:${e}`);
218
215
  }
219
- }).listen(port ? port : 80);
216
+ }).listen(port || 80);
220
217
  }
221
218
  catch (e) {
222
219
  await this.errorLog(`Failed to create webhook listener. Error:${e.message}`);
@@ -227,16 +224,15 @@ export class SwitchBotPlatform {
227
224
  method: 'POST',
228
225
  headers: this.generateHeaders(),
229
226
  body: JSON.stringify({
230
- 'action': 'setupWebhook',
231
- 'url': url,
232
- 'deviceList': 'ALL',
227
+ action: 'setupWebhook',
228
+ url,
229
+ deviceList: 'ALL',
233
230
  }),
234
231
  });
235
232
  const response = await body.json();
236
233
  await this.debugLog(`setupWebhook: url:${url}, body:${JSON.stringify(response)}, statusCode:${statusCode}`);
237
234
  if (statusCode !== 200 || response?.statusCode !== 100) {
238
- await this.errorLog(`Failed to configure webhook. Existing webhook well be overridden. HTTP:${statusCode} API:${response?.statusCode} `
239
- + `message:${response?.message}`);
235
+ await this.errorLog(`Failed to configure webhook. Existing webhook well be overridden. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
240
236
  }
241
237
  }
242
238
  catch (e) {
@@ -244,11 +240,13 @@ export class SwitchBotPlatform {
244
240
  }
245
241
  try {
246
242
  const { body, statusCode } = await request(updateWebhook, {
247
- method: 'POST', headers: this.generateHeaders(), body: JSON.stringify({
248
- 'action': 'updateWebhook',
249
- 'config': {
250
- 'url': url,
251
- 'enable': true,
243
+ method: 'POST',
244
+ headers: this.generateHeaders(),
245
+ body: JSON.stringify({
246
+ action: 'updateWebhook',
247
+ config: {
248
+ url,
249
+ enable: true,
252
250
  },
253
251
  }),
254
252
  });
@@ -266,7 +264,7 @@ export class SwitchBotPlatform {
266
264
  method: 'POST',
267
265
  headers: this.generateHeaders(),
268
266
  body: JSON.stringify({
269
- 'action': 'queryUrl',
267
+ action: 'queryUrl',
270
268
  }),
271
269
  });
272
270
  const response = await body.json();
@@ -288,8 +286,8 @@ export class SwitchBotPlatform {
288
286
  method: 'POST',
289
287
  headers: this.generateHeaders(),
290
288
  body: JSON.stringify({
291
- 'action': 'deleteWebhook',
292
- 'url': url,
289
+ action: 'deleteWebhook',
290
+ url,
293
291
  }),
294
292
  });
295
293
  const response = await body.json();
@@ -365,13 +363,13 @@ export class SwitchBotPlatform {
365
363
  this.config.options = this.config.options || {};
366
364
  const platformConfig = {};
367
365
  if (this.config.options.logging) {
368
- platformConfig['logging'] = this.config.options.logging;
366
+ platformConfig.logging = this.config.options.logging;
369
367
  }
370
368
  if (this.config.options.logging && this.config.options.refreshRate) {
371
- platformConfig['refreshRate'] = this.config.options.refreshRate;
369
+ platformConfig.refreshRate = this.config.options.refreshRate;
372
370
  }
373
371
  if (this.config.options.logging && this.config.options.pushRate) {
374
- platformConfig['pushRate'] = this.config.options.pushRate;
372
+ platformConfig.pushRate = this.config.options.pushRate;
375
373
  }
376
374
  if (Object.entries(platformConfig).length !== 0) {
377
375
  await this.debugWarnLog(`Platform Config: ${JSON.stringify(platformConfig)}`);
@@ -451,7 +449,6 @@ export class SwitchBotPlatform {
451
449
  /**
452
450
  * The openToken was old config.
453
451
  * This method saves the openToken as the token in the config.json file
454
- * @param this.config.credentials.openToken
455
452
  */
456
453
  async updateToken() {
457
454
  try {
@@ -463,7 +460,7 @@ export class SwitchBotPlatform {
463
460
  const currentConfig = JSON.parse(readFileSync(this.api.user.configPath(), 'utf8'));
464
461
  // check the platforms section is an array before we do array things on it
465
462
  if (!Array.isArray(currentConfig.platforms)) {
466
- throw new Error('Cannot find platforms array in config');
463
+ throw new TypeError('Cannot find platforms array in config');
467
464
  }
468
465
  // find this plugins current config
469
466
  const pluginConfig = currentConfig.platforms.find((x) => x.platform === PLATFORM_NAME);
@@ -472,17 +469,15 @@ export class SwitchBotPlatform {
472
469
  }
473
470
  // check the .credentials is an object before doing object things with it
474
471
  if (typeof pluginConfig.credentials !== 'object') {
475
- throw new Error('pluginConfig.credentials is not an object');
472
+ throw new TypeError('pluginConfig.credentials is not an object');
476
473
  }
477
474
  // Move openToken to token
478
475
  if (!this.config.credentials.secret) {
479
- await this.warnLog('This plugin has been updated to use OpenAPI v1.1, config is set with openToken,'
480
- + ' "openToken" cconfig has been moved to the "token" config');
476
+ await this.warnLog('This plugin has been updated to use OpenAPI v1.1, config is set with openToken, "openToken" cconfig has been moved to the "token" config');
481
477
  this.errorLog('"secret" config is not populated, you must populate then please restart Homebridge.');
482
478
  }
483
479
  else {
484
- await this.warnLog('This plugin has been updated to use OpenAPI v1.1, config is set with openToken, '
485
- + '"openToken" config has been moved to the "token" config, please restart Homebridge.');
480
+ await this.warnLog('This plugin has been updated to use OpenAPI v1.1, config is set with openToken, "openToken" config has been moved to the "token" config, please restart Homebridge.');
486
481
  }
487
482
  // set the refresh token
488
483
  pluginConfig.credentials.token = this.config.credentials?.openToken;
@@ -508,10 +503,10 @@ export class SwitchBotPlatform {
508
503
  .digest();
509
504
  const sign = signTerm.toString('base64');
510
505
  return {
511
- Authorization: this.config.credentials?.token,
512
- sign: sign,
513
- nonce: nonce,
514
- t: t,
506
+ 'Authorization': this.config.credentials?.token,
507
+ 'sign': sign,
508
+ 'nonce': nonce,
509
+ 't': t,
515
510
  'Content-Type': 'application/json',
516
511
  };
517
512
  };
@@ -543,8 +538,7 @@ export class SwitchBotPlatform {
543
538
  }
544
539
  catch (e) {
545
540
  retryCount++;
546
- await this.debugErrorLog(`Failed to Discover Devices, Error Message: ${JSON.stringify(e.message)},`
547
- + ' Submit Bugs Here: https://tinyurl.com/SwitchBotBug');
541
+ await this.debugErrorLog(`Failed to Discover Devices, Error Message: ${JSON.stringify(e.message)}, Submit Bugs Here: https://tinyurl.com/SwitchBotBug`);
548
542
  await this.debugErrorLog(`Failed to Discover Devices, Error: ${e}`);
549
543
  }
550
544
  }
@@ -626,7 +620,7 @@ export class SwitchBotPlatform {
626
620
  }
627
621
  mergeByDeviceId(a1, a2) {
628
622
  const normalizeDeviceId = (deviceId) => deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '');
629
- return a1.map(itm => {
623
+ return a1.map((itm) => {
630
624
  const matchingItem = a2.find(item => normalizeDeviceId(item.deviceId) === normalizeDeviceId(itm.deviceId));
631
625
  return { ...matchingItem, ...itm };
632
626
  });
@@ -654,6 +648,7 @@ export class SwitchBotPlatform {
654
648
  'Curtain': this.createCurtain.bind(this),
655
649
  'Curtain3': this.createCurtain.bind(this),
656
650
  'Blind Tilt': this.createBlindTilt.bind(this),
651
+ 'Roller Shade': this.createBlindTilt.bind(this),
657
652
  'Plug': this.createPlug.bind(this),
658
653
  'Plug Mini (US)': this.createPlug.bind(this),
659
654
  'Plug Mini (JP)': this.createPlug.bind(this),
@@ -679,8 +674,7 @@ export class SwitchBotPlatform {
679
674
  await this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}, is currently not supported, device: ${JSON.stringify(device)}`);
680
675
  }
681
676
  else {
682
- await this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.deviceType}, is currently not supported.`
683
- + ` Submit Feature Requests Here: https://tinyurl.com/SwitchBotFeatureRequest, device: ${JSON.stringify(device)}`);
677
+ await this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.deviceType}, is currently not supported. Submit Feature Requests Here: https://tinyurl.com/SwitchBotFeatureRequest, device: ${JSON.stringify(device)}`);
684
678
  }
685
679
  }
686
680
  async createIRDevice(device) {
@@ -722,15 +716,14 @@ export class SwitchBotPlatform {
722
716
  await deviceTypeHandlers[device.remoteType](device);
723
717
  }
724
718
  else {
725
- await this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.remoteType}, is currently not supported.`
726
- + ` Submit Feature Requests Here: https://tinyurl.com/SwitchBotFeatureRequest, device: ${JSON.stringify(device)}`);
719
+ await this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.remoteType}, is currently not supported. Submit Feature Requests Here: https://tinyurl.com/SwitchBotFeatureRequest, device: ${JSON.stringify(device)}`);
727
720
  }
728
721
  }
729
722
  async createHumidifier(device) {
730
723
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
731
724
  // see if an accessory with the same uuid has already been registered and restored from
732
725
  // the cached devices we stored in the `configureAccessory` method above
733
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
726
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
734
727
  if (existingAccessory) {
735
728
  // the accessory already exists
736
729
  if (await this.registerDevice(device)) {
@@ -789,7 +782,7 @@ export class SwitchBotPlatform {
789
782
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
790
783
  // see if an accessory with the same uuid has already been registered and restored from
791
784
  // the cached devices we stored in the `configureAccessory` method above
792
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
785
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
793
786
  if (existingAccessory) {
794
787
  // the accessory already exists
795
788
  if (await this.registerDevice(device)) {
@@ -850,7 +843,7 @@ export class SwitchBotPlatform {
850
843
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
851
844
  // see if an accessory with the same uuid has already been registered and restored from
852
845
  // the cached devices we stored in the `configureAccessory` method above
853
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
846
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
854
847
  if (existingAccessory) {
855
848
  // the accessory already exists
856
849
  if (await this.registerDevice(device)) {
@@ -910,7 +903,7 @@ export class SwitchBotPlatform {
910
903
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
911
904
  // see if an accessory with the same uuid has already been registered and restored from
912
905
  // the cached devices we stored in the `configureAccessory` method above
913
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
906
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
914
907
  if (existingAccessory) {
915
908
  // the accessory already exists
916
909
  if (await this.registerDevice(device)) {
@@ -971,7 +964,7 @@ export class SwitchBotPlatform {
971
964
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
972
965
  // see if an accessory with the same uuid has already been registered and restored from
973
966
  // the cached devices we stored in the `configureAccessory` method above
974
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
967
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
975
968
  if (existingAccessory) {
976
969
  // the accessory already exists
977
970
  if (await this.registerDevice(device)) {
@@ -1032,7 +1025,7 @@ export class SwitchBotPlatform {
1032
1025
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
1033
1026
  // see if an accessory with the same uuid has already been registered and restored from
1034
1027
  // the cached devices we stored in the `configureAccessory` method above
1035
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1028
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
1036
1029
  if (existingAccessory) {
1037
1030
  // the accessory already exists
1038
1031
  if (await this.registerDevice(device)) {
@@ -1092,7 +1085,7 @@ export class SwitchBotPlatform {
1092
1085
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
1093
1086
  // see if an accessory with the same uuid has already been registered and restored from
1094
1087
  // the cached devices we stored in the `configureAccessory` method above
1095
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1088
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
1096
1089
  if (existingAccessory) {
1097
1090
  // the accessory already exists
1098
1091
  if (await this.registerDevice(device)) {
@@ -1152,7 +1145,7 @@ export class SwitchBotPlatform {
1152
1145
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
1153
1146
  // see if an accessory with the same uuid has already been registered and restored from
1154
1147
  // the cached devices we stored in the `configureAccessory` method above
1155
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1148
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
1156
1149
  if (existingAccessory) {
1157
1150
  // the accessory already exists
1158
1151
  if (await this.registerDevice(device)) {
@@ -1212,7 +1205,7 @@ export class SwitchBotPlatform {
1212
1205
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
1213
1206
  // see if an accessory with the same uuid has already been registered and restored from
1214
1207
  // the cached devices we stored in the `configureAccessory` method above
1215
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1208
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
1216
1209
  if (existingAccessory) {
1217
1210
  // the accessory already exists
1218
1211
  if (await this.registerDevice(device)) {
@@ -1272,7 +1265,7 @@ export class SwitchBotPlatform {
1272
1265
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
1273
1266
  // see if an accessory with the same uuid has already been registered and restored from
1274
1267
  // the cached devices we stored in the `configureAccessory` method above
1275
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1268
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
1276
1269
  if (existingAccessory) {
1277
1270
  // the accessory already exists
1278
1271
  if (await this.registerDevice(device)) {
@@ -1300,8 +1293,8 @@ export class SwitchBotPlatform {
1300
1293
  else if (await this.registerDevice(device)) {
1301
1294
  if (isBlindTiltDevice(device)) {
1302
1295
  if (device.group && !device.curtain?.disable_group) {
1303
- this.debugLog('Your Curtains are grouped, ' +
1304
- `, Secondary curtain automatically hidden. Main Curtain: ${device.deviceName}, deviceId: ${device.deviceId}`);
1296
+ this.debugLog('Your Curtains are grouped, '
1297
+ + `, Secondary curtain automatically hidden. Main Curtain: ${device.deviceName}, deviceId: ${device.deviceId}`);
1305
1298
  }
1306
1299
  else {
1307
1300
  if (device.master) {
@@ -1319,7 +1312,6 @@ export class SwitchBotPlatform {
1319
1312
  // store a copy of the device object in the `accessory.context`
1320
1313
  // the `context` property can be used to store any data about the accessory you may need
1321
1314
  accessory.context.device = device;
1322
- ;
1323
1315
  accessory.context.deviceId = device.deviceId;
1324
1316
  accessory.context.deviceType = device.deviceType;
1325
1317
  accessory.context.model = SwitchBotModel.BlindTilt;
@@ -1347,7 +1339,7 @@ export class SwitchBotPlatform {
1347
1339
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
1348
1340
  // see if an accessory with the same uuid has already been registered and restored from
1349
1341
  // the cached devices we stored in the `configureAccessory` method above
1350
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1342
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
1351
1343
  if (existingAccessory) {
1352
1344
  // the accessory already exists
1353
1345
  if (await this.registerDevice(device)) {
@@ -1375,8 +1367,8 @@ export class SwitchBotPlatform {
1375
1367
  else if (await this.registerDevice(device)) {
1376
1368
  if (isCurtainDevice(device)) {
1377
1369
  if (device.group && !device.curtain?.disable_group) {
1378
- this.debugLog('Your Curtains are grouped, ' +
1379
- `, Secondary curtain automatically hidden. Main Curtain: ${device.deviceName}, deviceId: ${device.deviceId}`);
1370
+ this.debugLog('Your Curtains are grouped, '
1371
+ + `, Secondary curtain automatically hidden. Main Curtain: ${device.deviceName}, deviceId: ${device.deviceId}`);
1380
1372
  }
1381
1373
  else {
1382
1374
  if (device.master) {
@@ -1421,7 +1413,7 @@ export class SwitchBotPlatform {
1421
1413
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
1422
1414
  // see if an accessory with the same uuid has already been registered and restored from
1423
1415
  // the cached devices we stored in the `configureAccessory` method above
1424
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1416
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
1425
1417
  if (existingAccessory) {
1426
1418
  // the accessory already exists
1427
1419
  if (await this.registerDevice(device)) {
@@ -1429,8 +1421,11 @@ export class SwitchBotPlatform {
1429
1421
  existingAccessory.context.device = device;
1430
1422
  existingAccessory.context.deviceId = device.deviceId;
1431
1423
  existingAccessory.context.deviceType = device.deviceType;
1432
- existingAccessory.context.model = device.deviceType === 'Plug Mini (US)' ? SwitchBotModel.PlugMiniUS : device.deviceType === 'Plug Mini (JP)'
1433
- ? SwitchBotModel.PlugMiniJP : SwitchBotModel.Plug;
1424
+ existingAccessory.context.model = device.deviceType === 'Plug Mini (US)'
1425
+ ? SwitchBotModel.PlugMiniUS
1426
+ : device.deviceType === 'Plug Mini (JP)'
1427
+ ? SwitchBotModel.PlugMiniJP
1428
+ : SwitchBotModel.Plug;
1434
1429
  existingAccessory.displayName = device.configDeviceName
1435
1430
  ? await this.validateAndCleanDisplayName(device.configDeviceName, 'configDeviceName', device.configDeviceName)
1436
1431
  : await this.validateAndCleanDisplayName(device.deviceName, 'deviceName', device.deviceName);
@@ -1457,8 +1452,11 @@ export class SwitchBotPlatform {
1457
1452
  accessory.context.device = device;
1458
1453
  accessory.context.deviceId = device.deviceId;
1459
1454
  accessory.context.deviceType = device.deviceType;
1460
- accessory.context.model = device.deviceType === 'Plug Mini (US)' ? SwitchBotModel.PlugMiniUS : device.deviceType === 'Plug Mini (JP)'
1461
- ? SwitchBotModel.PlugMiniJP : SwitchBotModel.Plug;
1455
+ accessory.context.model = device.deviceType === 'Plug Mini (US)'
1456
+ ? SwitchBotModel.PlugMiniUS
1457
+ : device.deviceType === 'Plug Mini (JP)'
1458
+ ? SwitchBotModel.PlugMiniJP
1459
+ : SwitchBotModel.Plug;
1462
1460
  accessory.displayName = device.configDeviceName
1463
1461
  ? await this.validateAndCleanDisplayName(device.configDeviceName, 'configDeviceName', device.configDeviceName)
1464
1462
  : await this.validateAndCleanDisplayName(device.deviceName, 'deviceName', device.deviceName);
@@ -1483,7 +1481,7 @@ export class SwitchBotPlatform {
1483
1481
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
1484
1482
  // see if an accessory with the same uuid has already been registered and restored from
1485
1483
  // the cached devices we stored in the `configureAccessory` method above
1486
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1484
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
1487
1485
  if (existingAccessory) {
1488
1486
  // the accessory already exists
1489
1487
  if (await this.registerDevice(device)) {
@@ -1543,7 +1541,7 @@ export class SwitchBotPlatform {
1543
1541
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
1544
1542
  // see if an accessory with the same uuid has already been registered and restored from
1545
1543
  // the cached devices we stored in the `configureAccessory` method above
1546
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1544
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
1547
1545
  if (existingAccessory) {
1548
1546
  // the accessory already exists
1549
1547
  if (await this.registerDevice(device)) {
@@ -1603,7 +1601,7 @@ export class SwitchBotPlatform {
1603
1601
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
1604
1602
  // see if an accessory with the same uuid has already been registered and restored from
1605
1603
  // the cached devices we stored in the `configureAccessory` method above
1606
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1604
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
1607
1605
  if (existingAccessory) {
1608
1606
  // the accessory already exists
1609
1607
  if (await this.registerDevice(device)) {
@@ -1663,7 +1661,7 @@ export class SwitchBotPlatform {
1663
1661
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
1664
1662
  // see if an accessory with the same uuid has already been registered and restored from
1665
1663
  // the cached devices we stored in the `configureAccessory` method above
1666
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1664
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
1667
1665
  if (existingAccessory) {
1668
1666
  // the accessory already exists
1669
1667
  if (await this.registerDevice(device)) {
@@ -1723,7 +1721,7 @@ export class SwitchBotPlatform {
1723
1721
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
1724
1722
  // see if an accessory with the same uuid has already been registered and restored from
1725
1723
  // the cached devices we stored in the `configureAccessory` method above
1726
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1724
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
1727
1725
  if (existingAccessory) {
1728
1726
  // the accessory already exists
1729
1727
  if (await this.registerDevice(device)) {
@@ -1783,7 +1781,7 @@ export class SwitchBotPlatform {
1783
1781
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
1784
1782
  // see if an accessory with the same uuid has already been registered and restored from
1785
1783
  // the cached devices we stored in the `configureAccessory` method above
1786
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1784
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
1787
1785
  if (existingAccessory) {
1788
1786
  // the accessory already exists
1789
1787
  if (await this.registerDevice(device)) {
@@ -1791,11 +1789,17 @@ export class SwitchBotPlatform {
1791
1789
  existingAccessory.context.device = device;
1792
1790
  existingAccessory.context.deviceId = device.deviceId;
1793
1791
  existingAccessory.context.deviceType = device.deviceType;
1794
- existingAccessory.context.model = device.deviceType === 'Robot Vacuum Cleaner S1' ? SwitchBotModel.RobotVacuumCleanerS1
1795
- : device.deviceType === 'Robot Vacuum Cleaner S1 Plus' ? SwitchBotModel.RobotVacuumCleanerS1Plus
1796
- : device.deviceType === 'Robot Vacuum Cleaner S10' ? SwitchBotModel.RobotVacuumCleanerS10
1797
- : device.deviceType === 'WoSweeper' ? SwitchBotModel.WoSweeper : device.deviceType === 'WoSweeperMini' ? SwitchBotModel.WoSweeperMini
1798
- : SwitchBotModel.Unknown;
1792
+ existingAccessory.context.model = device.deviceType === 'Robot Vacuum Cleaner S1'
1793
+ ? SwitchBotModel.RobotVacuumCleanerS1
1794
+ : device.deviceType === 'Robot Vacuum Cleaner S1 Plus'
1795
+ ? SwitchBotModel.RobotVacuumCleanerS1Plus
1796
+ : device.deviceType === 'Robot Vacuum Cleaner S10'
1797
+ ? SwitchBotModel.RobotVacuumCleanerS10
1798
+ : device.deviceType === 'WoSweeper'
1799
+ ? SwitchBotModel.WoSweeper
1800
+ : device.deviceType === 'WoSweeperMini'
1801
+ ? SwitchBotModel.WoSweeperMini
1802
+ : SwitchBotModel.Unknown;
1799
1803
  existingAccessory.displayName = device.configDeviceName
1800
1804
  ? await this.validateAndCleanDisplayName(device.configDeviceName, 'configDeviceName', device.configDeviceName)
1801
1805
  : await this.validateAndCleanDisplayName(device.deviceName, 'deviceName', device.deviceName);
@@ -1822,11 +1826,17 @@ export class SwitchBotPlatform {
1822
1826
  accessory.context.device = device;
1823
1827
  accessory.context.deviceId = device.deviceId;
1824
1828
  accessory.context.deviceType = device.deviceType;
1825
- accessory.context.model = device.deviceType === 'Robot Vacuum Cleaner S1' ? SwitchBotModel.RobotVacuumCleanerS1
1826
- : device.deviceType === 'Robot Vacuum Cleaner S1 Plus' ? SwitchBotModel.RobotVacuumCleanerS1Plus
1827
- : device.deviceType === 'Robot Vacuum Cleaner S10' ? SwitchBotModel.RobotVacuumCleanerS10
1828
- : device.deviceType === 'WoSweeper' ? SwitchBotModel.WoSweeper : device.deviceType === 'WoSweeperMini' ? SwitchBotModel.WoSweeperMini
1829
- : SwitchBotModel.Unknown;
1829
+ accessory.context.model = device.deviceType === 'Robot Vacuum Cleaner S1'
1830
+ ? SwitchBotModel.RobotVacuumCleanerS1
1831
+ : device.deviceType === 'Robot Vacuum Cleaner S1 Plus'
1832
+ ? SwitchBotModel.RobotVacuumCleanerS1Plus
1833
+ : device.deviceType === 'Robot Vacuum Cleaner S10'
1834
+ ? SwitchBotModel.RobotVacuumCleanerS10
1835
+ : device.deviceType === 'WoSweeper'
1836
+ ? SwitchBotModel.WoSweeper
1837
+ : device.deviceType === 'WoSweeperMini'
1838
+ ? SwitchBotModel.WoSweeperMini
1839
+ : SwitchBotModel.Unknown;
1830
1840
  accessory.displayName = device.configDeviceName
1831
1841
  ? await this.validateAndCleanDisplayName(device.configDeviceName, 'configDeviceName', device.configDeviceName)
1832
1842
  : await this.validateAndCleanDisplayName(device.deviceName, 'deviceName', device.deviceName);
@@ -1851,7 +1861,7 @@ export class SwitchBotPlatform {
1851
1861
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
1852
1862
  // see if an accessory with the same uuid has already been registered and restored from
1853
1863
  // the cached devices we stored in the `configureAccessory` method above
1854
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1864
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
1855
1865
  if (!device.hide_device && existingAccessory) {
1856
1866
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1857
1867
  existingAccessory.context.device = device;
@@ -1902,7 +1912,7 @@ export class SwitchBotPlatform {
1902
1912
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
1903
1913
  // see if an accessory with the same uuid has already been registered and restored from
1904
1914
  // the cached devices we stored in the `configureAccessory` method above
1905
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1915
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
1906
1916
  if (existingAccessory) {
1907
1917
  // the accessory already exists
1908
1918
  if (!device.hide_device && device.hubDeviceId) {
@@ -1960,7 +1970,7 @@ export class SwitchBotPlatform {
1960
1970
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
1961
1971
  // see if an accessory with the same uuid has already been registered and restored from
1962
1972
  // the cached devices we stored in the `configureAccessory` method above
1963
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1973
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
1964
1974
  if (existingAccessory) {
1965
1975
  // the accessory already exists
1966
1976
  if (!device.hide_device && device.hubDeviceId) {
@@ -2018,7 +2028,7 @@ export class SwitchBotPlatform {
2018
2028
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
2019
2029
  // see if an accessory with the same uuid has already been registered and restored from
2020
2030
  // the cached devices we stored in the `configureAccessory` method above
2021
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
2031
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
2022
2032
  if (existingAccessory) {
2023
2033
  // the accessory already exists
2024
2034
  if (!device.hide_device && device.hubDeviceId) {
@@ -2076,7 +2086,7 @@ export class SwitchBotPlatform {
2076
2086
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
2077
2087
  // see if an accessory with the same uuid has already been registered and restored from
2078
2088
  // the cached devices we stored in the `configureAccessory` method above
2079
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
2089
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
2080
2090
  if (existingAccessory) {
2081
2091
  // the accessory already exists
2082
2092
  if (!device.hide_device && device.hubDeviceId) {
@@ -2134,7 +2144,7 @@ export class SwitchBotPlatform {
2134
2144
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
2135
2145
  // see if an accessory with the same uuid has already been registered and restored from
2136
2146
  // the cached devices we stored in the `configureAccessory` method above
2137
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
2147
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
2138
2148
  if (existingAccessory) {
2139
2149
  // the accessory already exists
2140
2150
  if (!device.hide_device && device.hubDeviceId) {
@@ -2192,7 +2202,7 @@ export class SwitchBotPlatform {
2192
2202
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
2193
2203
  // see if an accessory with the same uuid has already been registered and restored from
2194
2204
  // the cached devices we stored in the `configureAccessory` method above
2195
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
2205
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
2196
2206
  if (existingAccessory) {
2197
2207
  // the accessory already exists
2198
2208
  if (!device.hide_device && device.hubDeviceId) {
@@ -2250,7 +2260,7 @@ export class SwitchBotPlatform {
2250
2260
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
2251
2261
  // see if an accessory with the same uuid has already been registered and restored from
2252
2262
  // the cached devices we stored in the `configureAccessory` method above
2253
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
2263
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
2254
2264
  if (existingAccessory) {
2255
2265
  // the accessory already exists
2256
2266
  if (!device.hide_device && device.hubDeviceId) {
@@ -2308,7 +2318,7 @@ export class SwitchBotPlatform {
2308
2318
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
2309
2319
  // see if an accessory with the same uuid has already been registered and restored from
2310
2320
  // the cached devices we stored in the `configureAccessory` method above
2311
- const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
2321
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
2312
2322
  if (existingAccessory) {
2313
2323
  // the accessory already exists
2314
2324
  if (!device.hide_device && device.hubDeviceId) {
@@ -2365,15 +2375,11 @@ export class SwitchBotPlatform {
2365
2375
  async registerCurtains(device) {
2366
2376
  let registerWindowCovering;
2367
2377
  if (isCurtainDevice(device)) {
2368
- await this.debugWarnLog(`deviceName: ${device.deviceName} deviceId: ${device.deviceId}, curtainDevicesIds: ${device.curtainDevicesIds},`
2369
- + ` master: ${device.master}, group: ${device.group}, disable_group: ${device.curtain?.disable_group},`
2370
- + ` connectionType: ${device.connectionType}`);
2378
+ await this.debugWarnLog(`deviceName: ${device.deviceName} deviceId: ${device.deviceId}, curtainDevicesIds: ${device.curtainDevicesIds},x master: ${device.master}, group: ${device.group}, disable_group: ${device.curtain?.disable_group}, connectionType: ${device.connectionType}`);
2371
2379
  registerWindowCovering = await this.registerWindowCovering(device);
2372
2380
  }
2373
2381
  else if (isBlindTiltDevice(device)) {
2374
- await this.debugWarnLog(`deviceName: ${device.deviceName} deviceId: ${device.deviceId}, blindTiltDevicesIds: ${device.blindTiltDevicesIds},`
2375
- + ` master: ${device.master}, group: ${device.group}, disable_group: ${device.curtain?.disable_group},`
2376
- + ` connectionType: ${device.connectionType}`);
2382
+ await this.debugWarnLog(`deviceName: ${device.deviceName} deviceId: ${device.deviceId}, blindTiltDevicesIds: ${device.blindTiltDevicesIds}, master: ${device.master}, group: ${device.group}, disable_group: ${device.curtain?.disable_group}, connectionType: ${device.connectionType}`);
2377
2383
  registerWindowCovering = await this.registerWindowCovering(device);
2378
2384
  }
2379
2385
  else {
@@ -2387,36 +2393,31 @@ export class SwitchBotPlatform {
2387
2393
  if (device.master && device.group) {
2388
2394
  // OpenAPI: Master Curtains/Blind Tilt in Group
2389
2395
  registerCurtain = true;
2390
- await this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] device.master: ${device.master},`
2391
- + ` device.group: ${device.group} connectionType; ${device.connectionType}`);
2396
+ await this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] device.master: ${device.master}, device.group: ${device.group} connectionType; ${device.connectionType}`);
2392
2397
  await this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}`);
2393
2398
  }
2394
2399
  else if (!device.master && device.curtain?.disable_group) {
2395
- //!device.group && device.connectionType === 'BLE'
2400
+ // !device.group && device.connectionType === 'BLE'
2396
2401
  // OpenAPI: Non-Master Curtains/Blind Tilts that has Disable Grouping Checked
2397
2402
  registerCurtain = true;
2398
- await this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] device.master: ${device.master}, disable_group: `
2399
- + `${device.curtain?.disable_group}, connectionType; ${device.connectionType}`);
2403
+ await this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] device.master: ${device.master}, disable_group: ${device.curtain?.disable_group}, connectionType; ${device.connectionType}`);
2400
2404
  await this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}`);
2401
2405
  }
2402
2406
  else if (device.master && !device.group) {
2403
2407
  // OpenAPI: Master Curtains/Blind Tilts not in Group
2404
2408
  registerCurtain = true;
2405
- await this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] device.master: ${device.master},`
2406
- + ` device.group: ${device.group} connectionType; ${device.connectionType}`);
2409
+ await this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] device.master: ${device.master}, device.group: ${device.group} connectionType; ${device.connectionType}`);
2407
2410
  await this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}`);
2408
2411
  }
2409
2412
  else if (device.connectionType === 'BLE') {
2410
2413
  // BLE: Curtains/Blind Tilt
2411
2414
  registerCurtain = true;
2412
- await this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] connectionType: ${device.connectionType}, `
2413
- + ` group: ${device.group}`);
2415
+ await this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] connectionType: ${device.connectionType}, group: ${device.group}`);
2414
2416
  await this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}`);
2415
2417
  }
2416
2418
  else {
2417
2419
  registerCurtain = false;
2418
- await this.debugErrorLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] disable_group: ${device.curtain?.disable_group},`
2419
- + ` device.master: ${device.master}, device.group: ${device.group}`);
2420
+ await this.debugErrorLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] disable_group: ${device.curtain?.disable_group}, device.master: ${device.master}, device.group: ${device.group}`);
2420
2421
  await this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}, device.connectionType: ${device.connectionType}`);
2421
2422
  }
2422
2423
  return registerCurtain;
@@ -2515,8 +2516,7 @@ export class SwitchBotPlatform {
2515
2516
  }
2516
2517
  else {
2517
2518
  registerDevice = false;
2518
- await this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, hide_device: `
2519
- + `${device.hide_device}, will not display in HomeKit`);
2519
+ await this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, hide_device: ${device.hide_device}, will not display in HomeKit`);
2520
2520
  }
2521
2521
  return registerDevice;
2522
2522
  }
@@ -2666,32 +2666,28 @@ export class SwitchBotPlatform {
2666
2666
  * @param name - The name of the characteristic.
2667
2667
  * @param value - The value to be validated and cleaned.
2668
2668
  * @returns The cleaned string value.
2669
- */
2669
+ */
2670
2670
  async validateAndCleanDisplayName(displayName, name, value) {
2671
2671
  if (this.config.options?.allowInvalidCharacters) {
2672
2672
  return value;
2673
2673
  }
2674
2674
  else {
2675
- const validPattern = new RegExp(/^[\p{L}\p{N}][\p{L}\p{N} ']*[\p{L}\p{N}]$/u);
2675
+ const validPattern = /^[\p{L}\p{N}][\p{L}\p{N} ']*[\p{L}\p{N}]$/u;
2676
2676
  const invalidCharsPattern = /[^\p{L}\p{N} ']/gu;
2677
2677
  const invalidStartEndPattern = /^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu;
2678
2678
  if (typeof value === 'string' && !validPattern.test(value)) {
2679
- await this.warnLog(`WARNING: The accessory '${displayName}' has an invalid '${name}' characteristic ('${value}').`
2680
- + ' Please use only alphanumeric, space, and apostrophe characters. Ensure it starts and ends with an alphabetic or numeric character,'
2681
- + ' and avoid emojis. This may prevent the accessory from being added in the Home App or cause unresponsiveness.');
2679
+ await this.warnLog(`WARNING: The accessory '${displayName}' has an invalid '${name}' characteristic ('${value}'). Please use only alphanumeric, space, and apostrophe characters. Ensure it starts and ends with an alphabetic or numeric character, and avoid emojis. This may prevent the accessory from being added in the Home App or cause unresponsiveness.`);
2682
2680
  // Remove invalid characters
2683
2681
  if (invalidCharsPattern.test(value)) {
2684
2682
  const before = value;
2685
- await this.warnLog(`Removing invalid characters from '${name}' characteristic, if you feel this is incorrect,`
2686
- + ' please enable \'allowInvalidCharacter\' in the config to allow all characters');
2683
+ await this.warnLog(`Removing invalid characters from '${name}' characteristic, if you feel this is incorrect, please enable \'allowInvalidCharacter\' in the config to allow all characters`);
2687
2684
  value = value.replace(invalidCharsPattern, '');
2688
2685
  await this.warnLog(`${name} Before: '${before}' After: '${value}'`);
2689
2686
  }
2690
2687
  // Ensure it starts and ends with an alphanumeric character
2691
2688
  if (invalidStartEndPattern.test(value)) {
2692
2689
  const before = value;
2693
- await this.warnLog(`Removing invalid starting or ending characters from '${name}' characteristic, if you feel this is incorrect,`
2694
- + ' please enable \'allowInvalidCharacter\' in the config to allow all characters');
2690
+ await this.warnLog(`Removing invalid starting or ending characters from '${name}' characteristic, if you feel this is incorrect, please enable \'allowInvalidCharacter\' in the config to allow all characters`);
2695
2691
  value = value.replace(invalidStartEndPattern, '');
2696
2692
  await this.warnLog(`${name} Before: '${before}' After: '${value}'`);
2697
2693
  }