@switchbot/homebridge-switchbot 2.7.1-beta.0 → 2.7.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.
@@ -1,7 +1,7 @@
1
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
1
2
  import { request } from 'undici';
2
3
  import { SwitchBotPlatform } from '../platform';
3
- import { irDevicesConfig, irdevice, Devices } from '../settings';
4
- import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
4
+ import { Devices, irDevicesConfig, irdevice } from '../settings';
5
5
 
6
6
  /**
7
7
  * Platform Accessory
@@ -19,8 +19,7 @@ export class AirConditioner {
19
19
  CurrentRelativeHumidity?: CharacteristicValue;
20
20
  TargetHeaterCoolerState!: CharacteristicValue;
21
21
  CurrentHeaterCoolerState!: CharacteristicValue;
22
- HeatingThresholdTemperature!: CharacteristicValue;
23
- CoolingThresholdTemperature!: CharacteristicValue;
22
+ ThresholdTemperature!: CharacteristicValue;
24
23
 
25
24
  // Others
26
25
  state!: string;
@@ -66,7 +65,7 @@ export class AirConditioner {
66
65
  // get the Television service if it exists, otherwise create a new Television service
67
66
  // you can create multiple services for each accessory
68
67
  (this.coolerService = accessory.getService(this.platform.Service.HeaterCooler) || accessory.addService(this.platform.Service.HeaterCooler)),
69
- `${accessory.displayName} ${device.remoteType}`;
68
+ `${accessory.displayName} ${device.remoteType}`;
70
69
 
71
70
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
72
71
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -80,18 +79,11 @@ export class AirConditioner {
80
79
  }
81
80
 
82
81
  // handle on / off events using the Active characteristic
83
- this.coolerService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
82
+ this.coolerService.getCharacteristic(this.platform.Characteristic.Active)
83
+ .onSet(this.ActiveSet.bind(this));
84
84
 
85
- this.coolerService
86
- .getCharacteristic(this.platform.Characteristic.CurrentTemperature)
87
- .setProps({
88
- minValue: 0,
89
- maxValue: 100,
90
- minStep: 0.01,
91
- })
92
- .onGet(() => {
93
- return this.CurrentTemperatureGet();
94
- });
85
+ this.coolerService.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
86
+ .onGet(this.CurrentTemperatureGet.bind(this));
95
87
 
96
88
  if (this.hide_automode) {
97
89
  this.TargetHeaterCoolerState = 1 || 2;
@@ -108,64 +100,46 @@ export class AirConditioner {
108
100
  ` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
109
101
  );
110
102
  }
103
+
111
104
  if (this.meter) {
112
105
  this.coolerService
113
- .getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
114
- .setProps({
115
- minStep: 0.1,
116
- })
117
- .onGet(() => {
118
- return this.CurrentRelativeHumidityGet();
119
- });
120
- }
121
- this.coolerService
122
- .getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState)
106
+ .getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
107
+ .onGet(this.CurrentRelativeHumidityGet.bind(this));
108
+ }
109
+
110
+ this.coolerService.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState)
123
111
  .setProps({
124
112
  validValues: this.ValidValues,
125
113
  })
126
- .onGet(async () => {
127
- return this.TargetHeaterCoolerStateGet();
128
- })
114
+ .onGet(this.TargetHeaterCoolerStateGet.bind(this))
129
115
  .onSet(this.TargetHeaterCoolerStateSet.bind(this));
130
116
 
131
- this.coolerService.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).onGet(async () => {
132
- return this.CurrentHeaterCoolerStateGet();
133
- });
117
+ this.coolerService.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
118
+ .onGet(this.CurrentHeaterCoolerStateGet.bind(this));
134
119
 
135
- this.coolerService
136
- .getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
120
+
121
+ this.coolerService.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
137
122
  .setProps({
138
- minValue: 16,
139
- maxValue: 30,
140
- minStep: 1,
123
+ minStep: 0.5,
141
124
  })
142
- .onGet(() => {
143
- return this.HeatingThresholdTemperatureGet();
144
- })
145
- .onSet(this.HeatingThresholdTemperatureSet.bind(this));
125
+ .onGet(this.ThresholdTemperatureGet.bind(this))
126
+ .onSet(this.ThresholdTemperatureSet.bind(this));
146
127
 
147
- this.coolerService
148
- .getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature)
128
+ this.coolerService.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature)
149
129
  .setProps({
150
- minValue: 16,
151
- maxValue: 30,
152
- minStep: 1,
153
- })
154
- .onGet(() => {
155
- return this.CoolingThresholdTemperatureGet();
130
+ minStep: 0.5,
156
131
  })
157
- .onSet(this.CoolingThresholdTemperatureSet.bind(this));
132
+ .onGet(this.ThresholdTemperatureGet.bind(this))
133
+ .onSet(this.ThresholdTemperatureSet.bind(this));
158
134
 
159
- this.coolerService
160
- .getCharacteristic(this.platform.Characteristic.RotationSpeed)
135
+ this.coolerService.getCharacteristic(this.platform.Characteristic.RotationSpeed)
161
136
  .setProps({
137
+ format: "int",
162
138
  minStep: 1,
163
139
  minValue: 1,
164
140
  maxValue: 4,
165
141
  })
166
- .onGet(async () => {
167
- return this.RotationSpeedGet();
168
- })
142
+ .onGet(this.RotationSpeedGet.bind(this))
169
143
  .onSet(this.RotationSpeedSet.bind(this));
170
144
  }
171
145
 
@@ -237,19 +211,20 @@ export class AirConditioner {
237
211
  this.state = 'off';
238
212
  }
239
213
  if (this.CurrentMode === 1) {
240
- this.CurrentTemperature = 25;
214
+ // Remove or make configurable?
215
+ this.ThresholdTemperature = 25;
241
216
  this.debugLog(
242
217
  `${this.device.remoteType}: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},`
243
- + ` CurrentTemperature: ${this.CurrentTemperature}`,
218
+ + ` ThresholdTemperature: ${this.ThresholdTemperature}`,
244
219
  );
245
220
  }
246
- const parameter = `${this.CurrentTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
221
+ const parameter = `${this.ThresholdTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
247
222
 
248
223
  if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
249
224
  await this.context();
250
- if (this.CurrentTemperature < this.accessory.context.CurrentTemperature) {
225
+ if (this.ThresholdTemperature < this.accessory.context.CurrentTemperature) {
251
226
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
252
- } else if (this.CurrentTemperature > this.accessory.context.CurrentTemperature) {
227
+ } else if (this.ThresholdTemperature > this.accessory.context.CurrentTemperature) {
253
228
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
254
229
  }
255
230
  } else {
@@ -289,14 +264,16 @@ export class AirConditioner {
289
264
  this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
290
265
  + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
291
266
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
292
- + ` Connection Type: ${this.device.connectionType}, disablePushDetials: ${this.disablePushDetail}`);
267
+ + ` Connection Type: ${this.device.connectionType}, disablePushDetails: ${this.disablePushDetail}`);
293
268
  this.updateHomeKitCharacteristics();
294
269
  }
295
270
  }
296
271
 
297
272
  async CurrentTemperatureGet(): Promise<CharacteristicValue> {
298
- if (this.meter?.context) {
299
- this.CurrentTemperature = this.meter.context.CurrentTemperature;
273
+ 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;
300
277
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using CurrentTemperature from ${this.meter.context?.deviceType} (${this.meter.context?.deviceID})`)
301
278
  } else if (this.CurrentTemperature === undefined) {
302
279
  this.CurrentTemperature = 24;
@@ -308,24 +285,24 @@ export class AirConditioner {
308
285
  }
309
286
 
310
287
  async CurrentRelativeHumidityGet(): Promise<CharacteristicValue> {
311
- if (this.meter?.context) {
312
- this.CurrentRelativeHumidity = this.meter.context.CurrentRelativeHumidity;
313
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using CurrentRelativeHumidity from ${this.meter.context?.deviceType} (${this.meter.context?.deviceID})`)
288
+ 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})`)
314
293
  }
315
294
  else if (this.CurrentRelativeHumidity === undefined) {
316
- this.CurrentRelativeHumidity = 0;
295
+ this.CurrentRelativeHumidity = 0;
317
296
  }
318
297
  else {
319
- this.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity;
298
+ this.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity;
320
299
  }
321
300
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
322
301
  return this.CurrentRelativeHumidity as CharacteristicValue;
323
- }
302
+ }
324
303
 
325
304
  async RotationSpeedGet(): Promise<number> {
326
- if (!this.CurrentFanSpeed) {
327
- this.RotationSpeed = 4;
328
- } else if (this.CurrentFanSpeed === 1) {
305
+ if (!this.CurrentFanSpeed || this.CurrentFanSpeed === 1) {
329
306
  this.RotationSpeed = 4;
330
307
  } else {
331
308
  this.RotationSpeed = this.CurrentFanSpeed - 1;
@@ -385,30 +362,17 @@ export class AirConditioner {
385
362
  }
386
363
 
387
364
  async TargetHeaterCoolerStateSet(value: CharacteristicValue): Promise<void> {
388
- if (this.hide_automode) {
389
- if (value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT) {
390
- this.TargetHeaterCoolerStateHEAT();
391
- } else if (value === this.platform.Characteristic.TargetHeaterCoolerState.COOL) {
392
- this.TargetHeaterCoolerStateCOOL();
393
- } else {
394
- this.errorLog(
395
- `${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
396
- ` hide_automode: ${this.hide_automode} `,
397
- );
398
- }
365
+ if (!this.hide_automode && value === this.platform.Characteristic.TargetHeaterCoolerState.AUTO) {
366
+ this.TargetHeaterCoolerStateAUTO();
367
+ } else if (value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT) {
368
+ this.TargetHeaterCoolerStateHEAT();
369
+ } else if (value === this.platform.Characteristic.TargetHeaterCoolerState.COOL) {
370
+ this.TargetHeaterCoolerStateCOOL();
399
371
  } else {
400
- if (value === this.platform.Characteristic.TargetHeaterCoolerState.AUTO) {
401
- this.TargetHeaterCoolerStateAUTO();
402
- } else if (value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT) {
403
- this.TargetHeaterCoolerStateHEAT();
404
- } else if (value === this.platform.Characteristic.TargetHeaterCoolerState.COOL) {
405
- this.TargetHeaterCoolerStateCOOL();
406
- } else {
407
- this.errorLog(
408
- `${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
409
- ` hide_automode: ${this.hide_automode} `,
410
- );
411
- }
372
+ this.errorLog(
373
+ `${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
374
+ ` hide_automode: ${this.hide_automode} `,
375
+ );
412
376
  }
413
377
  this.pushAirConditionerStatusChanges();
414
378
  }
@@ -436,11 +400,11 @@ export class AirConditioner {
436
400
 
437
401
  async CurrentHeaterCoolerStateGet(): Promise<CharacteristicValue> {
438
402
  if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
439
- if (this.CurrentTemperature < this.accessory.context.CurrentTemperature) {
403
+ if (this.ThresholdTemperature < this.accessory.context.CurrentTemperature) {
440
404
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
441
405
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
442
- + ` Get (COOLLING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
443
- } else if (this.CurrentTemperature > this.accessory.context.CurrentTemperature) {
406
+ + ` Get (COOLING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
407
+ } else if (this.ThresholdTemperature > this.accessory.context.CurrentTemperature) {
444
408
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
445
409
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
446
410
  + ` Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
@@ -453,29 +417,16 @@ export class AirConditioner {
453
417
  return this.CurrentHeaterCoolerState;
454
418
  }
455
419
 
456
- async HeatingThresholdTemperatureGet(): Promise<CharacteristicValue> {
457
- await this.context();
458
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
459
- return this.HeatingThresholdTemperature;
460
- }
461
-
462
- async HeatingThresholdTemperatureSet(value: CharacteristicValue): Promise<void> {
463
- this.CurrentTemperature = value;
464
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set HeatingThresholdTemperature: ${this.HeatingThresholdTemperature},` +
465
- ` CurrentTemperatureCached: ${this.accessory.context.CurrentTemperature}`);
466
- this.pushAirConditionerStatusChanges();
467
- }
468
-
469
- async CoolingThresholdTemperatureGet(): Promise<CharacteristicValue> {
420
+ async ThresholdTemperatureGet(): Promise<CharacteristicValue> {
470
421
  await this.context();
471
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
472
- return this.CoolingThresholdTemperature;
422
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get ThresholdTemperature: ${this.ThresholdTemperature}`);
423
+ return this.ThresholdTemperature;
473
424
  }
474
425
 
475
- async CoolingThresholdTemperatureSet(value: CharacteristicValue): Promise<void> {
476
- this.CurrentTemperature = value;
477
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set CoolingThresholdTemperature: ${this.CoolingThresholdTemperature},` +
478
- ` CurrentTemperatureCached: ${this.accessory.context.CurrentTemperature}`);
426
+ async ThresholdTemperatureSet(value: CharacteristicValue): Promise<void> {
427
+ this.ThresholdTemperature = value;
428
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set ThresholdTemperature: ${this.ThresholdTemperature},` +
429
+ ` ThresholdTemperatureCached: ${this.accessory.context.ThresholdTemperature}`);
479
430
  this.pushAirConditionerStatusChanges();
480
431
  }
481
432
 
@@ -503,14 +454,14 @@ export class AirConditioner {
503
454
  }
504
455
  if (this.meter) {
505
456
  if (this.CurrentRelativeHumidity === undefined) {
506
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
457
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
507
458
  }
508
459
  else {
509
- this.accessory.context.CurrentRelativeHumidity = this.CurrentRelativeHumidity;
510
- this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
511
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
460
+ this.accessory.context.CurrentRelativeHumidity = this.CurrentRelativeHumidity;
461
+ this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
462
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
512
463
  }
513
- }
464
+ }
514
465
  if (this.TargetHeaterCoolerState === undefined) {
515
466
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
516
467
  } else {
@@ -530,24 +481,15 @@ export class AirConditioner {
530
481
  + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
531
482
  );
532
483
  }
533
- if (this.HeatingThresholdTemperature === undefined) {
534
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
535
- } else {
536
- this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperature;
537
- this.coolerService?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.HeatingThresholdTemperature);
538
- this.debugLog(
539
- `${this.device.remoteType}: ${this.accessory.displayName}`
540
- + ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`,
541
- );
542
- }
543
- if (this.CoolingThresholdTemperature === undefined) {
544
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
484
+ if (this.ThresholdTemperature === undefined) {
485
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ThresholdTemperature: ${this.ThresholdTemperature}`);
545
486
  } else {
546
- this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperature;
547
- this.coolerService?.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, this.CoolingThresholdTemperature);
487
+ this.accessory.context.ThresholdTemperature = this.ThresholdTemperature;
488
+ this.coolerService?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.ThresholdTemperature);
489
+ this.coolerService?.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, this.ThresholdTemperature);
548
490
  this.debugLog(
549
491
  `${this.device.remoteType}: ${this.accessory.displayName}`
550
- + ` updateCharacteristic CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`,
492
+ + ` updateCharacteristic ThresholdTemperature: ${this.ThresholdTemperature}`,
551
493
  );
552
494
  }
553
495
  }
@@ -646,6 +588,7 @@ export class AirConditioner {
646
588
  this.coolerService.updateCharacteristic(this.platform.Characteristic.Active, e);
647
589
  this.coolerService.updateCharacteristic(this.platform.Characteristic.RotationSpeed, e);
648
590
  this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
591
+ this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, e);
649
592
  this.coolerService.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, e);
650
593
  this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, e);
651
594
  this.coolerService.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, e);
@@ -686,12 +629,8 @@ export class AirConditioner {
686
629
  this.CurrentTemperature = this.accessory.context.CurrentTemperature;
687
630
  }
688
631
 
689
- if (this.CoolingThresholdTemperature === undefined) {
690
- this.CoolingThresholdTemperature = this.CurrentTemperature;
691
- }
692
-
693
- if (this.HeatingThresholdTemperature === undefined) {
694
- this.HeatingThresholdTemperature = this.CurrentTemperature;
632
+ if (this.ThresholdTemperature === undefined) {
633
+ this.ThresholdTemperature = 24;
695
634
  }
696
635
 
697
636
  if (this.device.irair?.hide_automode) {
@@ -701,17 +640,17 @@ export class AirConditioner {
701
640
  this.hide_automode = this.device.irair?.hide_automode;
702
641
  this.accessory.context.hide_automode = this.hide_automode;
703
642
  }
704
-
643
+
705
644
  if (this.device.irair?.meterUuid) {
706
- this.meter = this.platform.accessories.find((accessory) => accessory.UUID === this.device.irair?.meterUuid)
645
+ this.meter = this.platform.accessories.find((accessory) => accessory.UUID === this.device.irair?.meterUuid);
707
646
  }
708
647
  if (this.meter) {
709
648
  if (this.CurrentRelativeHumidity === undefined) {
710
- this.CurrentRelativeHumidity = 0;
649
+ this.CurrentRelativeHumidity = 0;
711
650
  } else {
712
- this.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity;
651
+ this.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity;
713
652
  }
714
- }
653
+ }
715
654
  }
716
655
 
717
656
  async config({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
@@ -783,10 +722,8 @@ export class AirConditioner {
783
722
  }
784
723
 
785
724
  debugWarnLog(...log: any[]): void {
786
- if (this.enablingDeviceLogging()) {
787
- if (this.deviceLogging?.includes('debug')) {
788
- this.platform.log.warn('[DEBUG]', String(...log));
789
- }
725
+ if (this.enablingDeviceLogging() && this.deviceLogging?.includes('debug')) {
726
+ this.platform.log.warn('[DEBUG]', String(...log));
790
727
  }
791
728
  }
792
729
 
@@ -797,10 +734,8 @@ export class AirConditioner {
797
734
  }
798
735
 
799
736
  debugErrorLog(...log: any[]): void {
800
- if (this.enablingDeviceLogging()) {
801
- if (this.deviceLogging?.includes('debug')) {
802
- this.platform.log.error('[DEBUG]', String(...log));
803
- }
737
+ if (this.enablingDeviceLogging() && this.deviceLogging?.includes('debug')) {
738
+ this.platform.log.error('[DEBUG]', String(...log));
804
739
  }
805
740
  }
806
741
 
@@ -1,81 +0,0 @@
1
- #!/bin/env node
2
-
3
- /**
4
- * This scripts queries the npm registry to pull out the latest version for a given tag.
5
- */
6
-
7
- const fs = require("fs");
8
- const semver = require("semver");
9
- const child_process = require("child_process");
10
- const assert = require("assert");
11
-
12
- const BRANCH_VERSION_PATTERN = /^([A-Za-z]*)-(\d+.\d+.\d+)$/
13
-
14
- // Load the contents of the package.json file
15
- const packageJSON = JSON.parse(fs.readFileSync("package.json", "utf8"));
16
-
17
- let refArgument = process.argv[2];
18
- let tagArgument = process.argv[3] || "latest";
19
-
20
- if (refArgument == null) {
21
- console.error("ref argument is missing");
22
- console.error("Usage: npm-version-script.js <ref> [tag]");
23
- process.exit(1);
24
- }
25
-
26
- /**
27
- * Queries the NPM registry for the latest version for the provided tag.
28
- * @param tag The tag to query for.
29
- * @returns {string} Returns the version.
30
- */
31
- function getTagVersionFromNpm(tag) {
32
- try {
33
- return child_process.execSync(`npm info ${packageJSON.name} version --tag="${tag}"`).toString("utf8").trim();
34
- } catch (e) {
35
- throw e;
36
- }
37
- }
38
-
39
- function desiredTargetVersion(ref) {
40
- // ref is a GitHub action ref string
41
- if (ref.startsWith("refs/pull/")) {
42
- throw Error("The version script was executed inside a PR!");
43
- }
44
-
45
- assert(ref.startsWith("refs/heads/"))
46
- let branchName = ref.slice("refs/heads/".length);
47
-
48
- let results = branchName.match(BRANCH_VERSION_PATTERN);
49
- if (results != null) {
50
- if (results[1] !== tagArgument) {
51
- console.warn(`The base branch name (${results[1]}) differs from the tag name ${tagArgument}`);
52
- }
53
-
54
- return results[2];
55
- }
56
-
57
- // legacy mode were we use the `betaVersion` property in the package.json
58
- if (branchName === "beta" && packageJSON.betaVersion) {
59
- return packageJSON.betaVersion
60
- }
61
-
62
- throw new Error("Malformed branch name for ref: " + ref + ". Can't derive the base version. Use a branch name like: beta-x.x.x!");
63
- }
64
-
65
- // derive the base version from the branch ref
66
- const baseVersion = desiredTargetVersion(refArgument);
67
-
68
- // query the npm registry for the latest version of the provided tag name
69
- const latestReleasedVersion = getTagVersionFromNpm(tagArgument); // e.g. 0.7.0-beta.12
70
- const latestReleaseBase = semver.inc(latestReleasedVersion, "patch"); // will produce 0.7.0 (removing the preid, needed for the equality check below)
71
-
72
- let publishTag;
73
- if (semver.eq(baseVersion, latestReleaseBase)) { // check if we are releasing another version for the latest beta
74
- publishTag = latestReleasedVersion; // set the current latest beta to be incremented
75
- } else {
76
- publishTag = baseVersion; // start of with a new beta version
77
- }
78
-
79
- // save the package.json
80
- packageJSON.version = publishTag;
81
- fs.writeFileSync("package.json", JSON.stringify(packageJSON, null, 2));