@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
@@ -1,7 +1,7 @@
1
- import { AxiosResponse } from "axios";
2
- import { SwitchBotPlatform } from "../platform";
3
- import { irDevicesConfig, DeviceURL, irdevice, payload } from "../settings";
4
- import { CharacteristicValue, PlatformAccessory, Service } from "homebridge";
1
+ import { AxiosResponse } from 'axios';
2
+ import { SwitchBotPlatform } from '../platform';
3
+ import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
4
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
5
5
 
6
6
  /**
7
7
  * Platform Accessory
@@ -60,19 +60,15 @@ export class AirPurifier {
60
60
  // set accessory information
61
61
  accessory
62
62
  .getService(this.platform.Service.AccessoryInformation)!
63
- .setCharacteristic(this.platform.Characteristic.Manufacturer, "SwitchBot")
63
+ .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
64
64
  .setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
65
- .setCharacteristic(
66
- this.platform.Characteristic.SerialNumber,
67
- device.deviceId!,
68
- );
65
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
69
66
 
70
67
  // get the Television service if it exists, otherwise create a new Television service
71
68
  // you can create multiple services for each accessory
72
69
  (this.service =
73
70
  accessory.getService(this.platform.Service.AirPurifier) ||
74
- accessory.addService(this.platform.Service.AirPurifier)),
75
- `${accessory.displayName} Air Purifier`;
71
+ accessory.addService(this.platform.Service.AirPurifier)), `${accessory.displayName} Air Purifier`;
76
72
 
77
73
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
78
74
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -80,31 +76,20 @@ export class AirPurifier {
80
76
 
81
77
  // set the service name, this is what is displayed as the default name on the Home app
82
78
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
83
- this.service.setCharacteristic(
84
- this.platform.Characteristic.Name,
85
- accessory.displayName,
86
- );
79
+ this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
87
80
 
88
81
  // handle on / off events using the Active characteristic
89
- this.service
90
- .getCharacteristic(this.platform.Characteristic.Active)
91
- .onSet(this.ActiveSet.bind(this));
92
-
93
- this.service
94
- .getCharacteristic(this.platform.Characteristic.CurrentAirPurifierState)
95
- .onGet(() => {
96
- return this.CurrentAirPurifierStateGet();
97
- });
98
-
99
- this.service
100
- .getCharacteristic(this.platform.Characteristic.TargetAirPurifierState)
101
- .onSet(this.TargetAirPurifierStateSet.bind(this));
82
+ this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
83
+
84
+ this.service.getCharacteristic(this.platform.Characteristic.CurrentAirPurifierState).onGet(() => {
85
+ return this.CurrentAirPurifierStateGet();
86
+ });
87
+
88
+ this.service.getCharacteristic(this.platform.Characteristic.TargetAirPurifierState).onSet(this.TargetAirPurifierStateSet.bind(this));
102
89
  }
103
90
 
104
91
  private ActiveSet(value: CharacteristicValue) {
105
- this.debugLog(
106
- `Air Purifier: ${this.accessory.displayName} Set Active: ${value}`,
107
- );
92
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} Set Active: ${value}`);
108
93
  if (value === this.platform.Characteristic.Active.INACTIVE) {
109
94
  this.pushAirPurifierOffChanges();
110
95
  } else {
@@ -117,45 +102,24 @@ export class AirPurifier {
117
102
 
118
103
  private updateHomeKitCharacteristics() {
119
104
  if (this.Active === undefined) {
120
- this.debugLog(
121
- `Air Purifier: ${this.accessory.displayName} Active: ${this.Active}`,
122
- );
105
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} Active: ${this.Active}`);
123
106
  } else {
124
- this.service?.updateCharacteristic(
125
- this.platform.Characteristic.Active,
126
- this.Active,
127
- );
128
- this.debugLog(
129
- `Air Purifier: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`,
130
- );
107
+ this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
108
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
131
109
  }
132
110
  if (this.CurrentAirPurifierState === undefined) {
133
- this.debugLog(
134
- `Air Purifier: ${this.accessory.displayName} CurrentAirPurifierState: ${this.CurrentAirPurifierState}`,
135
- );
111
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} CurrentAirPurifierState: ${this.CurrentAirPurifierState}`);
136
112
  } else {
137
- this.service?.updateCharacteristic(
138
- this.platform.Characteristic.CurrentAirPurifierState,
139
- this.CurrentAirPurifierState,
140
- );
141
- this.debugLog(
142
- `Air Purifier: ${this.accessory.displayName}` +
143
- ` updateCharacteristic CurrentAirPurifierState: ${this.CurrentAirPurifierState}`,
144
- );
113
+ this.service?.updateCharacteristic(this.platform.Characteristic.CurrentAirPurifierState, this.CurrentAirPurifierState);
114
+ this.debugLog(`Air Purifier: ${this.accessory.displayName}`
115
+ + ` updateCharacteristic CurrentAirPurifierState: ${this.CurrentAirPurifierState}`);
145
116
  }
146
117
  if (this.CurrentHeaterCoolerState === undefined) {
147
- this.debugLog(
148
- `Air Purifier: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
149
- );
118
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
150
119
  } else {
151
- this.service?.updateCharacteristic(
152
- this.platform.Characteristic.CurrentHeaterCoolerState,
153
- this.CurrentHeaterCoolerState,
154
- );
155
- this.debugLog(
156
- `Air Purifier: ${this.accessory.displayName}` +
157
- ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
158
- );
120
+ this.service?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
121
+ this.debugLog(`Air Purifier: ${this.accessory.displayName}`
122
+ + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
159
123
  }
160
124
  }
161
125
 
@@ -177,11 +141,9 @@ export class AirPurifier {
177
141
 
178
142
  private CurrentAirPurifierStateGet() {
179
143
  if (this.Active === 1) {
180
- this.CurrentAirPurifierState =
181
- this.platform.Characteristic.CurrentAirPurifierState.PURIFYING_AIR;
144
+ this.CurrentAirPurifierState = this.platform.Characteristic.CurrentAirPurifierState.PURIFYING_AIR;
182
145
  } else {
183
- this.CurrentAirPurifierState =
184
- this.platform.Characteristic.CurrentAirPurifierState.INACTIVE;
146
+ this.CurrentAirPurifierState = this.platform.Characteristic.CurrentAirPurifierState.INACTIVE;
185
147
  }
186
148
  return this.CurrentAirPurifierState;
187
149
  }
@@ -200,9 +162,9 @@ export class AirPurifier {
200
162
  async pushAirPurifierOnChanges() {
201
163
  if (this.Active !== 1) {
202
164
  const payload = {
203
- commandType: "command",
204
- parameter: "default",
205
- command: "turnOn",
165
+ commandType: 'command',
166
+ parameter: 'default',
167
+ command: 'turnOn',
206
168
  } as payload;
207
169
  await this.pushChanges(payload);
208
170
  }
@@ -211,9 +173,9 @@ export class AirPurifier {
211
173
  async pushAirPurifierOffChanges() {
212
174
  if (this.Active !== 0) {
213
175
  const payload = {
214
- commandType: "command",
215
- parameter: "default",
216
- command: "turnOff",
176
+ commandType: 'command',
177
+ parameter: 'default',
178
+ command: 'turnOff',
217
179
  } as payload;
218
180
  await this.pushChanges(payload);
219
181
  }
@@ -222,41 +184,34 @@ export class AirPurifier {
222
184
  async pushAirConditionerStatusChanges() {
223
185
  if (!this.Busy) {
224
186
  this.Busy = true;
225
- this.CurrentHeaterCoolerState =
226
- this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
187
+ this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
227
188
  }
228
189
  clearTimeout(this.Timeout);
229
190
 
230
191
  // Make a new Timeout set to go off in 1000ms (1 second)
231
- this.Timeout = setTimeout(
232
- this.pushAirConditionerDetailsChanges.bind(this),
233
- 1500,
234
- );
192
+ this.Timeout = setTimeout(this.pushAirConditionerDetailsChanges.bind(this), 1500);
235
193
  }
236
194
 
237
195
  async pushAirConditionerDetailsChanges() {
238
196
  const payload = {
239
- commandType: "command",
240
- command: "setAll",
197
+ commandType: 'command',
198
+ command: 'setAll',
241
199
  } as payload;
242
200
 
243
201
  this.CurrentAPTemp = this.CurrentTemperature || 24;
244
202
  this.CurrentAPMode = this.CurrentMode || 1;
245
203
  this.CurrentAPFanSpeed = this.CurrentFanSpeed || 1;
246
- this.APActive = this.Active === 1 ? "on" : "off";
204
+ this.APActive = this.Active === 1 ? 'on' : 'off';
247
205
  payload.parameter = `${this.CurrentAPTemp},${this.CurrentAPMode},${this.CurrentAPFanSpeed},${this.APActive}`;
248
206
 
249
207
  if (this.Active === 1) {
250
208
  if ((this.CurrentTemperature || 24) < (this.LastTemperature || 30)) {
251
- this.CurrentHeaterCoolerState =
252
- this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
209
+ this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
253
210
  } else {
254
- this.CurrentHeaterCoolerState =
255
- this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
211
+ this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
256
212
  }
257
213
  } else {
258
- this.CurrentHeaterCoolerState =
259
- this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
214
+ this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
260
215
  }
261
216
 
262
217
  await this.pushChanges(payload);
@@ -264,103 +219,63 @@ export class AirPurifier {
264
219
 
265
220
  public async pushChanges(payload: payload) {
266
221
  try {
267
- this.infoLog(
268
- `Air Purifier: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
269
- ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`,
270
- );
222
+ this.infoLog(`Air Purifier: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
223
+ + ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
271
224
 
272
225
  // Make the API request
273
- const push = await this.platform.axios.post(
274
- `${DeviceURL}/${this.device.deviceId}/commands`,
275
- payload,
276
- );
277
- this.debugLog(
278
- `Air Purifier: ${this.accessory.displayName} pushChanges: ${push.data}`,
279
- );
226
+ const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
227
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} pushChanges: ${push.data}`);
280
228
  this.statusCode(push);
281
229
  this.updateHomeKitCharacteristics();
282
230
  this.CurrentTemperatureCached = this.CurrentTemperature;
283
231
  this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
284
232
  } catch (e: any) {
285
- this.errorLog(
286
- `Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`,
287
- );
288
- if (this.deviceLogging === "debug") {
289
- this.errorLog(
290
- `Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
291
- ` Error Message: ${JSON.stringify(e.message)}`,
292
- );
233
+ this.errorLog(`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
234
+ if (this.deviceLogging === 'debug') {
235
+ this.errorLog(`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
236
+ + ` Error Message: ${JSON.stringify(e.message)}`);
293
237
  }
294
238
  if (this.platform.debugMode) {
295
- this.errorLog(
296
- `Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
297
- ` Error: ${JSON.stringify(e)}`,
298
- );
239
+ this.errorLog(`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
240
+ + ` Error: ${JSON.stringify(e)}`);
299
241
  }
300
242
  this.apiError(e);
301
243
  }
302
244
  }
303
245
 
304
- private statusCode(push: AxiosResponse<{ statusCode: number }>) {
246
+ private statusCode(push: AxiosResponse<{ statusCode: number; }>) {
305
247
  switch (push.data.statusCode) {
306
248
  case 151:
307
- this.errorLog(
308
- `Air Purifier: ${this.accessory.displayName} Command not supported by this device type.`,
309
- );
249
+ this.errorLog(`Air Purifier: ${this.accessory.displayName} Command not supported by this device type.`);
310
250
  break;
311
251
  case 152:
312
- this.errorLog(
313
- `Air Purifier: ${this.accessory.displayName} Device not found.`,
314
- );
252
+ this.errorLog(`Air Purifier: ${this.accessory.displayName} Device not found.`);
315
253
  break;
316
254
  case 160:
317
- this.errorLog(
318
- `Air Purifier: ${this.accessory.displayName} Command is not supported.`,
319
- );
255
+ this.errorLog(`Air Purifier: ${this.accessory.displayName} Command is not supported.`);
320
256
  break;
321
257
  case 161:
322
- this.errorLog(
323
- `Air Purifier: ${this.accessory.displayName} Device is offline.`,
324
- );
258
+ this.errorLog(`Air Purifier: ${this.accessory.displayName} Device is offline.`);
325
259
  break;
326
260
  case 171:
327
- this.errorLog(
328
- `Air Purifier: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`,
329
- );
261
+ this.errorLog(`Air Purifier: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
330
262
  break;
331
263
  case 190:
332
- this.errorLog(
333
- `Air Purifier: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
334
- ` with server, Or command: ${JSON.stringify(
335
- push.data,
336
- )} format is invalid`,
337
- );
264
+ this.errorLog(`Air Purifier: ${this.accessory.displayName} Device internal error due to device states not synchronized`
265
+ + ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`);
338
266
  break;
339
267
  case 100:
340
- this.debugLog(
341
- `Air Purifier: ${this.accessory.displayName} Command successfully sent.`,
342
- );
268
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} Command successfully sent.`);
343
269
  break;
344
270
  default:
345
- this.debugLog(
346
- `Air Purifier: ${this.accessory.displayName} Unknown statusCode.`,
347
- );
271
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} Unknown statusCode.`);
348
272
  }
349
273
  }
350
274
 
351
275
  public apiError(e: any) {
352
- this.service.updateCharacteristic(
353
- this.platform.Characteristic.CurrentHeaterCoolerState,
354
- e,
355
- );
356
- this.service.updateCharacteristic(
357
- this.platform.Characteristic.CurrentAirPurifierState,
358
- e,
359
- );
360
- this.service.updateCharacteristic(
361
- this.platform.Characteristic.TargetAirPurifierState,
362
- e,
363
- );
276
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, e);
277
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentAirPurifierState, e);
278
+ this.service.updateCharacteristic(this.platform.Characteristic.TargetAirPurifierState, e);
364
279
  this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
365
280
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
366
281
  }
@@ -371,45 +286,32 @@ export class AirPurifier {
371
286
  config = device.irpur;
372
287
  }
373
288
  if (device.logging !== undefined) {
374
- config["logging"] = device.logging;
289
+ config['logging'] = device.logging;
375
290
  }
376
291
  if (Object.entries(config).length !== 0) {
377
- this.warnLog(
378
- `Air Purifier: ${this.accessory.displayName} Config: ${JSON.stringify(
379
- config,
380
- )}`,
381
- );
292
+ this.warnLog(`Air Purifier: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
382
293
  }
383
294
  }
384
295
 
385
296
  logs(device: irdevice & irDevicesConfig) {
386
297
  if (this.platform.debugMode) {
387
- this.deviceLogging = this.accessory.context.logging = "debugMode";
388
- this.debugLog(
389
- `Air Purifier: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`,
390
- );
298
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
299
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
391
300
  } else if (device.logging) {
392
301
  this.deviceLogging = this.accessory.context.logging = device.logging;
393
- this.debugLog(
394
- `Air Purifier: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`,
395
- );
302
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
396
303
  } else if (this.platform.config.options?.logging) {
397
- this.deviceLogging = this.accessory.context.logging =
398
- this.platform.config.options?.logging;
399
- this.debugLog(
400
- `Air Purifier: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`,
401
- );
304
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
305
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
402
306
  } else {
403
- this.deviceLogging = this.accessory.context.logging = "standard";
404
- this.debugLog(
405
- `Air Purifier: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`,
406
- );
307
+ this.deviceLogging = this.accessory.context.logging = 'standard';
308
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
407
309
  }
408
310
  }
409
311
 
410
312
  /**
411
- * Logging for Device
412
- */
313
+ * Logging for Device
314
+ */
413
315
  infoLog(...log: any[]) {
414
316
  if (this.enablingDeviceLogging()) {
415
317
  this.platform.log.info(String(...log));
@@ -430,8 +332,8 @@ export class AirPurifier {
430
332
 
431
333
  debugLog(...log: any[]) {
432
334
  if (this.enablingDeviceLogging()) {
433
- if (this.deviceLogging === "debug") {
434
- this.platform.log.info("[DEBUG]", String(...log));
335
+ if (this.deviceLogging === 'debug') {
336
+ this.platform.log.info('[DEBUG]', String(...log));
435
337
  } else {
436
338
  this.platform.log.debug(String(...log));
437
339
  }
@@ -439,6 +341,6 @@ export class AirPurifier {
439
341
  }
440
342
 
441
343
  enablingDeviceLogging(): boolean {
442
- return this.deviceLogging.includes("debug") || this.deviceLogging === "standard";
344
+ return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
443
345
  }
444
346
  }