@switchbot/homebridge-switchbot 3.5.1-beta.1 → 3.5.1-beta.11
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/README.md +16 -0
- package/dist/device/blindtilt.d.ts +15 -6
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +203 -255
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +9 -4
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +196 -218
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +9 -4
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +203 -249
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +10 -5
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +329 -378
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +9 -4
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +99 -142
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +19 -7
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +203 -264
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +28 -32
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +186 -225
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts +9 -4
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +198 -227
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts +9 -5
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +106 -231
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +12 -4
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +192 -232
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +9 -4
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +91 -157
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +10 -5
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +287 -367
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +10 -5
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +171 -216
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +9 -4
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +93 -158
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +9 -4
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +94 -155
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +9 -4
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +84 -142
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +9 -4
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +99 -124
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +9 -6
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +170 -253
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +12 -4
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +105 -129
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +2 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +45 -51
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +2 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +17 -17
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +2 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +9 -9
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +2 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +19 -19
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +24 -11
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +90 -68
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts +2 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +15 -17
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +2 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +76 -76
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +2 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +35 -35
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +2 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +9 -9
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +2 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +9 -9
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +15 -15
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +288 -271
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +49 -191
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +19 -0
- package/dist/settings.js.map +1 -1
- package/dist/types/bledevicestatus.d.ts +279 -0
- package/dist/types/bledevicestatus.d.ts.map +1 -0
- package/dist/types/bledevicestatus.js +2 -0
- package/dist/types/bledevicestatus.js.map +1 -0
- package/dist/types/devicelist.d.ts +89 -0
- package/dist/types/devicelist.d.ts.map +1 -0
- package/dist/types/devicelist.js +6 -0
- package/dist/types/devicelist.js.map +1 -0
- package/dist/types/deviceresponse.d.ts +13 -0
- package/dist/types/deviceresponse.d.ts.map +1 -0
- package/dist/types/deviceresponse.js +2 -0
- package/dist/types/deviceresponse.js.map +1 -0
- package/dist/types/devicestatus.d.ts +149 -0
- package/dist/types/devicestatus.d.ts.map +1 -0
- package/dist/types/devicestatus.js +3 -0
- package/dist/types/devicestatus.js.map +1 -0
- package/dist/types/devicewebhookstatus.d.ts +156 -0
- package/dist/types/devicewebhookstatus.d.ts.map +1 -0
- package/dist/types/devicewebhookstatus.js +2 -0
- package/dist/types/devicewebhookstatus.js.map +1 -0
- package/dist/types/irdevicelist.d.ts +10 -0
- package/dist/types/irdevicelist.d.ts.map +1 -0
- package/dist/types/irdevicelist.js +2 -0
- package/dist/types/irdevicelist.js.map +1 -0
- package/dist/types/pushbody.d.ts +6 -0
- package/dist/types/pushbody.d.ts.map +1 -0
- package/dist/types/pushbody.js +2 -0
- package/dist/types/pushbody.js.map +1 -0
- package/dist/utils.d.ts +25 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +28 -0
- package/dist/utils.js.map +1 -1
- package/package.json +10 -10
- package/src/device/blindtilt.ts +224 -264
- package/src/device/bot.ts +208 -221
- package/src/device/ceilinglight.ts +211 -261
- package/src/device/colorbulb.ts +334 -397
- package/src/device/contact.ts +111 -146
- package/src/device/curtain.ts +220 -283
- package/src/device/device.ts +194 -245
- package/src/device/fan.ts +214 -230
- package/src/device/hub.ts +126 -246
- package/src/device/humidifier.ts +216 -243
- package/src/device/iosensor.ts +114 -166
- package/src/device/lightstrip.ts +302 -377
- package/src/device/lock.ts +187 -221
- package/src/device/meter.ts +116 -177
- package/src/device/meterplus.ts +117 -174
- package/src/device/motion.ts +99 -144
- package/src/device/plug.ts +110 -128
- package/src/device/robotvacuumcleaner.ts +189 -252
- package/src/device/waterdetector.ts +123 -139
- package/src/irdevice/airconditioner.ts +47 -52
- package/src/irdevice/airpurifier.ts +19 -18
- package/src/irdevice/camera.ts +11 -10
- package/src/irdevice/fan.ts +21 -20
- package/src/irdevice/irdevice.ts +95 -70
- package/src/irdevice/light.ts +17 -18
- package/src/irdevice/other.ts +78 -77
- package/src/irdevice/tv.ts +37 -36
- package/src/irdevice/vacuumcleaner.ts +11 -10
- package/src/irdevice/waterheater.ts +11 -10
- package/src/platform.ts +290 -272
- package/src/settings.ts +30 -239
- package/src/types/bledevicestatus.ts +305 -0
- package/src/types/devicelist.ts +124 -0
- package/src/types/deviceresponse.ts +15 -0
- package/src/types/devicestatus.ts +178 -0
- package/src/types/devicewebhookstatus.ts +196 -0
- package/src/types/irdevicelist.ts +15 -0
- package/src/types/pushbody.ts +9 -0
- package/src/utils.ts +33 -0
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
import { irdeviceBase } from './irdevice.js';
|
|
6
6
|
|
|
7
7
|
import type { SwitchBotPlatform } from '../platform.js';
|
|
8
|
-
import type { irDevicesConfig
|
|
8
|
+
import type { irDevicesConfig } from '../settings.js';
|
|
9
|
+
import type { irdevice } from '../types/irdevicelist.js';
|
|
9
10
|
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -180,7 +181,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
180
181
|
* AirConditioner: "command" "highSpeed" "default" = fan speed to high
|
|
181
182
|
*/
|
|
182
183
|
async pushAirConditionerOnChanges(): Promise<void> {
|
|
183
|
-
this.debugLog(
|
|
184
|
+
await this.debugLog(`pushAirConditionerOnChanges Active: ${this.HeaterCooler.Active},`
|
|
184
185
|
+ ` disablePushOn: ${this.disablePushOn}`);
|
|
185
186
|
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
186
187
|
const commandType: string = await this.commandType();
|
|
@@ -195,7 +196,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
195
196
|
}
|
|
196
197
|
|
|
197
198
|
async pushAirConditionerOffChanges(): Promise<void> {
|
|
198
|
-
this.debugLog(
|
|
199
|
+
await this.debugLog(`pushAirConditionerOffChanges Active: ${this.HeaterCooler.Active},`
|
|
199
200
|
+ ` disablePushOff: ${this.disablePushOff}`);
|
|
200
201
|
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
201
202
|
const commandType: string = await this.commandType();
|
|
@@ -210,7 +211,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
210
211
|
}
|
|
211
212
|
|
|
212
213
|
async pushAirConditionerStatusChanges(): Promise<void> {
|
|
213
|
-
this.debugLog(
|
|
214
|
+
await this.debugLog(`pushAirConditionerStatusChanges Active: ${this.HeaterCooler.Active},`
|
|
214
215
|
+ ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
|
|
215
216
|
if (!this.Busy) {
|
|
216
217
|
this.Busy = true;
|
|
@@ -223,7 +224,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
223
224
|
}
|
|
224
225
|
|
|
225
226
|
async pushAirConditionerDetailsChanges(): Promise<void> {
|
|
226
|
-
this.debugLog(
|
|
227
|
+
await this.debugLog(`pushAirConditionerDetailsChanges Active: ${this.HeaterCooler.Active},`
|
|
227
228
|
+ ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
|
|
228
229
|
//await this.deviceContext();
|
|
229
230
|
if (this.CurrentMode === undefined) {
|
|
@@ -240,7 +241,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
240
241
|
if (this.CurrentMode === 1) {
|
|
241
242
|
// Remove or make configurable?
|
|
242
243
|
this.HeaterCooler.ThresholdTemperature = 25;
|
|
243
|
-
this.debugLog(
|
|
244
|
+
await this.debugLog(`CurrentMode: ${this.CurrentMode},`
|
|
244
245
|
+ ` ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
245
246
|
}
|
|
246
247
|
const parameter = `${this.HeaterCooler.ThresholdTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
|
|
@@ -343,9 +344,9 @@ export class AirConditioner extends irdeviceBase {
|
|
|
343
344
|
}
|
|
344
345
|
|
|
345
346
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
346
|
-
this.debugLog(
|
|
347
|
+
await this.debugLog('pushChanges');
|
|
347
348
|
if (this.device.connectionType === 'OpenAPI' && !this.disablePushDetail) {
|
|
348
|
-
this.infoLog(
|
|
349
|
+
await this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
349
350
|
try {
|
|
350
351
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
351
352
|
const deviceStatus: any = await body.json();
|
|
@@ -362,35 +363,33 @@ export class AirConditioner extends irdeviceBase {
|
|
|
362
363
|
await this.pushChangeError(e);
|
|
363
364
|
}
|
|
364
365
|
} else {
|
|
365
|
-
this.warnLog(
|
|
366
|
-
|
|
367
|
-
this.
|
|
368
|
-
+ ` Connection Type: ${this.device.connectionType}, disablePushDetails: ${this.disablePushDetail}`);
|
|
369
|
-
this.updateHomeKitCharacteristics();
|
|
366
|
+
await this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
367
|
+
await this.debugLog(`Connection Type: ${this.device.connectionType}, disablePushDetails: ${this.disablePushDetail}`);
|
|
368
|
+
await this.updateHomeKitCharacteristics();
|
|
370
369
|
}
|
|
371
370
|
}
|
|
372
371
|
|
|
373
372
|
async CurrentTemperatureGet(): Promise<CharacteristicValue> {
|
|
374
373
|
if (this.meter?.context?.CurrentTemperature) {
|
|
375
374
|
this.accessory.context.CurrentTemperature = this.meter.context.CurrentTemperature;
|
|
376
|
-
this.debugLog(
|
|
375
|
+
await this.debugLog(''
|
|
377
376
|
+ `Using CurrentTemperature from ${this.meter.context.deviceType} (${this.meter.context.deviceID})`);
|
|
378
377
|
}
|
|
379
378
|
|
|
380
379
|
this.HeaterCooler.CurrentTemperature = this.accessory.context.CurrentTemperature || 24;
|
|
381
|
-
this.debugLog(
|
|
380
|
+
await this.debugLog(`Get CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
|
|
382
381
|
return this.HeaterCooler.CurrentTemperature;
|
|
383
382
|
}
|
|
384
383
|
|
|
385
384
|
async CurrentRelativeHumidityGet(): Promise<CharacteristicValue> {
|
|
386
385
|
if (this.meter?.context?.CurrentRelativeHumidity) {
|
|
387
386
|
this.accessory.context.CurrentRelativeHumidity = this.meter.context.CurrentRelativeHumidity;
|
|
388
|
-
this.debugLog(
|
|
387
|
+
await this.debugLog(''
|
|
389
388
|
+ `Using CurrentRelativeHumidity from ${this.meter.context.deviceType} (${this.meter.context.deviceID})`);
|
|
390
389
|
}
|
|
391
390
|
|
|
392
391
|
this.HumiditySensor!.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity || 0;
|
|
393
|
-
this.debugLog(
|
|
392
|
+
await this.debugLog('Get'
|
|
394
393
|
+ ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
|
|
395
394
|
return this.HumiditySensor!.CurrentRelativeHumidity as CharacteristicValue;
|
|
396
395
|
}
|
|
@@ -401,7 +400,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
401
400
|
} else {
|
|
402
401
|
this.HeaterCooler.RotationSpeed = this.CurrentFanSpeed - 1;
|
|
403
402
|
}
|
|
404
|
-
this.debugLog(
|
|
403
|
+
await this.debugLog(`Get RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
|
|
405
404
|
return this.HeaterCooler.RotationSpeed;
|
|
406
405
|
}
|
|
407
406
|
|
|
@@ -412,24 +411,23 @@ export class AirConditioner extends irdeviceBase {
|
|
|
412
411
|
this.CurrentFanSpeed = Number(value) + 1;
|
|
413
412
|
}
|
|
414
413
|
this.HeaterCooler.RotationSpeed = value;
|
|
415
|
-
this.debugLog(
|
|
416
|
-
+ `Set RotationSpeed: ${this.HeaterCooler.RotationSpeed}, CurrentFanSpeed: ${this.CurrentFanSpeed}`);
|
|
414
|
+
await this.debugLog(`Set RotationSpeed: ${this.HeaterCooler.RotationSpeed}, CurrentFanSpeed: ${this.CurrentFanSpeed}`);
|
|
417
415
|
this.pushAirConditionerStatusChanges();
|
|
418
416
|
}
|
|
419
417
|
|
|
420
418
|
async ActiveSet(value: CharacteristicValue): Promise<void> {
|
|
421
|
-
this.debugLog(
|
|
419
|
+
await this.debugLog(`Set Active: ${value}`);
|
|
422
420
|
|
|
423
421
|
this.HeaterCooler.Active = value;
|
|
424
422
|
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
425
|
-
this.debugLog(
|
|
423
|
+
await this.debugLog(`pushAirConditionerOnChanges, Active: ${this.HeaterCooler.Active}`);
|
|
426
424
|
if (this.disablePushOn) {
|
|
427
425
|
this.pushAirConditionerStatusChanges();
|
|
428
426
|
} else {
|
|
429
427
|
this.pushAirConditionerOnChanges();
|
|
430
428
|
}
|
|
431
429
|
} else {
|
|
432
|
-
this.debugLog(
|
|
430
|
+
await this.debugLog(`pushAirConditionerOffChanges, Active: ${this.HeaterCooler.Active}`);
|
|
433
431
|
this.pushAirConditionerOffChanges();
|
|
434
432
|
}
|
|
435
433
|
}
|
|
@@ -437,7 +435,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
437
435
|
async TargetHeaterCoolerStateGet(): Promise<CharacteristicValue> {
|
|
438
436
|
const targetState = this.HeaterCooler.TargetHeaterCoolerState || this.accessory.context.TargetHeaterCoolerState;
|
|
439
437
|
this.HeaterCooler.TargetHeaterCoolerState = this.ValidValues.includes(targetState) ? targetState : this.ValidValues[0];
|
|
440
|
-
this.debugLog(
|
|
438
|
+
await this.debugLog(`Get (${this.getTargetHeaterCoolerStateName()}) TargetHeaterCoolerState:`
|
|
441
439
|
+ ` ${this.HeaterCooler.TargetHeaterCoolerState}, ValidValues: ${this.ValidValues}, hide_automode: ${this.hide_automode}`);
|
|
442
440
|
return this.HeaterCooler.TargetHeaterCoolerState;
|
|
443
441
|
}
|
|
@@ -450,7 +448,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
450
448
|
} else if (value === this.hap.Characteristic.TargetHeaterCoolerState.COOL) {
|
|
451
449
|
this.TargetHeaterCoolerStateCOOL();
|
|
452
450
|
} else {
|
|
453
|
-
this.errorLog(
|
|
451
|
+
this.errorLog('Set TargetHeaterCoolerState: '
|
|
454
452
|
+ `${this.HeaterCooler.TargetHeaterCoolerState}, hide_automode: ${this.hide_automode} `);
|
|
455
453
|
}
|
|
456
454
|
this.pushAirConditionerStatusChanges();
|
|
@@ -459,31 +457,30 @@ export class AirConditioner extends irdeviceBase {
|
|
|
459
457
|
async TargetHeaterCoolerStateAUTO(): Promise<void> {
|
|
460
458
|
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
461
459
|
this.CurrentMode = 1;
|
|
462
|
-
this.debugLog(
|
|
460
|
+
await this.debugLog('Set (AUTO)'
|
|
463
461
|
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
464
|
-
this.debugLog(
|
|
462
|
+
await this.debugLog(`Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
465
463
|
}
|
|
466
464
|
|
|
467
465
|
async TargetHeaterCoolerStateCOOL(): Promise<void> {
|
|
468
466
|
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.COOL;
|
|
469
467
|
this.CurrentMode = 2;
|
|
470
|
-
this.debugLog(
|
|
468
|
+
await this.debugLog('Set (COOL)'
|
|
471
469
|
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
472
|
-
this.debugLog(
|
|
470
|
+
await this.debugLog(`Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
473
471
|
}
|
|
474
472
|
|
|
475
473
|
async TargetHeaterCoolerStateHEAT(): Promise<void> {
|
|
476
474
|
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
477
475
|
this.CurrentMode = 5;
|
|
478
|
-
this.debugLog(
|
|
476
|
+
await this.debugLog('Set (HEAT)'
|
|
479
477
|
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
480
|
-
this.debugLog(
|
|
478
|
+
await this.debugLog(`Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
481
479
|
}
|
|
482
480
|
|
|
483
481
|
async CurrentHeaterCoolerStateGet(): Promise<CharacteristicValue> {
|
|
484
482
|
await this.UpdateCurrentHeaterCoolerState();
|
|
485
|
-
this.debugLog(
|
|
486
|
-
+ ` Get (${this.getTargetHeaterCoolerStateName()}) CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
|
|
483
|
+
await this.debugLog(`Get (${this.getTargetHeaterCoolerStateName()}) CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
|
|
487
484
|
|
|
488
485
|
return this.HeaterCooler.CurrentHeaterCoolerState;
|
|
489
486
|
}
|
|
@@ -537,84 +534,82 @@ export class AirConditioner extends irdeviceBase {
|
|
|
537
534
|
this.HumiditySensor!.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
|
|
538
535
|
}
|
|
539
536
|
}
|
|
540
|
-
this.debugLog(
|
|
537
|
+
await this.debugLog(`Get ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
541
538
|
return this.HeaterCooler.ThresholdTemperature;
|
|
542
539
|
}
|
|
543
540
|
|
|
544
541
|
async ThresholdTemperatureSet(value: CharacteristicValue): Promise<void> {
|
|
545
542
|
this.HeaterCooler.ThresholdTemperature = value;
|
|
546
|
-
this.debugLog(
|
|
543
|
+
await this.debugLog(`Set ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature},`
|
|
547
544
|
+ ` ThresholdTemperatureCached: ${this.accessory.context.ThresholdTemperature}`);
|
|
548
545
|
this.pushAirConditionerStatusChanges();
|
|
549
546
|
}
|
|
550
547
|
|
|
551
548
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
549
|
+
await this.debugLog('updateHomeKitCharacteristics');
|
|
552
550
|
// Active
|
|
553
551
|
if (this.HeaterCooler.Active === undefined) {
|
|
554
|
-
this.debugLog(
|
|
552
|
+
await this.debugLog(`Active: ${this.HeaterCooler.Active}`);
|
|
555
553
|
} else {
|
|
556
554
|
this.accessory.context.Active = this.HeaterCooler.Active;
|
|
557
555
|
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.Active, this.HeaterCooler.Active);
|
|
558
|
-
this.debugLog(
|
|
556
|
+
await this.debugLog(`updateCharacteristic Active: ${this.HeaterCooler.Active}`);
|
|
559
557
|
}
|
|
560
558
|
// RotationSpeed
|
|
561
559
|
if (this.HeaterCooler.RotationSpeed === undefined) {
|
|
562
|
-
this.debugLog(
|
|
560
|
+
await this.debugLog(`RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
|
|
563
561
|
} else {
|
|
564
562
|
this.accessory.context.RotationSpeed = this.HeaterCooler.RotationSpeed;
|
|
565
563
|
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.RotationSpeed, this.HeaterCooler.RotationSpeed);
|
|
566
|
-
this.debugLog(
|
|
564
|
+
await this.debugLog('updateCharacteristic'
|
|
567
565
|
+ ` RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
|
|
568
566
|
}
|
|
569
567
|
// CurrentTemperature
|
|
570
568
|
if (this.HeaterCooler.CurrentTemperature === undefined) {
|
|
571
|
-
this.debugLog(
|
|
569
|
+
await this.debugLog(`CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
|
|
572
570
|
} else {
|
|
573
571
|
this.accessory.context.CurrentTemperature = this.HeaterCooler.CurrentTemperature;
|
|
574
572
|
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, this.HeaterCooler.CurrentTemperature);
|
|
575
|
-
this.debugLog(
|
|
573
|
+
await this.debugLog('updateCharacteristic'
|
|
576
574
|
+ ` CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
|
|
577
575
|
}
|
|
578
576
|
// CurrentRelativeHumidity
|
|
579
577
|
if (this.meter) {
|
|
580
578
|
if (this.HumiditySensor!.CurrentRelativeHumidity === undefined) {
|
|
581
|
-
this.debugLog(
|
|
582
|
-
+ ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
|
|
579
|
+
await this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
|
|
583
580
|
} else {
|
|
584
581
|
this.accessory.context.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity;
|
|
585
582
|
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity,
|
|
586
583
|
this.HumiditySensor!.CurrentRelativeHumidity);
|
|
587
|
-
this.debugLog(
|
|
584
|
+
await this.debugLog('updateCharacteristic'
|
|
588
585
|
+ ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
|
|
589
586
|
}
|
|
590
587
|
}
|
|
591
588
|
// TargetHeaterCoolerState
|
|
592
589
|
if (this.HeaterCooler.TargetHeaterCoolerState === undefined) {
|
|
593
|
-
this.debugLog(
|
|
590
|
+
await this.debugLog(`TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
594
591
|
} else {
|
|
595
592
|
this.accessory.context.TargetHeaterCoolerState = this.HeaterCooler.TargetHeaterCoolerState;
|
|
596
593
|
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState, this.HeaterCooler.TargetHeaterCoolerState);
|
|
597
|
-
this.debugLog(
|
|
594
|
+
await this.debugLog('updateCharacteristic'
|
|
598
595
|
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
599
596
|
}
|
|
600
597
|
// CurrentHeaterCoolerState
|
|
601
598
|
if (this.HeaterCooler.CurrentHeaterCoolerState === undefined) {
|
|
602
|
-
this.debugLog(
|
|
603
|
-
+ ` CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
|
|
599
|
+
await this.debugLog(`CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
|
|
604
600
|
} else {
|
|
605
601
|
this.accessory.context.CurrentHeaterCoolerState = this.HeaterCooler.CurrentHeaterCoolerState;
|
|
606
602
|
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, this.HeaterCooler.CurrentHeaterCoolerState);
|
|
607
|
-
this.debugLog(
|
|
608
|
-
+ ` updateCharacteristic CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
|
|
603
|
+
await this.debugLog(`updateCharacteristic CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
|
|
609
604
|
}
|
|
610
605
|
// ThresholdTemperature
|
|
611
606
|
if (this.HeaterCooler.ThresholdTemperature === undefined) {
|
|
612
|
-
this.debugLog(
|
|
607
|
+
await this.debugLog(`ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
613
608
|
} else {
|
|
614
609
|
this.accessory.context.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature;
|
|
615
610
|
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature, this.HeaterCooler.ThresholdTemperature);
|
|
616
611
|
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature, this.HeaterCooler.ThresholdTemperature);
|
|
617
|
-
this.debugLog(
|
|
612
|
+
await this.debugLog('updateCharacteristic'
|
|
618
613
|
+ ` ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
619
614
|
}
|
|
620
615
|
}
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
import { irdeviceBase } from './irdevice.js';
|
|
6
6
|
|
|
7
7
|
import type { SwitchBotPlatform } from '../platform.js';
|
|
8
|
-
import type { irDevicesConfig
|
|
8
|
+
import type { irDevicesConfig } from '../settings.js';
|
|
9
|
+
import type { irdevice } from '../types/irdevicelist.js';
|
|
9
10
|
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -105,7 +106,7 @@ export class AirPurifier extends irdeviceBase {
|
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
async ActiveSet(value: CharacteristicValue): Promise<void> {
|
|
108
|
-
this.debugLog(
|
|
109
|
+
await this.debugLog(`Set Active: ${value}`);
|
|
109
110
|
|
|
110
111
|
this.AirPurifier.Active = value;
|
|
111
112
|
if (this.AirPurifier.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
@@ -152,7 +153,7 @@ export class AirPurifier extends irdeviceBase {
|
|
|
152
153
|
* AirPurifier: "command" "highSpeed" "default" = fan speed to high
|
|
153
154
|
*/
|
|
154
155
|
async pushAirPurifierOnChanges(): Promise<void> {
|
|
155
|
-
this.debugLog(
|
|
156
|
+
await this.debugLog(`pushAirPurifierOnChanges Active: ${this.AirPurifier.Active},`
|
|
156
157
|
+ ` disablePushOn: ${this.disablePushOn}`);
|
|
157
158
|
if (this.AirPurifier.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
158
159
|
const commandType: string = await this.commandType();
|
|
@@ -167,7 +168,7 @@ export class AirPurifier extends irdeviceBase {
|
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
async pushAirPurifierOffChanges(): Promise<void> {
|
|
170
|
-
this.debugLog(
|
|
171
|
+
await this.debugLog(`pushAirPurifierOffChanges Active: ${this.AirPurifier.Active},`
|
|
171
172
|
+ ` disablePushOff: ${this.disablePushOff}`);
|
|
172
173
|
if (this.AirPurifier.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOn) {
|
|
173
174
|
const commandType: string = await this.commandType();
|
|
@@ -182,7 +183,7 @@ export class AirPurifier extends irdeviceBase {
|
|
|
182
183
|
}
|
|
183
184
|
|
|
184
185
|
async pushAirPurifierStatusChanges(): Promise<void> {
|
|
185
|
-
this.debugLog(
|
|
186
|
+
await this.debugLog(`pushAirPurifierStatusChanges Active: ${this.AirPurifier.Active},`
|
|
186
187
|
+ ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
|
|
187
188
|
if (!this.Busy) {
|
|
188
189
|
this.Busy = true;
|
|
@@ -195,7 +196,7 @@ export class AirPurifier extends irdeviceBase {
|
|
|
195
196
|
}
|
|
196
197
|
|
|
197
198
|
async pushAirPurifierDetailsChanges(): Promise<void> {
|
|
198
|
-
this.debugLog(
|
|
199
|
+
await this.debugLog(`pushAirPurifierDetailsChanges Active: ${this.AirPurifier.Active},`
|
|
199
200
|
+ ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
|
|
200
201
|
this.CurrentAPTemp = this.TemperatureSensor!.CurrentTemperature ?? 24;
|
|
201
202
|
this.CurrentAPMode = this.CurrentMode ?? 1;
|
|
@@ -220,9 +221,9 @@ export class AirPurifier extends irdeviceBase {
|
|
|
220
221
|
}
|
|
221
222
|
|
|
222
223
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
223
|
-
this.debugLog(
|
|
224
|
+
await this.debugLog('pushChanges');
|
|
224
225
|
if (this.device.connectionType === 'OpenAPI') {
|
|
225
|
-
this.infoLog(
|
|
226
|
+
this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
226
227
|
try {
|
|
227
228
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
228
229
|
const deviceStatus: any = await body.json();
|
|
@@ -239,45 +240,45 @@ export class AirPurifier extends irdeviceBase {
|
|
|
239
240
|
await this.pushChangeError(e);
|
|
240
241
|
}
|
|
241
242
|
} else {
|
|
242
|
-
this.warnLog(
|
|
243
|
-
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
243
|
+
this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
248
|
+
await this.debugLog('updateHomeKitCharacteristics');
|
|
248
249
|
// Active
|
|
249
250
|
if (this.AirPurifier.Active === undefined) {
|
|
250
|
-
this.debugLog(
|
|
251
|
+
await this.debugLog(`Active: ${this.AirPurifier.Active}`);
|
|
251
252
|
} else {
|
|
252
253
|
this.accessory.context.Active = this.AirPurifier.Active;
|
|
253
254
|
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.Active, this.AirPurifier.Active);
|
|
254
|
-
this.debugLog(
|
|
255
|
+
await this.debugLog(`updateCharacteristic Active: ${this.AirPurifier.Active}`);
|
|
255
256
|
}
|
|
256
257
|
// CurrentAirPurifierState
|
|
257
258
|
if (this.AirPurifier.CurrentAirPurifierState === undefined) {
|
|
258
|
-
this.debugLog(
|
|
259
|
+
await this.debugLog(`CurrentAirPurifierState: ${this.AirPurifier.CurrentAirPurifierState}`);
|
|
259
260
|
} else {
|
|
260
261
|
this.accessory.context.CurrentAirPurifierState = this.AirPurifier.CurrentAirPurifierState;
|
|
261
262
|
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentAirPurifierState, this.AirPurifier.CurrentAirPurifierState);
|
|
262
|
-
this.debugLog(
|
|
263
|
+
await this.debugLog('updateCharacteristic'
|
|
263
264
|
+ ` CurrentAirPurifierState: ${this.AirPurifier.CurrentAirPurifierState}`);
|
|
264
265
|
}
|
|
265
266
|
// CurrentHeaterCoolerState
|
|
266
267
|
if (this.CurrentHeaterCoolerState === undefined) {
|
|
267
|
-
this.debugLog(
|
|
268
|
+
await this.debugLog(`CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
268
269
|
} else {
|
|
269
270
|
this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerState;
|
|
270
271
|
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
|
|
271
|
-
this.debugLog(
|
|
272
|
+
await this.debugLog('updateCharacteristic'
|
|
272
273
|
+ ` CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
273
274
|
}
|
|
274
275
|
// CurrentTemperature
|
|
275
276
|
if (this.TemperatureSensor.CurrentTemperature === undefined) {
|
|
276
|
-
this.debugLog(
|
|
277
|
+
await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`);
|
|
277
278
|
} else {
|
|
278
279
|
this.accessory.context.CurrentTemperature = this.TemperatureSensor.CurrentTemperature;
|
|
279
280
|
this.TemperatureSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, this.TemperatureSensor.CurrentTemperature);
|
|
280
|
-
this.debugLog(
|
|
281
|
+
await this.debugLog('updateCharacteristic'
|
|
281
282
|
+ ` CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`);
|
|
282
283
|
}
|
|
283
284
|
}
|
package/src/irdevice/camera.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
import { irdeviceBase } from './irdevice.js';
|
|
6
6
|
|
|
7
7
|
import type { SwitchBotPlatform } from '../platform.js';
|
|
8
|
-
import type { irDevicesConfig
|
|
8
|
+
import type { irDevicesConfig } from '../settings.js';
|
|
9
|
+
import type { irdevice } from '../types/irdevicelist.js';
|
|
9
10
|
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -47,7 +48,7 @@ export class Camera extends irdeviceBase {
|
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
async OnSet(value: CharacteristicValue): Promise<void> {
|
|
50
|
-
this.debugLog(
|
|
51
|
+
await this.debugLog(`On: ${value}`);
|
|
51
52
|
|
|
52
53
|
this.Switch.On = value;
|
|
53
54
|
if (this.Switch.On) {
|
|
@@ -68,7 +69,7 @@ export class Camera extends irdeviceBase {
|
|
|
68
69
|
* Camera - "command" "channelSub" "default" = previous channel
|
|
69
70
|
*/
|
|
70
71
|
async pushOnChanges(): Promise<void> {
|
|
71
|
-
this.debugLog(
|
|
72
|
+
await this.debugLog(`pushOnChanges On: ${this.Switch.On},`
|
|
72
73
|
+ ` disablePushOn: ${this.disablePushOn}`);
|
|
73
74
|
if (this.Switch.On && !this.disablePushOn) {
|
|
74
75
|
const commandType: string = await this.commandType();
|
|
@@ -83,7 +84,7 @@ export class Camera extends irdeviceBase {
|
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
async pushOffChanges(): Promise<void> {
|
|
86
|
-
this.debugLog(
|
|
87
|
+
await this.debugLog(`pushOffChanges On: ${this.Switch.On},`
|
|
87
88
|
+ ` disablePushOff: ${this.disablePushOff}`);
|
|
88
89
|
if (!this.Switch.On && !this.disablePushOff) {
|
|
89
90
|
const commandType: string = await this.commandType();
|
|
@@ -98,9 +99,9 @@ export class Camera extends irdeviceBase {
|
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
101
|
-
this.debugLog(
|
|
102
|
+
await this.debugLog('pushChanges');
|
|
102
103
|
if (this.device.connectionType === 'OpenAPI') {
|
|
103
|
-
this.infoLog(
|
|
104
|
+
this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
104
105
|
try {
|
|
105
106
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
106
107
|
const deviceStatus: any = await body.json();
|
|
@@ -117,19 +118,19 @@ export class Camera extends irdeviceBase {
|
|
|
117
118
|
await this.pushChangeError(e);
|
|
118
119
|
}
|
|
119
120
|
} else {
|
|
120
|
-
this.warnLog(
|
|
121
|
-
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
121
|
+
await this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
126
|
+
await this.debugLog('updateHomeKitCharacteristics');
|
|
126
127
|
// On
|
|
127
128
|
if (this.Switch.On === undefined) {
|
|
128
|
-
this.debugLog(
|
|
129
|
+
await this.debugLog(`On: ${this.Switch.On}`);
|
|
129
130
|
} else {
|
|
130
131
|
this.accessory.context.On = this.Switch.On;
|
|
131
132
|
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, this.Switch.On);
|
|
132
|
-
this.debugLog(
|
|
133
|
+
await this.debugLog(`updateCharacteristic On: ${this.Switch.On}`);
|
|
133
134
|
}
|
|
134
135
|
}
|
|
135
136
|
|
package/src/irdevice/fan.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
import { irdeviceBase } from './irdevice.js';
|
|
6
6
|
|
|
7
7
|
import type { SwitchBotPlatform } from '../platform.js';
|
|
8
|
-
import type { irDevicesConfig
|
|
8
|
+
import type { irDevicesConfig } from '../settings.js';
|
|
9
|
+
import type { irdevice } from '../types/irdevicelist.js';
|
|
9
10
|
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -67,9 +68,9 @@ export class IRFan extends irdeviceBase {
|
|
|
67
68
|
} else if (this.Fan.Service.testCharacteristic(this.hap.Characteristic.RotationSpeed) && !device.irfan?.swing_mode) {
|
|
68
69
|
const characteristic = this.Fan.Service.getCharacteristic(this.hap.Characteristic.RotationSpeed);
|
|
69
70
|
this.Fan.Service.removeCharacteristic(characteristic);
|
|
70
|
-
this.debugLog(
|
|
71
|
+
this.debugLog('Rotation Speed Characteristic was removed.');
|
|
71
72
|
} else {
|
|
72
|
-
this.debugLog(
|
|
73
|
+
this.debugLog('RotationSpeed Characteristic was not removed/added, '
|
|
73
74
|
+ `Clear Cache on ${this.accessory.displayName} to remove Chracteristic`);
|
|
74
75
|
}
|
|
75
76
|
|
|
@@ -84,15 +85,15 @@ export class IRFan extends irdeviceBase {
|
|
|
84
85
|
} else if (this.Fan.Service.testCharacteristic(this.hap.Characteristic.SwingMode) && !device.irfan?.swing_mode) {
|
|
85
86
|
const characteristic = this.Fan.Service.getCharacteristic(this.hap.Characteristic.SwingMode);
|
|
86
87
|
this.Fan.Service.removeCharacteristic(characteristic);
|
|
87
|
-
this.debugLog(
|
|
88
|
+
this.debugLog('Swing Mode Characteristic was removed.');
|
|
88
89
|
} else {
|
|
89
|
-
this.debugLog(
|
|
90
|
+
this.debugLog('Swing Mode Characteristic was not removed/added, '
|
|
90
91
|
+ `Clear Cache on ${this.accessory.displayName} To Remove Chracteristic`);
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
async SwingModeSet(value: CharacteristicValue): Promise<void> {
|
|
95
|
-
this.debugLog(
|
|
96
|
+
await this.debugLog(`SwingMode: ${value}`);
|
|
96
97
|
if (value > this.Fan.SwingMode) {
|
|
97
98
|
this.Fan.SwingMode = 1;
|
|
98
99
|
await this.pushFanOnChanges();
|
|
@@ -107,7 +108,7 @@ export class IRFan extends irdeviceBase {
|
|
|
107
108
|
}
|
|
108
109
|
|
|
109
110
|
async RotationSpeedSet(value: CharacteristicValue): Promise<void> {
|
|
110
|
-
this.debugLog(
|
|
111
|
+
await this.debugLog(`RotationSpeed: ${value}`);
|
|
111
112
|
if (value > this.Fan.RotationSpeed) {
|
|
112
113
|
this.Fan.RotationSpeed = 1;
|
|
113
114
|
this.pushFanSpeedUpChanges();
|
|
@@ -121,7 +122,7 @@ export class IRFan extends irdeviceBase {
|
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
async ActiveSet(value: CharacteristicValue): Promise<void> {
|
|
124
|
-
this.debugLog(
|
|
125
|
+
await this.debugLog(`Active: ${value}`);
|
|
125
126
|
|
|
126
127
|
this.Fan.Active = value;
|
|
127
128
|
if (this.Fan.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
@@ -141,7 +142,7 @@ export class IRFan extends irdeviceBase {
|
|
|
141
142
|
* Fan - "command" "highSpeed" "default" = fan speed to high
|
|
142
143
|
*/
|
|
143
144
|
async pushFanOnChanges(): Promise<void> {
|
|
144
|
-
this.debugLog(
|
|
145
|
+
await this.debugLog(`pushFanOnChanges Active: ${this.Fan.Active},`
|
|
145
146
|
+ ` disablePushOn: ${this.disablePushOn}`);
|
|
146
147
|
if (this.Fan.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
147
148
|
const commandType: string = await this.commandType();
|
|
@@ -156,7 +157,7 @@ export class IRFan extends irdeviceBase {
|
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
async pushFanOffChanges(): Promise<void> {
|
|
159
|
-
this.debugLog(
|
|
160
|
+
await this.debugLog(`pushLightOffChanges Active: ${this.Fan.Active},`
|
|
160
161
|
+ ` disablePushOff: ${this.disablePushOff}`);
|
|
161
162
|
if (this.Fan.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
162
163
|
const commandType: string = await this.commandType();
|
|
@@ -198,9 +199,9 @@ export class IRFan extends irdeviceBase {
|
|
|
198
199
|
}
|
|
199
200
|
|
|
200
201
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
201
|
-
this.debugLog(
|
|
202
|
+
await this.debugLog('pushChanges');
|
|
202
203
|
if (this.device.connectionType === 'OpenAPI') {
|
|
203
|
-
this.infoLog(
|
|
204
|
+
this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
204
205
|
try {
|
|
205
206
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
206
207
|
const deviceStatus: any = await body.json();
|
|
@@ -217,32 +218,32 @@ export class IRFan extends irdeviceBase {
|
|
|
217
218
|
await this.pushChangeError(e);
|
|
218
219
|
}
|
|
219
220
|
} else {
|
|
220
|
-
this.warnLog(
|
|
221
|
-
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
221
|
+
await this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
226
|
+
await this.debugLog('updateHomeKitCharacteristics');
|
|
226
227
|
if (this.Fan.Active === undefined) {
|
|
227
|
-
this.debugLog(
|
|
228
|
+
await this.debugLog(`Active: ${this.Fan.Active}`);
|
|
228
229
|
} else {
|
|
229
230
|
this.accessory.context.Active = this.Fan.Active;
|
|
230
231
|
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.Active, this.Fan.Active);
|
|
231
|
-
this.debugLog(
|
|
232
|
+
await this.debugLog(`updateCharacteristic Active: ${this.Fan.Active}`);
|
|
232
233
|
}
|
|
233
234
|
if (this.Fan.SwingMode === undefined) {
|
|
234
|
-
this.debugLog(
|
|
235
|
+
await this.debugLog(`SwingMode: ${this.Fan.SwingMode}`);
|
|
235
236
|
} else {
|
|
236
237
|
this.accessory.context.SwingMode = this.Fan.SwingMode;
|
|
237
238
|
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.SwingMode, this.Fan.SwingMode);
|
|
238
|
-
this.debugLog(
|
|
239
|
+
await this.debugLog(`updateCharacteristic SwingMode: ${this.Fan.SwingMode}`);
|
|
239
240
|
}
|
|
240
241
|
if (this.Fan.RotationSpeed === undefined) {
|
|
241
|
-
this.debugLog(
|
|
242
|
+
await this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`);
|
|
242
243
|
} else {
|
|
243
244
|
this.accessory.context.RotationSpeed = this.Fan.RotationSpeed;
|
|
244
245
|
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.RotationSpeed, this.Fan.RotationSpeed);
|
|
245
|
-
this.debugLog(
|
|
246
|
+
await this.debugLog(`updateCharacteristic RotationSpeed: ${this.Fan.RotationSpeed}`);
|
|
246
247
|
}
|
|
247
248
|
}
|
|
248
249
|
|