@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
@@ -72,15 +72,19 @@ export class AirConditioner {
72
72
  // set accessory information
73
73
  accessory
74
74
  .getService(this.platform.Service.AccessoryInformation)!
75
- .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
75
+ .setCharacteristic(this.platform.Characteristic.Manufacturer, "SwitchBot")
76
76
  .setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
77
- .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
77
+ .setCharacteristic(
78
+ this.platform.Characteristic.SerialNumber,
79
+ device.deviceId!,
80
+ );
78
81
 
79
82
  // get the Television service if it exists, otherwise create a new Television service
80
83
  // you can create multiple services for each accessory
81
84
  (this.service =
82
85
  accessory.getService(this.platform.Service.HeaterCooler) ||
83
- accessory.addService(this.platform.Service.HeaterCooler)), `${accessory.displayName} Air Conditioner`;
86
+ accessory.addService(this.platform.Service.HeaterCooler)),
87
+ `${accessory.displayName} Air Conditioner`;
84
88
 
85
89
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
86
90
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -88,10 +92,15 @@ export class AirConditioner {
88
92
 
89
93
  // set the service name, this is what is displayed as the default name on the Home app
90
94
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
91
- this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
95
+ this.service.setCharacteristic(
96
+ this.platform.Characteristic.Name,
97
+ accessory.displayName,
98
+ );
92
99
 
93
100
  // handle on / off events using the Active characteristic
94
- this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
101
+ this.service
102
+ .getCharacteristic(this.platform.Characteristic.Active)
103
+ .onSet(this.ActiveSet.bind(this));
95
104
 
96
105
  this.service
97
106
  .getCharacteristic(this.platform.Characteristic.CurrentTemperature)
@@ -107,13 +116,21 @@ export class AirConditioner {
107
116
  if (this.hide_automode) {
108
117
  this.TargetHeaterCoolerState = 1 || 2;
109
118
  this.ValidValues = [1, 2];
110
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} ValidValues: ${JSON.stringify(this.ValidValues)},`
111
- + ` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
119
+ this.debugLog(
120
+ `Air Conditioner: ${
121
+ this.accessory.displayName
122
+ } ValidValues: ${JSON.stringify(this.ValidValues)},` +
123
+ ` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
124
+ );
112
125
  } else {
113
126
  this.TargetHeaterCoolerState = 0 || 1 || 2;
114
127
  this.ValidValues = [0, 1, 2];
115
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} ValidValues: ${JSON.stringify(this.ValidValues)},`
116
- + ` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
128
+ this.debugLog(
129
+ `Air Conditioner: ${
130
+ this.accessory.displayName
131
+ } ValidValues: ${JSON.stringify(this.ValidValues)},` +
132
+ ` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
133
+ );
117
134
  }
118
135
  this.service
119
136
  .getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState)
@@ -125,13 +142,16 @@ export class AirConditioner {
125
142
  })
126
143
  .onSet(this.TargetHeaterCoolerStateSet.bind(this));
127
144
 
128
- this.service.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
145
+ this.service
146
+ .getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
129
147
  .onGet(async () => {
130
148
  return this.CurrentHeaterCoolerStateGet();
131
149
  });
132
150
 
133
151
  this.service
134
- .getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
152
+ .getCharacteristic(
153
+ this.platform.Characteristic.HeatingThresholdTemperature,
154
+ )
135
155
  .setProps({
136
156
  minValue: 16,
137
157
  maxValue: 30,
@@ -143,7 +163,9 @@ export class AirConditioner {
143
163
  .onSet(this.HeatingThresholdTemperatureSet.bind(this));
144
164
 
145
165
  this.service
146
- .getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature)
166
+ .getCharacteristic(
167
+ this.platform.Characteristic.CoolingThresholdTemperature,
168
+ )
147
169
  .setProps({
148
170
  minValue: 16,
149
171
  maxValue: 30,
@@ -189,9 +211,9 @@ export class AirConditioner {
189
211
 
190
212
  async pushAirConditionerOffChanges() {
191
213
  const payload = {
192
- commandType: 'command',
193
- parameter: 'default',
194
- command: 'turnOff',
214
+ commandType: "command",
215
+ parameter: "default",
216
+ command: "turnOff",
195
217
  } as any;
196
218
  await this.pushChanges(payload);
197
219
  }
@@ -199,18 +221,22 @@ export class AirConditioner {
199
221
  async pushAirConditionerStatusChanges() {
200
222
  if (!this.Busy) {
201
223
  this.Busy = true;
202
- this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
224
+ this.CurrentHeaterCoolerState =
225
+ this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
203
226
  }
204
227
  clearTimeout(this.Timeout);
205
228
 
206
229
  // Make a new Timeout set to go off in 1000ms (1 second)
207
- this.Timeout = setTimeout(this.pushAirConditionerDetailsChanges.bind(this), 1500);
230
+ this.Timeout = setTimeout(
231
+ this.pushAirConditionerDetailsChanges.bind(this),
232
+ 1500,
233
+ );
208
234
  }
209
235
 
210
236
  async pushAirConditionerDetailsChanges() {
211
237
  const payload = {
212
- commandType: 'command',
213
- command: 'setAll',
238
+ commandType: "command",
239
+ command: "setAll",
214
240
  } as any;
215
241
 
216
242
  this.CurrentTemperatureUndefined();
@@ -221,27 +247,31 @@ export class AirConditioner {
221
247
  this.CurrentFanSpeed = 1;
222
248
  }
223
249
  if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
224
- this.state = 'on';
250
+ this.state = "on";
225
251
  } else {
226
- this.state = 'off';
252
+ this.state = "off";
227
253
  }
228
254
  if (this.CurrentMode === 1) {
229
255
  this.CurrentTemperature = 25;
230
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},`
231
- + ` CurrentTemperature: ${this.CurrentTemperature}`);
256
+ this.debugLog(
257
+ `Air Conditioner: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},` +
258
+ ` CurrentTemperature: ${this.CurrentTemperature}`,
259
+ );
232
260
  }
233
261
  payload.parameter = `${this.CurrentTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
234
262
 
235
-
236
263
  if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
237
264
  this.CurrentTemperatureUndefined();
238
265
  if (this.CurrentTemperature < this.CurrentTemperatureCached) {
239
- this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
266
+ this.CurrentHeaterCoolerState =
267
+ this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
240
268
  } else if (this.CurrentTemperature > this.CurrentTemperatureCached) {
241
- this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
269
+ this.CurrentHeaterCoolerState =
270
+ this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
242
271
  }
243
272
  } else {
244
- this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
273
+ this.CurrentHeaterCoolerState =
274
+ this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
245
275
  }
246
276
 
247
277
  await this.pushChanges(payload);
@@ -249,122 +279,224 @@ export class AirConditioner {
249
279
 
250
280
  public async pushChanges(payload: payload) {
251
281
  try {
252
- this.infoLog(`Air Conditioner: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
253
- + ` parameter: [${payload.parameter}], commandType: ${payload.commandType}`);
282
+ this.infoLog(
283
+ `Air Conditioner: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
284
+ ` parameter: [${payload.parameter}], commandType: ${payload.commandType}`,
285
+ );
254
286
 
255
287
  // Make the API request
256
- const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
257
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
288
+ const push: any = await this.platform.axios.post(
289
+ `${DeviceURL}/${this.device.deviceId}/commands`,
290
+ payload,
291
+ );
292
+ this.debugLog(
293
+ `Air Conditioner: ${
294
+ this.accessory.displayName
295
+ } pushChanges: ${JSON.stringify(push.data)}`,
296
+ );
258
297
  this.statusCode(push);
259
298
  this.CurrentTemperatureCached = this.CurrentTemperature;
260
299
  this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
261
300
  this.HeatingThresholdTemperature = this.CurrentTemperatureCached;
262
301
  this.HeatingThresholdTemperatureCached = this.CurrentTemperatureCached;
263
- this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
302
+ this.accessory.context.HeatingThresholdTemperature =
303
+ this.HeatingThresholdTemperatureCached;
264
304
  this.CoolingThresholdTemperature = this.CurrentTemperatureCached;
265
305
  this.CoolingThresholdTemperatureCached = this.CurrentTemperatureCached;
266
- this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
306
+ this.accessory.context.CoolingThresholdTemperature =
307
+ this.CoolingThresholdTemperatureCached;
267
308
  this.updateHomeKitCharacteristics();
268
309
  } catch (e: any) {
269
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges`);
270
- if (this.deviceLogging === 'debug') {
271
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,`
272
- + ` Error Message: ${JSON.stringify(e.message)}`);
310
+ this.errorLog(
311
+ `Air Conditioner: ${this.accessory.displayName} failed pushChanges`,
312
+ );
313
+ if (this.deviceLogging === "debug") {
314
+ this.errorLog(
315
+ `Air Conditioner: ${this.accessory.displayName} failed pushChanges,` +
316
+ ` Error Message: ${JSON.stringify(e.message)}`,
317
+ );
273
318
  }
274
319
  if (this.platform.debugMode) {
275
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,`
276
- + ` Error: ${JSON.stringify(e)}`);
320
+ this.errorLog(
321
+ `Air Conditioner: ${this.accessory.displayName} failed pushChanges,` +
322
+ ` Error: ${JSON.stringify(e)}`,
323
+ );
277
324
  }
278
325
  this.apiError(e);
279
326
  }
280
327
  }
281
328
 
282
- statusCode(push: AxiosResponse<{ statusCode: number; }>) {
329
+ statusCode(push: AxiosResponse<{ statusCode: number }>) {
283
330
  switch (push.data.statusCode) {
284
331
  case 151:
285
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Command not supported by this device type.`);
332
+ this.errorLog(
333
+ `Air Conditioner: ${this.accessory.displayName} Command not supported by this device type.`,
334
+ );
286
335
  break;
287
336
  case 152:
288
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device not found.`);
337
+ this.errorLog(
338
+ `Air Conditioner: ${this.accessory.displayName} Device not found.`,
339
+ );
289
340
  break;
290
341
  case 160:
291
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Command is not supported.`);
342
+ this.errorLog(
343
+ `Air Conditioner: ${this.accessory.displayName} Command is not supported.`,
344
+ );
292
345
  break;
293
346
  case 161:
294
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device is offline.`);
347
+ this.errorLog(
348
+ `Air Conditioner: ${this.accessory.displayName} Device is offline.`,
349
+ );
295
350
  break;
296
351
  case 171:
297
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
352
+ this.errorLog(
353
+ `Air Conditioner: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`,
354
+ );
298
355
  break;
299
356
  case 190:
300
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device internal error due to device states not synchronized`
301
- + ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`);
357
+ this.errorLog(
358
+ `Air Conditioner: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
359
+ ` with server, Or command: ${JSON.stringify(
360
+ push.data,
361
+ )} format is invalid`,
362
+ );
302
363
  break;
303
364
  case 100:
304
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Command successfully sent.`);
365
+ this.debugLog(
366
+ `Air Conditioner: ${this.accessory.displayName} Command successfully sent.`,
367
+ );
305
368
  break;
306
369
  default:
307
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Unknown statusCode.`);
370
+ this.debugLog(
371
+ `Air Conditioner: ${this.accessory.displayName} Unknown statusCode.`,
372
+ );
308
373
  }
309
374
  }
310
375
 
311
376
  updateHomeKitCharacteristics() {
312
377
  if (this.Active === undefined) {
313
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Active: ${this.Active}`);
378
+ this.debugLog(
379
+ `Air Conditioner: ${this.accessory.displayName} Active: ${this.Active}`,
380
+ );
314
381
  } else {
315
- this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
316
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
382
+ this.service?.updateCharacteristic(
383
+ this.platform.Characteristic.Active,
384
+ this.Active,
385
+ );
386
+ this.debugLog(
387
+ `Air Conditioner: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`,
388
+ );
317
389
  }
318
390
  if (this.RotationSpeed === undefined) {
319
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
391
+ this.debugLog(
392
+ `Air Conditioner: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`,
393
+ );
320
394
  } else {
321
- this.service?.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed);
322
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`);
395
+ this.service?.updateCharacteristic(
396
+ this.platform.Characteristic.RotationSpeed,
397
+ this.RotationSpeed,
398
+ );
399
+ this.debugLog(
400
+ `Air Conditioner: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`,
401
+ );
323
402
  }
324
403
  if (this.CurrentTemperature === undefined) {
325
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
404
+ this.debugLog(
405
+ `Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`,
406
+ );
326
407
  } else {
327
- this.service?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
328
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
408
+ this.service?.updateCharacteristic(
409
+ this.platform.Characteristic.CurrentTemperature,
410
+ this.CurrentTemperature,
411
+ );
412
+ this.debugLog(
413
+ `Air Conditioner: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`,
414
+ );
329
415
  }
330
416
  if (this.TargetHeaterCoolerState === undefined) {
331
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
417
+ this.debugLog(
418
+ `Air Conditioner: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
419
+ );
332
420
  } else {
333
- this.service?.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.TargetHeaterCoolerState);
334
- this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
335
- + ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
421
+ this.service?.updateCharacteristic(
422
+ this.platform.Characteristic.TargetHeaterCoolerState,
423
+ this.TargetHeaterCoolerState,
424
+ );
425
+ this.debugLog(
426
+ `Air Conditioner: ${this.accessory.displayName}` +
427
+ ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
428
+ );
336
429
  }
337
430
  if (this.CurrentHeaterCoolerState === undefined) {
338
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
431
+ this.debugLog(
432
+ `Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
433
+ );
339
434
  } else {
340
- this.service?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
341
- this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
342
- + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
435
+ this.service?.updateCharacteristic(
436
+ this.platform.Characteristic.CurrentHeaterCoolerState,
437
+ this.CurrentHeaterCoolerState,
438
+ );
439
+ this.debugLog(
440
+ `Air Conditioner: ${this.accessory.displayName}` +
441
+ ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
442
+ );
343
443
  }
344
444
  if (this.HeatingThresholdTemperature === undefined) {
345
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
445
+ this.debugLog(
446
+ `Air Conditioner: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`,
447
+ );
346
448
  } else {
347
- this.service?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.HeatingThresholdTemperature);
348
- this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
349
- + ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
449
+ this.service?.updateCharacteristic(
450
+ this.platform.Characteristic.HeatingThresholdTemperature,
451
+ this.HeatingThresholdTemperature,
452
+ );
453
+ this.debugLog(
454
+ `Air Conditioner: ${this.accessory.displayName}` +
455
+ ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`,
456
+ );
350
457
  }
351
458
  if (this.CoolingThresholdTemperature === undefined) {
352
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
459
+ this.debugLog(
460
+ `Air Conditioner: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`,
461
+ );
353
462
  } else {
354
- this.service?.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, this.CoolingThresholdTemperature);
355
- this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
356
- + ` updateCharacteristic CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
463
+ this.service?.updateCharacteristic(
464
+ this.platform.Characteristic.CoolingThresholdTemperature,
465
+ this.CoolingThresholdTemperature,
466
+ );
467
+ this.debugLog(
468
+ `Air Conditioner: ${this.accessory.displayName}` +
469
+ ` updateCharacteristic CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`,
470
+ );
357
471
  }
358
472
  }
359
473
 
360
474
  public apiError(e: any) {
361
475
  this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
362
- this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, e);
363
- this.service.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
364
- this.service.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, e);
365
- this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, e);
366
- this.service.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, e);
367
- this.service.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, e);
476
+ this.service.updateCharacteristic(
477
+ this.platform.Characteristic.RotationSpeed,
478
+ e,
479
+ );
480
+ this.service.updateCharacteristic(
481
+ this.platform.Characteristic.CurrentTemperature,
482
+ e,
483
+ );
484
+ this.service.updateCharacteristic(
485
+ this.platform.Characteristic.TargetHeaterCoolerState,
486
+ e,
487
+ );
488
+ this.service.updateCharacteristic(
489
+ this.platform.Characteristic.CurrentHeaterCoolerState,
490
+ e,
491
+ );
492
+ this.service.updateCharacteristic(
493
+ this.platform.Characteristic.HeatingThresholdTemperature,
494
+ e,
495
+ );
496
+ this.service.updateCharacteristic(
497
+ this.platform.Characteristic.CoolingThresholdTemperature,
498
+ e,
499
+ );
368
500
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
369
501
  }
370
502
 
@@ -375,7 +507,9 @@ export class AirConditioner {
375
507
  } else {
376
508
  this.CurrentTemperatureCached = this.CurrentTemperature;
377
509
  }
378
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`);
510
+ this.debugLog(
511
+ `Air Conditioner: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`,
512
+ );
379
513
  this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
380
514
  return this.CurrentTemperature;
381
515
  }
@@ -388,7 +522,9 @@ export class AirConditioner {
388
522
  } else {
389
523
  this.RotationSpeed = this.CurrentFanSpeed - 1;
390
524
  }
391
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get RotationSpeed: ${this.RotationSpeed}`);
525
+ this.debugLog(
526
+ `Air Conditioner: ${this.accessory.displayName} Get RotationSpeed: ${this.RotationSpeed}`,
527
+ );
392
528
  this.RotationSpeedCached = this.RotationSpeed;
393
529
  this.accessory.context.RotationSpeed = this.RotationSpeedCached;
394
530
  return this.RotationSpeed;
@@ -406,38 +542,53 @@ export class AirConditioner {
406
542
  this.pushAirConditionerStatusChanges();
407
543
  }
408
544
 
409
- ActiveSet(value: CharacteristicValue) {
410
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set Active: ${value}`);
545
+ ActiveSet(value: CharacteristicValue): void {
546
+ this.debugLog(
547
+ `Air Conditioner: ${this.accessory.displayName} Set Active: ${value}`,
548
+ );
411
549
 
412
550
  this.Active = value;
413
551
  this.ActiveCached = this.Active;
414
552
  this.accessory.context.Active = this.ActiveCached;
415
553
 
416
554
  if (value === this.platform.Characteristic.Active.INACTIVE) {
417
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
555
+ this.debugLog(
556
+ `Air Conditioner: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`,
557
+ );
418
558
  this.pushAirConditionerOffChanges();
419
559
  } else {
420
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.Active}`);
560
+ this.debugLog(
561
+ `Air Conditioner: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.Active}`,
562
+ );
421
563
  this.pushAirConditionerStatusChanges();
422
564
  }
423
565
  }
424
566
 
425
567
  TargetHeaterCoolerStateGet() {
426
568
  if (this.ValidValues === [0, 1, 2]) {
427
- this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
428
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (AUTO) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},`
429
- + ` ValidValues: ${this.ValidValues}`);
569
+ this.TargetHeaterCoolerState =
570
+ this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
571
+ this.debugLog(
572
+ `Air Conditioner: ${this.accessory.displayName} Get (AUTO) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
573
+ ` ValidValues: ${this.ValidValues}`,
574
+ );
430
575
  } else if (this.ValidValues === [1, 2]) {
431
- this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.COOL
432
- || this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
433
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (COOL/HEAT) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},`
434
- + ` ValidValues: ${this.ValidValues}`);
576
+ this.TargetHeaterCoolerState =
577
+ this.platform.Characteristic.TargetHeaterCoolerState.COOL ||
578
+ this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
579
+ this.debugLog(
580
+ `Air Conditioner: ${this.accessory.displayName} Get (COOL/HEAT) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
581
+ ` ValidValues: ${this.ValidValues}`,
582
+ );
435
583
  } else {
436
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},`
437
- + ` ValidValues: ${this.ValidValues}`);
584
+ this.debugLog(
585
+ `Air Conditioner: ${this.accessory.displayName} Get TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
586
+ ` ValidValues: ${this.ValidValues}`,
587
+ );
438
588
  }
439
589
  this.TargetHeaterCoolerStateCached = this.TargetHeaterCoolerState;
440
- this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerStateCached;
590
+ this.accessory.context.TargetHeaterCoolerState =
591
+ this.TargetHeaterCoolerStateCached;
441
592
  return this.TargetHeaterCoolerState;
442
593
  }
443
594
 
@@ -445,66 +596,102 @@ export class AirConditioner {
445
596
  if (this.hide_automode) {
446
597
  if (value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT) {
447
598
  this.TargetHeaterCoolerStateHEAT();
448
- } else if (value === this.platform.Characteristic.TargetHeaterCoolerState.COOL) {
599
+ } else if (
600
+ value === this.platform.Characteristic.TargetHeaterCoolerState.COOL
601
+ ) {
449
602
  this.TargetHeaterCoolerStateCOOL();
450
603
  } else {
451
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},`
452
- + ` hide_automode: ${this.hide_automode} `);
604
+ this.errorLog(
605
+ `Air Conditioner: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
606
+ ` hide_automode: ${this.hide_automode} `,
607
+ );
453
608
  }
454
609
  } else {
455
610
  if (value === this.platform.Characteristic.TargetHeaterCoolerState.AUTO) {
456
611
  this.TargetHeaterCoolerStateAUTO();
457
- } else if (value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT) {
612
+ } else if (
613
+ value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT
614
+ ) {
458
615
  this.TargetHeaterCoolerStateHEAT();
459
- } else if (value === this.platform.Characteristic.TargetHeaterCoolerState.COOL) {
616
+ } else if (
617
+ value === this.platform.Characteristic.TargetHeaterCoolerState.COOL
618
+ ) {
460
619
  this.TargetHeaterCoolerStateCOOL();
461
620
  } else {
462
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},`
463
- + ` hide_automode: ${this.hide_automode} `);
621
+ this.errorLog(
622
+ `Air Conditioner: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
623
+ ` hide_automode: ${this.hide_automode} `,
624
+ );
464
625
  }
465
626
  }
466
627
  this.TargetHeaterCoolerStateCached = this.TargetHeaterCoolerState;
467
- this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerStateCached;
628
+ this.accessory.context.TargetHeaterCoolerState =
629
+ this.TargetHeaterCoolerStateCached;
468
630
  this.pushAirConditionerStatusChanges();
469
631
  }
470
632
 
471
633
  private TargetHeaterCoolerStateAUTO() {
472
- this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
634
+ this.TargetHeaterCoolerState =
635
+ this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
473
636
  this.CurrentMode = 1;
474
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set (AUTO) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
475
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
637
+ this.debugLog(
638
+ `Air Conditioner: ${this.accessory.displayName} Set (AUTO) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
639
+ );
640
+ this.debugLog(
641
+ `Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`,
642
+ );
476
643
  }
477
644
 
478
645
  private TargetHeaterCoolerStateCOOL() {
479
- this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.COOL;
646
+ this.TargetHeaterCoolerState =
647
+ this.platform.Characteristic.TargetHeaterCoolerState.COOL;
480
648
  this.CurrentMode = 2;
481
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set (COOL) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
482
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
649
+ this.debugLog(
650
+ `Air Conditioner: ${this.accessory.displayName} Set (COOL) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
651
+ );
652
+ this.debugLog(
653
+ `Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`,
654
+ );
483
655
  }
484
656
 
485
657
  private TargetHeaterCoolerStateHEAT() {
486
- this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
658
+ this.TargetHeaterCoolerState =
659
+ this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
487
660
  this.CurrentMode = 5;
488
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set (HEAT) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
489
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
661
+ this.debugLog(
662
+ `Air Conditioner: ${this.accessory.displayName} Set (HEAT) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
663
+ );
664
+ this.debugLog(
665
+ `Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`,
666
+ );
490
667
  }
491
668
 
492
669
  CurrentHeaterCoolerStateGet() {
493
670
  if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
494
671
  this.CurrentTemperatureUndefined();
495
672
  if (this.CurrentTemperature < this.CurrentTemperatureCached) {
496
- this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
497
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (COOLLING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
673
+ this.CurrentHeaterCoolerState =
674
+ this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
675
+ this.debugLog(
676
+ `Air Conditioner: ${this.accessory.displayName} Get (COOLLING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
677
+ );
498
678
  } else if (this.CurrentTemperature > this.CurrentTemperatureCached) {
499
- this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
500
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
679
+ this.CurrentHeaterCoolerState =
680
+ this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
681
+ this.debugLog(
682
+ `Air Conditioner: ${this.accessory.displayName} Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
683
+ );
501
684
  }
502
685
  } else {
503
- this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
504
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (INACTIVE) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
686
+ this.CurrentHeaterCoolerState =
687
+ this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
688
+ this.debugLog(
689
+ `Air Conditioner: ${this.accessory.displayName} Get (INACTIVE) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
690
+ );
505
691
  }
506
692
  this.CurrentHeaterCoolerStateCached = this.CurrentHeaterCoolerState;
507
- this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerStateCached;
693
+ this.accessory.context.CurrentHeaterCoolerState =
694
+ this.CurrentHeaterCoolerStateCached;
508
695
  return this.CurrentHeaterCoolerState;
509
696
  }
510
697
 
@@ -513,8 +700,11 @@ export class AirConditioner {
513
700
  this.CurrentTemperature = this.CurrentTemperatureCached;
514
701
  this.HeatingThresholdTemperature = this.CurrentTemperatureCached;
515
702
  this.HeatingThresholdTemperatureCached = this.HeatingThresholdTemperature;
516
- this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
517
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
703
+ this.accessory.context.HeatingThresholdTemperature =
704
+ this.HeatingThresholdTemperatureCached;
705
+ this.debugLog(
706
+ `Air Conditioner: ${this.accessory.displayName} Get HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`,
707
+ );
518
708
  return this.HeatingThresholdTemperature;
519
709
  }
520
710
 
@@ -522,20 +712,25 @@ export class AirConditioner {
522
712
  this.CurrentTemperatureCached = this.CurrentTemperature;
523
713
  this.CurrentTemperature = value;
524
714
  this.HeatingThresholdTemperatureCached = this.HeatingThresholdTemperature;
525
- this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
526
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set HeatingThresholdTemperature: ${this.HeatingThresholdTemperature},`
527
- + ` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`);
715
+ this.accessory.context.HeatingThresholdTemperature =
716
+ this.HeatingThresholdTemperatureCached;
717
+ this.debugLog(
718
+ `Air Conditioner: ${this.accessory.displayName} Set HeatingThresholdTemperature: ${this.HeatingThresholdTemperature},` +
719
+ ` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`,
720
+ );
528
721
  this.pushAirConditionerStatusChanges();
529
722
  }
530
723
 
531
-
532
724
  private CoolingThresholdTemperatureGet() {
533
725
  this.CurrentTemperatureUndefined;
534
726
  this.CurrentTemperature = this.CurrentTemperatureCached;
535
727
  this.CoolingThresholdTemperature = this.CurrentTemperatureCached;
536
728
  this.CoolingThresholdTemperatureCached = this.CoolingThresholdTemperature;
537
- this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
538
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
729
+ this.accessory.context.CoolingThresholdTemperature =
730
+ this.CoolingThresholdTemperatureCached;
731
+ this.debugLog(
732
+ `Air Conditioner: ${this.accessory.displayName} Get CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`,
733
+ );
539
734
  return this.CoolingThresholdTemperature;
540
735
  }
541
736
 
@@ -543,9 +738,12 @@ export class AirConditioner {
543
738
  this.CurrentTemperatureCached = this.CurrentTemperature;
544
739
  this.CurrentTemperature = value;
545
740
  this.CoolingThresholdTemperatureCached = this.CoolingThresholdTemperature;
546
- this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
547
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set CoolingThresholdTemperature: ${this.CoolingThresholdTemperature},`
548
- + ` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`);
741
+ this.accessory.context.CoolingThresholdTemperature =
742
+ this.CoolingThresholdTemperatureCached;
743
+ this.debugLog(
744
+ `Air Conditioner: ${this.accessory.displayName} Set CoolingThresholdTemperature: ${this.CoolingThresholdTemperature},` +
745
+ ` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`,
746
+ );
549
747
  this.pushAirConditionerStatusChanges();
550
748
  }
551
749
 
@@ -564,32 +762,45 @@ export class AirConditioner {
564
762
  config = device.irair;
565
763
  }
566
764
  if (device.logging !== undefined) {
567
- config['logging'] = device.logging;
765
+ config["logging"] = device.logging;
568
766
  }
569
767
  if (Object.entries(config).length !== 0) {
570
- this.warnLog(`Air Conditioner: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
768
+ this.warnLog(
769
+ `Air Conditioner: ${
770
+ this.accessory.displayName
771
+ } Config: ${JSON.stringify(config)}`,
772
+ );
571
773
  }
572
774
  }
573
775
 
574
776
  logs(device: irdevice & irDevicesConfig) {
575
777
  if (this.platform.debugMode) {
576
- this.deviceLogging = this.accessory.context.logging = 'debugMode';
577
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
778
+ this.deviceLogging = this.accessory.context.logging = "debugMode";
779
+ this.debugLog(
780
+ `Air Conditioner: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`,
781
+ );
578
782
  } else if (device.logging) {
579
783
  this.deviceLogging = this.accessory.context.logging = device.logging;
580
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
784
+ this.debugLog(
785
+ `Air Conditioner: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`,
786
+ );
581
787
  } else if (this.platform.config.options?.logging) {
582
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
583
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
788
+ this.deviceLogging = this.accessory.context.logging =
789
+ this.platform.config.options?.logging;
790
+ this.debugLog(
791
+ `Air Conditioner: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`,
792
+ );
584
793
  } else {
585
- this.deviceLogging = this.accessory.context.logging = 'standard';
586
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
794
+ this.deviceLogging = this.accessory.context.logging = "standard";
795
+ this.debugLog(
796
+ `Air Conditioner: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`,
797
+ );
587
798
  }
588
799
  }
589
800
 
590
801
  /**
591
- * Logging for Device
592
- */
802
+ * Logging for Device
803
+ */
593
804
  infoLog(...log: any[]) {
594
805
  if (this.enablingDeviceLogging()) {
595
806
  this.platform.log.info(String(...log));
@@ -610,8 +821,8 @@ export class AirConditioner {
610
821
 
611
822
  debugLog(...log: any[]) {
612
823
  if (this.enablingDeviceLogging()) {
613
- if (this.deviceLogging === 'debug') {
614
- this.platform.log.info('[DEBUG]', String(...log));
824
+ if (this.deviceLogging === "debug") {
825
+ this.platform.log.info("[DEBUG]", String(...log));
615
826
  } else {
616
827
  this.platform.log.debug(String(...log));
617
828
  }
@@ -619,6 +830,6 @@ export class AirConditioner {
619
830
  }
620
831
 
621
832
  enablingDeviceLogging(): boolean {
622
- return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
833
+ return this.deviceLogging.includes("debug") || this.deviceLogging === "standard";
623
834
  }
624
835
  }