@switchbot/homebridge-switchbot 1.9.0 → 1.10.1

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 (116) hide show
  1. package/.eslintrc +14 -45
  2. package/.github/ISSUE_TEMPLATE/bug-report.yml +3 -3
  3. package/.github/ISSUE_TEMPLATE/feature-request.yml +2 -2
  4. package/.github/ISSUE_TEMPLATE/support-request.yml +3 -3
  5. package/.github/labeler.yml +1 -1
  6. package/.github/workflows/codeql-analysis.yml +29 -29
  7. package/.github/workflows/nodejs-beta.yml +1 -1
  8. package/.github/workflows/prerelease-beta.js +1 -1
  9. package/.github/workflows/stale.yml +1 -1
  10. package/.prettierrc +9 -0
  11. package/.vscode/extensions.json +2 -4
  12. package/.vscode/settings.json +13 -1
  13. package/CHANGELOG.md +16 -0
  14. package/README.md +100 -99
  15. package/SECURITY.md +2 -2
  16. package/config.schema.json +8 -0
  17. package/dist/devices/bots.d.ts +2 -2
  18. package/dist/devices/bots.d.ts.map +1 -1
  19. package/dist/devices/bots.js +91 -86
  20. package/dist/devices/bots.js.map +1 -1
  21. package/dist/devices/colorbulb.d.ts +15 -15
  22. package/dist/devices/colorbulb.d.ts.map +1 -1
  23. package/dist/devices/colorbulb.js +60 -71
  24. package/dist/devices/colorbulb.js.map +1 -1
  25. package/dist/devices/contact.d.ts +2 -2
  26. package/dist/devices/contact.d.ts.map +1 -1
  27. package/dist/devices/contact.js +33 -31
  28. package/dist/devices/contact.js.map +1 -1
  29. package/dist/devices/curtains.d.ts +2 -2
  30. package/dist/devices/curtains.d.ts.map +1 -1
  31. package/dist/devices/curtains.js +71 -71
  32. package/dist/devices/curtains.js.map +1 -1
  33. package/dist/devices/humidifiers.d.ts +2 -2
  34. package/dist/devices/humidifiers.d.ts.map +1 -1
  35. package/dist/devices/humidifiers.js +74 -76
  36. package/dist/devices/humidifiers.js.map +1 -1
  37. package/dist/devices/meters.d.ts +2 -2
  38. package/dist/devices/meters.d.ts.map +1 -1
  39. package/dist/devices/meters.js +29 -27
  40. package/dist/devices/meters.js.map +1 -1
  41. package/dist/devices/motion.d.ts +2 -2
  42. package/dist/devices/motion.d.ts.map +1 -1
  43. package/dist/devices/motion.js +34 -32
  44. package/dist/devices/motion.js.map +1 -1
  45. package/dist/devices/plugs.d.ts +7 -7
  46. package/dist/devices/plugs.d.ts.map +1 -1
  47. package/dist/devices/plugs.js +18 -23
  48. package/dist/devices/plugs.js.map +1 -1
  49. package/dist/irdevices/airconditioners.d.ts +5 -2
  50. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  51. package/dist/irdevices/airconditioners.js +61 -56
  52. package/dist/irdevices/airconditioners.js.map +1 -1
  53. package/dist/irdevices/airpurifiers.d.ts +2 -2
  54. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  55. package/dist/irdevices/airpurifiers.js +12 -17
  56. package/dist/irdevices/airpurifiers.js.map +1 -1
  57. package/dist/irdevices/cameras.d.ts +2 -2
  58. package/dist/irdevices/cameras.d.ts.map +1 -1
  59. package/dist/irdevices/cameras.js +10 -13
  60. package/dist/irdevices/cameras.js.map +1 -1
  61. package/dist/irdevices/fans.d.ts +2 -2
  62. package/dist/irdevices/fans.d.ts.map +1 -1
  63. package/dist/irdevices/fans.js +15 -17
  64. package/dist/irdevices/fans.js.map +1 -1
  65. package/dist/irdevices/lights.d.ts +2 -2
  66. package/dist/irdevices/lights.d.ts.map +1 -1
  67. package/dist/irdevices/lights.js +10 -13
  68. package/dist/irdevices/lights.js.map +1 -1
  69. package/dist/irdevices/others.d.ts +2 -2
  70. package/dist/irdevices/others.d.ts.map +1 -1
  71. package/dist/irdevices/others.js +10 -13
  72. package/dist/irdevices/others.js.map +1 -1
  73. package/dist/irdevices/tvs.d.ts +2 -2
  74. package/dist/irdevices/tvs.d.ts.map +1 -1
  75. package/dist/irdevices/tvs.js +22 -30
  76. package/dist/irdevices/tvs.js.map +1 -1
  77. package/dist/irdevices/vacuumcleaners.d.ts +2 -2
  78. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  79. package/dist/irdevices/vacuumcleaners.js +11 -13
  80. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  81. package/dist/irdevices/waterheaters.d.ts +2 -2
  82. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  83. package/dist/irdevices/waterheaters.js +10 -13
  84. package/dist/irdevices/waterheaters.js.map +1 -1
  85. package/dist/platform.d.ts +3 -3
  86. package/dist/platform.d.ts.map +1 -1
  87. package/dist/platform.js +13 -14
  88. package/dist/platform.js.map +1 -1
  89. package/dist/settings.d.ts +1 -0
  90. package/dist/settings.d.ts.map +1 -1
  91. package/dist/settings.js.map +1 -1
  92. package/homebridge-ui/public/index.html +231 -245
  93. package/homebridge-ui/server.js +2 -4
  94. package/nodemon.json +2 -4
  95. package/package.json +15 -9
  96. package/src/devices/bots.ts +217 -186
  97. package/src/devices/colorbulb.ts +90 -84
  98. package/src/devices/contact.ts +85 -78
  99. package/src/devices/curtains.ts +152 -135
  100. package/src/devices/humidifiers.ts +162 -137
  101. package/src/devices/meters.ts +76 -73
  102. package/src/devices/motion.ts +87 -78
  103. package/src/devices/plugs.ts +27 -31
  104. package/src/irdevices/airconditioners.ts +91 -59
  105. package/src/irdevices/airpurifiers.ts +22 -23
  106. package/src/irdevices/cameras.ts +18 -19
  107. package/src/irdevices/fans.ts +27 -25
  108. package/src/irdevices/lights.ts +18 -20
  109. package/src/irdevices/others.ts +18 -19
  110. package/src/irdevices/tvs.ts +33 -41
  111. package/src/irdevices/vacuumcleaners.ts +19 -19
  112. package/src/irdevices/waterheaters.ts +21 -31
  113. package/src/platform.ts +32 -33
  114. package/src/settings.ts +9 -19
  115. package/tsconfig.json +5 -14
  116. package/.github/PULL_REQUEST_TEMPLATE/pull_requests.md +0 -27
@@ -42,15 +42,13 @@ export class AirConditioner {
42
42
  // Config
43
43
  deviceLogging!: string;
44
44
  hide_automode?: boolean;
45
+ pushOn?: boolean;
45
46
 
46
- constructor(
47
- private readonly platform: SwitchBotPlatform,
48
- private accessory: PlatformAccessory,
49
- public device: irdevice & irDevicesConfig,
50
- ) {
47
+ constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
51
48
  // default placeholders
52
49
  this.logs(device);
53
50
  this.config(device);
51
+ this.pushOnChanges(device);
54
52
  if (this.Active === undefined) {
55
53
  this.Active = this.platform.Characteristic.Active.INACTIVE;
56
54
  } else {
@@ -78,9 +76,8 @@ export class AirConditioner {
78
76
 
79
77
  // get the Television service if it exists, otherwise create a new Television service
80
78
  // you can create multiple services for each accessory
81
- (this.service =
82
- accessory.getService(this.platform.Service.HeaterCooler) ||
83
- accessory.addService(this.platform.Service.HeaterCooler)), `${accessory.displayName} Air Conditioner`;
79
+ (this.service = accessory.getService(this.platform.Service.HeaterCooler) || accessory.addService(this.platform.Service.HeaterCooler)),
80
+ `${accessory.displayName} Air Conditioner`;
84
81
 
85
82
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
86
83
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -107,13 +104,17 @@ export class AirConditioner {
107
104
  if (this.hide_automode) {
108
105
  this.TargetHeaterCoolerState = 1 || 2;
109
106
  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}`);
107
+ this.debugLog(
108
+ `Air Conditioner: ${this.accessory.displayName} ValidValues: ${JSON.stringify(this.ValidValues)},` +
109
+ ` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
110
+ );
112
111
  } else {
113
112
  this.TargetHeaterCoolerState = 0 || 1 || 2;
114
113
  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}`);
114
+ this.debugLog(
115
+ `Air Conditioner: ${this.accessory.displayName} ValidValues: ${JSON.stringify(this.ValidValues)},` +
116
+ ` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
117
+ );
117
118
  }
118
119
  this.service
119
120
  .getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState)
@@ -125,10 +126,9 @@ export class AirConditioner {
125
126
  })
126
127
  .onSet(this.TargetHeaterCoolerStateSet.bind(this));
127
128
 
128
- this.service.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
129
- .onGet(async () => {
130
- return this.CurrentHeaterCoolerStateGet();
131
- });
129
+ this.service.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).onGet(async () => {
130
+ return this.CurrentHeaterCoolerStateGet();
131
+ });
132
132
 
133
133
  this.service
134
134
  .getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
@@ -176,8 +176,8 @@ export class AirConditioner {
176
176
  * AirConditioner: "command" "middleSpeed" "default" = fan speed to medium
177
177
  * AirConditioner: "command" "highSpeed" "default" = fan speed to high
178
178
  */
179
- /*async pushAirConditionerOnChanges() {
180
- if (this.Active !== this.platform.Characteristic.Active.ACTIVE) {
179
+ async pushAirConditionerOnChanges() {
180
+ if (this.Active !== this.platform.Characteristic.Active.ACTIVE || this.pushOn) {
181
181
  const payload = {
182
182
  commandType: 'command',
183
183
  parameter: 'default',
@@ -185,7 +185,7 @@ export class AirConditioner {
185
185
  } as any;
186
186
  await this.pushChanges(payload);
187
187
  }
188
- }*/
188
+ }
189
189
 
190
190
  async pushAirConditionerOffChanges() {
191
191
  const payload = {
@@ -227,12 +227,12 @@ export class AirConditioner {
227
227
  }
228
228
  if (this.CurrentMode === 1) {
229
229
  this.CurrentTemperature = 25;
230
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},`
231
- + ` CurrentTemperature: ${this.CurrentTemperature}`);
230
+ this.debugLog(
231
+ `Air Conditioner: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},` + ` CurrentTemperature: ${this.CurrentTemperature}`,
232
+ );
232
233
  }
233
234
  payload.parameter = `${this.CurrentTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
234
235
 
235
-
236
236
  if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
237
237
  this.CurrentTemperatureUndefined();
238
238
  if (this.CurrentTemperature < this.CurrentTemperatureCached) {
@@ -249,8 +249,10 @@ export class AirConditioner {
249
249
 
250
250
  public async pushChanges(payload: payload) {
251
251
  try {
252
- this.infoLog(`Air Conditioner: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
253
- + ` parameter: [${payload.parameter}], commandType: ${payload.commandType}`);
252
+ this.infoLog(
253
+ `Air Conditioner: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
254
+ ` parameter: [${payload.parameter}], commandType: ${payload.commandType}`,
255
+ );
254
256
 
255
257
  // Make the API request
256
258
  const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
@@ -268,18 +270,16 @@ export class AirConditioner {
268
270
  } catch (e: any) {
269
271
  this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges`);
270
272
  if (this.deviceLogging === 'debug') {
271
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,`
272
- + ` Error Message: ${JSON.stringify(e.message)}`);
273
+ this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${JSON.stringify(e.message)}`);
273
274
  }
274
275
  if (this.platform.debugMode) {
275
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,`
276
- + ` Error: ${JSON.stringify(e)}`);
276
+ this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,` + ` Error: ${JSON.stringify(e)}`);
277
277
  }
278
278
  this.apiError(e);
279
279
  }
280
280
  }
281
281
 
282
- statusCode(push: AxiosResponse<{ statusCode: number; }>) {
282
+ statusCode(push: AxiosResponse<{ statusCode: number }>) {
283
283
  switch (push.data.statusCode) {
284
284
  case 151:
285
285
  this.errorLog(`Air Conditioner: ${this.accessory.displayName} Command not supported by this device type.`);
@@ -297,8 +297,10 @@ export class AirConditioner {
297
297
  this.errorLog(`Air Conditioner: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
298
298
  break;
299
299
  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`);
300
+ this.errorLog(
301
+ `Air Conditioner: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
302
+ ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`,
303
+ );
302
304
  break;
303
305
  case 100:
304
306
  this.debugLog(`Air Conditioner: ${this.accessory.displayName} Command successfully sent.`);
@@ -331,29 +333,33 @@ export class AirConditioner {
331
333
  this.debugLog(`Air Conditioner: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
332
334
  } else {
333
335
  this.service?.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.TargetHeaterCoolerState);
334
- this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
335
- + ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
336
+ this.debugLog(
337
+ `Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
338
+ );
336
339
  }
337
340
  if (this.CurrentHeaterCoolerState === undefined) {
338
341
  this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
339
342
  } else {
340
343
  this.service?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
341
- this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
342
- + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
344
+ this.debugLog(
345
+ `Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
346
+ );
343
347
  }
344
348
  if (this.HeatingThresholdTemperature === undefined) {
345
349
  this.debugLog(`Air Conditioner: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
346
350
  } else {
347
351
  this.service?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.HeatingThresholdTemperature);
348
- this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
349
- + ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
352
+ this.debugLog(
353
+ `Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`,
354
+ );
350
355
  }
351
356
  if (this.CoolingThresholdTemperature === undefined) {
352
357
  this.debugLog(`Air Conditioner: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
353
358
  } else {
354
359
  this.service?.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, this.CoolingThresholdTemperature);
355
- this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
356
- + ` updateCharacteristic CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
360
+ this.debugLog(
361
+ `Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`,
362
+ );
357
363
  }
358
364
  }
359
365
 
@@ -418,23 +424,33 @@ export class AirConditioner {
418
424
  this.pushAirConditionerOffChanges();
419
425
  } else {
420
426
  this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.Active}`);
421
- this.pushAirConditionerStatusChanges();
427
+ if (this.pushOn) {
428
+ this.pushAirConditionerOnChanges();
429
+ } else {
430
+ this.pushAirConditionerStatusChanges();
431
+ }
422
432
  }
423
433
  }
424
434
 
425
435
  TargetHeaterCoolerStateGet() {
426
436
  if (this.ValidValues === [0, 1, 2]) {
427
437
  this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
428
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (AUTO) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},`
429
- + ` ValidValues: ${this.ValidValues}`);
438
+ this.debugLog(
439
+ `Air Conditioner: ${this.accessory.displayName} Get (AUTO) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
440
+ ` ValidValues: ${this.ValidValues}`,
441
+ );
430
442
  } 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}`);
443
+ this.TargetHeaterCoolerState =
444
+ this.platform.Characteristic.TargetHeaterCoolerState.COOL || this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
445
+ this.debugLog(
446
+ `Air Conditioner: ${this.accessory.displayName} Get (COOL/HEAT) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
447
+ ` ValidValues: ${this.ValidValues}`,
448
+ );
435
449
  } else {
436
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},`
437
- + ` ValidValues: ${this.ValidValues}`);
450
+ this.debugLog(
451
+ `Air Conditioner: ${this.accessory.displayName} Get TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
452
+ ` ValidValues: ${this.ValidValues}`,
453
+ );
438
454
  }
439
455
  this.TargetHeaterCoolerStateCached = this.TargetHeaterCoolerState;
440
456
  this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerStateCached;
@@ -448,8 +464,10 @@ export class AirConditioner {
448
464
  } else if (value === this.platform.Characteristic.TargetHeaterCoolerState.COOL) {
449
465
  this.TargetHeaterCoolerStateCOOL();
450
466
  } else {
451
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},`
452
- + ` hide_automode: ${this.hide_automode} `);
467
+ this.errorLog(
468
+ `Air Conditioner: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
469
+ ` hide_automode: ${this.hide_automode} `,
470
+ );
453
471
  }
454
472
  } else {
455
473
  if (value === this.platform.Characteristic.TargetHeaterCoolerState.AUTO) {
@@ -459,8 +477,10 @@ export class AirConditioner {
459
477
  } else if (value === this.platform.Characteristic.TargetHeaterCoolerState.COOL) {
460
478
  this.TargetHeaterCoolerStateCOOL();
461
479
  } else {
462
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},`
463
- + ` hide_automode: ${this.hide_automode} `);
480
+ this.errorLog(
481
+ `Air Conditioner: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
482
+ ` hide_automode: ${this.hide_automode} `,
483
+ );
464
484
  }
465
485
  }
466
486
  this.TargetHeaterCoolerStateCached = this.TargetHeaterCoolerState;
@@ -523,12 +543,13 @@ export class AirConditioner {
523
543
  this.CurrentTemperature = value;
524
544
  this.HeatingThresholdTemperatureCached = this.HeatingThresholdTemperature;
525
545
  this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
526
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set HeatingThresholdTemperature: ${this.HeatingThresholdTemperature},`
527
- + ` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`);
546
+ this.debugLog(
547
+ `Air Conditioner: ${this.accessory.displayName} Set HeatingThresholdTemperature: ${this.HeatingThresholdTemperature},` +
548
+ ` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`,
549
+ );
528
550
  this.pushAirConditionerStatusChanges();
529
551
  }
530
552
 
531
-
532
553
  private CoolingThresholdTemperatureGet() {
533
554
  this.CurrentTemperatureUndefined;
534
555
  this.CurrentTemperature = this.CurrentTemperatureCached;
@@ -544,8 +565,10 @@ export class AirConditioner {
544
565
  this.CurrentTemperature = value;
545
566
  this.CoolingThresholdTemperatureCached = this.CoolingThresholdTemperature;
546
567
  this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
547
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set CoolingThresholdTemperature: ${this.CoolingThresholdTemperature},`
548
- + ` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`);
568
+ this.debugLog(
569
+ `Air Conditioner: ${this.accessory.displayName} Set CoolingThresholdTemperature: ${this.CoolingThresholdTemperature},` +
570
+ ` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`,
571
+ );
549
572
  this.pushAirConditionerStatusChanges();
550
573
  }
551
574
 
@@ -587,9 +610,18 @@ export class AirConditioner {
587
610
  }
588
611
  }
589
612
 
613
+
614
+ pushOnChanges(device: irdevice & irDevicesConfig) {
615
+ if (device.irair?.pushOn) {
616
+ this.pushOn = true;
617
+ } else {
618
+ this.pushOn = false;
619
+ }
620
+ }
621
+
590
622
  /**
591
- * Logging for Device
592
- */
623
+ * Logging for Device
624
+ */
593
625
  infoLog(...log: any[]) {
594
626
  if (this.enablingDeviceLogging()) {
595
627
  this.platform.log.info(String(...log));
@@ -38,11 +38,7 @@ export class AirPurifier {
38
38
  // Config
39
39
  deviceLogging!: string;
40
40
 
41
- constructor(
42
- private readonly platform: SwitchBotPlatform,
43
- private accessory: PlatformAccessory,
44
- public device: irdevice & irDevicesConfig,
45
- ) {
41
+ constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
46
42
  // default placeholders
47
43
  this.logs(device);
48
44
  this.config(device);
@@ -66,9 +62,8 @@ export class AirPurifier {
66
62
 
67
63
  // get the Television service if it exists, otherwise create a new Television service
68
64
  // you can create multiple services for each accessory
69
- (this.service =
70
- accessory.getService(this.platform.Service.AirPurifier) ||
71
- accessory.addService(this.platform.Service.AirPurifier)), `${accessory.displayName} Air Purifier`;
65
+ (this.service = accessory.getService(this.platform.Service.AirPurifier) || accessory.addService(this.platform.Service.AirPurifier)),
66
+ `${accessory.displayName} Air Purifier`;
72
67
 
73
68
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
74
69
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -111,15 +106,15 @@ export class AirPurifier {
111
106
  this.debugLog(`Air Purifier: ${this.accessory.displayName} CurrentAirPurifierState: ${this.CurrentAirPurifierState}`);
112
107
  } else {
113
108
  this.service?.updateCharacteristic(this.platform.Characteristic.CurrentAirPurifierState, this.CurrentAirPurifierState);
114
- this.debugLog(`Air Purifier: ${this.accessory.displayName}`
115
- + ` updateCharacteristic CurrentAirPurifierState: ${this.CurrentAirPurifierState}`);
109
+ this.debugLog(`Air Purifier: ${this.accessory.displayName}` + ` updateCharacteristic CurrentAirPurifierState: ${this.CurrentAirPurifierState}`);
116
110
  }
117
111
  if (this.CurrentHeaterCoolerState === undefined) {
118
112
  this.debugLog(`Air Purifier: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
119
113
  } else {
120
114
  this.service?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
121
- this.debugLog(`Air Purifier: ${this.accessory.displayName}`
122
- + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
115
+ this.debugLog(
116
+ `Air Purifier: ${this.accessory.displayName}` + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
117
+ );
123
118
  }
124
119
  }
125
120
 
@@ -219,8 +214,10 @@ export class AirPurifier {
219
214
 
220
215
  public async pushChanges(payload: payload) {
221
216
  try {
222
- this.infoLog(`Air Purifier: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
223
- + ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
217
+ this.infoLog(
218
+ `Air Purifier: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
219
+ ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`,
220
+ );
224
221
 
225
222
  // Make the API request
226
223
  const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
@@ -232,18 +229,18 @@ export class AirPurifier {
232
229
  } catch (e: any) {
233
230
  this.errorLog(`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
234
231
  if (this.deviceLogging === 'debug') {
235
- this.errorLog(`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
236
- + ` Error Message: ${JSON.stringify(e.message)}`);
232
+ this.errorLog(
233
+ `Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
234
+ );
237
235
  }
238
236
  if (this.platform.debugMode) {
239
- this.errorLog(`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
240
- + ` Error: ${JSON.stringify(e)}`);
237
+ this.errorLog(`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
241
238
  }
242
239
  this.apiError(e);
243
240
  }
244
241
  }
245
242
 
246
- private statusCode(push: AxiosResponse<{ statusCode: number; }>) {
243
+ private statusCode(push: AxiosResponse<{ statusCode: number }>) {
247
244
  switch (push.data.statusCode) {
248
245
  case 151:
249
246
  this.errorLog(`Air Purifier: ${this.accessory.displayName} Command not supported by this device type.`);
@@ -261,8 +258,10 @@ export class AirPurifier {
261
258
  this.errorLog(`Air Purifier: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
262
259
  break;
263
260
  case 190:
264
- this.errorLog(`Air Purifier: ${this.accessory.displayName} Device internal error due to device states not synchronized`
265
- + ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`);
261
+ this.errorLog(
262
+ `Air Purifier: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
263
+ ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`,
264
+ );
266
265
  break;
267
266
  case 100:
268
267
  this.debugLog(`Air Purifier: ${this.accessory.displayName} Command successfully sent.`);
@@ -310,8 +309,8 @@ export class AirPurifier {
310
309
  }
311
310
 
312
311
  /**
313
- * Logging for Device
314
- */
312
+ * Logging for Device
313
+ */
315
314
  infoLog(...log: any[]) {
316
315
  if (this.enablingDeviceLogging()) {
317
316
  this.platform.log.info(String(...log));
@@ -19,11 +19,7 @@ export class Camera {
19
19
  // Config
20
20
  deviceLogging!: string;
21
21
 
22
- constructor(
23
- private readonly platform: SwitchBotPlatform,
24
- private accessory: PlatformAccessory,
25
- public device: irdevice & irDevicesConfig,
26
- ) {
22
+ constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
27
23
  // default placeholders
28
24
  this.logs(device);
29
25
  this.config(device);
@@ -42,9 +38,8 @@ export class Camera {
42
38
 
43
39
  // get the Television service if it exists, otherwise create a new Television service
44
40
  // you can create multiple services for each accessory
45
- (this.service =
46
- accessory.getService(this.platform.Service.Switch) ||
47
- accessory.addService(this.platform.Service.Switch)), `${accessory.displayName} Camera`;
41
+ (this.service = accessory.getService(this.platform.Service.Switch) || accessory.addService(this.platform.Service.Switch)),
42
+ `${accessory.displayName} Camera`;
48
43
 
49
44
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
50
45
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -111,8 +106,10 @@ export class Camera {
111
106
 
112
107
  public async pushChanges(payload: payload) {
113
108
  try {
114
- this.infoLog(`Camera: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
115
- + ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
109
+ this.infoLog(
110
+ `Camera: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
111
+ ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`,
112
+ );
116
113
 
117
114
  // Make the API request
118
115
  const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
@@ -124,18 +121,18 @@ export class Camera {
124
121
  } catch (e: any) {
125
122
  this.errorLog(`Camera: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
126
123
  if (this.deviceLogging === 'debug') {
127
- this.errorLog(`Camera: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
128
- + ` Error Message: ${JSON.stringify(e.message)}`);
124
+ this.errorLog(
125
+ `Camera: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
126
+ );
129
127
  }
130
128
  if (this.platform.debugMode) {
131
- this.errorLog(`Camera: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
132
- + ` Error: ${JSON.stringify(e)}`);
129
+ this.errorLog(`Camera: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
133
130
  }
134
131
  this.apiError(e);
135
132
  }
136
133
  }
137
134
 
138
- private statusCode(push: AxiosResponse<{ statusCode: number; }>) {
135
+ private statusCode(push: AxiosResponse<{ statusCode: number }>) {
139
136
  switch (push.data.statusCode) {
140
137
  case 151:
141
138
  this.errorLog(`Camera: ${this.accessory.displayName} Command not supported by this device type.`);
@@ -153,8 +150,10 @@ export class Camera {
153
150
  this.errorLog(`Camera: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
154
151
  break;
155
152
  case 190:
156
- this.errorLog(`Camera: ${this.accessory.displayName} Device internal error due to device states not synchronized`
157
- + ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`);
153
+ this.errorLog(
154
+ `Camera: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
155
+ ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`,
156
+ );
158
157
  break;
159
158
  case 100:
160
159
  this.debugLog(`Camera: ${this.accessory.displayName} Command successfully sent.`);
@@ -199,8 +198,8 @@ export class Camera {
199
198
  }
200
199
 
201
200
  /**
202
- * Logging for Device
203
- */
201
+ * Logging for Device
202
+ */
204
203
  infoLog(...log: any[]) {
205
204
  if (this.enablingDeviceLogging()) {
206
205
  this.platform.log.info(String(...log));
@@ -29,11 +29,7 @@ export class Fan {
29
29
  maxValue?: number;
30
30
  deviceLogging!: string;
31
31
 
32
- constructor(
33
- private readonly platform: SwitchBotPlatform,
34
- private accessory: PlatformAccessory,
35
- public device: irdevice & irDevicesConfig,
36
- ) {
32
+ constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
37
33
  // default placeholders
38
34
  this.logs(device);
39
35
  this.config(device);
@@ -52,9 +48,8 @@ export class Fan {
52
48
 
53
49
  // get the Television service if it exists, otherwise create a new Television service
54
50
  // you can create multiple services for each accessory
55
- (this.service =
56
- accessory.getService(this.platform.Service.Fanv2) ||
57
- accessory.addService(this.platform.Service.Fanv2)), `${accessory.displayName} Fan`;
51
+ (this.service = accessory.getService(this.platform.Service.Fanv2) || accessory.addService(this.platform.Service.Fanv2)),
52
+ `${accessory.displayName} Fan`;
58
53
 
59
54
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
60
55
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -92,15 +87,16 @@ export class Fan {
92
87
  maxValue: this.maxValue,
93
88
  })
94
89
  .onSet(this.RotationSpeedSet.bind(this));
95
- } else if (
96
- this.service.testCharacteristic(this.platform.Characteristic.RotationSpeed) &&
97
- !device.irfan?.swing_mode) {
90
+ } else if (this.service.testCharacteristic(this.platform.Characteristic.RotationSpeed) && !device.irfan?.swing_mode) {
98
91
  const characteristic = this.service.getCharacteristic(this.platform.Characteristic.RotationSpeed);
99
92
  this.service.removeCharacteristic(characteristic);
100
93
  this.debugLog(`Fan: ${this.accessory.displayName} Rotation Speed Characteristic was removed.`);
101
94
  } else {
102
95
  // eslint-disable-next-line max-len
103
- this.debugLog(`Fan: ${this.accessory.displayName} Rotation Speed Characteristic was not removed or not added. To Remove Chracteristic, Clear Cache on this Accessory.`);
96
+ this.debugLog(
97
+ `Fan: ${this.accessory.displayName} RotationSpeed Characteristic was not removed/added, ` +
98
+ `Clear Cache on ${this.accessory.displayName} to remove Chracteristic`,
99
+ );
104
100
  }
105
101
 
106
102
  if (device.irfan?.swing_mode) {
@@ -112,8 +108,10 @@ export class Fan {
112
108
  this.debugLog(`Fan: ${this.accessory.displayName} Swing Mode Characteristic was removed.`);
113
109
  } else {
114
110
  // eslint-disable-next-line max-len
115
- this.debugLog(`Fan: ${this.accessory.displayName} Swing Mode Characteristic was not removed or not added. To Remove Chracteristic, Clear Cache on this Accessory.`);
116
-
111
+ this.debugLog(
112
+ `Fan: ${this.accessory.displayName} Swing Mode Characteristic was not removed/added, ` +
113
+ `Clear Cache on ${this.accessory.displayName} To Remove Chracteristic`,
114
+ );
117
115
  }
118
116
  }
119
117
 
@@ -235,8 +233,10 @@ export class Fan {
235
233
 
236
234
  public async pushTVChanges(payload: payload) {
237
235
  try {
238
- this.infoLog(`Fan: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
239
- + ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
236
+ this.infoLog(
237
+ `Fan: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
238
+ ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`,
239
+ );
240
240
 
241
241
  // Make the API request
242
242
  const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
@@ -246,18 +246,18 @@ export class Fan {
246
246
  } catch (e: any) {
247
247
  this.errorLog(`Fan: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
248
248
  if (this.deviceLogging === 'debug') {
249
- this.errorLog(`Fan: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
250
- + ` Error Message: ${JSON.stringify(e.message)}`);
249
+ this.errorLog(
250
+ `Fan: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
251
+ );
251
252
  }
252
253
  if (this.platform.debugMode) {
253
- this.errorLog(`Fan: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
254
- + ` Error: ${JSON.stringify(e)}`);
254
+ this.errorLog(`Fan: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
255
255
  }
256
256
  this.apiError(e);
257
257
  }
258
258
  }
259
259
 
260
- private statusCode(push: AxiosResponse<{ statusCode: number; }>) {
260
+ private statusCode(push: AxiosResponse<{ statusCode: number }>) {
261
261
  switch (push.data.statusCode) {
262
262
  case 151:
263
263
  this.errorLog(`Fan: ${this.accessory.displayName} Command not supported by this device type.`);
@@ -275,8 +275,10 @@ export class Fan {
275
275
  this.errorLog(`Fan: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
276
276
  break;
277
277
  case 190:
278
- this.errorLog(`Fan: ${this.accessory.displayName} Device internal error due to device states not synchronized`
279
- + ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`);
278
+ this.errorLog(
279
+ `Fan: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
280
+ ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`,
281
+ );
280
282
  break;
281
283
  case 100:
282
284
  this.debugLog(`Fan: ${this.accessory.displayName} Command successfully sent.`);
@@ -323,8 +325,8 @@ export class Fan {
323
325
  }
324
326
 
325
327
  /**
326
- * Logging for Device
327
- */
328
+ * Logging for Device
329
+ */
328
330
  infoLog(...log: any[]) {
329
331
  if (this.enablingDeviceLogging()) {
330
332
  this.platform.log.info(String(...log));