@switchbot/homebridge-switchbot 2.0.0-beta.18 → 2.0.0-beta.19

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 (106) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/config.schema.json +11 -2
  3. package/dist/device/bot.d.ts +2 -0
  4. package/dist/device/bot.d.ts.map +1 -1
  5. package/dist/device/bot.js +201 -163
  6. package/dist/device/bot.js.map +1 -1
  7. package/dist/device/colorbulb.d.ts +2 -0
  8. package/dist/device/colorbulb.d.ts.map +1 -1
  9. package/dist/device/colorbulb.js +250 -218
  10. package/dist/device/colorbulb.js.map +1 -1
  11. package/dist/device/contact.d.ts +2 -0
  12. package/dist/device/contact.d.ts.map +1 -1
  13. package/dist/device/contact.js +85 -66
  14. package/dist/device/contact.js.map +1 -1
  15. package/dist/device/curtain.d.ts +2 -0
  16. package/dist/device/curtain.d.ts.map +1 -1
  17. package/dist/device/curtain.js +166 -136
  18. package/dist/device/curtain.js.map +1 -1
  19. package/dist/device/humidifier.d.ts.map +1 -1
  20. package/dist/device/humidifier.js +126 -115
  21. package/dist/device/humidifier.js.map +1 -1
  22. package/dist/device/lock.d.ts +2 -0
  23. package/dist/device/lock.d.ts.map +1 -1
  24. package/dist/device/lock.js +156 -130
  25. package/dist/device/lock.js.map +1 -1
  26. package/dist/device/meter.d.ts +2 -0
  27. package/dist/device/meter.d.ts.map +1 -1
  28. package/dist/device/meter.js +85 -64
  29. package/dist/device/meter.js.map +1 -1
  30. package/dist/device/meterplus.d.ts +2 -0
  31. package/dist/device/meterplus.d.ts.map +1 -1
  32. package/dist/device/meterplus.js +78 -59
  33. package/dist/device/meterplus.js.map +1 -1
  34. package/dist/device/motion.d.ts +2 -0
  35. package/dist/device/motion.d.ts.map +1 -1
  36. package/dist/device/motion.js +76 -57
  37. package/dist/device/motion.js.map +1 -1
  38. package/dist/device/plug.d.ts +2 -0
  39. package/dist/device/plug.d.ts.map +1 -1
  40. package/dist/device/plug.js +133 -107
  41. package/dist/device/plug.js.map +1 -1
  42. package/dist/device/striplight.d.ts +2 -0
  43. package/dist/device/striplight.d.ts.map +1 -1
  44. package/dist/device/striplight.js +224 -195
  45. package/dist/device/striplight.js.map +1 -1
  46. package/dist/irdevice/airconditioner.d.ts +2 -0
  47. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  48. package/dist/irdevice/airconditioner.js +127 -105
  49. package/dist/irdevice/airconditioner.js.map +1 -1
  50. package/dist/irdevice/airpurifier.d.ts +2 -0
  51. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  52. package/dist/irdevice/airpurifier.js +83 -66
  53. package/dist/irdevice/airpurifier.js.map +1 -1
  54. package/dist/irdevice/camera.d.ts +8 -6
  55. package/dist/irdevice/camera.d.ts.map +1 -1
  56. package/dist/irdevice/camera.js +83 -68
  57. package/dist/irdevice/camera.js.map +1 -1
  58. package/dist/irdevice/fan.d.ts +7 -5
  59. package/dist/irdevice/fan.d.ts.map +1 -1
  60. package/dist/irdevice/fan.js +90 -75
  61. package/dist/irdevice/fan.js.map +1 -1
  62. package/dist/irdevice/light.d.ts +8 -6
  63. package/dist/irdevice/light.d.ts.map +1 -1
  64. package/dist/irdevice/light.js +83 -68
  65. package/dist/irdevice/light.js.map +1 -1
  66. package/dist/irdevice/other.d.ts +8 -6
  67. package/dist/irdevice/other.d.ts.map +1 -1
  68. package/dist/irdevice/other.js +93 -78
  69. package/dist/irdevice/other.js.map +1 -1
  70. package/dist/irdevice/tv.d.ts +8 -6
  71. package/dist/irdevice/tv.d.ts.map +1 -1
  72. package/dist/irdevice/tv.js +68 -52
  73. package/dist/irdevice/tv.js.map +1 -1
  74. package/dist/irdevice/vacuumcleaner.d.ts +8 -6
  75. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  76. package/dist/irdevice/vacuumcleaner.js +83 -69
  77. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  78. package/dist/irdevice/waterheater.d.ts +2 -0
  79. package/dist/irdevice/waterheater.d.ts.map +1 -1
  80. package/dist/irdevice/waterheater.js +75 -60
  81. package/dist/irdevice/waterheater.js.map +1 -1
  82. package/dist/settings.d.ts +12 -11
  83. package/dist/settings.d.ts.map +1 -1
  84. package/dist/settings.js.map +1 -1
  85. package/package.json +1 -1
  86. package/src/device/bot.ts +200 -163
  87. package/src/device/colorbulb.ts +252 -221
  88. package/src/device/contact.ts +85 -66
  89. package/src/device/curtain.ts +165 -136
  90. package/src/device/humidifier.ts +126 -115
  91. package/src/device/lock.ts +156 -131
  92. package/src/device/meter.ts +85 -64
  93. package/src/device/meterplus.ts +78 -59
  94. package/src/device/motion.ts +76 -57
  95. package/src/device/plug.ts +132 -107
  96. package/src/device/striplight.ts +226 -198
  97. package/src/irdevice/airconditioner.ts +126 -103
  98. package/src/irdevice/airpurifier.ts +84 -66
  99. package/src/irdevice/camera.ts +84 -68
  100. package/src/irdevice/fan.ts +91 -75
  101. package/src/irdevice/light.ts +84 -68
  102. package/src/irdevice/other.ts +94 -78
  103. package/src/irdevice/tv.ts +69 -53
  104. package/src/irdevice/vacuumcleaner.ts +83 -68
  105. package/src/irdevice/waterheater.ts +76 -60
  106. package/src/settings.ts +12 -11
@@ -46,6 +46,7 @@ export class AirConditioner {
46
46
  deviceLogging!: string;
47
47
  hide_automode?: boolean;
48
48
  pushOn?: boolean;
49
+ OpenAPI?: boolean;
49
50
 
50
51
  private readonly valid12 = [1, 2];
51
52
  private readonly valid012 = [0, 1, 2];
@@ -111,14 +112,14 @@ export class AirConditioner {
111
112
  this.TargetHeaterCoolerState = 1 || 2;
112
113
  this.ValidValues = [1, 2];
113
114
  this.debugLog(
114
- `Air Conditioner: ${this.accessory.displayName} ValidValues: ${superStringify(this.ValidValues)},` +
115
+ `${this.device.remoteType}: ${this.accessory.displayName} ValidValues: ${superStringify(this.ValidValues)},` +
115
116
  ` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
116
117
  );
117
118
  } else {
118
119
  this.TargetHeaterCoolerState = 0 || 1 || 2;
119
120
  this.ValidValues = [0, 1, 2];
120
121
  this.debugLog(
121
- `Air Conditioner: ${this.accessory.displayName} ValidValues: ${superStringify(this.ValidValues)},` +
122
+ `${this.device.remoteType}: ${this.accessory.displayName} ValidValues: ${superStringify(this.ValidValues)},` +
122
123
  ` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
123
124
  );
124
125
  }
@@ -229,7 +230,8 @@ export class AirConditioner {
229
230
  if (this.CurrentMode === 1) {
230
231
  this.CurrentTemperature = 25;
231
232
  this.debugLog(
232
- `Air Conditioner: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},` + ` CurrentTemperature: ${this.CurrentTemperature}`,
233
+ `${this.device.remoteType}: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},`
234
+ + ` CurrentTemperature: ${this.CurrentTemperature}`,
233
235
  );
234
236
  }
235
237
  const parameter = `${this.CurrentTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
@@ -254,142 +256,148 @@ export class AirConditioner {
254
256
  }
255
257
 
256
258
  async pushChanges(body): Promise<void> {
257
- try {
259
+ if (this.OpenAPI) {
260
+ try {
258
261
  // Make Push On request to the API
259
- const t = Date.now();
260
- const nonce = 'requestID';
261
- const data = this.platform.config.credentials?.token + t + nonce;
262
- const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret)
263
- .update(Buffer.from(data, 'utf-8'))
264
- .digest();
265
- const sign = signTerm.toString('base64');
266
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} sign: ${sign}`);
267
- this.infoLog(`Air Conditioner: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
268
- const options = {
269
- hostname: HostDomain,
270
- port: 443,
271
- path: `${DevicePath}/${this.device.deviceId}/commands`,
272
- method: 'POST',
273
- headers: {
274
- 'Authorization': this.platform.config.credentials?.token,
275
- 'sign': sign,
276
- 'nonce': nonce,
277
- 't': t,
278
- 'Content-Type': 'application/json',
279
- 'Content-Length': body.length,
280
- },
281
- };
282
- const req = https.request(options, res => {
283
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
284
- this.statusCode({ res });
285
- res.on('data', d => {
286
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} d: ${d}`);
262
+ const t = Date.now();
263
+ const nonce = 'requestID';
264
+ const data = this.platform.config.credentials?.token + t + nonce;
265
+ const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret)
266
+ .update(Buffer.from(data, 'utf-8'))
267
+ .digest();
268
+ const sign = signTerm.toString('base64');
269
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} sign: ${sign}`);
270
+ this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
271
+ const options = {
272
+ hostname: HostDomain,
273
+ port: 443,
274
+ path: `${DevicePath}/${this.device.deviceId}/commands`,
275
+ method: 'POST',
276
+ headers: {
277
+ 'Authorization': this.platform.config.credentials?.token,
278
+ 'sign': sign,
279
+ 'nonce': nonce,
280
+ 't': t,
281
+ 'Content-Type': 'application/json',
282
+ 'Content-Length': body.length,
283
+ },
284
+ };
285
+ const req = https.request(options, res => {
286
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
287
+ this.statusCode({ res });
288
+ res.on('data', d => {
289
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} d: ${d}`);
290
+ });
287
291
  });
288
- });
289
- req.on('error', (e: any) => {
290
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} error message: ${e.message}`);
291
- });
292
- req.write(body);
293
- req.end();
294
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushchanges: ${superStringify(req)}`);
295
- this.CurrentTemperatureCached = this.CurrentTemperature;
296
- this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
297
- this.HeatingThresholdTemperature = this.CurrentTemperatureCached;
298
- this.HeatingThresholdTemperatureCached = this.CurrentTemperatureCached;
299
- this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
300
- this.CoolingThresholdTemperature = this.CurrentTemperatureCached;
301
- this.CoolingThresholdTemperatureCached = this.CurrentTemperatureCached;
302
- this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
303
- this.updateHomeKitCharacteristics();
304
- } catch (e: any) {
305
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges`);
306
- if (this.deviceLogging.includes('debug')) {
307
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${superStringify(e.message)}`);
292
+ req.on('error', (e: any) => {
293
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} error message: ${e.message}`);
294
+ });
295
+ req.write(body);
296
+ req.end();
297
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges: ${superStringify(req)}`);
298
+ this.CurrentTemperatureCached = this.CurrentTemperature;
299
+ this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
300
+ this.HeatingThresholdTemperature = this.CurrentTemperatureCached;
301
+ this.HeatingThresholdTemperatureCached = this.CurrentTemperatureCached;
302
+ this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
303
+ this.CoolingThresholdTemperature = this.CurrentTemperatureCached;
304
+ this.CoolingThresholdTemperatureCached = this.CurrentTemperatureCached;
305
+ this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
306
+ this.updateHomeKitCharacteristics();
307
+ } catch (e: any) {
308
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges`);
309
+ if (this.deviceLogging.includes('debug')) {
310
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges,`
311
+ + ` Error Message: ${superStringify(e.message)}`);
312
+ }
313
+ this.apiError(e);
308
314
  }
309
- this.apiError(e);
310
315
  }
311
316
  }
312
317
 
313
318
  async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
314
319
  switch (res.statusCode) {
315
320
  case 151:
316
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Command not supported by this device type.`);
321
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command not supported by this device type.`);
317
322
  break;
318
323
  case 152:
319
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device not found.`);
324
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device not found.`);
320
325
  break;
321
326
  case 160:
322
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Command is not supported.`);
327
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command is not supported.`);
323
328
  break;
324
329
  case 161:
325
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device is offline.`);
330
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline.`);
326
331
  break;
327
332
  case 171:
328
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
333
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
329
334
  break;
330
335
  case 190:
331
336
  this.errorLog(
332
- `Air Conditioner: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
337
+ `${this.device.remoteType}: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
333
338
  ` with server, Or command: ${superStringify(res)} format is invalid`,
334
339
  );
335
340
  break;
336
341
  case 100:
337
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Command successfully sent.`);
342
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent.`);
338
343
  break;
339
344
  default:
340
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Unknown statusCode.`);
345
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode.`);
341
346
  }
342
347
  }
343
348
 
344
349
  async updateHomeKitCharacteristics(): Promise<void> {
345
350
  if (this.Active === undefined) {
346
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Active: ${this.Active}`);
351
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`);
347
352
  } else {
348
353
  this.coolerService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
349
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
354
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
350
355
  }
351
356
  if (this.RotationSpeed === undefined) {
352
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
357
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
353
358
  } else {
354
359
  this.coolerService?.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed);
355
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`);
360
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`);
356
361
  }
357
362
  if (this.CurrentTemperature === undefined) {
358
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
363
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
359
364
  } else {
360
365
  this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
361
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
366
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
362
367
  }
363
368
  if (this.TargetHeaterCoolerState === undefined) {
364
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
369
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
365
370
  } else {
366
371
  this.coolerService?.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.TargetHeaterCoolerState);
367
372
  this.debugLog(
368
- `Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
373
+ `${this.device.remoteType}: ${this.accessory.displayName}` + ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
369
374
  );
370
375
  }
371
376
  if (this.CurrentHeaterCoolerState === undefined) {
372
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
377
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
373
378
  } else {
374
379
  this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
375
380
  this.debugLog(
376
- `Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
381
+ `${this.device.remoteType}: ${this.accessory.displayName}`
382
+ + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
377
383
  );
378
384
  }
379
385
  if (this.HeatingThresholdTemperature === undefined) {
380
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
386
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
381
387
  } else {
382
388
  this.coolerService?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.HeatingThresholdTemperature);
383
389
  this.debugLog(
384
- `Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`,
390
+ `${this.device.remoteType}: ${this.accessory.displayName}`
391
+ + ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`,
385
392
  );
386
393
  }
387
394
  if (this.CoolingThresholdTemperature === undefined) {
388
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
395
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
389
396
  } else {
390
397
  this.coolerService?.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, this.CoolingThresholdTemperature);
391
398
  this.debugLog(
392
- `Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`,
399
+ `${this.device.remoteType}: ${this.accessory.displayName}`
400
+ + ` updateCharacteristic CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`,
393
401
  );
394
402
  }
395
403
  }
@@ -412,7 +420,7 @@ export class AirConditioner {
412
420
  } else {
413
421
  this.CurrentTemperatureCached = this.CurrentTemperature;
414
422
  }
415
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`);
423
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`);
416
424
  this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
417
425
  return this.CurrentTemperature;
418
426
  }
@@ -425,7 +433,7 @@ export class AirConditioner {
425
433
  } else {
426
434
  this.RotationSpeed = this.CurrentFanSpeed - 1;
427
435
  }
428
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get RotationSpeed: ${this.RotationSpeed}`);
436
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get RotationSpeed: ${this.RotationSpeed}`);
429
437
  this.RotationSpeedCached = this.RotationSpeed;
430
438
  this.accessory.context.RotationSpeed = this.RotationSpeedCached;
431
439
  return this.RotationSpeed;
@@ -444,17 +452,17 @@ export class AirConditioner {
444
452
  }
445
453
 
446
454
  async ActiveSet(value: CharacteristicValue): Promise<void> {
447
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set Active: ${value}`);
455
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
448
456
 
449
457
  this.Active = value;
450
458
  this.ActiveCached = this.Active;
451
459
  this.accessory.context.Active = this.ActiveCached;
452
460
 
453
461
  if (value === this.platform.Characteristic.Active.INACTIVE) {
454
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
462
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
455
463
  this.pushAirConditionerOffChanges();
456
464
  } else {
457
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.Active}`);
465
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.Active}`);
458
466
  if (this.pushOn) {
459
467
  this.pushAirConditionerOnChanges();
460
468
  } else {
@@ -467,19 +475,19 @@ export class AirConditioner {
467
475
  if (this.ValidValues === this.valid012) {
468
476
  this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
469
477
  this.debugLog(
470
- `Air Conditioner: ${this.accessory.displayName} Get (AUTO) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
478
+ `${this.device.remoteType}: ${this.accessory.displayName} Get (AUTO) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
471
479
  ` ValidValues: ${this.ValidValues}`,
472
480
  );
473
481
  } else if (this.ValidValues === this.valid12) {
474
482
  this.TargetHeaterCoolerState =
475
483
  this.platform.Characteristic.TargetHeaterCoolerState.COOL || this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
476
484
  this.debugLog(
477
- `Air Conditioner: ${this.accessory.displayName} Get (COOL/HEAT) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
485
+ `${this.device.remoteType}: ${this.accessory.displayName} Get (COOL/HEAT) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
478
486
  ` ValidValues: ${this.ValidValues}`,
479
487
  );
480
488
  } else {
481
489
  this.debugLog(
482
- `Air Conditioner: ${this.accessory.displayName} Get TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
490
+ `${this.device.remoteType}: ${this.accessory.displayName} Get TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
483
491
  ` ValidValues: ${this.ValidValues}`,
484
492
  );
485
493
  }
@@ -496,7 +504,7 @@ export class AirConditioner {
496
504
  this.TargetHeaterCoolerStateCOOL();
497
505
  } else {
498
506
  this.errorLog(
499
- `Air Conditioner: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
507
+ `${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
500
508
  ` hide_automode: ${this.hide_automode} `,
501
509
  );
502
510
  }
@@ -509,7 +517,7 @@ export class AirConditioner {
509
517
  this.TargetHeaterCoolerStateCOOL();
510
518
  } else {
511
519
  this.errorLog(
512
- `Air Conditioner: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
520
+ `${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
513
521
  ` hide_automode: ${this.hide_automode} `,
514
522
  );
515
523
  }
@@ -522,22 +530,22 @@ export class AirConditioner {
522
530
  async TargetHeaterCoolerStateAUTO(): Promise<void> {
523
531
  this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
524
532
  this.CurrentMode = 1;
525
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set (AUTO) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
526
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
533
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (AUTO) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
534
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
527
535
  }
528
536
 
529
537
  async TargetHeaterCoolerStateCOOL(): Promise<void> {
530
538
  this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.COOL;
531
539
  this.CurrentMode = 2;
532
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set (COOL) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
533
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
540
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (COOL) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
541
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
534
542
  }
535
543
 
536
544
  async TargetHeaterCoolerStateHEAT(): Promise<void> {
537
545
  this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
538
546
  this.CurrentMode = 5;
539
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set (HEAT) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
540
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
547
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (HEAT) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
548
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
541
549
  }
542
550
 
543
551
  async CurrentHeaterCoolerStateGet(): Promise<CharacteristicValue> {
@@ -545,14 +553,17 @@ export class AirConditioner {
545
553
  this.CurrentTemperatureUndefined();
546
554
  if (this.CurrentTemperature < this.CurrentTemperatureCached) {
547
555
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
548
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (COOLLING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
556
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
557
+ +` Get (COOLLING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
549
558
  } else if (this.CurrentTemperature > this.CurrentTemperatureCached) {
550
559
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
551
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
560
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
561
+ +` Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
552
562
  }
553
563
  } else {
554
564
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
555
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (INACTIVE) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
565
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
566
+ +` Get (INACTIVE) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
556
567
  }
557
568
  this.CurrentHeaterCoolerStateCached = this.CurrentHeaterCoolerState;
558
569
  this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerStateCached;
@@ -565,7 +576,7 @@ export class AirConditioner {
565
576
  this.HeatingThresholdTemperature = this.CurrentTemperatureCached;
566
577
  this.HeatingThresholdTemperatureCached = this.HeatingThresholdTemperature;
567
578
  this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
568
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
579
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
569
580
  return this.HeatingThresholdTemperature;
570
581
  }
571
582
 
@@ -575,7 +586,7 @@ export class AirConditioner {
575
586
  this.HeatingThresholdTemperatureCached = this.HeatingThresholdTemperature;
576
587
  this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
577
588
  this.debugLog(
578
- `Air Conditioner: ${this.accessory.displayName} Set HeatingThresholdTemperature: ${this.HeatingThresholdTemperature},` +
589
+ `${this.device.remoteType}: ${this.accessory.displayName} Set HeatingThresholdTemperature: ${this.HeatingThresholdTemperature},` +
579
590
  ` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`,
580
591
  );
581
592
  this.pushAirConditionerStatusChanges();
@@ -587,7 +598,7 @@ export class AirConditioner {
587
598
  this.CoolingThresholdTemperature = this.CurrentTemperatureCached;
588
599
  this.CoolingThresholdTemperatureCached = this.CoolingThresholdTemperature;
589
600
  this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
590
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
601
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
591
602
  return this.CoolingThresholdTemperature;
592
603
  }
593
604
 
@@ -597,7 +608,7 @@ export class AirConditioner {
597
608
  this.CoolingThresholdTemperatureCached = this.CoolingThresholdTemperature;
598
609
  this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
599
610
  this.debugLog(
600
- `Air Conditioner: ${this.accessory.displayName} Set CoolingThresholdTemperature: ${this.CoolingThresholdTemperature},` +
611
+ `${this.device.remoteType}: ${this.accessory.displayName} Set CoolingThresholdTemperature: ${this.CoolingThresholdTemperature},` +
601
612
  ` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`,
602
613
  );
603
614
  this.pushAirConditionerStatusChanges();
@@ -612,6 +623,15 @@ export class AirConditioner {
612
623
  }
613
624
  }
614
625
 
626
+ async openAPI() {
627
+ if (!this.device.openAPI) {
628
+ this.OpenAPI = true;
629
+ } else {
630
+ this.OpenAPI = this.device.openAPI;
631
+ }
632
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using OpenAPI: ${this.OpenAPI}`);
633
+ }
634
+
615
635
  async config(device: irdevice & irDevicesConfig): Promise<void> {
616
636
  let config = {};
617
637
  if (device.irair) {
@@ -620,24 +640,27 @@ export class AirConditioner {
620
640
  if (device.logging !== undefined) {
621
641
  config['logging'] = device.logging;
622
642
  }
643
+ if (device.openAPI !== undefined) {
644
+ config['openAPI'] = device.openAPI;
645
+ }
623
646
  if (Object.entries(config).length !== 0) {
624
- this.infoLog(`Air Conditioner: ${this.accessory.displayName} Config: ${superStringify(config)}`);
647
+ this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
625
648
  }
626
649
  }
627
650
 
628
651
  async logs(device: irdevice & irDevicesConfig): Promise<void> {
629
652
  if (this.platform.debugMode) {
630
653
  this.deviceLogging = this.accessory.context.logging = 'debugMode';
631
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
654
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
632
655
  } else if (device.logging) {
633
656
  this.deviceLogging = this.accessory.context.logging = device.logging;
634
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
657
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
635
658
  } else if (this.platform.config.options?.logging) {
636
659
  this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
637
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
660
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
638
661
  } else {
639
662
  this.deviceLogging = this.accessory.context.logging = 'standard';
640
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
663
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
641
664
  }
642
665
  }
643
666