@switchbot/homebridge-switchbot 3.5.1-beta.11 → 3.5.1-beta.12

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.
@@ -23,6 +23,7 @@ export class AirPurifier extends irdeviceBase {
23
23
  RotationSpeed: CharacteristicValue;
24
24
  CurrentAirPurifierState: CharacteristicValue;
25
25
  TargetAirPurifierState: CharacteristicValue;
26
+ CurrentHeaterCoolerState: CharacteristicValue;
26
27
  };
27
28
 
28
29
  private TemperatureSensor: {
@@ -36,7 +37,6 @@ export class AirPurifier extends irdeviceBase {
36
37
  CurrentAPTemp!: CharacteristicValue;
37
38
  CurrentAPMode!: CharacteristicValue;
38
39
  CurrentAPFanSpeed!: CharacteristicValue;
39
- CurrentHeaterCoolerState!: CharacteristicValue;
40
40
 
41
41
  // Others
42
42
  Busy: any;
@@ -64,6 +64,7 @@ export class AirPurifier extends irdeviceBase {
64
64
  RotationSpeed: accessory.context.RotationSpeed ?? 0,
65
65
  CurrentAirPurifierState: accessory.context.CurrentAirPurifierState ?? this.hap.Characteristic.CurrentAirPurifierState.INACTIVE,
66
66
  TargetAirPurifierState: accessory.context.TargetAirPurifierState ?? this.hap.Characteristic.TargetAirPurifierState.AUTO,
67
+ CurrentHeaterCoolerState: accessory.context.CurrentHeaterCoolerState ?? this.hap.Characteristic.CurrentHeaterCoolerState.INACTIVE,
67
68
  };
68
69
  accessory.context.AirPurifier = this.AirPurifier as object;
69
70
 
@@ -187,7 +188,7 @@ export class AirPurifier extends irdeviceBase {
187
188
  + ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
188
189
  if (!this.Busy) {
189
190
  this.Busy = true;
190
- this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE;
191
+ this.AirPurifier.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE;
191
192
  }
192
193
  clearTimeout(this.Timeout);
193
194
 
@@ -210,12 +211,12 @@ export class AirPurifier extends irdeviceBase {
210
211
  });
211
212
  if (this.AirPurifier.Active === 1) {
212
213
  if ((Number(this.TemperatureSensor!.CurrentTemperature) || 24) < (this.LastTemperature || 30)) {
213
- this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.COOLING;
214
+ this.AirPurifier.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.COOLING;
214
215
  } else {
215
- this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.HEATING;
216
+ this.AirPurifier.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.HEATING;
216
217
  }
217
218
  } else {
218
- this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.INACTIVE;
219
+ this.AirPurifier.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.INACTIVE;
219
220
  }
220
221
  await this.pushChanges(bodyChange);
221
222
  }
@@ -247,40 +248,17 @@ export class AirPurifier extends irdeviceBase {
247
248
  async updateHomeKitCharacteristics(): Promise<void> {
248
249
  await this.debugLog('updateHomeKitCharacteristics');
249
250
  // Active
250
- if (this.AirPurifier.Active === undefined) {
251
- await this.debugLog(`Active: ${this.AirPurifier.Active}`);
252
- } else {
253
- this.accessory.context.Active = this.AirPurifier.Active;
254
- this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.Active, this.AirPurifier.Active);
255
- await this.debugLog(`updateCharacteristic Active: ${this.AirPurifier.Active}`);
256
- }
251
+ await this.updateCharacteristic(this.AirPurifier.Service, this.hap.Characteristic.Active,
252
+ this.AirPurifier.Active, 'Active');
257
253
  // CurrentAirPurifierState
258
- if (this.AirPurifier.CurrentAirPurifierState === undefined) {
259
- await this.debugLog(`CurrentAirPurifierState: ${this.AirPurifier.CurrentAirPurifierState}`);
260
- } else {
261
- this.accessory.context.CurrentAirPurifierState = this.AirPurifier.CurrentAirPurifierState;
262
- this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentAirPurifierState, this.AirPurifier.CurrentAirPurifierState);
263
- await this.debugLog('updateCharacteristic'
264
- + ` CurrentAirPurifierState: ${this.AirPurifier.CurrentAirPurifierState}`);
265
- }
254
+ await this.updateCharacteristic(this.AirPurifier.Service, this.hap.Characteristic.CurrentAirPurifierState,
255
+ this.AirPurifier.CurrentAirPurifierState, 'CurrentAirPurifierState');
266
256
  // CurrentHeaterCoolerState
267
- if (this.CurrentHeaterCoolerState === undefined) {
268
- await this.debugLog(`CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
269
- } else {
270
- this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerState;
271
- this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
272
- await this.debugLog('updateCharacteristic'
273
- + ` CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
274
- }
257
+ await this.updateCharacteristic(this.AirPurifier.Service, this.hap.Characteristic.CurrentHeaterCoolerState,
258
+ this.AirPurifier.CurrentHeaterCoolerState, 'CurrentHeaterCoolerState');
275
259
  // CurrentTemperature
276
- if (this.TemperatureSensor.CurrentTemperature === undefined) {
277
- await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`);
278
- } else {
279
- this.accessory.context.CurrentTemperature = this.TemperatureSensor.CurrentTemperature;
280
- this.TemperatureSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, this.TemperatureSensor.CurrentTemperature);
281
- await this.debugLog('updateCharacteristic'
282
- + ` CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`);
283
- }
260
+ await this.updateCharacteristic(this.TemperatureSensor.Service, this.hap.Characteristic.CurrentTemperature,
261
+ this.TemperatureSensor.CurrentTemperature, 'CurrentTemperature');
284
262
  }
285
263
 
286
264
  async apiError(e: any): Promise<void> {
@@ -218,13 +218,13 @@ export abstract class irdeviceBase {
218
218
  async updateCharacteristic(Service: Service, Characteristic: any,
219
219
  CharacteristicValue: CharacteristicValue | undefined, CharacteristicName: string): Promise<void> {
220
220
  if (CharacteristicValue === undefined) {
221
- await await this.debugLog(`${CharacteristicName}: ${CharacteristicValue}`);
221
+ await this.debugLog(`${CharacteristicName}: ${CharacteristicValue}`);
222
222
  } else {
223
223
  Service.updateCharacteristic(Characteristic, CharacteristicValue);
224
- await await this.debugLog(`updateCharacteristic ${CharacteristicName}: ${CharacteristicValue}`);
225
- await await this.debugWarnLog(`context before: ${this.accessory.context[CharacteristicName]}`);
224
+ await this.debugLog(`updateCharacteristic ${CharacteristicName}: ${CharacteristicValue}`);
225
+ await this.debugWarnLog(`context before: ${this.accessory.context[CharacteristicName]}`);
226
226
  this.accessory.context[CharacteristicName] = CharacteristicValue;
227
- await await this.debugWarnLog(`context after: ${this.accessory.context[CharacteristicName]}`);
227
+ await this.debugWarnLog(`context after: ${this.accessory.context[CharacteristicName]}`);
228
228
  }
229
229
  }
230
230