@switchbot/homebridge-switchbot 3.5.0-beta.22 → 3.5.0-beta.24
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/config.schema.json +23 -2
- package/dist/device/blindtilt.d.ts +21 -98
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +332 -785
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +25 -75
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +566 -778
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +13 -71
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +168 -606
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +13 -78
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +218 -655
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +14 -69
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +196 -553
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +17 -90
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +324 -810
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +58 -0
- package/dist/device/device.d.ts.map +1 -0
- package/dist/device/device.js +629 -0
- package/dist/device/device.js.map +1 -0
- package/dist/device/hub.d.ts +15 -63
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +223 -610
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +10 -69
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +192 -595
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +11 -68
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +156 -599
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +10 -72
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +204 -591
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +15 -66
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +199 -566
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +13 -67
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +152 -592
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +13 -68
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +151 -599
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +13 -73
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +129 -540
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +9 -61
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +71 -476
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +11 -66
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +122 -471
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +9 -66
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +105 -478
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +5 -36
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +228 -337
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +5 -34
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +19 -267
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +5 -34
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +13 -261
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +5 -34
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +13 -260
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +39 -0
- package/dist/irdevice/irdevice.d.ts.map +1 -0
- package/dist/irdevice/irdevice.js +502 -0
- package/dist/irdevice/irdevice.js.map +1 -0
- package/dist/irdevice/light.d.ts +5 -34
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +13 -267
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +18 -48
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +349 -551
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +7 -40
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +79 -325
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +6 -36
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +38 -288
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +6 -36
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +39 -291
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/settings.d.ts +15 -2
- package/dist/settings.d.ts.map +1 -1
- package/dist/utils.d.ts +68 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +71 -0
- package/dist/utils.js.map +1 -1
- package/package.json +8 -8
- package/src/device/blindtilt.ts +356 -809
- package/src/device/bot.ts +601 -865
- package/src/device/ceilinglight.ts +182 -628
- package/src/device/colorbulb.ts +235 -683
- package/src/device/contact.ts +220 -575
- package/src/device/curtain.ts +344 -836
- package/src/device/device.ts +655 -0
- package/src/device/hub.ts +246 -636
- package/src/device/humidifier.ts +224 -645
- package/src/device/iosensor.ts +181 -625
- package/src/device/lightstrip.ts +230 -622
- package/src/device/lock.ts +236 -607
- package/src/device/meter.ts +177 -616
- package/src/device/meterplus.ts +175 -624
- package/src/device/motion.ts +147 -563
- package/src/device/plug.ts +81 -505
- package/src/device/robotvacuumcleaner.ts +139 -494
- package/src/device/waterdetector.ts +126 -506
- package/src/irdevice/airconditioner.ts +228 -353
- package/src/irdevice/airpurifier.ts +23 -282
- package/src/irdevice/camera.ts +18 -277
- package/src/irdevice/fan.ts +18 -275
- package/src/irdevice/irdevice.ts +518 -0
- package/src/irdevice/light.ts +18 -283
- package/src/irdevice/other.ts +394 -621
- package/src/irdevice/tv.ts +97 -344
- package/src/irdevice/vacuumcleaner.ts +46 -310
- package/src/irdevice/waterheater.ts +47 -315
- package/src/settings.ts +20 -3
- package/src/utils.ts +71 -0
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
/* Copyright(C) 2021-2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* airconditioners.ts: @switchbot/homebridge-switchbot.
|
|
4
|
+
*/
|
|
2
5
|
import { request } from 'undici';
|
|
6
|
+
import { irdeviceBase } from './irdevice.js';
|
|
3
7
|
import { SwitchBotPlatform } from '../platform.js';
|
|
4
|
-
import { Devices, irDevicesConfig, irdevice
|
|
8
|
+
import { Devices, irDevicesConfig, irdevice } from '../settings.js';
|
|
9
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
5
10
|
|
|
6
11
|
/**
|
|
7
12
|
* Platform Accessory
|
|
8
13
|
* An instance of this class is created for each accessory your platform registers
|
|
9
14
|
* Each accessory may expose multiple services of different service types.
|
|
10
15
|
*/
|
|
11
|
-
export class AirConditioner {
|
|
12
|
-
public readonly api: API;
|
|
13
|
-
public readonly log: Logging;
|
|
14
|
-
public readonly config!: SwitchBotPlatformConfig;
|
|
15
|
-
protected readonly hap: HAP;
|
|
16
|
+
export class AirConditioner extends irdeviceBase {
|
|
16
17
|
// Services
|
|
17
18
|
coolerService!: Service;
|
|
18
19
|
|
|
19
20
|
// Characteristic Values
|
|
20
21
|
Active!: CharacteristicValue;
|
|
21
22
|
RotationSpeed!: CharacteristicValue;
|
|
22
|
-
FirmwareRevision!: CharacteristicValue;
|
|
23
23
|
CurrentTemperature!: CharacteristicValue;
|
|
24
24
|
ThresholdTemperature!: CharacteristicValue;
|
|
25
25
|
CurrentRelativeHumidity?: CharacteristicValue;
|
|
@@ -38,44 +38,94 @@ export class AirConditioner {
|
|
|
38
38
|
static MODE_HEAT: number;
|
|
39
39
|
|
|
40
40
|
// Config
|
|
41
|
-
deviceLogging!: string;
|
|
42
41
|
hide_automode?: boolean;
|
|
43
42
|
set_max_heat?: number;
|
|
44
43
|
set_min_heat?: number;
|
|
45
44
|
set_max_cool?: number;
|
|
46
45
|
set_min_cool?: number;
|
|
47
|
-
disablePushOn?: boolean;
|
|
48
|
-
disablePushOff?: boolean;
|
|
49
46
|
meter?: PlatformAccessory;
|
|
50
|
-
disablePushDetail?: boolean;
|
|
51
47
|
|
|
52
48
|
private readonly valid12 = [1, 2];
|
|
53
49
|
private readonly valid012 = [0, 1, 2];
|
|
54
50
|
|
|
55
51
|
constructor(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
readonly platform: SwitchBotPlatform,
|
|
53
|
+
accessory: PlatformAccessory,
|
|
54
|
+
device: irdevice & irDevicesConfig,
|
|
59
55
|
) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
this.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
56
|
+
super(platform, accessory, device);
|
|
57
|
+
|
|
58
|
+
if (this.Active === undefined) {
|
|
59
|
+
this.Active = this.hap.Characteristic.Active.INACTIVE;
|
|
60
|
+
} else if (this.Active) {
|
|
61
|
+
this.Active;
|
|
62
|
+
} else {
|
|
63
|
+
this.Active = this.accessory.context.Active;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (this.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
|
|
67
|
+
this.CurrentTemperature = 24;
|
|
68
|
+
} else {
|
|
69
|
+
this.CurrentTemperature = this.CurrentTemperature || this.accessory.context.CurrentTemperature;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (this.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
|
|
73
|
+
this.ThresholdTemperature = 24;
|
|
74
|
+
} else {
|
|
75
|
+
this.ThresholdTemperature = this.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (this.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
|
|
79
|
+
this.RotationSpeed = 4;
|
|
80
|
+
} else {
|
|
81
|
+
this.RotationSpeed = this.RotationSpeed || this.accessory.context.RotationSpeed;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (this.device.irair?.hide_automode) {
|
|
85
|
+
this.hide_automode = this.device.irair?.hide_automode;
|
|
86
|
+
this.accessory.context.hide_automode = this.hide_automode;
|
|
87
|
+
} else {
|
|
88
|
+
this.hide_automode = this.device.irair?.hide_automode;
|
|
89
|
+
this.accessory.context.hide_automode = this.hide_automode;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (this.device.irair?.set_max_heat) {
|
|
93
|
+
this.set_max_heat = this.device.irair?.set_max_heat;
|
|
94
|
+
this.accessory.context.set_max_heat = this.set_max_heat;
|
|
95
|
+
} else {
|
|
96
|
+
this.set_max_heat = 35;
|
|
97
|
+
this.accessory.context.set_max_heat = this.set_max_heat;
|
|
98
|
+
}
|
|
99
|
+
if (this.device.irair?.set_min_heat) {
|
|
100
|
+
this.set_min_heat = this.device.irair?.set_min_heat;
|
|
101
|
+
this.accessory.context.set_min_heat = this.set_min_heat;
|
|
102
|
+
} else {
|
|
103
|
+
this.set_min_heat = 0;
|
|
104
|
+
this.accessory.context.set_min_heat = this.set_min_heat;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (this.device.irair?.set_max_cool) {
|
|
108
|
+
this.set_max_cool = this.device.irair?.set_max_cool;
|
|
109
|
+
this.accessory.context.set_max_cool = this.set_max_cool;
|
|
110
|
+
} else {
|
|
111
|
+
this.set_max_cool = 35;
|
|
112
|
+
this.accessory.context.set_max_cool = this.set_max_cool;
|
|
113
|
+
}
|
|
114
|
+
if (this.device.irair?.set_min_cool) {
|
|
115
|
+
this.set_min_cool = this.device.irair?.set_min_cool;
|
|
116
|
+
this.accessory.context.set_min_cool = this.set_min_cool;
|
|
117
|
+
} else {
|
|
118
|
+
this.set_min_cool = 0;
|
|
119
|
+
this.accessory.context.set_min_cool = this.set_min_cool;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (this.meter) {
|
|
123
|
+
if (this.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
|
|
124
|
+
this.CurrentRelativeHumidity = 0;
|
|
125
|
+
} else {
|
|
126
|
+
this.CurrentRelativeHumidity = this.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
79
129
|
|
|
80
130
|
// get the Television service if it exists, otherwise create a new Television service
|
|
81
131
|
// you can create multiple services for each accessory
|
|
@@ -84,9 +134,6 @@ export class AirConditioner {
|
|
|
84
134
|
|| accessory.addService(this.hap.Service.HeaterCooler)), coolerService;
|
|
85
135
|
|
|
86
136
|
this.coolerService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
87
|
-
if (!this.coolerService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
88
|
-
this.coolerService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
89
|
-
}
|
|
90
137
|
|
|
91
138
|
// handle on / off events using the Active characteristic
|
|
92
139
|
this.coolerService.getCharacteristic(this.hap.Characteristic.Active).onSet(this.ActiveSet.bind(this));
|
|
@@ -243,7 +290,78 @@ export class AirConditioner {
|
|
|
243
290
|
|
|
244
291
|
private async UpdateCurrentHeaterCoolerState() {
|
|
245
292
|
if (this.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
246
|
-
|
|
293
|
+
|
|
294
|
+
if (this.Active === undefined) {
|
|
295
|
+
this.Active = this.hap.Characteristic.Active.INACTIVE;
|
|
296
|
+
} else if (this.Active) {
|
|
297
|
+
this.Active;
|
|
298
|
+
} else {
|
|
299
|
+
this.Active = this.accessory.context.Active;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (this.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
|
|
303
|
+
this.CurrentTemperature = 24;
|
|
304
|
+
} else {
|
|
305
|
+
this.CurrentTemperature = this.CurrentTemperature || this.accessory.context.CurrentTemperature;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (this.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
|
|
309
|
+
this.ThresholdTemperature = 24;
|
|
310
|
+
} else {
|
|
311
|
+
this.ThresholdTemperature = this.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (this.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
|
|
315
|
+
this.RotationSpeed = 4;
|
|
316
|
+
} else {
|
|
317
|
+
this.RotationSpeed = this.RotationSpeed || this.accessory.context.RotationSpeed;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (this.device.irair?.hide_automode) {
|
|
321
|
+
this.hide_automode = this.device.irair?.hide_automode;
|
|
322
|
+
this.accessory.context.hide_automode = this.hide_automode;
|
|
323
|
+
} else {
|
|
324
|
+
this.hide_automode = this.device.irair?.hide_automode;
|
|
325
|
+
this.accessory.context.hide_automode = this.hide_automode;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
if (this.device.irair?.set_max_heat) {
|
|
329
|
+
this.set_max_heat = this.device.irair?.set_max_heat;
|
|
330
|
+
this.accessory.context.set_max_heat = this.set_max_heat;
|
|
331
|
+
} else {
|
|
332
|
+
this.set_max_heat = 35;
|
|
333
|
+
this.accessory.context.set_max_heat = this.set_max_heat;
|
|
334
|
+
}
|
|
335
|
+
if (this.device.irair?.set_min_heat) {
|
|
336
|
+
this.set_min_heat = this.device.irair?.set_min_heat;
|
|
337
|
+
this.accessory.context.set_min_heat = this.set_min_heat;
|
|
338
|
+
} else {
|
|
339
|
+
this.set_min_heat = 0;
|
|
340
|
+
this.accessory.context.set_min_heat = this.set_min_heat;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (this.device.irair?.set_max_cool) {
|
|
344
|
+
this.set_max_cool = this.device.irair?.set_max_cool;
|
|
345
|
+
this.accessory.context.set_max_cool = this.set_max_cool;
|
|
346
|
+
} else {
|
|
347
|
+
this.set_max_cool = 35;
|
|
348
|
+
this.accessory.context.set_max_cool = this.set_max_cool;
|
|
349
|
+
}
|
|
350
|
+
if (this.device.irair?.set_min_cool) {
|
|
351
|
+
this.set_min_cool = this.device.irair?.set_min_cool;
|
|
352
|
+
this.accessory.context.set_min_cool = this.set_min_cool;
|
|
353
|
+
} else {
|
|
354
|
+
this.set_min_cool = 0;
|
|
355
|
+
this.accessory.context.set_min_cool = this.set_min_cool;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (this.meter) {
|
|
359
|
+
if (this.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
|
|
360
|
+
this.CurrentRelativeHumidity = 0;
|
|
361
|
+
} else {
|
|
362
|
+
this.CurrentRelativeHumidity = this.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
247
365
|
if (this.ThresholdTemperature < this.CurrentTemperature &&
|
|
248
366
|
this.TargetHeaterCoolerState !== this.hap.Characteristic.TargetHeaterCoolerState.HEAT) {
|
|
249
367
|
this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
@@ -440,7 +558,78 @@ export class AirConditioner {
|
|
|
440
558
|
}
|
|
441
559
|
|
|
442
560
|
async ThresholdTemperatureGet(): Promise<CharacteristicValue> {
|
|
443
|
-
|
|
561
|
+
|
|
562
|
+
if (this.Active === undefined) {
|
|
563
|
+
this.Active = this.hap.Characteristic.Active.INACTIVE;
|
|
564
|
+
} else if (this.Active) {
|
|
565
|
+
this.Active;
|
|
566
|
+
} else {
|
|
567
|
+
this.Active = this.accessory.context.Active;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
if (this.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
|
|
571
|
+
this.CurrentTemperature = 24;
|
|
572
|
+
} else {
|
|
573
|
+
this.CurrentTemperature = this.CurrentTemperature || this.accessory.context.CurrentTemperature;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
if (this.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
|
|
577
|
+
this.ThresholdTemperature = 24;
|
|
578
|
+
} else {
|
|
579
|
+
this.ThresholdTemperature = this.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
if (this.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
|
|
583
|
+
this.RotationSpeed = 4;
|
|
584
|
+
} else {
|
|
585
|
+
this.RotationSpeed = this.RotationSpeed || this.accessory.context.RotationSpeed;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
if (this.device.irair?.hide_automode) {
|
|
589
|
+
this.hide_automode = this.device.irair?.hide_automode;
|
|
590
|
+
this.accessory.context.hide_automode = this.hide_automode;
|
|
591
|
+
} else {
|
|
592
|
+
this.hide_automode = this.device.irair?.hide_automode;
|
|
593
|
+
this.accessory.context.hide_automode = this.hide_automode;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
if (this.device.irair?.set_max_heat) {
|
|
597
|
+
this.set_max_heat = this.device.irair?.set_max_heat;
|
|
598
|
+
this.accessory.context.set_max_heat = this.set_max_heat;
|
|
599
|
+
} else {
|
|
600
|
+
this.set_max_heat = 35;
|
|
601
|
+
this.accessory.context.set_max_heat = this.set_max_heat;
|
|
602
|
+
}
|
|
603
|
+
if (this.device.irair?.set_min_heat) {
|
|
604
|
+
this.set_min_heat = this.device.irair?.set_min_heat;
|
|
605
|
+
this.accessory.context.set_min_heat = this.set_min_heat;
|
|
606
|
+
} else {
|
|
607
|
+
this.set_min_heat = 0;
|
|
608
|
+
this.accessory.context.set_min_heat = this.set_min_heat;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
if (this.device.irair?.set_max_cool) {
|
|
612
|
+
this.set_max_cool = this.device.irair?.set_max_cool;
|
|
613
|
+
this.accessory.context.set_max_cool = this.set_max_cool;
|
|
614
|
+
} else {
|
|
615
|
+
this.set_max_cool = 35;
|
|
616
|
+
this.accessory.context.set_max_cool = this.set_max_cool;
|
|
617
|
+
}
|
|
618
|
+
if (this.device.irair?.set_min_cool) {
|
|
619
|
+
this.set_min_cool = this.device.irair?.set_min_cool;
|
|
620
|
+
this.accessory.context.set_min_cool = this.set_min_cool;
|
|
621
|
+
} else {
|
|
622
|
+
this.set_min_cool = 0;
|
|
623
|
+
this.accessory.context.set_min_cool = this.set_min_cool;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
if (this.meter) {
|
|
627
|
+
if (this.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
|
|
628
|
+
this.CurrentRelativeHumidity = 0;
|
|
629
|
+
} else {
|
|
630
|
+
this.CurrentRelativeHumidity = this.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
444
633
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get ThresholdTemperature: ${this.ThresholdTemperature}`);
|
|
445
634
|
return this.ThresholdTemperature;
|
|
446
635
|
}
|
|
@@ -525,136 +714,6 @@ export class AirConditioner {
|
|
|
525
714
|
}
|
|
526
715
|
}
|
|
527
716
|
|
|
528
|
-
async disablePushOnChanges(device: irdevice & irDevicesConfig): Promise<void> {
|
|
529
|
-
if (device.disablePushOn === undefined) {
|
|
530
|
-
this.disablePushOn = false;
|
|
531
|
-
} else {
|
|
532
|
-
this.disablePushOn = device.disablePushOn;
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
async disablePushOffChanges(device: irdevice & irDevicesConfig): Promise<void> {
|
|
537
|
-
if (device.disablePushOff === undefined) {
|
|
538
|
-
this.disablePushOff = false;
|
|
539
|
-
} else {
|
|
540
|
-
this.disablePushOff = device.disablePushOff;
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
async disablePushDetailChanges(device: irdevice & irDevicesConfig): Promise<void> {
|
|
545
|
-
if (device.disablePushDetail === undefined) {
|
|
546
|
-
this.disablePushDetail = false;
|
|
547
|
-
} else {
|
|
548
|
-
this.disablePushDetail = device.disablePushDetail;
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
async commandType(): Promise<string> {
|
|
553
|
-
let commandType: string;
|
|
554
|
-
if (this.device.customize) {
|
|
555
|
-
commandType = 'customize';
|
|
556
|
-
} else {
|
|
557
|
-
commandType = 'command';
|
|
558
|
-
}
|
|
559
|
-
return commandType;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
async commandOn(): Promise<string> {
|
|
563
|
-
let command: string;
|
|
564
|
-
if (this.device.customize && this.device.customOn) {
|
|
565
|
-
command = this.device.customOn;
|
|
566
|
-
} else {
|
|
567
|
-
command = 'turnOn';
|
|
568
|
-
}
|
|
569
|
-
return command;
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
async commandOff(): Promise<string> {
|
|
573
|
-
let command: string;
|
|
574
|
-
if (this.device.customize && this.device.customOff) {
|
|
575
|
-
command = this.device.customOff;
|
|
576
|
-
} else {
|
|
577
|
-
command = 'turnOff';
|
|
578
|
-
}
|
|
579
|
-
return command;
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
async statusCode(statusCode: number): Promise<void> {
|
|
583
|
-
switch (statusCode) {
|
|
584
|
-
case 151:
|
|
585
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command not supported by this deviceType, statusCode: ${statusCode}`);
|
|
586
|
-
break;
|
|
587
|
-
case 152:
|
|
588
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device not found, statusCode: ${statusCode}`);
|
|
589
|
-
break;
|
|
590
|
-
case 160:
|
|
591
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command is not supported, statusCode: ${statusCode}`);
|
|
592
|
-
break;
|
|
593
|
-
case 161:
|
|
594
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
|
|
595
|
-
break;
|
|
596
|
-
case 171:
|
|
597
|
-
this.errorLog(
|
|
598
|
-
`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
|
|
599
|
-
`Hub: ${this.device.hubDeviceId}`,
|
|
600
|
-
);
|
|
601
|
-
break;
|
|
602
|
-
case 190:
|
|
603
|
-
this.errorLog(
|
|
604
|
-
`${this.device.remoteType}: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
|
|
605
|
-
` Or command format is invalid, statusCode: ${statusCode}`,
|
|
606
|
-
);
|
|
607
|
-
break;
|
|
608
|
-
case 100:
|
|
609
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent, statusCode: ${statusCode}`);
|
|
610
|
-
break;
|
|
611
|
-
case 200:
|
|
612
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
|
|
613
|
-
break;
|
|
614
|
-
case 400:
|
|
615
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Bad Request, The client has issued an invalid request. `
|
|
616
|
-
+ `This is commonly used to specify validation errors in a request payload, statusCode: ${statusCode}`);
|
|
617
|
-
break;
|
|
618
|
-
case 401:
|
|
619
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Unauthorized, Authorization for the API is required, `
|
|
620
|
-
+ `but the request has not been authenticated, statusCode: ${statusCode}`);
|
|
621
|
-
break;
|
|
622
|
-
case 403:
|
|
623
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Forbidden, The request has been authenticated but does not `
|
|
624
|
-
+ `have appropriate permissions, or a requested resource is not found, statusCode: ${statusCode}`);
|
|
625
|
-
break;
|
|
626
|
-
case 404:
|
|
627
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Not Found, Specifies the requested path does not exist, `
|
|
628
|
-
+ `statusCode: ${statusCode}`);
|
|
629
|
-
break;
|
|
630
|
-
case 406:
|
|
631
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Not Acceptable, The client has requested a MIME type via `
|
|
632
|
-
+ `the Accept header for a value not supported by the server, statusCode: ${statusCode}`);
|
|
633
|
-
break;
|
|
634
|
-
case 415:
|
|
635
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Unsupported Media Type, The client has defined a contentType `
|
|
636
|
-
+ `header that is not supported by the server, statusCode: ${statusCode}`);
|
|
637
|
-
break;
|
|
638
|
-
case 422:
|
|
639
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Unprocessable Entity, The client has made a valid request, but `
|
|
640
|
-
+ `the server cannot process it. This is often used for APIs for which certain limits have been exceeded, statusCode: ${statusCode}`);
|
|
641
|
-
break;
|
|
642
|
-
case 429:
|
|
643
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Too Many Requests, The client has exceeded the number of `
|
|
644
|
-
+ `requests allowed for a given time window, statusCode: ${statusCode}`);
|
|
645
|
-
break;
|
|
646
|
-
case 500:
|
|
647
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Internal Server Error, An unexpected error on the SmartThings `
|
|
648
|
-
+ `servers has occurred. These errors should be rare, statusCode: ${statusCode}`);
|
|
649
|
-
break;
|
|
650
|
-
default:
|
|
651
|
-
this.infoLog(
|
|
652
|
-
`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: ` +
|
|
653
|
-
`${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
|
|
654
|
-
);
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
|
|
658
717
|
async apiError({ e }: { e: any }): Promise<void> {
|
|
659
718
|
this.coolerService.updateCharacteristic(this.hap.Characteristic.Active, e);
|
|
660
719
|
this.coolerService.updateCharacteristic(this.hap.Characteristic.RotationSpeed, e);
|
|
@@ -665,188 +724,4 @@ export class AirConditioner {
|
|
|
665
724
|
this.coolerService.updateCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature, e);
|
|
666
725
|
this.coolerService.updateCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature, e);
|
|
667
726
|
}
|
|
668
|
-
|
|
669
|
-
async deviceContext(): Promise<void> {
|
|
670
|
-
if (this.Active === undefined) {
|
|
671
|
-
this.Active = this.hap.Characteristic.Active.INACTIVE;
|
|
672
|
-
} else if (this.Active) {
|
|
673
|
-
this.Active;
|
|
674
|
-
} else {
|
|
675
|
-
this.Active = this.accessory.context.Active;
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
if (this.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
|
|
679
|
-
this.CurrentTemperature = 24;
|
|
680
|
-
} else {
|
|
681
|
-
this.CurrentTemperature = this.CurrentTemperature || this.accessory.context.CurrentTemperature;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
if (this.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
|
|
685
|
-
this.ThresholdTemperature = 24;
|
|
686
|
-
} else {
|
|
687
|
-
this.ThresholdTemperature = this.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
if (this.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
|
|
691
|
-
this.RotationSpeed = 4;
|
|
692
|
-
} else {
|
|
693
|
-
this.RotationSpeed = this.RotationSpeed || this.accessory.context.RotationSpeed;
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
if (this.device.irair?.hide_automode) {
|
|
697
|
-
this.hide_automode = this.device.irair?.hide_automode;
|
|
698
|
-
this.accessory.context.hide_automode = this.hide_automode;
|
|
699
|
-
} else {
|
|
700
|
-
this.hide_automode = this.device.irair?.hide_automode;
|
|
701
|
-
this.accessory.context.hide_automode = this.hide_automode;
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
if (this.device.irair?.set_max_heat) {
|
|
705
|
-
this.set_max_heat = this.device.irair?.set_max_heat;
|
|
706
|
-
this.accessory.context.set_max_heat = this.set_max_heat;
|
|
707
|
-
} else {
|
|
708
|
-
this.set_max_heat = 35;
|
|
709
|
-
this.accessory.context.set_max_heat = this.set_max_heat;
|
|
710
|
-
}
|
|
711
|
-
if (this.device.irair?.set_min_heat) {
|
|
712
|
-
this.set_min_heat = this.device.irair?.set_min_heat;
|
|
713
|
-
this.accessory.context.set_min_heat = this.set_min_heat;
|
|
714
|
-
} else {
|
|
715
|
-
this.set_min_heat = 0;
|
|
716
|
-
this.accessory.context.set_min_heat = this.set_min_heat;
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
if (this.device.irair?.set_max_cool) {
|
|
720
|
-
this.set_max_cool = this.device.irair?.set_max_cool;
|
|
721
|
-
this.accessory.context.set_max_cool = this.set_max_cool;
|
|
722
|
-
} else {
|
|
723
|
-
this.set_max_cool = 35;
|
|
724
|
-
this.accessory.context.set_max_cool = this.set_max_cool;
|
|
725
|
-
}
|
|
726
|
-
if (this.device.irair?.set_min_cool) {
|
|
727
|
-
this.set_min_cool = this.device.irair?.set_min_cool;
|
|
728
|
-
this.accessory.context.set_min_cool = this.set_min_cool;
|
|
729
|
-
} else {
|
|
730
|
-
this.set_min_cool = 0;
|
|
731
|
-
this.accessory.context.set_min_cool = this.set_min_cool;
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
if (this.meter) {
|
|
735
|
-
if (this.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
|
|
736
|
-
this.CurrentRelativeHumidity = 0;
|
|
737
|
-
} else {
|
|
738
|
-
this.CurrentRelativeHumidity = this.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
if (this.FirmwareRevision === undefined) {
|
|
742
|
-
this.FirmwareRevision = this.platform.version;
|
|
743
|
-
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
async deviceConfig(device: irdevice & irDevicesConfig): Promise<void> {
|
|
748
|
-
let config = {};
|
|
749
|
-
if (device.irair) {
|
|
750
|
-
config = device.irair;
|
|
751
|
-
}
|
|
752
|
-
if (device.logging !== undefined) {
|
|
753
|
-
config['logging'] = device.logging;
|
|
754
|
-
}
|
|
755
|
-
if (device.connectionType !== undefined) {
|
|
756
|
-
config['connectionType'] = device.connectionType;
|
|
757
|
-
}
|
|
758
|
-
if (device.external !== undefined) {
|
|
759
|
-
config['external'] = device.external;
|
|
760
|
-
}
|
|
761
|
-
if (device.customOn !== undefined) {
|
|
762
|
-
config['customOn'] = device.customOn;
|
|
763
|
-
}
|
|
764
|
-
if (device.customOff !== undefined) {
|
|
765
|
-
config['customOff'] = device.customOff;
|
|
766
|
-
}
|
|
767
|
-
if (device.customize !== undefined) {
|
|
768
|
-
config['customize'] = device.customize;
|
|
769
|
-
}
|
|
770
|
-
if (device.disablePushOn !== undefined) {
|
|
771
|
-
config['disablePushOn'] = device.disablePushOn;
|
|
772
|
-
}
|
|
773
|
-
if (device.disablePushOff !== undefined) {
|
|
774
|
-
config['disablePushOff'] = device.disablePushOff;
|
|
775
|
-
}
|
|
776
|
-
if (device.disablePushDetail !== undefined) {
|
|
777
|
-
config['disablePushDetail'] = device.disablePushDetail;
|
|
778
|
-
}
|
|
779
|
-
if (Object.entries(config).length !== 0) {
|
|
780
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
async deviceLogs(device: irdevice & irDevicesConfig): Promise<void> {
|
|
785
|
-
if (this.platform.debugMode) {
|
|
786
|
-
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
787
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
788
|
-
} else if (device.logging) {
|
|
789
|
-
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
790
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
791
|
-
} else if (this.platform.config.options?.logging) {
|
|
792
|
-
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
793
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
794
|
-
} else {
|
|
795
|
-
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
796
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
/**
|
|
801
|
-
* Logging for Device
|
|
802
|
-
*/
|
|
803
|
-
successLog(...log: any[]): void {
|
|
804
|
-
if (this.enablingDeviceLogging()) {
|
|
805
|
-
this.platform.log.success(String(...log));
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
infoLog(...log: any[]): void {
|
|
810
|
-
if (this.enablingDeviceLogging()) {
|
|
811
|
-
this.platform.log.info(String(...log));
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
warnLog(...log: any[]): void {
|
|
816
|
-
if (this.enablingDeviceLogging()) {
|
|
817
|
-
this.platform.log.warn(String(...log));
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
debugWarnLog(...log: any[]): void {
|
|
822
|
-
if (this.enablingDeviceLogging() && this.deviceLogging?.includes('debug')) {
|
|
823
|
-
this.platform.log.warn('[DEBUG]', String(...log));
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
errorLog(...log: any[]): void {
|
|
828
|
-
if (this.enablingDeviceLogging()) {
|
|
829
|
-
this.platform.log.error(String(...log));
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
debugErrorLog(...log: any[]): void {
|
|
834
|
-
if (this.enablingDeviceLogging() && this.deviceLogging?.includes('debug')) {
|
|
835
|
-
this.platform.log.error('[DEBUG]', String(...log));
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
debugLog(...log: any[]): void {
|
|
840
|
-
if (this.enablingDeviceLogging()) {
|
|
841
|
-
if (this.deviceLogging === 'debug') {
|
|
842
|
-
this.platform.log.info('[DEBUG]', String(...log));
|
|
843
|
-
} else {
|
|
844
|
-
this.platform.log.debug(String(...log));
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
enablingDeviceLogging(): boolean {
|
|
850
|
-
return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
|
|
851
|
-
}
|
|
852
727
|
}
|