@switchbot/homebridge-switchbot 2.8.0-beta.0 → 2.8.0-beta.2

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 (118) hide show
  1. package/.prettierrc +1 -1
  2. package/.vscode/settings.json +1 -1
  3. package/CHANGELOG.md +10 -0
  4. package/config.schema.json +8 -0
  5. package/dist/device/blindtilt.d.ts.map +1 -1
  6. package/dist/device/blindtilt.js +49 -59
  7. package/dist/device/blindtilt.js.map +1 -1
  8. package/dist/device/bot.d.ts.map +1 -1
  9. package/dist/device/bot.js +44 -50
  10. package/dist/device/bot.js.map +1 -1
  11. package/dist/device/ceilinglight.d.ts.map +1 -1
  12. package/dist/device/ceilinglight.js +60 -63
  13. package/dist/device/ceilinglight.js.map +1 -1
  14. package/dist/device/colorbulb.d.ts.map +1 -1
  15. package/dist/device/colorbulb.js +68 -70
  16. package/dist/device/colorbulb.js.map +1 -1
  17. package/dist/device/contact.d.ts.map +1 -1
  18. package/dist/device/contact.js +22 -25
  19. package/dist/device/contact.js.map +1 -1
  20. package/dist/device/curtain.d.ts.map +1 -1
  21. package/dist/device/curtain.js +50 -58
  22. package/dist/device/curtain.js.map +1 -1
  23. package/dist/device/hub.d.ts +6 -0
  24. package/dist/device/hub.d.ts.map +1 -1
  25. package/dist/device/hub.js +168 -26
  26. package/dist/device/hub.js.map +1 -1
  27. package/dist/device/humidifier.d.ts.map +1 -1
  28. package/dist/device/humidifier.js +49 -56
  29. package/dist/device/humidifier.js.map +1 -1
  30. package/dist/device/iosensor.d.ts.map +1 -1
  31. package/dist/device/iosensor.js +18 -20
  32. package/dist/device/iosensor.js.map +1 -1
  33. package/dist/device/lightstrip.d.ts.map +1 -1
  34. package/dist/device/lightstrip.js +59 -61
  35. package/dist/device/lightstrip.js.map +1 -1
  36. package/dist/device/lock.d.ts.map +1 -1
  37. package/dist/device/lock.js +40 -41
  38. package/dist/device/lock.js.map +1 -1
  39. package/dist/device/meter.d.ts +3 -3
  40. package/dist/device/meter.d.ts.map +1 -1
  41. package/dist/device/meter.js +65 -68
  42. package/dist/device/meter.js.map +1 -1
  43. package/dist/device/meterplus.d.ts.map +1 -1
  44. package/dist/device/meterplus.js +18 -20
  45. package/dist/device/meterplus.js.map +1 -1
  46. package/dist/device/motion.d.ts.map +1 -1
  47. package/dist/device/motion.js +20 -23
  48. package/dist/device/motion.js.map +1 -1
  49. package/dist/device/plug.d.ts.map +1 -1
  50. package/dist/device/plug.js +30 -33
  51. package/dist/device/plug.js.map +1 -1
  52. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  53. package/dist/device/robotvacuumcleaner.js +48 -51
  54. package/dist/device/robotvacuumcleaner.js.map +1 -1
  55. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  56. package/dist/irdevice/airconditioner.js +58 -62
  57. package/dist/irdevice/airconditioner.js.map +1 -1
  58. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  59. package/dist/irdevice/airpurifier.js +29 -31
  60. package/dist/irdevice/airpurifier.js.map +1 -1
  61. package/dist/irdevice/camera.d.ts.map +1 -1
  62. package/dist/irdevice/camera.js +17 -20
  63. package/dist/irdevice/camera.js.map +1 -1
  64. package/dist/irdevice/fan.d.ts.map +1 -1
  65. package/dist/irdevice/fan.js +27 -29
  66. package/dist/irdevice/fan.js.map +1 -1
  67. package/dist/irdevice/light.d.ts.map +1 -1
  68. package/dist/irdevice/light.js +23 -26
  69. package/dist/irdevice/light.js.map +1 -1
  70. package/dist/irdevice/other.d.ts.map +1 -1
  71. package/dist/irdevice/other.js +19 -20
  72. package/dist/irdevice/other.js.map +1 -1
  73. package/dist/irdevice/tv.d.ts.map +1 -1
  74. package/dist/irdevice/tv.js +44 -47
  75. package/dist/irdevice/tv.js.map +1 -1
  76. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  77. package/dist/irdevice/vacuumcleaner.js +17 -20
  78. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  79. package/dist/irdevice/waterheater.d.ts.map +1 -1
  80. package/dist/irdevice/waterheater.js +19 -20
  81. package/dist/irdevice/waterheater.js.map +1 -1
  82. package/dist/platform.d.ts.map +1 -1
  83. package/dist/platform.js +44 -43
  84. package/dist/platform.js.map +1 -1
  85. package/dist/settings.d.ts +1 -0
  86. package/dist/settings.d.ts.map +1 -1
  87. package/dist/settings.js.map +1 -1
  88. package/dist/utils.js +1 -1
  89. package/dist/utils.js.map +1 -1
  90. package/package.json +1 -1
  91. package/src/device/blindtilt.ts +106 -72
  92. package/src/device/bot.ts +94 -58
  93. package/src/device/ceilinglight.ts +102 -68
  94. package/src/device/colorbulb.ts +134 -82
  95. package/src/device/contact.ts +54 -33
  96. package/src/device/curtain.ts +130 -101
  97. package/src/device/hub.ts +198 -35
  98. package/src/device/humidifier.ts +128 -80
  99. package/src/device/iosensor.ts +43 -27
  100. package/src/device/lightstrip.ts +108 -67
  101. package/src/device/lock.ts +73 -45
  102. package/src/device/meter.ts +94 -75
  103. package/src/device/meterplus.ts +43 -27
  104. package/src/device/motion.ts +50 -32
  105. package/src/device/plug.ts +62 -39
  106. package/src/device/robotvacuumcleaner.ts +78 -54
  107. package/src/irdevice/airconditioner.ts +112 -84
  108. package/src/irdevice/airpurifier.ts +55 -34
  109. package/src/irdevice/camera.ts +35 -23
  110. package/src/irdevice/fan.ts +47 -33
  111. package/src/irdevice/light.ts +43 -29
  112. package/src/irdevice/other.ts +39 -23
  113. package/src/irdevice/tv.ts +65 -51
  114. package/src/irdevice/vacuumcleaner.ts +35 -23
  115. package/src/irdevice/waterheater.ts +43 -27
  116. package/src/platform.ts +85 -55
  117. package/src/settings.ts +41 -40
  118. package/src/utils.ts +1 -1
@@ -43,7 +43,11 @@ export class AirConditioner {
43
43
  private readonly valid12 = [1, 2];
44
44
  private readonly valid012 = [0, 1, 2];
45
45
 
46
- constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
46
+ constructor(
47
+ private readonly platform: SwitchBotPlatform,
48
+ private accessory: PlatformAccessory,
49
+ public device: irdevice & irDevicesConfig,
50
+ ) {
47
51
  // default placeholders
48
52
  this.logs({ device });
49
53
  this.config({ device });
@@ -65,7 +69,7 @@ export class AirConditioner {
65
69
  // get the Television service if it exists, otherwise create a new Television service
66
70
  // you can create multiple services for each accessory
67
71
  (this.coolerService = accessory.getService(this.platform.Service.HeaterCooler) || accessory.addService(this.platform.Service.HeaterCooler)),
68
- `${accessory.displayName} ${device.remoteType}`;
72
+ `${accessory.displayName} ${device.remoteType}`;
69
73
 
70
74
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
71
75
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -79,11 +83,9 @@ export class AirConditioner {
79
83
  }
80
84
 
81
85
  // handle on / off events using the Active characteristic
82
- this.coolerService.getCharacteristic(this.platform.Characteristic.Active)
83
- .onSet(this.ActiveSet.bind(this));
86
+ this.coolerService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
84
87
 
85
- this.coolerService.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
86
- .onGet(this.CurrentTemperatureGet.bind(this));
88
+ this.coolerService.getCharacteristic(this.platform.Characteristic.CurrentTemperature).onGet(this.CurrentTemperatureGet.bind(this));
87
89
 
88
90
  if (this.hide_automode) {
89
91
  this.TargetHeaterCoolerState = 1 || 2;
@@ -102,39 +104,39 @@ export class AirConditioner {
102
104
  }
103
105
 
104
106
  if (this.meter) {
105
- this.coolerService
106
- .getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
107
- .onGet(this.CurrentRelativeHumidityGet.bind(this));
107
+ this.coolerService.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity).onGet(this.CurrentRelativeHumidityGet.bind(this));
108
108
  }
109
109
 
110
- this.coolerService.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState)
110
+ this.coolerService
111
+ .getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState)
111
112
  .setProps({
112
113
  validValues: this.ValidValues,
113
114
  })
114
115
  .onGet(this.TargetHeaterCoolerStateGet.bind(this))
115
116
  .onSet(this.TargetHeaterCoolerStateSet.bind(this));
116
117
 
117
- this.coolerService.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
118
- .onGet(this.CurrentHeaterCoolerStateGet.bind(this));
118
+ this.coolerService.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).onGet(this.CurrentHeaterCoolerStateGet.bind(this));
119
119
 
120
-
121
- this.coolerService.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
120
+ this.coolerService
121
+ .getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
122
122
  .setProps({
123
123
  minStep: 0.5,
124
124
  })
125
125
  .onGet(this.ThresholdTemperatureGet.bind(this))
126
126
  .onSet(this.ThresholdTemperatureSet.bind(this));
127
127
 
128
- this.coolerService.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature)
128
+ this.coolerService
129
+ .getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature)
129
130
  .setProps({
130
131
  minStep: 0.5,
131
132
  })
132
133
  .onGet(this.ThresholdTemperatureGet.bind(this))
133
134
  .onSet(this.ThresholdTemperatureSet.bind(this));
134
135
 
135
- this.coolerService.getCharacteristic(this.platform.Characteristic.RotationSpeed)
136
+ this.coolerService
137
+ .getCharacteristic(this.platform.Characteristic.RotationSpeed)
136
138
  .setProps({
137
- format: "int",
139
+ format: 'int',
138
140
  minStep: 1,
139
141
  minValue: 1,
140
142
  maxValue: 4,
@@ -153,38 +155,44 @@ export class AirConditioner {
153
155
  * AirConditioner: "command" "highSpeed" "default" = fan speed to high
154
156
  */
155
157
  async pushAirConditionerOnChanges(): Promise<void> {
156
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges Active: ${this.Active},`
157
- + ` disablePushOn: ${this.disablePushOn}`);
158
+ this.debugLog(
159
+ `${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges Active: ${this.Active},` +
160
+ ` disablePushOn: ${this.disablePushOn}`,
161
+ );
158
162
  if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
159
163
  const commandType: string = await this.commandType();
160
164
  const command: string = await this.commandOn();
161
165
  const bodyChange = JSON.stringify({
162
- 'command': command,
163
- 'parameter': 'default',
164
- 'commandType': commandType,
166
+ command: command,
167
+ parameter: 'default',
168
+ commandType: commandType,
165
169
  });
166
170
  await this.pushChanges(bodyChange);
167
171
  }
168
172
  }
169
173
 
170
174
  async pushAirConditionerOffChanges(): Promise<void> {
171
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges Active: ${this.Active},`
172
- + ` disablePushOff: ${this.disablePushOff}`);
175
+ this.debugLog(
176
+ `${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges Active: ${this.Active},` +
177
+ ` disablePushOff: ${this.disablePushOff}`,
178
+ );
173
179
  if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
174
180
  const commandType: string = await this.commandType();
175
181
  const command: string = await this.commandOff();
176
182
  const bodyChange = JSON.stringify({
177
- 'command': command,
178
- 'parameter': 'default',
179
- 'commandType': commandType,
183
+ command: command,
184
+ parameter: 'default',
185
+ commandType: commandType,
180
186
  });
181
187
  await this.pushChanges(bodyChange);
182
188
  }
183
189
  }
184
190
 
185
191
  async pushAirConditionerStatusChanges(): Promise<void> {
186
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerStatusChanges Active: ${this.Active},`
187
- + ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
192
+ this.debugLog(
193
+ `${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerStatusChanges Active: ${this.Active},` +
194
+ ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`,
195
+ );
188
196
  if (!this.Busy) {
189
197
  this.Busy = true;
190
198
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
@@ -196,8 +204,10 @@ export class AirConditioner {
196
204
  }
197
205
 
198
206
  async pushAirConditionerDetailsChanges(): Promise<void> {
199
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerDetailsChanges Active: ${this.Active},`
200
- + ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
207
+ this.debugLog(
208
+ `${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerDetailsChanges Active: ${this.Active},` +
209
+ ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`,
210
+ );
201
211
  //await this.context();
202
212
  if (this.CurrentMode === undefined) {
203
213
  this.CurrentMode = 1;
@@ -214,8 +224,8 @@ export class AirConditioner {
214
224
  // Remove or make configurable?
215
225
  this.ThresholdTemperature = 25;
216
226
  this.debugLog(
217
- `${this.device.remoteType}: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},`
218
- + ` ThresholdTemperature: ${this.ThresholdTemperature}`,
227
+ `${this.device.remoteType}: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},` +
228
+ ` ThresholdTemperature: ${this.ThresholdTemperature}`,
219
229
  );
220
230
  }
221
231
  const parameter = `${this.ThresholdTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
@@ -231,9 +241,9 @@ export class AirConditioner {
231
241
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
232
242
  }
233
243
  const bodyChange = JSON.stringify({
234
- 'command': 'setAll',
235
- 'parameter': `${parameter}`,
236
- 'commandType': 'command',
244
+ command: 'setAll',
245
+ parameter: `${parameter}`,
246
+ commandType: 'command',
237
247
  });
238
248
 
239
249
  await this.pushChanges(bodyChange);
@@ -242,7 +252,7 @@ export class AirConditioner {
242
252
  async pushChanges(bodyChange: any): Promise<void> {
243
253
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
244
254
  if (this.device.connectionType === 'OpenAPI' && !this.disablePushDetail) {
245
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
255
+ this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
246
256
  try {
247
257
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
248
258
  body: bodyChange,
@@ -256,25 +266,33 @@ export class AirConditioner {
256
266
  this.updateHomeKitCharacteristics();
257
267
  } catch (e: any) {
258
268
  this.apiError(e);
259
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
260
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`,
269
+ this.errorLog(
270
+ `${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}` +
271
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
261
272
  );
262
273
  }
263
274
  } else {
264
- this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
265
- + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
266
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
267
- + ` Connection Type: ${this.device.connectionType}, disablePushDetails: ${this.disablePushDetail}`);
275
+ this.warnLog(
276
+ `${this.device.remoteType}: ${this.accessory.displayName}` +
277
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`,
278
+ );
279
+ this.debugLog(
280
+ `${this.device.remoteType}: ${this.accessory.displayName}` +
281
+ ` Connection Type: ${this.device.connectionType}, disablePushDetails: ${this.disablePushDetail}`,
282
+ );
268
283
  this.updateHomeKitCharacteristics();
269
284
  }
270
285
  }
271
286
 
272
287
  async CurrentTemperatureGet(): Promise<CharacteristicValue> {
273
288
  if (this.meter) {
274
- this.CurrentTemperature = this.meter.context?.CurrentTemperature
275
- || this.meter.getService(this.platform.Service.TemperatureSensor)?.getCharacteristic(this.platform.Characteristic.CurrentTemperature).value
276
- || 24;
277
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using CurrentTemperature from ${this.meter.context?.deviceType} (${this.meter.context?.deviceID})`)
289
+ this.CurrentTemperature =
290
+ this.meter.context?.CurrentTemperature ||
291
+ this.meter.getService(this.platform.Service.TemperatureSensor)?.getCharacteristic(this.platform.Characteristic.CurrentTemperature).value ||
292
+ 24;
293
+ this.debugLog(
294
+ `${this.device.remoteType}: ${this.accessory.displayName} Using CurrentTemperature from ${this.meter.context?.deviceType} (${this.meter.context?.deviceID})`,
295
+ );
278
296
  } else if (this.CurrentTemperature === undefined) {
279
297
  this.CurrentTemperature = 24;
280
298
  } else {
@@ -286,15 +304,16 @@ export class AirConditioner {
286
304
 
287
305
  async CurrentRelativeHumidityGet(): Promise<CharacteristicValue> {
288
306
  if (this.meter) {
289
- this.CurrentRelativeHumidity = this.meter.context?.CurrentRelativeHumidity
290
- || this.meter.getService(this.platform.Service.HumiditySensor)?.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity).value
291
- || 0;
292
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using CurrentRelativeHumidity from ${this.meter.context?.deviceType} (${this.meter.context?.deviceID})`)
293
- }
294
- else if (this.CurrentRelativeHumidity === undefined) {
307
+ this.CurrentRelativeHumidity =
308
+ this.meter.context?.CurrentRelativeHumidity ||
309
+ this.meter.getService(this.platform.Service.HumiditySensor)?.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity).value ||
310
+ 0;
311
+ this.debugLog(
312
+ `${this.device.remoteType}: ${this.accessory.displayName} Using CurrentRelativeHumidity from ${this.meter.context?.deviceType} (${this.meter.context?.deviceID})`,
313
+ );
314
+ } else if (this.CurrentRelativeHumidity === undefined) {
295
315
  this.CurrentRelativeHumidity = 0;
296
- }
297
- else {
316
+ } else {
298
317
  this.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity;
299
318
  }
300
319
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
@@ -402,17 +421,20 @@ export class AirConditioner {
402
421
  if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
403
422
  if (this.ThresholdTemperature < this.accessory.context.CurrentTemperature) {
404
423
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
405
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
406
- + ` Get (COOLING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
424
+ this.debugLog(
425
+ `${this.device.remoteType}: ${this.accessory.displayName}` + ` Get (COOLING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
426
+ );
407
427
  } else if (this.ThresholdTemperature > this.accessory.context.CurrentTemperature) {
408
428
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
409
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
410
- + ` Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
429
+ this.debugLog(
430
+ `${this.device.remoteType}: ${this.accessory.displayName}` + ` Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
431
+ );
411
432
  }
412
433
  } else {
413
434
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
414
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
415
- + ` Get (INACTIVE) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
435
+ this.debugLog(
436
+ `${this.device.remoteType}: ${this.accessory.displayName}` + ` Get (INACTIVE) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
437
+ );
416
438
  }
417
439
  return this.CurrentHeaterCoolerState;
418
440
  }
@@ -425,8 +447,10 @@ export class AirConditioner {
425
447
 
426
448
  async ThresholdTemperatureSet(value: CharacteristicValue): Promise<void> {
427
449
  this.ThresholdTemperature = value;
428
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set ThresholdTemperature: ${this.ThresholdTemperature},` +
429
- ` ThresholdTemperatureCached: ${this.accessory.context.ThresholdTemperature}`);
450
+ this.debugLog(
451
+ `${this.device.remoteType}: ${this.accessory.displayName} Set ThresholdTemperature: ${this.ThresholdTemperature},` +
452
+ ` ThresholdTemperatureCached: ${this.accessory.context.ThresholdTemperature}`,
453
+ );
430
454
  this.pushAirConditionerStatusChanges();
431
455
  }
432
456
 
@@ -455,11 +479,12 @@ export class AirConditioner {
455
479
  if (this.meter) {
456
480
  if (this.CurrentRelativeHumidity === undefined) {
457
481
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
458
- }
459
- else {
482
+ } else {
460
483
  this.accessory.context.CurrentRelativeHumidity = this.CurrentRelativeHumidity;
461
484
  this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
462
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
485
+ this.debugLog(
486
+ `${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`,
487
+ );
463
488
  }
464
489
  }
465
490
  if (this.TargetHeaterCoolerState === undefined) {
@@ -477,8 +502,8 @@ export class AirConditioner {
477
502
  this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerState;
478
503
  this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
479
504
  this.debugLog(
480
- `${this.device.remoteType}: ${this.accessory.displayName}`
481
- + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
505
+ `${this.device.remoteType}: ${this.accessory.displayName}` +
506
+ ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
482
507
  );
483
508
  }
484
509
  if (this.ThresholdTemperature === undefined) {
@@ -488,13 +513,12 @@ export class AirConditioner {
488
513
  this.coolerService?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.ThresholdTemperature);
489
514
  this.coolerService?.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, this.ThresholdTemperature);
490
515
  this.debugLog(
491
- `${this.device.remoteType}: ${this.accessory.displayName}`
492
- + ` updateCharacteristic ThresholdTemperature: ${this.ThresholdTemperature}`,
516
+ `${this.device.remoteType}: ${this.accessory.displayName}` + ` updateCharacteristic ThresholdTemperature: ${this.ThresholdTemperature}`,
493
517
  );
494
518
  }
495
519
  }
496
520
 
497
- async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
521
+ async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
498
522
  if (device.disablePushOn === undefined) {
499
523
  this.disablePushOn = false;
500
524
  } else {
@@ -502,7 +526,7 @@ export class AirConditioner {
502
526
  }
503
527
  }
504
528
 
505
- async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
529
+ async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
506
530
  if (device.disablePushOff === undefined) {
507
531
  this.disablePushOff = false;
508
532
  } else {
@@ -510,7 +534,7 @@ export class AirConditioner {
510
534
  }
511
535
  }
512
536
 
513
- async disablePushDetailChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
537
+ async disablePushDetailChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
514
538
  if (device.disablePushDetail === undefined) {
515
539
  this.disablePushDetail = false;
516
540
  } else {
@@ -563,8 +587,10 @@ export class AirConditioner {
563
587
  this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
564
588
  break;
565
589
  case 171:
566
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. `
567
- + `Hub: ${this.device.hubDeviceId}`);
590
+ this.errorLog(
591
+ `${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
592
+ `Hub: ${this.device.hubDeviceId}`,
593
+ );
568
594
  break;
569
595
  case 190:
570
596
  this.errorLog(
@@ -579,12 +605,14 @@ export class AirConditioner {
579
605
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
580
606
  break;
581
607
  default:
582
- this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: `
583
- + `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
608
+ this.infoLog(
609
+ `${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: ` +
610
+ `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
611
+ );
584
612
  }
585
613
  }
586
614
 
587
- async apiError({ e }: { e: any; }): Promise<void> {
615
+ async apiError({ e }: { e: any }): Promise<void> {
588
616
  this.coolerService.updateCharacteristic(this.platform.Characteristic.Active, e);
589
617
  this.coolerService.updateCharacteristic(this.platform.Characteristic.RotationSpeed, e);
590
618
  this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
@@ -595,10 +623,11 @@ export class AirConditioner {
595
623
  this.coolerService.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, e);
596
624
  }
597
625
 
598
- FirmwareRevision({ accessory, device }: { accessory: PlatformAccessory; device: irdevice & irDevicesConfig; }): string {
626
+ FirmwareRevision({ accessory, device }: { accessory: PlatformAccessory; device: irdevice & irDevicesConfig }): string {
599
627
  let FirmwareRevision: string;
600
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
601
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
628
+ this.debugLog(
629
+ `${this.device.remoteType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
630
+ );
602
631
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
603
632
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
604
633
  if (accessory.context.FirmwareRevision) {
@@ -653,7 +682,7 @@ export class AirConditioner {
653
682
  }
654
683
  }
655
684
 
656
- async config({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
685
+ async config({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
657
686
  let config = {};
658
687
  if (device.irair) {
659
688
  config = device.irair;
@@ -690,7 +719,7 @@ export class AirConditioner {
690
719
  }
691
720
  }
692
721
 
693
- async logs({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
722
+ async logs({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
694
723
  if (this.platform.debugMode) {
695
724
  this.deviceLogging = this.accessory.context.logging = 'debugMode';
696
725
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
@@ -753,4 +782,3 @@ export class AirConditioner {
753
782
  return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
754
783
  }
755
784
  }
756
-
@@ -38,7 +38,11 @@ export class AirPurifier {
38
38
  disablePushOff?: boolean;
39
39
  deviceLogging!: string;
40
40
 
41
- constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
41
+ constructor(
42
+ private readonly platform: SwitchBotPlatform,
43
+ private accessory: PlatformAccessory,
44
+ public device: irdevice & irDevicesConfig,
45
+ ) {
42
46
  // default placeholders
43
47
  this.logs(device);
44
48
  this.config(device);
@@ -129,38 +133,44 @@ export class AirPurifier {
129
133
  * AirPurifier: "command" "highSpeed" "default" = fan speed to high
130
134
  */
131
135
  async pushAirPurifierOnChanges(): Promise<void> {
132
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirPurifierOnChanges Active: ${this.Active},`
133
- + ` disablePushOn: ${this.disablePushOn}`);
136
+ this.debugLog(
137
+ `${this.device.remoteType}: ${this.accessory.displayName} pushAirPurifierOnChanges Active: ${this.Active},` +
138
+ ` disablePushOn: ${this.disablePushOn}`,
139
+ );
134
140
  if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
135
141
  const commandType: string = await this.commandType();
136
142
  const command: string = await this.commandOn();
137
143
  const bodyChange = JSON.stringify({
138
- 'command': command,
139
- 'parameter': 'default',
140
- 'commandType': commandType,
144
+ command: command,
145
+ parameter: 'default',
146
+ commandType: commandType,
141
147
  });
142
148
  await this.pushChanges(bodyChange);
143
149
  }
144
150
  }
145
151
 
146
152
  async pushAirPurifierOffChanges(): Promise<void> {
147
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirPurifierOffChanges Active: ${this.Active},`
148
- + ` disablePushOff: ${this.disablePushOff}`);
153
+ this.debugLog(
154
+ `${this.device.remoteType}: ${this.accessory.displayName} pushAirPurifierOffChanges Active: ${this.Active},` +
155
+ ` disablePushOff: ${this.disablePushOff}`,
156
+ );
149
157
  if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOn) {
150
158
  const commandType: string = await this.commandType();
151
159
  const command: string = await this.commandOff();
152
160
  const bodyChange = JSON.stringify({
153
- 'command': command,
154
- 'parameter': 'default',
155
- 'commandType': commandType,
161
+ command: command,
162
+ parameter: 'default',
163
+ commandType: commandType,
156
164
  });
157
165
  await this.pushChanges(bodyChange);
158
166
  }
159
167
  }
160
168
 
161
169
  async pushAirPurifierStatusChanges(): Promise<void> {
162
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirPurifierStatusChanges Active: ${this.Active},`
163
- + ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
170
+ this.debugLog(
171
+ `${this.device.remoteType}: ${this.accessory.displayName} pushAirPurifierStatusChanges Active: ${this.Active},` +
172
+ ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`,
173
+ );
164
174
  if (!this.Busy) {
165
175
  this.Busy = true;
166
176
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
@@ -172,17 +182,19 @@ export class AirPurifier {
172
182
  }
173
183
 
174
184
  async pushAirPurifierDetailsChanges(): Promise<void> {
175
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirPurifierDetailsChanges Active: ${this.Active},`
176
- + ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
185
+ this.debugLog(
186
+ `${this.device.remoteType}: ${this.accessory.displayName} pushAirPurifierDetailsChanges Active: ${this.Active},` +
187
+ ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`,
188
+ );
177
189
  this.CurrentAPTemp = this.CurrentTemperature || 24;
178
190
  this.CurrentAPMode = this.CurrentMode || 1;
179
191
  this.CurrentAPFanSpeed = this.CurrentFanSpeed || 1;
180
192
  this.APActive = this.Active === 1 ? 'on' : 'off';
181
193
  const parameter = `${this.CurrentAPTemp},${this.CurrentAPMode},${this.CurrentAPFanSpeed},${this.APActive}`;
182
194
  const bodyChange = JSON.stringify({
183
- 'command': 'setAll',
184
- 'parameter': `${parameter}`,
185
- 'commandType': 'command',
195
+ command: 'setAll',
196
+ parameter: `${parameter}`,
197
+ commandType: 'command',
186
198
  });
187
199
  if (this.Active === 1) {
188
200
  if ((Number(this.CurrentTemperature) || 24) < (this.LastTemperature || 30)) {
@@ -213,13 +225,16 @@ export class AirPurifier {
213
225
  this.updateHomeKitCharacteristics();
214
226
  } catch (e: any) {
215
227
  this.apiError(e);
216
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
217
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`,
228
+ this.errorLog(
229
+ `${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}` +
230
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
218
231
  );
219
232
  }
220
233
  } else {
221
- this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
222
- + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
234
+ this.warnLog(
235
+ `${this.device.remoteType}: ${this.accessory.displayName}` +
236
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`,
237
+ );
223
238
  }
224
239
  }
225
240
 
@@ -236,8 +251,9 @@ export class AirPurifier {
236
251
  } else {
237
252
  this.accessory.context.CurrentAirPurifierState = this.CurrentAirPurifierState;
238
253
  this.airPurifierService?.updateCharacteristic(this.platform.Characteristic.CurrentAirPurifierState, this.CurrentAirPurifierState);
239
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
240
- + ` updateCharacteristic CurrentAirPurifierState: ${this.CurrentAirPurifierState}`);
254
+ this.debugLog(
255
+ `${this.device.remoteType}: ${this.accessory.displayName}` + ` updateCharacteristic CurrentAirPurifierState: ${this.CurrentAirPurifierState}`,
256
+ );
241
257
  }
242
258
  if (this.CurrentHeaterCoolerState === undefined) {
243
259
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
@@ -245,13 +261,13 @@ export class AirPurifier {
245
261
  this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerState;
246
262
  this.airPurifierService?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
247
263
  this.debugLog(
248
- `${this.device.remoteType}: ${this.accessory.displayName}`
249
- + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
264
+ `${this.device.remoteType}: ${this.accessory.displayName}` +
265
+ ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
250
266
  );
251
267
  }
252
268
  }
253
269
 
254
- async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
270
+ async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
255
271
  if (device.disablePushOn === undefined) {
256
272
  this.disablePushOn = false;
257
273
  } else {
@@ -259,7 +275,7 @@ export class AirPurifier {
259
275
  }
260
276
  }
261
277
 
262
- async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
278
+ async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
263
279
  if (device.disablePushOff === undefined) {
264
280
  this.disablePushOff = false;
265
281
  } else {
@@ -312,8 +328,10 @@ export class AirPurifier {
312
328
  this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
313
329
  break;
314
330
  case 171:
315
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. `
316
- + `Hub: ${this.device.hubDeviceId}`);
331
+ this.errorLog(
332
+ `${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
333
+ `Hub: ${this.device.hubDeviceId}`,
334
+ );
317
335
  break;
318
336
  case 190:
319
337
  this.errorLog(
@@ -328,8 +346,10 @@ export class AirPurifier {
328
346
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
329
347
  break;
330
348
  default:
331
- this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: `
332
- + `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
349
+ this.infoLog(
350
+ `${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: ` +
351
+ `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
352
+ );
333
353
  }
334
354
  }
335
355
 
@@ -342,8 +362,9 @@ export class AirPurifier {
342
362
 
343
363
  FirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): string {
344
364
  let FirmwareRevision: string;
345
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
346
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
365
+ this.debugLog(
366
+ `${this.device.remoteType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
367
+ );
347
368
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
348
369
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
349
370
  if (accessory.context.FirmwareRevision) {