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