@switchbot/homebridge-switchbot 1.8.3-beta.0 → 1.9.0

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 (105) hide show
  1. package/.eslintrc +1 -1
  2. package/.vscode/settings.json +1 -1
  3. package/CHANGELOG.md +8 -0
  4. package/config.schema.json +9 -0
  5. package/dist/devices/bots.d.ts +37 -34
  6. package/dist/devices/bots.d.ts.map +1 -1
  7. package/dist/devices/bots.js +196 -243
  8. package/dist/devices/bots.js.map +1 -1
  9. package/dist/devices/colorbulb.d.ts +50 -50
  10. package/dist/devices/colorbulb.d.ts.map +1 -1
  11. package/dist/devices/colorbulb.js +131 -145
  12. package/dist/devices/colorbulb.js.map +1 -1
  13. package/dist/devices/contact.d.ts +29 -27
  14. package/dist/devices/contact.d.ts.map +1 -1
  15. package/dist/devices/contact.js +115 -138
  16. package/dist/devices/contact.js.map +1 -1
  17. package/dist/devices/curtains.d.ts +31 -29
  18. package/dist/devices/curtains.d.ts.map +1 -1
  19. package/dist/devices/curtains.js +176 -211
  20. package/dist/devices/curtains.js.map +1 -1
  21. package/dist/devices/humidifiers.d.ts +33 -33
  22. package/dist/devices/humidifiers.d.ts.map +1 -1
  23. package/dist/devices/humidifiers.js +189 -214
  24. package/dist/devices/humidifiers.js.map +1 -1
  25. package/dist/devices/meters.d.ts +31 -30
  26. package/dist/devices/meters.d.ts.map +1 -1
  27. package/dist/devices/meters.js +100 -124
  28. package/dist/devices/meters.js.map +1 -1
  29. package/dist/devices/motion.d.ts +26 -25
  30. package/dist/devices/motion.d.ts.map +1 -1
  31. package/dist/devices/motion.js +102 -120
  32. package/dist/devices/motion.js.map +1 -1
  33. package/dist/devices/plugs.d.ts +23 -23
  34. package/dist/devices/plugs.d.ts.map +1 -1
  35. package/dist/devices/plugs.js +63 -81
  36. package/dist/devices/plugs.js.map +1 -1
  37. package/dist/index.d.ts +2 -2
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +3 -22
  40. package/dist/index.js.map +1 -1
  41. package/dist/irdevices/airconditioners.d.ts +6 -6
  42. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  43. package/dist/irdevices/airconditioners.js +79 -105
  44. package/dist/irdevices/airconditioners.js.map +1 -1
  45. package/dist/irdevices/airpurifiers.d.ts +5 -5
  46. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  47. package/dist/irdevices/airpurifiers.js +42 -56
  48. package/dist/irdevices/airpurifiers.js.map +1 -1
  49. package/dist/irdevices/cameras.d.ts +5 -5
  50. package/dist/irdevices/cameras.d.ts.map +1 -1
  51. package/dist/irdevices/cameras.js +27 -31
  52. package/dist/irdevices/cameras.js.map +1 -1
  53. package/dist/irdevices/fans.d.ts +5 -5
  54. package/dist/irdevices/fans.d.ts.map +1 -1
  55. package/dist/irdevices/fans.js +38 -45
  56. package/dist/irdevices/fans.js.map +1 -1
  57. package/dist/irdevices/lights.d.ts +5 -5
  58. package/dist/irdevices/lights.d.ts.map +1 -1
  59. package/dist/irdevices/lights.js +33 -37
  60. package/dist/irdevices/lights.js.map +1 -1
  61. package/dist/irdevices/others.d.ts +5 -5
  62. package/dist/irdevices/others.d.ts.map +1 -1
  63. package/dist/irdevices/others.js +29 -34
  64. package/dist/irdevices/others.js.map +1 -1
  65. package/dist/irdevices/tvs.d.ts +5 -5
  66. package/dist/irdevices/tvs.d.ts.map +1 -1
  67. package/dist/irdevices/tvs.js +76 -91
  68. package/dist/irdevices/tvs.js.map +1 -1
  69. package/dist/irdevices/vacuumcleaners.d.ts +5 -5
  70. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  71. package/dist/irdevices/vacuumcleaners.js +27 -31
  72. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  73. package/dist/irdevices/waterheaters.d.ts +5 -5
  74. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  75. package/dist/irdevices/waterheaters.js +27 -31
  76. package/dist/irdevices/waterheaters.js.map +1 -1
  77. package/dist/platform.d.ts +12 -12
  78. package/dist/platform.d.ts.map +1 -1
  79. package/dist/platform.js +172 -241
  80. package/dist/platform.js.map +1 -1
  81. package/dist/settings.d.ts +2 -1
  82. package/dist/settings.d.ts.map +1 -1
  83. package/dist/settings.js +4 -4
  84. package/dist/settings.js.map +1 -1
  85. package/package.json +71 -72
  86. package/src/devices/bots.ts +455 -929
  87. package/src/devices/colorbulb.ts +246 -473
  88. package/src/devices/contact.ts +208 -381
  89. package/src/devices/curtains.ts +321 -613
  90. package/src/devices/humidifiers.ts +323 -594
  91. package/src/devices/meters.ts +186 -331
  92. package/src/devices/motion.ts +184 -327
  93. package/src/devices/plugs.ts +107 -175
  94. package/src/index.ts +5 -5
  95. package/src/irdevices/airconditioners.ts +149 -360
  96. package/src/irdevices/airpurifiers.ts +80 -178
  97. package/src/irdevices/cameras.ts +51 -109
  98. package/src/irdevices/fans.ts +77 -174
  99. package/src/irdevices/lights.ts +57 -110
  100. package/src/irdevices/others.ts +62 -137
  101. package/src/irdevices/tvs.ts +124 -249
  102. package/src/irdevices/vacuumcleaners.ts +52 -112
  103. package/src/irdevices/waterheaters.ts +53 -115
  104. package/src/platform.ts +357 -768
  105. package/src/settings.ts +24 -17
package/dist/platform.js CHANGED
@@ -1,47 +1,28 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
22
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
4
  };
24
5
  Object.defineProperty(exports, "__esModule", { value: true });
25
6
  exports.SwitchBotPlatform = void 0;
26
- const axios_1 = __importDefault(require("axios"));
27
7
  const bots_1 = require("./devices/bots");
28
- const colorbulb_1 = require("./devices/colorbulb");
8
+ const plugs_1 = require("./devices/plugs");
9
+ const meters_1 = require("./devices/meters");
10
+ const motion_1 = require("./devices/motion");
29
11
  const contact_1 = require("./devices/contact");
30
12
  const curtains_1 = require("./devices/curtains");
13
+ const colorbulb_1 = require("./devices/colorbulb");
31
14
  const humidifiers_1 = require("./devices/humidifiers");
32
- const meters_1 = require("./devices/meters");
33
- const motion_1 = require("./devices/motion");
34
- const plugs_1 = require("./devices/plugs");
35
- const airconditioners_1 = require("./irdevices/airconditioners");
36
- const airpurifiers_1 = require("./irdevices/airpurifiers");
37
- const cameras_1 = require("./irdevices/cameras");
15
+ const tvs_1 = require("./irdevices/tvs");
38
16
  const fans_1 = require("./irdevices/fans");
39
17
  const lights_1 = require("./irdevices/lights");
40
18
  const others_1 = require("./irdevices/others");
41
- const tvs_1 = require("./irdevices/tvs");
42
- const vacuumcleaners_1 = require("./irdevices/vacuumcleaners");
19
+ const cameras_1 = require("./irdevices/cameras");
20
+ const airpurifiers_1 = require("./irdevices/airpurifiers");
43
21
  const waterheaters_1 = require("./irdevices/waterheaters");
44
- const settings = __importStar(require("./settings"));
22
+ const vacuumcleaners_1 = require("./irdevices/vacuumcleaners");
23
+ const airconditioners_1 = require("./irdevices/airconditioners");
24
+ const axios_1 = __importDefault(require("axios"));
25
+ const settings_1 = require("./settings");
45
26
  /**
46
27
  * HomebridgePlatform
47
28
  * This class is the main constructor for your plugin, this is where you should
@@ -57,28 +38,28 @@ class SwitchBotPlatform {
57
38
  // this is used to track restored cached accessories
58
39
  this.accessories = [];
59
40
  this.axios = axios_1.default.create({
60
- responseType: "json",
41
+ responseType: 'json',
61
42
  });
62
- this.version = require("../package.json").version; // eslint-disable-line @typescript-eslint/no-var-requires
43
+ this.version = require('../package.json').version; // eslint-disable-line @typescript-eslint/no-var-requires
63
44
  this.logs();
64
- this.debugLog("Finished initializing platform:", this.config.name);
45
+ this.debugLog('Finished initializing platform:', this.config.name);
65
46
  // only load if configured
66
47
  if (!this.config) {
67
48
  return;
68
49
  }
69
50
  // HOOBS notice
70
- if (__dirname.includes("hoobs")) {
71
- this.log.warn("This plugin has not been tested under HOOBS, it is highly recommended that " +
72
- "you switch to Homebridge: https://git.io/Jtxb0");
51
+ if (__dirname.includes('hoobs')) {
52
+ this.log.warn('This plugin has not been tested under HOOBS, it is highly recommended that ' +
53
+ 'you switch to Homebridge: https://git.io/Jtxb0');
73
54
  }
74
55
  // verify the config
75
56
  try {
76
57
  this.verifyConfig();
77
- this.debugLog("Config OK");
58
+ this.debugLog('Config OK');
78
59
  }
79
60
  catch (e) {
80
61
  this.errorLog(JSON.stringify(e.message));
81
- if (this.platformLogging === "debugMode") {
62
+ if (this.platformLogging === 'debugMode') {
82
63
  this.errorLog(JSON.stringify(e));
83
64
  }
84
65
  return;
@@ -86,47 +67,44 @@ class SwitchBotPlatform {
86
67
  // setup axios interceptor to add headers / api key to each request
87
68
  this.axios.interceptors.request.use((request) => {
88
69
  request.headers.Authorization = this.config.credentials?.openToken;
89
- request.headers["Content-Type"] = "application/json; charset=utf8";
70
+ request.headers['Content-Type'] = 'application/json; charset=utf8';
90
71
  return request;
91
72
  });
92
73
  // When this event is fired it means Homebridge has restored all cached accessories from disk.
93
74
  // Dynamic Platform plugins should only register new accessories after this event was fired,
94
75
  // in order to ensure they weren't added to homebridge already. This event can also be used
95
76
  // to start discovery of new accessories.
96
- this.api.on("didFinishLaunching", async () => {
97
- this.debugLog("Executed didFinishLaunching callback");
77
+ this.api.on('didFinishLaunching', async () => {
78
+ this.debugLog('Executed didFinishLaunching callback');
98
79
  // run the method to discover / register your devices as accessories
99
80
  try {
100
81
  this.discoverDevices();
101
82
  }
102
83
  catch (e) {
103
- this.errorLog("Failed to Discover Devices.", JSON.stringify(e.message));
104
- if (this.platformLogging === "debugMode") {
84
+ this.errorLog('Failed to Discover Devices.', JSON.stringify(e.message));
85
+ if (this.platformLogging === 'debugMode') {
105
86
  this.errorLog(JSON.stringify(e));
106
87
  }
107
88
  }
108
89
  });
109
90
  }
110
91
  logs() {
111
- this.debugMode =
112
- process.argv.includes("-D") || process.argv.includes("--debug");
113
- if (this.config.options?.logging === "debug" ||
114
- this.config.options?.logging === "standard" ||
115
- this.config.options?.logging === "none") {
92
+ this.debugMode = process.argv.includes('-D') || process.argv.includes('--debug');
93
+ if (this.config.options?.logging === 'debug' || this.config.options?.logging === 'standard' || this.config.options?.logging === 'none') {
116
94
  this.platformLogging = this.config.options.logging;
117
- if (this.platformLogging.includes("debug")) {
95
+ if (this.platformLogging.includes('debug')) {
118
96
  this.log.warn(`Using Config Logging: ${this.platformLogging}`);
119
97
  }
120
98
  }
121
99
  else if (this.debugMode) {
122
- this.platformLogging = "debugMode";
123
- if (this.platformLogging?.includes("debug")) {
100
+ this.platformLogging = 'debugMode';
101
+ if (this.platformLogging?.includes('debug')) {
124
102
  this.log.warn(`Using ${this.platformLogging} Logging`);
125
103
  }
126
104
  }
127
105
  else {
128
- this.platformLogging = "standard";
129
- if (this.platformLogging?.includes("debug")) {
106
+ this.platformLogging = 'standard';
107
+ if (this.platformLogging?.includes('debug')) {
130
108
  this.log.warn(`Using ${this.platformLogging} Logging`);
131
109
  }
132
110
  }
@@ -147,13 +125,13 @@ class SwitchBotPlatform {
147
125
  this.config.options = this.config.options || {};
148
126
  const platformConfig = {};
149
127
  if (this.config.options.logging) {
150
- platformConfig["logging"] = this.config.options.logging;
128
+ platformConfig['logging'] = this.config.options.logging;
151
129
  }
152
130
  if (this.config.options.logging) {
153
- platformConfig["refreshRate"] = this.config.options.refreshRate;
131
+ platformConfig['refreshRate'] = this.config.options.refreshRate;
154
132
  }
155
133
  if (this.config.options.logging) {
156
- platformConfig["pushRate"] = this.config.options.pushRate;
134
+ platformConfig['pushRate'] = this.config.options.pushRate;
157
135
  }
158
136
  if (Object.entries(platformConfig).length !== 0) {
159
137
  this.warnLog(`Platform Config: ${JSON.stringify(platformConfig)}`);
@@ -164,10 +142,10 @@ class SwitchBotPlatform {
164
142
  for (const deviceConfig of this.config.options.devices) {
165
143
  if (!deviceConfig.hide_device) {
166
144
  if (!deviceConfig.deviceId) {
167
- throw new Error("The devices config section is missing the *Device ID* in the config, Check Your Conifg.");
145
+ throw new Error('The devices config section is missing the *Device ID* in the config, Check Your Conifg.');
168
146
  }
169
147
  if (!deviceConfig.configDeviceType && deviceConfig.ble) {
170
- throw new Error("The devices config section is missing the *Device Type* in the config, Check Your Conifg.");
148
+ throw new Error('The devices config section is missing the *Device Type* in the config, Check Your Conifg.');
171
149
  }
172
150
  }
173
151
  }
@@ -177,51 +155,51 @@ class SwitchBotPlatform {
177
155
  for (const irDeviceConfig of this.config.options.irdevices) {
178
156
  if (!irDeviceConfig.hide_device) {
179
157
  if (!irDeviceConfig.deviceId) {
180
- this.errorLog("The devices config section is missing the *Device ID* in the config, Check Your Conifg.");
158
+ this.errorLog('The devices config section is missing the *Device ID* in the config, Check Your Conifg.');
181
159
  }
182
160
  if (!irDeviceConfig.deviceId && !irDeviceConfig.configRemoteType) {
183
- this.errorLog("The devices config section is missing the *Device Type* in the config, Check Your Conifg.");
161
+ this.errorLog('The devices config section is missing the *Device Type* in the config, Check Your Conifg.');
184
162
  }
185
163
  }
186
164
  }
187
165
  }
188
166
  }
189
167
  if (this.config.options.refreshRate < 30) {
190
- throw new Error("Refresh Rate must be above 30 (30 seconds).");
168
+ throw new Error('Refresh Rate must be above 30 (30 seconds).');
191
169
  }
192
170
  if (!this.config.options.refreshRate) {
193
171
  // default 120 seconds (2 minutes)
194
172
  this.config.options.refreshRate = 120;
195
- if (this.platformLogging?.includes("debug")) {
196
- this.debugLog("Using Default Refresh Rate (2 minutes).");
173
+ if (this.platformLogging?.includes('debug')) {
174
+ this.debugLog('Using Default Refresh Rate (2 minutes).');
197
175
  }
198
176
  if (!this.config.options.pushRate) {
199
177
  // default 100 milliseconds
200
178
  this.config.options.pushRate = 0.1;
201
- if (this.platformLogging?.includes("debug")) {
202
- this.warnLog("Using Default Push Rate.");
179
+ if (this.platformLogging?.includes('debug')) {
180
+ this.warnLog('Using Default Push Rate.');
203
181
  }
204
182
  }
205
183
  if (!this.config.credentials) {
206
- if (this.platformLogging?.includes("debug")) {
207
- this.debugLog("Missing Credentials");
184
+ if (this.platformLogging?.includes('debug')) {
185
+ this.debugLog('Missing Credentials');
208
186
  }
209
187
  }
210
188
  if (!this.config.credentials?.openToken) {
211
- if (this.platformLogging?.includes("debug")) {
212
- this.errorLog("Missing openToken");
213
- this.warnLog("Cloud Enabled SwitchBot Devices & IR Devices will not work");
189
+ if (this.platformLogging?.includes('debug')) {
190
+ this.errorLog('Missing openToken');
191
+ this.warnLog('Cloud Enabled SwitchBot Devices & IR Devices will not work');
214
192
  }
215
193
  }
216
194
  }
217
195
  }
218
196
  /**
219
- * this method discovers devices
220
- */
197
+ * this method discovers devices
198
+ */
221
199
  async discoverDevices() {
222
200
  try {
223
201
  if (this.config.credentials?.openToken) {
224
- const devicesAPI = (await this.axios.get(settings.DeviceURL)).data;
202
+ const devicesAPI = (await this.axios.get(settings_1.DeviceURL)).data;
225
203
  this.deviceListInfo(devicesAPI);
226
204
  this.debugLog(JSON.stringify(devicesAPI));
227
205
  // SwitchBot Devices
@@ -239,14 +217,11 @@ class SwitchBotPlatform {
239
217
  }
240
218
  }
241
219
  }
242
- else if (this.config.credentials?.openToken &&
243
- this.config.options.devices) {
220
+ else if (this.config.credentials?.openToken && this.config.options.devices) {
244
221
  this.debugLog(`SwitchBot Device Config Set: ${JSON.stringify(this.config.options?.devices)}`);
245
222
  const deviceConfigs = this.config.options?.devices;
246
223
  const mergeBydeviceId = (a1, a2) => a1.map((itm) => ({
247
- ...a2.find((item) => item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, "") ===
248
- itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, "") &&
249
- item),
224
+ ...a2.find((item) => (item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '')) && item),
250
225
  ...itm,
251
226
  }));
252
227
  const devices = mergeBydeviceId(deviceLists, deviceConfigs);
@@ -261,7 +236,7 @@ class SwitchBotPlatform {
261
236
  }
262
237
  }
263
238
  else {
264
- this.errorLog("Neither SwitchBot OpenToken or Device Config are not set.");
239
+ this.errorLog('Neither SwitchBot OpenToken or Device Config are not set.');
265
240
  }
266
241
  // IR Devices
267
242
  this.infoLog(`Total IR Devices Found: ${devicesAPI.body.infraredRemoteList.length}`);
@@ -279,9 +254,7 @@ class SwitchBotPlatform {
279
254
  this.debugLog(`IR Device Config Set: ${JSON.stringify(this.config.options?.irdevices)}`);
280
255
  const irDeviceConfig = this.config.options?.irdevices;
281
256
  const mergeIRBydeviceId = (a1, a2) => a1.map((itm) => ({
282
- ...a2.find((item) => item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, "") ===
283
- itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, "") &&
284
- item),
257
+ ...a2.find((item) => (item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '')) && item),
285
258
  ...itm,
286
259
  }));
287
260
  const devices = mergeIRBydeviceId(irDeviceLists, irDeviceConfig);
@@ -293,8 +266,7 @@ class SwitchBotPlatform {
293
266
  }
294
267
  }
295
268
  }
296
- else if (!this.config.credentials?.openToken &&
297
- this.config.options?.devices) {
269
+ else if (!this.config.credentials?.openToken && this.config.options?.devices) {
298
270
  this.debugLog(`SwitchBot Device Manual Config Set: ${JSON.stringify(this.config.options?.devices)}`);
299
271
  const deviceConfigs = this.config.options?.devices;
300
272
  const devices = deviceConfigs.map((v) => v);
@@ -307,7 +279,7 @@ class SwitchBotPlatform {
307
279
  }
308
280
  }
309
281
  else {
310
- this.errorLog("Neither SwitchBot OpenToken or Device Config are not set.");
282
+ this.errorLog('Neither SwitchBot OpenToken or Device Config are not set.');
311
283
  }
312
284
  }
313
285
  catch (e) {
@@ -315,167 +287,167 @@ class SwitchBotPlatform {
315
287
  }
316
288
  }
317
289
  deviceError(e) {
318
- if (e.message.includes("400")) {
319
- this.errorLog("Failed to Discover Devices: Bad Request");
320
- this.debugLog("The client has issued an invalid request. This is commonly used to specify validation errors in a request payload.");
290
+ if (e.message.includes('400')) {
291
+ this.errorLog('Failed to Discover Devices: Bad Request');
292
+ this.debugLog('The client has issued an invalid request. This is commonly used to specify validation errors in a request payload.');
321
293
  }
322
- else if (e.message.includes("401")) {
323
- this.errorLog("Failed to Discover Devices: Unauthorized Request");
324
- this.debugLog("Authorization for the API is required, but the request has not been authenticated.");
294
+ else if (e.message.includes('401')) {
295
+ this.errorLog('Failed to Discover Devices: Unauthorized Request');
296
+ this.debugLog('Authorization for the API is required, but the request has not been authenticated.');
325
297
  }
326
- else if (e.message.includes("403")) {
327
- this.errorLog("Failed to Discover Devices: Forbidden Request");
328
- this.debugLog("The request has been authenticated but does not have appropriate permissions, or a requested resource is not found.");
298
+ else if (e.message.includes('403')) {
299
+ this.errorLog('Failed to Discover Devices: Forbidden Request');
300
+ this.debugLog('The request has been authenticated but does not have appropriate permissions, or a requested resource is not found.');
329
301
  }
330
- else if (e.message.includes("404")) {
331
- this.errorLog("Failed to Discover Devices: Requst Not Found");
332
- this.debugLog("Specifies the requested path does not exist.");
302
+ else if (e.message.includes('404')) {
303
+ this.errorLog('Failed to Discover Devices: Requst Not Found');
304
+ this.debugLog('Specifies the requested path does not exist.');
333
305
  }
334
- else if (e.message.includes("406")) {
335
- this.errorLog("Failed to Discover Devices: Request Not Acceptable");
336
- this.debugLog("The client has requested a MIME type via the Accept header for a value not supported by the server.");
306
+ else if (e.message.includes('406')) {
307
+ this.errorLog('Failed to Discover Devices: Request Not Acceptable');
308
+ this.debugLog('The client has requested a MIME type via the Accept header for a value not supported by the server.');
337
309
  }
338
- else if (e.message.includes("415")) {
339
- this.errorLog("Failed to Discover Devices: Unsupported Requst Header");
340
- this.debugLog("The client has defined a contentType header that is not supported by the server.");
310
+ else if (e.message.includes('415')) {
311
+ this.errorLog('Failed to Discover Devices: Unsupported Requst Header');
312
+ this.debugLog('The client has defined a contentType header that is not supported by the server.');
341
313
  }
342
- else if (e.message.includes("422")) {
343
- this.errorLog("Failed to Discover Devices: Unprocessable Entity");
344
- this.debugLog("The client has made a valid request, but the server cannot process it." +
345
- " This is often used for APIs for which certain limits have been exceeded.");
314
+ else if (e.message.includes('422')) {
315
+ this.errorLog('Failed to Discover Devices: Unprocessable Entity');
316
+ this.debugLog('The client has made a valid request, but the server cannot process it.'
317
+ + ' This is often used for APIs for which certain limits have been exceeded.');
346
318
  }
347
- else if (e.message.includes("429")) {
348
- this.errorLog("Failed to Discover Devices: Too Many Requests");
349
- this.debugLog("The client has exceeded the number of requests allowed for a given time window.");
319
+ else if (e.message.includes('429')) {
320
+ this.errorLog('Failed to Discover Devices: Too Many Requests');
321
+ this.debugLog('The client has exceeded the number of requests allowed for a given time window.');
350
322
  }
351
- else if (e.message.includes("500")) {
352
- this.errorLog("Failed to Discover Devices: Internal Server Error");
353
- this.debugLog("An unexpected error on the SmartThings servers has occurred. These errors should be rare.");
323
+ else if (e.message.includes('500')) {
324
+ this.errorLog('Failed to Discover Devices: Internal Server Error');
325
+ this.debugLog('An unexpected error on the SmartThings servers has occurred. These errors should be rare.');
354
326
  }
355
327
  else {
356
- this.errorLog("Failed to Discover Devices");
328
+ this.errorLog('Failed to Discover Devices');
357
329
  }
358
- if (this.platformLogging === "debug") {
330
+ if (this.platformLogging === 'debug') {
359
331
  this.errorLog(`Failed to Discover Devices, Error Message: ${JSON.stringify(e.message)}`);
360
332
  }
361
- if (this.platformLogging === "debugMode") {
333
+ if (this.platformLogging === 'debugMode') {
362
334
  this.errorLog(`Failed to Discover Devices, Error: ${JSON.stringify(e)}`);
363
335
  }
364
336
  }
365
337
  createDevice(device) {
366
338
  switch (device.deviceType) {
367
- case "Humidifier":
339
+ case 'Humidifier':
368
340
  this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
369
341
  this.createHumidifier(device);
370
342
  break;
371
- case "Hub Mini":
343
+ case 'Hub Mini':
372
344
  this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
373
345
  break;
374
- case "Hub Plus":
346
+ case 'Hub Plus':
375
347
  this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
376
348
  break;
377
- case "Bot":
349
+ case 'Bot':
378
350
  this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
379
351
  this.createBot(device);
380
352
  break;
381
- case "Meter":
353
+ case 'Meter':
382
354
  this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
383
355
  this.createMeter(device);
384
356
  break;
385
- case "Motion Sensor":
357
+ case 'Motion Sensor':
386
358
  this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
387
359
  this.createMotion(device);
388
360
  break;
389
- case "Contact Sensor":
361
+ case 'Contact Sensor':
390
362
  this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
391
363
  this.createContact(device);
392
364
  break;
393
- case "Curtain":
365
+ case 'Curtain':
394
366
  this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
395
367
  this.createCurtain(device);
396
368
  break;
397
- case "Plug":
369
+ case 'Plug':
398
370
  this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
399
371
  this.createPlug(device);
400
372
  break;
401
- case "Color Bulb":
373
+ case 'Color Bulb':
402
374
  this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
403
375
  this.createColorBulb(device);
404
376
  break;
405
- case "Indoor Cam":
377
+ case 'Indoor Cam':
406
378
  this.deviceInfo(device);
407
379
  this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
408
380
  this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.deviceType}, is currently not supported.`);
409
381
  break;
410
- case "Remote":
382
+ case 'Remote':
411
383
  this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId} is Not Supported.`);
412
384
  break;
413
385
  default:
414
386
  this.deviceInfo(device);
415
387
  this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.deviceType}, is currently not supported.`);
416
- this.warnLog("Submit Feature Requests Here: https://git.io/JL14Z");
388
+ this.warnLog('Submit Feature Requests Here: https://git.io/JL14Z');
417
389
  }
418
390
  }
419
391
  createIRDevice(device) {
420
392
  switch (device.remoteType) {
421
- case "TV":
422
- case "DIY TV":
423
- case "Projector":
424
- case "DIY Projector":
425
- case "Set Top Box":
426
- case "DIY Set Top Box":
427
- case "IPTV":
428
- case "DIY IPTV":
429
- case "DVD":
430
- case "DIY DVD":
431
- case "Speaker":
432
- case "DIY Speaker":
393
+ case 'TV':
394
+ case 'DIY TV':
395
+ case 'Projector':
396
+ case 'DIY Projector':
397
+ case 'Set Top Box':
398
+ case 'DIY Set Top Box':
399
+ case 'IPTV':
400
+ case 'DIY IPTV':
401
+ case 'DVD':
402
+ case 'DIY DVD':
403
+ case 'Speaker':
404
+ case 'DIY Speaker':
433
405
  this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
434
406
  this.createTV(device);
435
407
  break;
436
- case "Fan":
437
- case "DIY Fan":
408
+ case 'Fan':
409
+ case 'DIY Fan':
438
410
  this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
439
411
  this.createFan(device);
440
412
  break;
441
- case "Air Conditioner":
442
- case "DIY Air Conditioner":
413
+ case 'Air Conditioner':
414
+ case 'DIY Air Conditioner':
443
415
  this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
444
416
  this.createAirConditioner(device);
445
417
  break;
446
- case "Light":
447
- case "DIY Light":
418
+ case 'Light':
419
+ case 'DIY Light':
448
420
  this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
449
421
  this.createLight(device);
450
422
  break;
451
- case "Air Purifier":
452
- case "DIY Air Purifier":
423
+ case 'Air Purifier':
424
+ case 'DIY Air Purifier':
453
425
  this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
454
426
  this.createAirPurifier(device);
455
427
  break;
456
- case "Water Heater":
457
- case "DIY Water Heater":
428
+ case 'Water Heater':
429
+ case 'DIY Water Heater':
458
430
  this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
459
431
  this.createWaterHeater(device);
460
432
  break;
461
- case "Vacuum Cleaner":
462
- case "DIY Vacuum Cleaner":
433
+ case 'Vacuum Cleaner':
434
+ case 'DIY Vacuum Cleaner':
463
435
  this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
464
436
  this.createVacuumCleaner(device);
465
437
  break;
466
- case "Camera":
467
- case "DIY Camera":
438
+ case 'Camera':
439
+ case 'DIY Camera':
468
440
  this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
469
441
  this.createCamera(device);
470
442
  break;
471
- case "Others":
443
+ case 'Others':
472
444
  this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
473
445
  this.createOthers(device);
474
446
  break;
475
447
  default:
476
448
  this.deviceInfo(device);
477
449
  this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.remoteType}, is currently not supported.`);
478
- this.warnLog("Submit Feature Requests Here: https://git.io/JL14Z");
450
+ this.warnLog('Submit Feature Requests Here: https://git.io/JL14Z');
479
451
  }
480
452
  }
481
453
  registerDevice(device) {
@@ -483,17 +455,11 @@ class SwitchBotPlatform {
483
455
  this.registeringDevice = true;
484
456
  this.debugLog(`Device: ${device.deviceName} Both OpenAPI and BLE Connections Enabled`);
485
457
  }
486
- else if (!device.hide_device &&
487
- device.deviceId &&
488
- device.configDeviceType &&
489
- device.configDeviceName &&
490
- !device.enableCloudService) {
458
+ else if (!device.hide_device && device.deviceId && device.configDeviceType && device.configDeviceName && !device.enableCloudService) {
491
459
  this.registeringDevice = true;
492
460
  this.debugLog(`Device: ${device.deviceName} BLE Connection Enabled`);
493
461
  }
494
- else if (!device.hide_device &&
495
- device.enableCloudService &&
496
- !device.ble) {
462
+ else if (!device.hide_device && device.enableCloudService && !device.ble) {
497
463
  this.registeringDevice = true;
498
464
  this.debugLog(`Device: ${device.deviceName} OpenAPI Connection Enabled`);
499
465
  }
@@ -548,9 +514,7 @@ class SwitchBotPlatform {
548
514
  new humidifiers_1.Humidifier(this, accessory, device);
549
515
  this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
550
516
  // link the accessory to your platform
551
- this.api.registerPlatformAccessories(settings.PLUGIN_NAME, settings.PLATFORM_NAME, [
552
- accessory,
553
- ]);
517
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
554
518
  this.accessories.push(accessory);
555
519
  }
556
520
  else {
@@ -604,9 +568,7 @@ class SwitchBotPlatform {
604
568
  new bots_1.Bot(this, accessory, device);
605
569
  this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
606
570
  // link the accessory to your platform
607
- this.api.registerPlatformAccessories(settings.PLUGIN_NAME, settings.PLATFORM_NAME, [
608
- accessory,
609
- ]);
571
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
610
572
  this.accessories.push(accessory);
611
573
  }
612
574
  else {
@@ -657,9 +619,7 @@ class SwitchBotPlatform {
657
619
  new meters_1.Meter(this, accessory, device);
658
620
  this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
659
621
  // link the accessory to your platform
660
- this.api.registerPlatformAccessories(settings.PLUGIN_NAME, settings.PLATFORM_NAME, [
661
- accessory,
662
- ]);
622
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
663
623
  this.accessories.push(accessory);
664
624
  }
665
625
  else {
@@ -710,9 +670,7 @@ class SwitchBotPlatform {
710
670
  new motion_1.Motion(this, accessory, device);
711
671
  this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
712
672
  // link the accessory to your platform
713
- this.api.registerPlatformAccessories(settings.PLUGIN_NAME, settings.PLATFORM_NAME, [
714
- accessory,
715
- ]);
673
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
716
674
  this.accessories.push(accessory);
717
675
  }
718
676
  else {
@@ -763,9 +721,7 @@ class SwitchBotPlatform {
763
721
  new contact_1.Contact(this, accessory, device);
764
722
  this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
765
723
  // link the accessory to your platform
766
- this.api.registerPlatformAccessories(settings.PLUGIN_NAME, settings.PLATFORM_NAME, [
767
- accessory,
768
- ]);
724
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
769
725
  this.accessories.push(accessory);
770
726
  }
771
727
  else {
@@ -828,9 +784,7 @@ class SwitchBotPlatform {
828
784
  new curtains_1.Curtain(this, accessory, device);
829
785
  this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
830
786
  // link the accessory to your platform
831
- this.api.registerPlatformAccessories(settings.PLUGIN_NAME, settings.PLATFORM_NAME, [
832
- accessory,
833
- ]);
787
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
834
788
  this.accessories.push(accessory);
835
789
  }
836
790
  else {
@@ -838,8 +792,8 @@ class SwitchBotPlatform {
838
792
  }
839
793
  }
840
794
  isCurtainGrouped(device) {
841
- this.debugLog(`deviceId: ${device.deviceId}, curtainDevicesIds: ${device.curtainDevicesIds},` +
842
- ` master: ${device.master}, group: ${device.group}, disable_group: ${device.curtain?.disable_group}`);
795
+ this.debugLog(`deviceId: ${device.deviceId}, curtainDevicesIds: ${device.curtainDevicesIds},`
796
+ + ` master: ${device.master}, group: ${device.group}, disable_group: ${device.curtain?.disable_group}`);
843
797
  if (device.group && !device.curtain?.disable_group) {
844
798
  this.debugLog(`[Curtain Config] disable_group: ${device.curtain?.disable_group}`);
845
799
  return device.master && this.registerDevice(device);
@@ -893,9 +847,7 @@ class SwitchBotPlatform {
893
847
  new plugs_1.Plug(this, accessory, device);
894
848
  this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
895
849
  // link the accessory to your platform
896
- this.api.registerPlatformAccessories(settings.PLUGIN_NAME, settings.PLATFORM_NAME, [
897
- accessory,
898
- ]);
850
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
899
851
  this.accessories.push(accessory);
900
852
  }
901
853
  else {
@@ -946,9 +898,7 @@ class SwitchBotPlatform {
946
898
  new colorbulb_1.ColorBulb(this, accessory, device);
947
899
  this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
948
900
  // link the accessory to your platform
949
- this.api.registerPlatformAccessories(settings.PLUGIN_NAME, settings.PLATFORM_NAME, [
950
- accessory,
951
- ]);
901
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
952
902
  this.accessories.push(accessory);
953
903
  }
954
904
  else {
@@ -993,11 +943,11 @@ class SwitchBotPlatform {
993
943
  new tvs_1.TV(this, accessory, device);
994
944
  this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
995
945
  /**
996
- * Publish as external accessory
997
- * Only one TV can exist per bridge, to bypass this limitation, you should
998
- * publish your TV as an external accessory.
999
- */
1000
- this.api.publishExternalAccessories(settings.PLUGIN_NAME, [accessory]);
946
+ * Publish as external accessory
947
+ * Only one TV can exist per bridge, to bypass this limitation, you should
948
+ * publish your TV as an external accessory.
949
+ */
950
+ this.api.publishExternalAccessories(settings_1.PLUGIN_NAME, [accessory]);
1001
951
  this.accessories.push(accessory);
1002
952
  }
1003
953
  else {
@@ -1048,9 +998,7 @@ class SwitchBotPlatform {
1048
998
  new fans_1.Fan(this, accessory, device);
1049
999
  this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1050
1000
  // link the accessory to your platform
1051
- this.api.registerPlatformAccessories(settings.PLUGIN_NAME, settings.PLATFORM_NAME, [
1052
- accessory,
1053
- ]);
1001
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
1054
1002
  this.accessories.push(accessory);
1055
1003
  }
1056
1004
  else {
@@ -1101,9 +1049,7 @@ class SwitchBotPlatform {
1101
1049
  new lights_1.Light(this, accessory, device);
1102
1050
  this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1103
1051
  // link the accessory to your platform
1104
- this.api.registerPlatformAccessories(settings.PLUGIN_NAME, settings.PLATFORM_NAME, [
1105
- accessory,
1106
- ]);
1052
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
1107
1053
  this.accessories.push(accessory);
1108
1054
  }
1109
1055
  else {
@@ -1154,9 +1100,7 @@ class SwitchBotPlatform {
1154
1100
  new airconditioners_1.AirConditioner(this, accessory, device);
1155
1101
  this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1156
1102
  // link the accessory to your platform
1157
- this.api.registerPlatformAccessories(settings.PLUGIN_NAME, settings.PLATFORM_NAME, [
1158
- accessory,
1159
- ]);
1103
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
1160
1104
  this.accessories.push(accessory);
1161
1105
  }
1162
1106
  else {
@@ -1207,9 +1151,7 @@ class SwitchBotPlatform {
1207
1151
  new airpurifiers_1.AirPurifier(this, accessory, device);
1208
1152
  this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1209
1153
  // link the accessory to your platform
1210
- this.api.registerPlatformAccessories(settings.PLUGIN_NAME, settings.PLATFORM_NAME, [
1211
- accessory,
1212
- ]);
1154
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
1213
1155
  this.accessories.push(accessory);
1214
1156
  }
1215
1157
  else {
@@ -1260,9 +1202,7 @@ class SwitchBotPlatform {
1260
1202
  new waterheaters_1.WaterHeater(this, accessory, device);
1261
1203
  this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1262
1204
  // link the accessory to your platform
1263
- this.api.registerPlatformAccessories(settings.PLUGIN_NAME, settings.PLATFORM_NAME, [
1264
- accessory,
1265
- ]);
1205
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
1266
1206
  this.accessories.push(accessory);
1267
1207
  }
1268
1208
  else {
@@ -1313,9 +1253,7 @@ class SwitchBotPlatform {
1313
1253
  new vacuumcleaners_1.VacuumCleaner(this, accessory, device);
1314
1254
  this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1315
1255
  // link the accessory to your platform
1316
- this.api.registerPlatformAccessories(settings.PLUGIN_NAME, settings.PLATFORM_NAME, [
1317
- accessory,
1318
- ]);
1256
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
1319
1257
  this.accessories.push(accessory);
1320
1258
  }
1321
1259
  else {
@@ -1366,9 +1304,7 @@ class SwitchBotPlatform {
1366
1304
  new cameras_1.Camera(this, accessory, device);
1367
1305
  this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1368
1306
  // link the accessory to your platform
1369
- this.api.registerPlatformAccessories(settings.PLUGIN_NAME, settings.PLATFORM_NAME, [
1370
- accessory,
1371
- ]);
1307
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
1372
1308
  this.accessories.push(accessory);
1373
1309
  }
1374
1310
  else {
@@ -1419,9 +1355,7 @@ class SwitchBotPlatform {
1419
1355
  new others_1.Others(this, accessory, device);
1420
1356
  this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
1421
1357
  // link the accessory to your platform
1422
- this.api.registerPlatformAccessories(settings.PLUGIN_NAME, settings.PLATFORM_NAME, [
1423
- accessory,
1424
- ]);
1358
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
1425
1359
  this.accessories.push(accessory);
1426
1360
  }
1427
1361
  else {
@@ -1430,48 +1364,46 @@ class SwitchBotPlatform {
1430
1364
  }
1431
1365
  async connectionTypeNewAccessory(device, accessory) {
1432
1366
  if (device.ble) {
1433
- accessory.context.connectionType = "BLE";
1367
+ accessory.context.connectionType = 'BLE';
1434
1368
  }
1435
1369
  else {
1436
- accessory.context.connectionType = "OpenAPI";
1370
+ accessory.context.connectionType = 'OpenAPI';
1437
1371
  }
1438
1372
  }
1439
1373
  async connectionTypeExistingAccessory(device, existingAccessory) {
1440
1374
  if (device.ble) {
1441
- existingAccessory.context.connectionType = "BLE";
1375
+ existingAccessory.context.connectionType = 'BLE';
1442
1376
  }
1443
1377
  else {
1444
- existingAccessory.context.connectionType = "OpenAPI";
1378
+ existingAccessory.context.connectionType = 'OpenAPI';
1445
1379
  }
1446
1380
  }
1447
1381
  async connectionTypeNewIRAccessory(accessory) {
1448
- accessory.context.connectionType = "IR wirth OpenAPI";
1382
+ accessory.context.connectionType = 'IR wirth OpenAPI';
1449
1383
  }
1450
1384
  async connectionTypeExistingIRAccessory(existingAccessory) {
1451
- existingAccessory.context.connectionType = "IR with OpenAPI";
1385
+ existingAccessory.context.connectionType = 'IR with OpenAPI';
1452
1386
  }
1453
1387
  unregisterPlatformAccessories(existingAccessory) {
1454
1388
  // remove platform accessories when no longer present
1455
- this.api.unregisterPlatformAccessories(settings.PLUGIN_NAME, settings.PLATFORM_NAME, [
1456
- existingAccessory,
1457
- ]);
1458
- this.infoLog("Removing existing accessory from cache:", existingAccessory.displayName);
1389
+ this.api.unregisterPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [existingAccessory]);
1390
+ this.infoLog('Removing existing accessory from cache:', existingAccessory.displayName);
1459
1391
  }
1460
1392
  deviceListInfo(devices) {
1461
- if (this.platformLogging === "debug") {
1393
+ if (this.platformLogging === 'debug') {
1462
1394
  this.warnLog(`deviceListInfoStatus: ${JSON.stringify(devices)}`);
1463
1395
  }
1464
1396
  }
1465
1397
  async deviceInfo(device) {
1466
- if (this.platformLogging === "debug") {
1398
+ if (this.platformLogging === 'debug') {
1467
1399
  this.warnLog(JSON.stringify(device));
1468
- this.deviceStatus = (await this.axios.get(`${settings.DeviceURL}/${device.deviceId}/status`)).data;
1469
- if (this.deviceStatus.message === "success") {
1400
+ this.deviceStatus = (await this.axios.get(`${settings_1.DeviceURL}/${device.deviceId}/status`)).data;
1401
+ if (this.deviceStatus.message === 'success') {
1470
1402
  this.warnLog(`${device.deviceName} deviceInfoStatus: ${JSON.stringify(this.deviceStatus)}`);
1471
1403
  }
1472
1404
  else {
1473
1405
  this.warnLog(`${device.deviceName} deviceInfoStatus: ${JSON.stringify(this.deviceStatus.message)}`);
1474
- this.warnLog("Unable to retreive deviceInfoStatus.");
1406
+ this.warnLog('Unable to retreive deviceInfoStatus.');
1475
1407
  }
1476
1408
  }
1477
1409
  }
@@ -1480,7 +1412,7 @@ class SwitchBotPlatform {
1480
1412
  let Switchbot;
1481
1413
  let switchbot;
1482
1414
  try {
1483
- Switchbot = require("node-switchbot");
1415
+ Switchbot = require('node-switchbot');
1484
1416
  switchbot = new Switchbot();
1485
1417
  }
1486
1418
  catch (e) {
@@ -1510,17 +1442,16 @@ class SwitchBotPlatform {
1510
1442
  }
1511
1443
  debugLog(...log) {
1512
1444
  if (this.enablingPlatfromLogging()) {
1513
- if (this.platformLogging === "debugMode") {
1445
+ if (this.platformLogging === 'debugMode') {
1514
1446
  this.log.debug(String(...log));
1515
1447
  }
1516
- else if (this.platformLogging === "debug") {
1517
- this.log.info("[DEBUG]", String(...log));
1448
+ else if (this.platformLogging === 'debug') {
1449
+ this.log.info('[DEBUG]', String(...log));
1518
1450
  }
1519
1451
  }
1520
1452
  }
1521
1453
  enablingPlatfromLogging() {
1522
- return (this.platformLogging?.includes("debug") ||
1523
- this.platformLogging === "standard");
1454
+ return this.platformLogging?.includes('debug') || this.platformLogging === 'standard';
1524
1455
  }
1525
1456
  }
1526
1457
  exports.SwitchBotPlatform = SwitchBotPlatform;