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