@switchbot/homebridge-switchbot 3.5.1-beta.9 → 3.5.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.
- package/CHANGELOG.md +7 -0
- package/config.schema.json +19 -3
- package/dist/device/blindtilt.d.ts +6 -4
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +60 -46
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +6 -3
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +59 -25
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +6 -3
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +47 -29
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +6 -3
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +53 -36
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +6 -3
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +45 -31
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +6 -4
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +41 -27
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +6 -3
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +59 -152
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts +6 -3
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +53 -32
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts +6 -3
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +49 -30
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +6 -3
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +47 -28
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +6 -3
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +44 -27
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +6 -3
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +46 -28
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +6 -3
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +38 -25
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +6 -3
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +43 -27
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +6 -3
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +42 -27
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +6 -3
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +37 -24
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +6 -3
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +30 -17
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +6 -3
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +37 -22
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +6 -3
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +43 -26
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/homebridge-ui/public/index.html +2 -2
- package/dist/irdevice/airconditioner.d.ts +1 -3
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +67 -177
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +0 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +24 -53
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +12 -17
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +22 -38
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +22 -10
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +94 -100
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +20 -38
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +79 -77
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +38 -53
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +11 -16
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +11 -16
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +4 -6
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +564 -665
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +10 -8
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/dist/types/bledevicestatus.d.ts +2 -1
- package/dist/types/bledevicestatus.d.ts.map +1 -1
- package/dist/types/devicestatus.d.ts +1 -1
- package/dist/types/devicestatus.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/device/blindtilt.ts +64 -48
- package/src/device/bot.ts +79 -26
- package/src/device/ceilinglight.ts +57 -31
- package/src/device/colorbulb.ts +57 -43
- package/src/device/contact.ts +49 -31
- package/src/device/curtain.ts +51 -28
- package/src/device/device.ts +61 -135
- package/src/device/fan.ts +67 -33
- package/src/device/hub.ts +62 -33
- package/src/device/humidifier.ts +60 -33
- package/src/device/iosensor.ts +51 -30
- package/src/device/lightstrip.ts +52 -29
- package/src/device/lock.ts +55 -26
- package/src/device/meter.ts +60 -29
- package/src/device/meterplus.ts +56 -29
- package/src/device/motion.ts +50 -26
- package/src/device/plug.ts +38 -18
- package/src/device/robotvacuumcleaner.ts +53 -24
- package/src/device/waterdetector.ts +62 -28
- package/src/homebridge-ui/public/index.html +2 -2
- package/src/irdevice/airconditioner.ts +76 -165
- package/src/irdevice/airpurifier.ts +29 -49
- package/src/irdevice/camera.ts +13 -16
- package/src/irdevice/fan.ts +25 -35
- package/src/irdevice/irdevice.ts +97 -96
- package/src/irdevice/light.ts +21 -35
- package/src/irdevice/other.ts +79 -77
- package/src/irdevice/tv.ts +40 -51
- package/src/irdevice/vacuumcleaner.ts +12 -15
- package/src/irdevice/waterheater.ts +12 -15
- package/src/platform.ts +566 -696
- package/src/settings.ts +11 -8
- package/src/types/bledevicestatus.ts +4 -2
- package/src/types/devicestatus.ts +1 -1
- package/.github/npm-version-script.cjs +0 -81
|
@@ -28,6 +28,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
meter?: PlatformAccessory;
|
|
31
|
+
|
|
31
32
|
private HumiditySensor?: {
|
|
32
33
|
Name: CharacteristicValue;
|
|
33
34
|
Service: Service;
|
|
@@ -55,13 +56,14 @@ export class AirConditioner extends irdeviceBase {
|
|
|
55
56
|
device: irdevice & irDevicesConfig,
|
|
56
57
|
) {
|
|
57
58
|
super(platform, accessory, device);
|
|
59
|
+
// Set category
|
|
60
|
+
accessory.category = this.hap.Categories.AIR_CONDITIONER;
|
|
58
61
|
|
|
59
62
|
// default placeholders
|
|
60
63
|
this.getAirConditionerConfigSettings(accessory, device);
|
|
61
64
|
|
|
62
65
|
this.ValidValues = this.hide_automode ? [1, 2] : [0, 1, 2];
|
|
63
66
|
|
|
64
|
-
|
|
65
67
|
// Initialize HeaterCooler Service
|
|
66
68
|
accessory.context.HeaterCooler = accessory.context.HeaterCooler ?? {};
|
|
67
69
|
this.HeaterCooler = {
|
|
@@ -181,7 +183,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
181
183
|
* AirConditioner: "command" "highSpeed" "default" = fan speed to high
|
|
182
184
|
*/
|
|
183
185
|
async pushAirConditionerOnChanges(): Promise<void> {
|
|
184
|
-
this.debugLog(
|
|
186
|
+
await this.debugLog(`pushAirConditionerOnChanges Active: ${this.HeaterCooler.Active},`
|
|
185
187
|
+ ` disablePushOn: ${this.disablePushOn}`);
|
|
186
188
|
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
187
189
|
const commandType: string = await this.commandType();
|
|
@@ -196,7 +198,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
196
198
|
}
|
|
197
199
|
|
|
198
200
|
async pushAirConditionerOffChanges(): Promise<void> {
|
|
199
|
-
this.debugLog(
|
|
201
|
+
await this.debugLog(`pushAirConditionerOffChanges Active: ${this.HeaterCooler.Active},`
|
|
200
202
|
+ ` disablePushOff: ${this.disablePushOff}`);
|
|
201
203
|
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
202
204
|
const commandType: string = await this.commandType();
|
|
@@ -211,7 +213,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
211
213
|
}
|
|
212
214
|
|
|
213
215
|
async pushAirConditionerStatusChanges(): Promise<void> {
|
|
214
|
-
this.debugLog(
|
|
216
|
+
await this.debugLog(`pushAirConditionerStatusChanges Active: ${this.HeaterCooler.Active},`
|
|
215
217
|
+ ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
|
|
216
218
|
if (!this.Busy) {
|
|
217
219
|
this.Busy = true;
|
|
@@ -224,7 +226,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
224
226
|
}
|
|
225
227
|
|
|
226
228
|
async pushAirConditionerDetailsChanges(): Promise<void> {
|
|
227
|
-
this.debugLog(
|
|
229
|
+
await this.debugLog(`pushAirConditionerDetailsChanges Active: ${this.HeaterCooler.Active},`
|
|
228
230
|
+ ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
|
|
229
231
|
//await this.deviceContext();
|
|
230
232
|
if (this.CurrentMode === undefined) {
|
|
@@ -241,7 +243,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
241
243
|
if (this.CurrentMode === 1) {
|
|
242
244
|
// Remove or make configurable?
|
|
243
245
|
this.HeaterCooler.ThresholdTemperature = 25;
|
|
244
|
-
this.debugLog(
|
|
246
|
+
await this.debugLog(`CurrentMode: ${this.CurrentMode},`
|
|
245
247
|
+ ` ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
246
248
|
}
|
|
247
249
|
const parameter = `${this.HeaterCooler.ThresholdTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
|
|
@@ -344,14 +346,14 @@ export class AirConditioner extends irdeviceBase {
|
|
|
344
346
|
}
|
|
345
347
|
|
|
346
348
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
347
|
-
this.debugLog(
|
|
349
|
+
await this.debugLog('pushChanges');
|
|
348
350
|
if (this.device.connectionType === 'OpenAPI' && !this.disablePushDetail) {
|
|
349
|
-
this.infoLog(
|
|
351
|
+
await this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
350
352
|
try {
|
|
351
353
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
352
354
|
const deviceStatus: any = await body.json();
|
|
353
355
|
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
354
|
-
if (
|
|
356
|
+
if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
|
|
355
357
|
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
356
358
|
await this.updateHomeKitCharacteristics();
|
|
357
359
|
} else {
|
|
@@ -363,35 +365,33 @@ export class AirConditioner extends irdeviceBase {
|
|
|
363
365
|
await this.pushChangeError(e);
|
|
364
366
|
}
|
|
365
367
|
} else {
|
|
366
|
-
this.warnLog(
|
|
367
|
-
|
|
368
|
-
this.
|
|
369
|
-
+ ` Connection Type: ${this.device.connectionType}, disablePushDetails: ${this.disablePushDetail}`);
|
|
370
|
-
this.updateHomeKitCharacteristics();
|
|
368
|
+
await this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
369
|
+
await this.debugLog(`Connection Type: ${this.device.connectionType}, disablePushDetails: ${this.disablePushDetail}`);
|
|
370
|
+
await this.updateHomeKitCharacteristics();
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
373
|
|
|
374
374
|
async CurrentTemperatureGet(): Promise<CharacteristicValue> {
|
|
375
375
|
if (this.meter?.context?.CurrentTemperature) {
|
|
376
376
|
this.accessory.context.CurrentTemperature = this.meter.context.CurrentTemperature;
|
|
377
|
-
this.debugLog(
|
|
378
|
-
+ `Using CurrentTemperature from ${this.meter.context.deviceType} (${this.meter.context.
|
|
377
|
+
await this.debugLog(''
|
|
378
|
+
+ `Using CurrentTemperature from ${this.meter.context.deviceType} (${this.meter.context.deviceId})`);
|
|
379
379
|
}
|
|
380
380
|
|
|
381
381
|
this.HeaterCooler.CurrentTemperature = this.accessory.context.CurrentTemperature || 24;
|
|
382
|
-
this.debugLog(
|
|
382
|
+
await this.debugLog(`Get CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
|
|
383
383
|
return this.HeaterCooler.CurrentTemperature;
|
|
384
384
|
}
|
|
385
385
|
|
|
386
386
|
async CurrentRelativeHumidityGet(): Promise<CharacteristicValue> {
|
|
387
387
|
if (this.meter?.context?.CurrentRelativeHumidity) {
|
|
388
388
|
this.accessory.context.CurrentRelativeHumidity = this.meter.context.CurrentRelativeHumidity;
|
|
389
|
-
this.debugLog(
|
|
390
|
-
+ `Using CurrentRelativeHumidity from ${this.meter.context.deviceType} (${this.meter.context.
|
|
389
|
+
await this.debugLog(''
|
|
390
|
+
+ `Using CurrentRelativeHumidity from ${this.meter.context.deviceType} (${this.meter.context.deviceId})`);
|
|
391
391
|
}
|
|
392
392
|
|
|
393
393
|
this.HumiditySensor!.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity || 0;
|
|
394
|
-
this.debugLog(
|
|
394
|
+
await this.debugLog('Get'
|
|
395
395
|
+ ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
|
|
396
396
|
return this.HumiditySensor!.CurrentRelativeHumidity as CharacteristicValue;
|
|
397
397
|
}
|
|
@@ -402,7 +402,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
402
402
|
} else {
|
|
403
403
|
this.HeaterCooler.RotationSpeed = this.CurrentFanSpeed - 1;
|
|
404
404
|
}
|
|
405
|
-
this.debugLog(
|
|
405
|
+
await this.debugLog(`Get RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
|
|
406
406
|
return this.HeaterCooler.RotationSpeed;
|
|
407
407
|
}
|
|
408
408
|
|
|
@@ -413,24 +413,23 @@ export class AirConditioner extends irdeviceBase {
|
|
|
413
413
|
this.CurrentFanSpeed = Number(value) + 1;
|
|
414
414
|
}
|
|
415
415
|
this.HeaterCooler.RotationSpeed = value;
|
|
416
|
-
this.debugLog(
|
|
417
|
-
+ `Set RotationSpeed: ${this.HeaterCooler.RotationSpeed}, CurrentFanSpeed: ${this.CurrentFanSpeed}`);
|
|
416
|
+
await this.debugLog(`Set RotationSpeed: ${this.HeaterCooler.RotationSpeed}, CurrentFanSpeed: ${this.CurrentFanSpeed}`);
|
|
418
417
|
this.pushAirConditionerStatusChanges();
|
|
419
418
|
}
|
|
420
419
|
|
|
421
420
|
async ActiveSet(value: CharacteristicValue): Promise<void> {
|
|
422
|
-
this.debugLog(
|
|
421
|
+
await this.debugLog(`Set Active: ${value}`);
|
|
423
422
|
|
|
424
423
|
this.HeaterCooler.Active = value;
|
|
425
424
|
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
426
|
-
this.debugLog(
|
|
425
|
+
await this.debugLog(`pushAirConditionerOnChanges, Active: ${this.HeaterCooler.Active}`);
|
|
427
426
|
if (this.disablePushOn) {
|
|
428
427
|
this.pushAirConditionerStatusChanges();
|
|
429
428
|
} else {
|
|
430
429
|
this.pushAirConditionerOnChanges();
|
|
431
430
|
}
|
|
432
431
|
} else {
|
|
433
|
-
this.debugLog(
|
|
432
|
+
await this.debugLog(`pushAirConditionerOffChanges, Active: ${this.HeaterCooler.Active}`);
|
|
434
433
|
this.pushAirConditionerOffChanges();
|
|
435
434
|
}
|
|
436
435
|
}
|
|
@@ -438,7 +437,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
438
437
|
async TargetHeaterCoolerStateGet(): Promise<CharacteristicValue> {
|
|
439
438
|
const targetState = this.HeaterCooler.TargetHeaterCoolerState || this.accessory.context.TargetHeaterCoolerState;
|
|
440
439
|
this.HeaterCooler.TargetHeaterCoolerState = this.ValidValues.includes(targetState) ? targetState : this.ValidValues[0];
|
|
441
|
-
this.debugLog(
|
|
440
|
+
await this.debugLog(`Get (${this.getTargetHeaterCoolerStateName()}) TargetHeaterCoolerState:`
|
|
442
441
|
+ ` ${this.HeaterCooler.TargetHeaterCoolerState}, ValidValues: ${this.ValidValues}, hide_automode: ${this.hide_automode}`);
|
|
443
442
|
return this.HeaterCooler.TargetHeaterCoolerState;
|
|
444
443
|
}
|
|
@@ -451,7 +450,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
451
450
|
} else if (value === this.hap.Characteristic.TargetHeaterCoolerState.COOL) {
|
|
452
451
|
this.TargetHeaterCoolerStateCOOL();
|
|
453
452
|
} else {
|
|
454
|
-
this.errorLog(
|
|
453
|
+
this.errorLog('Set TargetHeaterCoolerState: '
|
|
455
454
|
+ `${this.HeaterCooler.TargetHeaterCoolerState}, hide_automode: ${this.hide_automode} `);
|
|
456
455
|
}
|
|
457
456
|
this.pushAirConditionerStatusChanges();
|
|
@@ -460,31 +459,30 @@ export class AirConditioner extends irdeviceBase {
|
|
|
460
459
|
async TargetHeaterCoolerStateAUTO(): Promise<void> {
|
|
461
460
|
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
462
461
|
this.CurrentMode = 1;
|
|
463
|
-
this.debugLog(
|
|
462
|
+
await this.debugLog('Set (AUTO)'
|
|
464
463
|
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
465
|
-
this.debugLog(
|
|
464
|
+
await this.debugLog(`Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
466
465
|
}
|
|
467
466
|
|
|
468
467
|
async TargetHeaterCoolerStateCOOL(): Promise<void> {
|
|
469
468
|
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.COOL;
|
|
470
469
|
this.CurrentMode = 2;
|
|
471
|
-
this.debugLog(
|
|
470
|
+
await this.debugLog('Set (COOL)'
|
|
472
471
|
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
473
|
-
this.debugLog(
|
|
472
|
+
await this.debugLog(`Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
474
473
|
}
|
|
475
474
|
|
|
476
475
|
async TargetHeaterCoolerStateHEAT(): Promise<void> {
|
|
477
476
|
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
478
477
|
this.CurrentMode = 5;
|
|
479
|
-
this.debugLog(
|
|
478
|
+
await this.debugLog('Set (HEAT)'
|
|
480
479
|
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
481
|
-
this.debugLog(
|
|
480
|
+
await this.debugLog(`Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
482
481
|
}
|
|
483
482
|
|
|
484
483
|
async CurrentHeaterCoolerStateGet(): Promise<CharacteristicValue> {
|
|
485
484
|
await this.UpdateCurrentHeaterCoolerState();
|
|
486
|
-
this.debugLog(
|
|
487
|
-
+ ` Get (${this.getTargetHeaterCoolerStateName()}) CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
|
|
485
|
+
await this.debugLog(`Get (${this.getTargetHeaterCoolerStateName()}) CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
|
|
488
486
|
|
|
489
487
|
return this.HeaterCooler.CurrentHeaterCoolerState;
|
|
490
488
|
}
|
|
@@ -504,123 +502,68 @@ export class AirConditioner extends irdeviceBase {
|
|
|
504
502
|
}
|
|
505
503
|
|
|
506
504
|
async ThresholdTemperatureGet(): Promise<CharacteristicValue> {
|
|
505
|
+
this.HeaterCooler.Active = this.HeaterCooler.Active === undefined ? this.hap.Characteristic.Active.INACTIVE
|
|
506
|
+
: this.HeaterCooler.Active ?? this.accessory.context.Active;
|
|
507
507
|
|
|
508
|
-
|
|
509
|
-
this.
|
|
510
|
-
|
|
511
|
-
this.HeaterCooler.Active = this.HeaterCooler.Active ? this.HeaterCooler.Active : this.accessory.context.Active;
|
|
512
|
-
}
|
|
508
|
+
this.HeaterCooler.CurrentTemperature = (this.HeaterCooler.CurrentTemperature === undefined
|
|
509
|
+
&& this.accessory.context.CurrentTemperature === undefined) ? 24 : this.HeaterCooler.CurrentTemperature
|
|
510
|
+
?? this.accessory.context.CurrentTemperature;
|
|
513
511
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
} else {
|
|
517
|
-
this.HeaterCooler.CurrentTemperature = this.HeaterCooler.CurrentTemperature || this.accessory.context.CurrentTemperature;
|
|
518
|
-
}
|
|
512
|
+
this.HeaterCooler.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature === undefined ? 24 : this.HeaterCooler.ThresholdTemperature
|
|
513
|
+
?? this.accessory.context.ThresholdTemperature;
|
|
519
514
|
|
|
520
|
-
|
|
521
|
-
this.HeaterCooler.
|
|
522
|
-
} else {
|
|
523
|
-
this.HeaterCooler.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
if (this.HeaterCooler.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
|
|
527
|
-
this.HeaterCooler.RotationSpeed = 4;
|
|
528
|
-
} else {
|
|
529
|
-
this.HeaterCooler.RotationSpeed = this.HeaterCooler.RotationSpeed || this.accessory.context.RotationSpeed;
|
|
530
|
-
}
|
|
515
|
+
this.HeaterCooler.RotationSpeed = (this.HeaterCooler.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) ? 4
|
|
516
|
+
: this.HeaterCooler.RotationSpeed ?? this.accessory.context.RotationSpeed;
|
|
531
517
|
|
|
532
518
|
await this.getAirConditionerConfigSettings(this.accessory, this.device);
|
|
533
519
|
|
|
534
|
-
if (this.meter) {
|
|
535
|
-
|
|
536
|
-
this.
|
|
537
|
-
|
|
538
|
-
this.HumiditySensor!.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
|
|
539
|
-
}
|
|
520
|
+
if (this.meter && this.HumiditySensor?.Service) {
|
|
521
|
+
this.HumiditySensor.CurrentRelativeHumidity = (this.HumiditySensor.CurrentRelativeHumidity === undefined
|
|
522
|
+
&& this.accessory.context.CurrentRelativeHumidity === undefined) ? 0 : this.HumiditySensor.CurrentRelativeHumidity
|
|
523
|
+
?? this.accessory.context.CurrentRelativeHumidity;
|
|
540
524
|
}
|
|
541
|
-
this.debugLog(
|
|
525
|
+
await this.debugLog(`Get ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
542
526
|
return this.HeaterCooler.ThresholdTemperature;
|
|
543
527
|
}
|
|
544
528
|
|
|
545
529
|
async ThresholdTemperatureSet(value: CharacteristicValue): Promise<void> {
|
|
546
530
|
this.HeaterCooler.ThresholdTemperature = value;
|
|
547
|
-
this.debugLog(
|
|
531
|
+
await this.debugLog(`Set ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature},`
|
|
548
532
|
+ ` ThresholdTemperatureCached: ${this.accessory.context.ThresholdTemperature}`);
|
|
549
533
|
this.pushAirConditionerStatusChanges();
|
|
550
534
|
}
|
|
551
535
|
|
|
552
536
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
537
|
+
await this.debugLog('updateHomeKitCharacteristics');
|
|
553
538
|
// Active
|
|
554
|
-
|
|
555
|
-
this.
|
|
556
|
-
} else {
|
|
557
|
-
this.accessory.context.Active = this.HeaterCooler.Active;
|
|
558
|
-
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.Active, this.HeaterCooler.Active);
|
|
559
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.HeaterCooler.Active}`);
|
|
560
|
-
}
|
|
539
|
+
await this.updateCharacteristic(this.HeaterCooler.Service, this.hap.Characteristic.Active,
|
|
540
|
+
this.HeaterCooler.Active, 'Active');
|
|
561
541
|
// RotationSpeed
|
|
562
|
-
|
|
563
|
-
this.
|
|
564
|
-
} else {
|
|
565
|
-
this.accessory.context.RotationSpeed = this.HeaterCooler.RotationSpeed;
|
|
566
|
-
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.RotationSpeed, this.HeaterCooler.RotationSpeed);
|
|
567
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
568
|
-
+ ` RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
|
|
569
|
-
}
|
|
542
|
+
await this.updateCharacteristic(this.HeaterCooler.Service, this.hap.Characteristic.RotationSpeed,
|
|
543
|
+
this.HeaterCooler.RotationSpeed, 'RotationSpeed');
|
|
570
544
|
// CurrentTemperature
|
|
571
|
-
|
|
572
|
-
this.
|
|
573
|
-
} else {
|
|
574
|
-
this.accessory.context.CurrentTemperature = this.HeaterCooler.CurrentTemperature;
|
|
575
|
-
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, this.HeaterCooler.CurrentTemperature);
|
|
576
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
577
|
-
+ ` CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
|
|
578
|
-
}
|
|
579
|
-
// CurrentRelativeHumidity
|
|
580
|
-
if (this.meter) {
|
|
581
|
-
if (this.HumiditySensor!.CurrentRelativeHumidity === undefined) {
|
|
582
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
583
|
-
+ ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
|
|
584
|
-
} else {
|
|
585
|
-
this.accessory.context.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity;
|
|
586
|
-
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity,
|
|
587
|
-
this.HumiditySensor!.CurrentRelativeHumidity);
|
|
588
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
589
|
-
+ ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
545
|
+
await this.updateCharacteristic(this.HeaterCooler.Service, this.hap.Characteristic.CurrentTemperature,
|
|
546
|
+
this.HeaterCooler.CurrentTemperature, 'CurrentTemperature');
|
|
592
547
|
// TargetHeaterCoolerState
|
|
593
|
-
|
|
594
|
-
this.
|
|
595
|
-
} else {
|
|
596
|
-
this.accessory.context.TargetHeaterCoolerState = this.HeaterCooler.TargetHeaterCoolerState;
|
|
597
|
-
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState, this.HeaterCooler.TargetHeaterCoolerState);
|
|
598
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
599
|
-
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
600
|
-
}
|
|
548
|
+
await this.updateCharacteristic(this.HeaterCooler.Service, this.hap.Characteristic.TargetHeaterCoolerState,
|
|
549
|
+
this.HeaterCooler.TargetHeaterCoolerState, 'TargetHeaterCoolerState');
|
|
601
550
|
// CurrentHeaterCoolerState
|
|
602
|
-
|
|
603
|
-
this.
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
this.
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
} else {
|
|
615
|
-
this.accessory.context.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature;
|
|
616
|
-
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature, this.HeaterCooler.ThresholdTemperature);
|
|
617
|
-
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature, this.HeaterCooler.ThresholdTemperature);
|
|
618
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
619
|
-
+ ` ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
551
|
+
await this.updateCharacteristic(this.HeaterCooler.Service, this.hap.Characteristic.CurrentHeaterCoolerState,
|
|
552
|
+
this.HeaterCooler.CurrentHeaterCoolerState, 'CurrentHeaterCoolerState');
|
|
553
|
+
// HeatingThresholdTemperature
|
|
554
|
+
await this.updateCharacteristic(this.HeaterCooler.Service, this.hap.Characteristic.HeatingThresholdTemperature,
|
|
555
|
+
this.HeaterCooler.ThresholdTemperature, 'ThresholdTemperature');
|
|
556
|
+
// CoolingThresholdTemperature
|
|
557
|
+
await this.updateCharacteristic(this.HeaterCooler.Service, this.hap.Characteristic.CoolingThresholdTemperature,
|
|
558
|
+
this.HeaterCooler.ThresholdTemperature, 'ThresholdTemperature');
|
|
559
|
+
if (this.meter && this.HumiditySensor?.Service) {
|
|
560
|
+
// CurrentRelativeHumidity
|
|
561
|
+
await this.updateCharacteristic(this.HumiditySensor.Service, this.hap.Characteristic.CurrentRelativeHumidity,
|
|
562
|
+
this.HumiditySensor.CurrentRelativeHumidity, 'CurrentRelativeHumidity');
|
|
620
563
|
}
|
|
621
564
|
}
|
|
622
565
|
|
|
623
|
-
async apiError(
|
|
566
|
+
async apiError(e: any): Promise<void> {
|
|
624
567
|
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.Active, e);
|
|
625
568
|
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.RotationSpeed, e);
|
|
626
569
|
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, e);
|
|
@@ -632,42 +575,10 @@ export class AirConditioner extends irdeviceBase {
|
|
|
632
575
|
}
|
|
633
576
|
|
|
634
577
|
async getAirConditionerConfigSettings(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): Promise<void> {
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
accessory.context.hide_automode = this.hide_automode;
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
if (this.device.irair?.set_max_heat) {
|
|
644
|
-
this.set_max_heat = device.irair?.set_max_heat;
|
|
645
|
-
accessory.context.set_max_heat = this.set_max_heat;
|
|
646
|
-
} else {
|
|
647
|
-
this.set_max_heat = 35;
|
|
648
|
-
accessory.context.set_max_heat = this.set_max_heat;
|
|
649
|
-
}
|
|
650
|
-
if (this.device.irair?.set_min_heat) {
|
|
651
|
-
this.set_min_heat = device.irair?.set_min_heat;
|
|
652
|
-
accessory.context.set_min_heat = this.set_min_heat;
|
|
653
|
-
} else {
|
|
654
|
-
this.set_min_heat = 0;
|
|
655
|
-
accessory.context.set_min_heat = this.set_min_heat;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
if (this.device.irair?.set_max_cool) {
|
|
659
|
-
this.set_max_cool = device.irair?.set_max_cool;
|
|
660
|
-
accessory.context.set_max_cool = this.set_max_cool;
|
|
661
|
-
} else {
|
|
662
|
-
this.set_max_cool = 35;
|
|
663
|
-
accessory.context.set_max_cool = this.set_max_cool;
|
|
664
|
-
}
|
|
665
|
-
if (this.device.irair?.set_min_cool) {
|
|
666
|
-
this.set_min_cool = device.irair?.set_min_cool;
|
|
667
|
-
accessory.context.set_min_cool = this.set_min_cool;
|
|
668
|
-
} else {
|
|
669
|
-
this.set_min_cool = 0;
|
|
670
|
-
accessory.context.set_min_cool = this.set_min_cool;
|
|
671
|
-
}
|
|
578
|
+
accessory.context.hide_automode = this.hide_automode = device.irair?.hide_automode;
|
|
579
|
+
accessory.context.set_max_heat = this.set_max_heat = device.irair?.set_max_heat ?? 35;
|
|
580
|
+
accessory.context.set_min_heat = this.set_min_heat = device.irair?.set_min_heat ?? 0;
|
|
581
|
+
accessory.context.set_max_cool = this.set_max_cool = device.irair?.set_max_cool ?? 35;
|
|
582
|
+
accessory.context.set_min_cool = this.set_min_cool = device.irair?.set_min_cool ?? 0;
|
|
672
583
|
}
|
|
673
584
|
}
|
|
@@ -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;
|
|
@@ -54,6 +54,8 @@ export class AirPurifier extends irdeviceBase {
|
|
|
54
54
|
device: irdevice & irDevicesConfig,
|
|
55
55
|
) {
|
|
56
56
|
super(platform, accessory, device);
|
|
57
|
+
// Set category
|
|
58
|
+
accessory.category = this.hap.Categories.AIR_PURIFIER;
|
|
57
59
|
|
|
58
60
|
// Initialize AirPurifier Service
|
|
59
61
|
accessory.context.AirPurifier = accessory.context.AirPurifier ?? {};
|
|
@@ -64,6 +66,7 @@ export class AirPurifier extends irdeviceBase {
|
|
|
64
66
|
RotationSpeed: accessory.context.RotationSpeed ?? 0,
|
|
65
67
|
CurrentAirPurifierState: accessory.context.CurrentAirPurifierState ?? this.hap.Characteristic.CurrentAirPurifierState.INACTIVE,
|
|
66
68
|
TargetAirPurifierState: accessory.context.TargetAirPurifierState ?? this.hap.Characteristic.TargetAirPurifierState.AUTO,
|
|
69
|
+
CurrentHeaterCoolerState: accessory.context.CurrentHeaterCoolerState ?? this.hap.Characteristic.CurrentHeaterCoolerState.INACTIVE,
|
|
67
70
|
};
|
|
68
71
|
accessory.context.AirPurifier = this.AirPurifier as object;
|
|
69
72
|
|
|
@@ -106,7 +109,7 @@ export class AirPurifier extends irdeviceBase {
|
|
|
106
109
|
}
|
|
107
110
|
|
|
108
111
|
async ActiveSet(value: CharacteristicValue): Promise<void> {
|
|
109
|
-
this.debugLog(
|
|
112
|
+
await this.debugLog(`Set Active: ${value}`);
|
|
110
113
|
|
|
111
114
|
this.AirPurifier.Active = value;
|
|
112
115
|
if (this.AirPurifier.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
@@ -153,7 +156,7 @@ export class AirPurifier extends irdeviceBase {
|
|
|
153
156
|
* AirPurifier: "command" "highSpeed" "default" = fan speed to high
|
|
154
157
|
*/
|
|
155
158
|
async pushAirPurifierOnChanges(): Promise<void> {
|
|
156
|
-
this.debugLog(
|
|
159
|
+
await this.debugLog(`pushAirPurifierOnChanges Active: ${this.AirPurifier.Active},`
|
|
157
160
|
+ ` disablePushOn: ${this.disablePushOn}`);
|
|
158
161
|
if (this.AirPurifier.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
159
162
|
const commandType: string = await this.commandType();
|
|
@@ -168,7 +171,7 @@ export class AirPurifier extends irdeviceBase {
|
|
|
168
171
|
}
|
|
169
172
|
|
|
170
173
|
async pushAirPurifierOffChanges(): Promise<void> {
|
|
171
|
-
this.debugLog(
|
|
174
|
+
await this.debugLog(`pushAirPurifierOffChanges Active: ${this.AirPurifier.Active},`
|
|
172
175
|
+ ` disablePushOff: ${this.disablePushOff}`);
|
|
173
176
|
if (this.AirPurifier.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOn) {
|
|
174
177
|
const commandType: string = await this.commandType();
|
|
@@ -183,11 +186,11 @@ export class AirPurifier extends irdeviceBase {
|
|
|
183
186
|
}
|
|
184
187
|
|
|
185
188
|
async pushAirPurifierStatusChanges(): Promise<void> {
|
|
186
|
-
this.debugLog(
|
|
189
|
+
await this.debugLog(`pushAirPurifierStatusChanges Active: ${this.AirPurifier.Active},`
|
|
187
190
|
+ ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
|
|
188
191
|
if (!this.Busy) {
|
|
189
192
|
this.Busy = true;
|
|
190
|
-
this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
193
|
+
this.AirPurifier.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
191
194
|
}
|
|
192
195
|
clearTimeout(this.Timeout);
|
|
193
196
|
|
|
@@ -196,7 +199,7 @@ export class AirPurifier extends irdeviceBase {
|
|
|
196
199
|
}
|
|
197
200
|
|
|
198
201
|
async pushAirPurifierDetailsChanges(): Promise<void> {
|
|
199
|
-
this.debugLog(
|
|
202
|
+
await this.debugLog(`pushAirPurifierDetailsChanges Active: ${this.AirPurifier.Active},`
|
|
200
203
|
+ ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
|
|
201
204
|
this.CurrentAPTemp = this.TemperatureSensor!.CurrentTemperature ?? 24;
|
|
202
205
|
this.CurrentAPMode = this.CurrentMode ?? 1;
|
|
@@ -210,25 +213,25 @@ export class AirPurifier extends irdeviceBase {
|
|
|
210
213
|
});
|
|
211
214
|
if (this.AirPurifier.Active === 1) {
|
|
212
215
|
if ((Number(this.TemperatureSensor!.CurrentTemperature) || 24) < (this.LastTemperature || 30)) {
|
|
213
|
-
this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
216
|
+
this.AirPurifier.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
214
217
|
} else {
|
|
215
|
-
this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
218
|
+
this.AirPurifier.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
216
219
|
}
|
|
217
220
|
} else {
|
|
218
|
-
this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
221
|
+
this.AirPurifier.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
219
222
|
}
|
|
220
223
|
await this.pushChanges(bodyChange);
|
|
221
224
|
}
|
|
222
225
|
|
|
223
226
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
224
|
-
this.debugLog(
|
|
227
|
+
await this.debugLog('pushChanges');
|
|
225
228
|
if (this.device.connectionType === 'OpenAPI') {
|
|
226
|
-
this.infoLog(
|
|
229
|
+
this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
227
230
|
try {
|
|
228
231
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
229
232
|
const deviceStatus: any = await body.json();
|
|
230
233
|
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
231
|
-
if (
|
|
234
|
+
if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
|
|
232
235
|
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
233
236
|
await this.updateHomeKitCharacteristics();
|
|
234
237
|
} else {
|
|
@@ -240,54 +243,31 @@ export class AirPurifier extends irdeviceBase {
|
|
|
240
243
|
await this.pushChangeError(e);
|
|
241
244
|
}
|
|
242
245
|
} else {
|
|
243
|
-
this.warnLog(
|
|
244
|
-
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
246
|
+
this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
245
247
|
}
|
|
246
248
|
}
|
|
247
249
|
|
|
248
250
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
251
|
+
await this.debugLog('updateHomeKitCharacteristics');
|
|
249
252
|
// Active
|
|
250
|
-
|
|
251
|
-
this.
|
|
252
|
-
} else {
|
|
253
|
-
this.accessory.context.Active = this.AirPurifier.Active;
|
|
254
|
-
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.Active, this.AirPurifier.Active);
|
|
255
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.AirPurifier.Active}`);
|
|
256
|
-
}
|
|
253
|
+
await this.updateCharacteristic(this.AirPurifier.Service, this.hap.Characteristic.Active,
|
|
254
|
+
this.AirPurifier.Active, 'Active');
|
|
257
255
|
// CurrentAirPurifierState
|
|
258
|
-
|
|
259
|
-
this.
|
|
260
|
-
} else {
|
|
261
|
-
this.accessory.context.CurrentAirPurifierState = this.AirPurifier.CurrentAirPurifierState;
|
|
262
|
-
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentAirPurifierState, this.AirPurifier.CurrentAirPurifierState);
|
|
263
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
264
|
-
+ ` CurrentAirPurifierState: ${this.AirPurifier.CurrentAirPurifierState}`);
|
|
265
|
-
}
|
|
256
|
+
await this.updateCharacteristic(this.AirPurifier.Service, this.hap.Characteristic.CurrentAirPurifierState,
|
|
257
|
+
this.AirPurifier.CurrentAirPurifierState, 'CurrentAirPurifierState');
|
|
266
258
|
// CurrentHeaterCoolerState
|
|
267
|
-
|
|
268
|
-
this.
|
|
269
|
-
} else {
|
|
270
|
-
this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerState;
|
|
271
|
-
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
|
|
272
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
273
|
-
+ ` CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
274
|
-
}
|
|
259
|
+
await this.updateCharacteristic(this.AirPurifier.Service, this.hap.Characteristic.CurrentHeaterCoolerState,
|
|
260
|
+
this.AirPurifier.CurrentHeaterCoolerState, 'CurrentHeaterCoolerState');
|
|
275
261
|
// CurrentTemperature
|
|
276
|
-
|
|
277
|
-
this.
|
|
278
|
-
} else {
|
|
279
|
-
this.accessory.context.CurrentTemperature = this.TemperatureSensor.CurrentTemperature;
|
|
280
|
-
this.TemperatureSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, this.TemperatureSensor.CurrentTemperature);
|
|
281
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
282
|
-
+ ` CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`);
|
|
283
|
-
}
|
|
262
|
+
await this.updateCharacteristic(this.TemperatureSensor.Service, this.hap.Characteristic.CurrentTemperature,
|
|
263
|
+
this.TemperatureSensor.CurrentTemperature, 'CurrentTemperature');
|
|
284
264
|
}
|
|
285
265
|
|
|
286
266
|
async apiError(e: any): Promise<void> {
|
|
287
|
-
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, e);
|
|
288
|
-
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentAirPurifierState, e);
|
|
289
|
-
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.TargetAirPurifierState, e);
|
|
290
267
|
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.Active, e);
|
|
268
|
+
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.TargetAirPurifierState, e);
|
|
269
|
+
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentAirPurifierState, e);
|
|
270
|
+
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, e);
|
|
291
271
|
this.TemperatureSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, e);
|
|
292
272
|
}
|
|
293
273
|
}
|