@switchbot/homebridge-switchbot 3.5.0-beta.26 → 3.5.0-beta.28
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/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +19 -16
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.js +15 -15
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.js +8 -8
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.js +4 -4
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.js +6 -6
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +13 -13
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +2 -1
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +10 -3
- package/dist/device/device.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +7 -7
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.js +5 -5
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.js +6 -6
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.js +4 -4
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.js +7 -7
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.js +6 -6
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.js +6 -6
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.js +6 -7
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.js +4 -4
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.js +6 -6
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +10 -17
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +4 -14
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +227 -235
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +3 -6
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +66 -57
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +2 -3
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +25 -28
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +2 -7
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +58 -62
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +2 -1
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +10 -3
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +14 -16
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.js +52 -51
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.js +3 -3
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +2 -2
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.js +2 -2
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +22 -1
- package/dist/platform.js.map +1 -1
- package/package.json +2 -2
- package/src/custom.d.ts +1 -0
- package/src/device/blindtilt.ts +22 -20
- package/src/device/bot.ts +16 -16
- package/src/device/ceilinglight.ts +9 -9
- package/src/device/colorbulb.ts +5 -5
- package/src/device/contact.ts +7 -7
- package/src/device/curtain.ts +15 -14
- package/src/device/device.ts +11 -3
- package/src/device/hub.ts +8 -7
- package/src/device/humidifier.ts +6 -6
- package/src/device/iosensor.ts +7 -7
- package/src/device/lightstrip.ts +5 -5
- package/src/device/lock.ts +8 -8
- package/src/device/meter.ts +7 -7
- package/src/device/meterplus.ts +7 -7
- package/src/device/motion.ts +7 -7
- package/src/device/plug.ts +5 -5
- package/src/device/robotvacuumcleaner.ts +7 -7
- package/src/device/waterdetector.ts +10 -18
- package/src/irdevice/airconditioner.ts +240 -239
- package/src/irdevice/airpurifier.ts +76 -57
- package/src/irdevice/camera.ts +28 -28
- package/src/irdevice/fan.ts +64 -64
- package/src/irdevice/irdevice.ts +11 -3
- package/src/irdevice/light.ts +18 -16
- package/src/irdevice/other.ts +52 -52
- package/src/irdevice/tv.ts +3 -3
- package/src/irdevice/vacuumcleaner.ts +2 -2
- package/src/irdevice/waterheater.ts +2 -2
- package/src/platform.ts +21 -4
|
@@ -15,16 +15,20 @@ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
|
15
15
|
*/
|
|
16
16
|
export class AirConditioner extends irdeviceBase {
|
|
17
17
|
// Services
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
private HeaterCooler: {
|
|
19
|
+
Service: Service;
|
|
20
|
+
Active: CharacteristicValue;
|
|
21
|
+
CurrentHeaterCoolerState: CharacteristicValue;
|
|
22
|
+
TargetHeaterCoolerState: CharacteristicValue;
|
|
23
|
+
CurrentTemperature: CharacteristicValue;
|
|
24
|
+
ThresholdTemperature: CharacteristicValue;
|
|
25
|
+
RotationSpeed: CharacteristicValue;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
private HumiditySensor?: {
|
|
29
|
+
Service: Service;
|
|
30
|
+
CurrentRelativeHumidity: CharacteristicValue;
|
|
31
|
+
};
|
|
28
32
|
|
|
29
33
|
// Others
|
|
30
34
|
state!: string;
|
|
@@ -33,9 +37,6 @@ export class AirConditioner extends irdeviceBase {
|
|
|
33
37
|
CurrentMode!: number;
|
|
34
38
|
ValidValues: number[];
|
|
35
39
|
CurrentFanSpeed!: number;
|
|
36
|
-
static MODE_AUTO: number;
|
|
37
|
-
static MODE_COOL: number;
|
|
38
|
-
static MODE_HEAT: number;
|
|
39
40
|
|
|
40
41
|
// Config
|
|
41
42
|
hide_automode?: boolean;
|
|
@@ -45,9 +46,6 @@ export class AirConditioner extends irdeviceBase {
|
|
|
45
46
|
set_min_cool?: number;
|
|
46
47
|
meter?: PlatformAccessory;
|
|
47
48
|
|
|
48
|
-
private readonly valid12 = [1, 2];
|
|
49
|
-
private readonly valid012 = [0, 1, 2];
|
|
50
|
-
|
|
51
49
|
constructor(
|
|
52
50
|
readonly platform: SwitchBotPlatform,
|
|
53
51
|
accessory: PlatformAccessory,
|
|
@@ -55,90 +53,44 @@ export class AirConditioner extends irdeviceBase {
|
|
|
55
53
|
) {
|
|
56
54
|
super(platform, accessory, device);
|
|
57
55
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
}
|
|
56
|
+
// default placeholders
|
|
57
|
+
this.getAirConditionerConfigSettings(accessory, device);
|
|
58
|
+
|
|
59
|
+
// Initialize HeaterCooler property
|
|
60
|
+
this.HeaterCooler = {
|
|
61
|
+
Service: accessory.getService(this.hap.Service.Switch)!,
|
|
62
|
+
Active: accessory.context.Active || this.hap.Characteristic.Active.INACTIVE,
|
|
63
|
+
CurrentHeaterCoolerState: accessory.context.CurrentHeaterCoolerState || this.hap.Characteristic.CurrentHeaterCoolerState.IDLE,
|
|
64
|
+
TargetHeaterCoolerState: accessory.context.TargetHeaterCoolerState || this.hap.Characteristic.TargetHeaterCoolerState.AUTO,
|
|
65
|
+
CurrentTemperature: accessory.context.CurrentTemperature || 24,
|
|
66
|
+
ThresholdTemperature: accessory.context.ThresholdTemperature || 24,
|
|
67
|
+
RotationSpeed: accessory.context.RotationSpeed || 4,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// Initialize HumiditySensor property
|
|
71
|
+
if (this.device.irair?.meterType && this.device.irair?.meterId) {
|
|
72
|
+
const meterUuid = this.platform.api.hap.uuid.generate(`${this.device.irair.meterId}-${this.device.irair.meterType}`);
|
|
73
|
+
this.meter = this.platform.accessories.find((accessory) => accessory.UUID === meterUuid);
|
|
74
|
+
this.HumiditySensor = {
|
|
75
|
+
Service: this.meter!.getService(this.hap.Service.HumiditySensor)!,
|
|
76
|
+
CurrentRelativeHumidity: this.meter!.context.CurrentRelativeHumidity || 0,
|
|
77
|
+
};
|
|
128
78
|
}
|
|
129
79
|
|
|
130
80
|
// get the Television service if it exists, otherwise create a new Television service
|
|
131
81
|
// you can create multiple services for each accessory
|
|
132
|
-
const
|
|
133
|
-
(this.
|
|
134
|
-
|| accessory.addService(this.hap.Service.HeaterCooler)),
|
|
82
|
+
const HeaterCoolerService = `${accessory.displayName} ${device.remoteType}`;
|
|
83
|
+
(this.HeaterCooler.Service = accessory.getService(this.hap.Service.HeaterCooler)
|
|
84
|
+
|| accessory.addService(this.hap.Service.HeaterCooler)), HeaterCoolerService;
|
|
135
85
|
|
|
136
|
-
this.
|
|
86
|
+
this.HeaterCooler.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
137
87
|
|
|
138
88
|
// handle on / off events using the Active characteristic
|
|
139
|
-
this.
|
|
89
|
+
this.HeaterCooler.Service.getCharacteristic(this.hap.Characteristic.Active)
|
|
90
|
+
.onSet(this.ActiveSet.bind(this));
|
|
140
91
|
|
|
141
|
-
this.
|
|
92
|
+
this.HeaterCooler.Service.getCharacteristic(this.hap.Characteristic.CurrentTemperature)
|
|
93
|
+
.onGet(this.CurrentTemperatureGet.bind(this));
|
|
142
94
|
|
|
143
95
|
this.ValidValues = this.hide_automode ? [1, 2] : [0, 1, 2];
|
|
144
96
|
|
|
@@ -148,10 +100,11 @@ export class AirConditioner extends irdeviceBase {
|
|
|
148
100
|
}
|
|
149
101
|
|
|
150
102
|
if (this.meter) {
|
|
151
|
-
this.
|
|
103
|
+
this.HumiditySensor!.Service.getCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity)
|
|
104
|
+
.onGet(this.CurrentRelativeHumidityGet.bind(this));
|
|
152
105
|
}
|
|
153
106
|
|
|
154
|
-
this.
|
|
107
|
+
this.HeaterCooler.Service
|
|
155
108
|
.getCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState)
|
|
156
109
|
.setProps({
|
|
157
110
|
validValues: this.ValidValues,
|
|
@@ -159,9 +112,10 @@ export class AirConditioner extends irdeviceBase {
|
|
|
159
112
|
.onGet(this.TargetHeaterCoolerStateGet.bind(this))
|
|
160
113
|
.onSet(this.TargetHeaterCoolerStateSet.bind(this));
|
|
161
114
|
|
|
162
|
-
this.
|
|
115
|
+
this.HeaterCooler.Service.getCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState)
|
|
116
|
+
.onGet(this.CurrentHeaterCoolerStateGet.bind(this));
|
|
163
117
|
|
|
164
|
-
this.
|
|
118
|
+
this.HeaterCooler.Service
|
|
165
119
|
.getCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature)
|
|
166
120
|
.setProps({
|
|
167
121
|
minValue: this.set_min_heat,
|
|
@@ -171,7 +125,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
171
125
|
.onGet(this.ThresholdTemperatureGet.bind(this))
|
|
172
126
|
.onSet(this.ThresholdTemperatureSet.bind(this));
|
|
173
127
|
|
|
174
|
-
this.
|
|
128
|
+
this.HeaterCooler.Service
|
|
175
129
|
.getCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature)
|
|
176
130
|
.setProps({
|
|
177
131
|
minValue: this.set_min_cool,
|
|
@@ -181,7 +135,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
181
135
|
.onGet(this.ThresholdTemperatureGet.bind(this))
|
|
182
136
|
.onSet(this.ThresholdTemperatureSet.bind(this));
|
|
183
137
|
|
|
184
|
-
this.
|
|
138
|
+
this.HeaterCooler.Service
|
|
185
139
|
.getCharacteristic(this.hap.Characteristic.RotationSpeed)
|
|
186
140
|
.setProps({
|
|
187
141
|
format: 'int',
|
|
@@ -204,10 +158,10 @@ export class AirConditioner extends irdeviceBase {
|
|
|
204
158
|
*/
|
|
205
159
|
async pushAirConditionerOnChanges(): Promise<void> {
|
|
206
160
|
this.debugLog(
|
|
207
|
-
`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges Active: ${this.Active},` +
|
|
161
|
+
`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges Active: ${this.HeaterCooler.Active},` +
|
|
208
162
|
` disablePushOn: ${this.disablePushOn}`,
|
|
209
163
|
);
|
|
210
|
-
if (this.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
164
|
+
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
211
165
|
const commandType: string = await this.commandType();
|
|
212
166
|
const command: string = await this.commandOn();
|
|
213
167
|
const bodyChange = JSON.stringify({
|
|
@@ -221,10 +175,10 @@ export class AirConditioner extends irdeviceBase {
|
|
|
221
175
|
|
|
222
176
|
async pushAirConditionerOffChanges(): Promise<void> {
|
|
223
177
|
this.debugLog(
|
|
224
|
-
`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges Active: ${this.Active},` +
|
|
178
|
+
`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges Active: ${this.HeaterCooler.Active},` +
|
|
225
179
|
` disablePushOff: ${this.disablePushOff}`,
|
|
226
180
|
);
|
|
227
|
-
if (this.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
181
|
+
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
228
182
|
const commandType: string = await this.commandType();
|
|
229
183
|
const command: string = await this.commandOff();
|
|
230
184
|
const bodyChange = JSON.stringify({
|
|
@@ -238,12 +192,12 @@ export class AirConditioner extends irdeviceBase {
|
|
|
238
192
|
|
|
239
193
|
async pushAirConditionerStatusChanges(): Promise<void> {
|
|
240
194
|
this.debugLog(
|
|
241
|
-
`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerStatusChanges Active: ${this.Active},` +
|
|
195
|
+
`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerStatusChanges Active: ${this.HeaterCooler.Active},` +
|
|
242
196
|
` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`,
|
|
243
197
|
);
|
|
244
198
|
if (!this.Busy) {
|
|
245
199
|
this.Busy = true;
|
|
246
|
-
this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
200
|
+
this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
247
201
|
}
|
|
248
202
|
clearTimeout(this.Timeout);
|
|
249
203
|
|
|
@@ -253,7 +207,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
253
207
|
|
|
254
208
|
async pushAirConditionerDetailsChanges(): Promise<void> {
|
|
255
209
|
this.debugLog(
|
|
256
|
-
`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerDetailsChanges Active: ${this.Active},` +
|
|
210
|
+
`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerDetailsChanges Active: ${this.HeaterCooler.Active},` +
|
|
257
211
|
` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`,
|
|
258
212
|
);
|
|
259
213
|
//await this.deviceContext();
|
|
@@ -263,20 +217,20 @@ export class AirConditioner extends irdeviceBase {
|
|
|
263
217
|
if (this.CurrentFanSpeed === undefined) {
|
|
264
218
|
this.CurrentFanSpeed = 1;
|
|
265
219
|
}
|
|
266
|
-
if (this.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
220
|
+
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
267
221
|
this.state = 'on';
|
|
268
222
|
} else {
|
|
269
223
|
this.state = 'off';
|
|
270
224
|
}
|
|
271
225
|
if (this.CurrentMode === 1) {
|
|
272
226
|
// Remove or make configurable?
|
|
273
|
-
this.ThresholdTemperature = 25;
|
|
227
|
+
this.HeaterCooler.ThresholdTemperature = 25;
|
|
274
228
|
this.debugLog(
|
|
275
229
|
`${this.device.remoteType}: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},` +
|
|
276
|
-
` ThresholdTemperature: ${this.ThresholdTemperature}`,
|
|
230
|
+
` ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`,
|
|
277
231
|
);
|
|
278
232
|
}
|
|
279
|
-
const parameter = `${this.ThresholdTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
|
|
233
|
+
const parameter = `${this.HeaterCooler.ThresholdTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
|
|
280
234
|
|
|
281
235
|
await this.UpdateCurrentHeaterCoolerState();
|
|
282
236
|
const bodyChange = JSON.stringify({
|
|
@@ -289,32 +243,32 @@ export class AirConditioner extends irdeviceBase {
|
|
|
289
243
|
}
|
|
290
244
|
|
|
291
245
|
private async UpdateCurrentHeaterCoolerState() {
|
|
292
|
-
if (this.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
246
|
+
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
293
247
|
|
|
294
|
-
if (this.Active === undefined) {
|
|
295
|
-
this.Active = this.hap.Characteristic.Active.INACTIVE;
|
|
296
|
-
} else if (this.Active) {
|
|
297
|
-
this.Active;
|
|
248
|
+
if (this.HeaterCooler.Active === undefined) {
|
|
249
|
+
this.HeaterCooler.Active = this.hap.Characteristic.Active.INACTIVE;
|
|
250
|
+
} else if (this.HeaterCooler.Active) {
|
|
251
|
+
this.HeaterCooler.Active;
|
|
298
252
|
} else {
|
|
299
|
-
this.Active = this.accessory.context.Active;
|
|
253
|
+
this.HeaterCooler.Active = this.accessory.context.Active;
|
|
300
254
|
}
|
|
301
255
|
|
|
302
|
-
if (this.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
|
|
303
|
-
this.CurrentTemperature = 24;
|
|
256
|
+
if (this.HeaterCooler.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
|
|
257
|
+
this.HeaterCooler.CurrentTemperature = 24;
|
|
304
258
|
} else {
|
|
305
|
-
this.CurrentTemperature = this.CurrentTemperature || this.accessory.context.CurrentTemperature;
|
|
259
|
+
this.HeaterCooler.CurrentTemperature = this.HeaterCooler.CurrentTemperature || this.accessory.context.CurrentTemperature;
|
|
306
260
|
}
|
|
307
261
|
|
|
308
|
-
if (this.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
|
|
309
|
-
this.ThresholdTemperature = 24;
|
|
262
|
+
if (this.HeaterCooler.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
|
|
263
|
+
this.HeaterCooler.ThresholdTemperature = 24;
|
|
310
264
|
} else {
|
|
311
|
-
this.ThresholdTemperature = this.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
|
|
265
|
+
this.HeaterCooler.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
|
|
312
266
|
}
|
|
313
267
|
|
|
314
|
-
if (this.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
|
|
315
|
-
this.RotationSpeed = 4;
|
|
268
|
+
if (this.HeaterCooler.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
|
|
269
|
+
this.HeaterCooler.RotationSpeed = 4;
|
|
316
270
|
} else {
|
|
317
|
-
this.RotationSpeed = this.RotationSpeed || this.accessory.context.RotationSpeed;
|
|
271
|
+
this.HeaterCooler.RotationSpeed = this.HeaterCooler.RotationSpeed || this.accessory.context.RotationSpeed;
|
|
318
272
|
}
|
|
319
273
|
|
|
320
274
|
if (this.device.irair?.hide_automode) {
|
|
@@ -356,23 +310,24 @@ export class AirConditioner extends irdeviceBase {
|
|
|
356
310
|
}
|
|
357
311
|
|
|
358
312
|
if (this.meter) {
|
|
359
|
-
if (this.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
|
|
360
|
-
this.CurrentRelativeHumidity = 0;
|
|
313
|
+
if (this.HumiditySensor!.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
|
|
314
|
+
this.HumiditySensor!.CurrentRelativeHumidity = 0;
|
|
361
315
|
} else {
|
|
362
|
-
this.CurrentRelativeHumidity = this.CurrentRelativeHumidity
|
|
316
|
+
this.HumiditySensor!.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity
|
|
317
|
+
|| this.accessory.context.CurrentRelativeHumidity;
|
|
363
318
|
}
|
|
364
319
|
}
|
|
365
|
-
if (this.ThresholdTemperature < this.CurrentTemperature &&
|
|
366
|
-
this.TargetHeaterCoolerState !== this.hap.Characteristic.TargetHeaterCoolerState.HEAT) {
|
|
367
|
-
this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
368
|
-
} else if (this.ThresholdTemperature > this.CurrentTemperature &&
|
|
369
|
-
this.TargetHeaterCoolerState !== this.hap.Characteristic.TargetHeaterCoolerState.COOL) {
|
|
370
|
-
this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
320
|
+
if (this.HeaterCooler.ThresholdTemperature < this.HeaterCooler.CurrentTemperature &&
|
|
321
|
+
this.HeaterCooler.TargetHeaterCoolerState !== this.hap.Characteristic.TargetHeaterCoolerState.HEAT) {
|
|
322
|
+
this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
323
|
+
} else if (this.HeaterCooler.ThresholdTemperature > this.HeaterCooler.CurrentTemperature &&
|
|
324
|
+
this.HeaterCooler.TargetHeaterCoolerState !== this.hap.Characteristic.TargetHeaterCoolerState.COOL) {
|
|
325
|
+
this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
371
326
|
} else {
|
|
372
|
-
this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
327
|
+
this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
373
328
|
}
|
|
374
329
|
} else {
|
|
375
|
-
this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
330
|
+
this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
376
331
|
}
|
|
377
332
|
}
|
|
378
333
|
|
|
@@ -391,7 +346,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
391
346
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
392
347
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
393
348
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
394
|
-
this.
|
|
349
|
+
this.debugSuccessLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
395
350
|
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
396
351
|
this.successLog(`${this.device.remoteType}: ${this.accessory.displayName} request to SwitchBot API, body: ${bodyChange} sent successfully`);
|
|
397
352
|
this.updateHomeKitCharacteristics();
|
|
@@ -428,9 +383,9 @@ export class AirConditioner extends irdeviceBase {
|
|
|
428
383
|
);
|
|
429
384
|
}
|
|
430
385
|
|
|
431
|
-
this.CurrentTemperature = this.accessory.context.CurrentTemperature || 24;
|
|
432
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`);
|
|
433
|
-
return this.CurrentTemperature;
|
|
386
|
+
this.HeaterCooler.CurrentTemperature = this.accessory.context.CurrentTemperature || 24;
|
|
387
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
|
|
388
|
+
return this.HeaterCooler.CurrentTemperature;
|
|
434
389
|
}
|
|
435
390
|
|
|
436
391
|
async CurrentRelativeHumidityGet(): Promise<CharacteristicValue> {
|
|
@@ -442,19 +397,20 @@ export class AirConditioner extends irdeviceBase {
|
|
|
442
397
|
);
|
|
443
398
|
}
|
|
444
399
|
|
|
445
|
-
this.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity || 0;
|
|
446
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get
|
|
447
|
-
|
|
400
|
+
this.HumiditySensor!.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity || 0;
|
|
401
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get`
|
|
402
|
+
+ ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
|
|
403
|
+
return this.HumiditySensor!.CurrentRelativeHumidity as CharacteristicValue;
|
|
448
404
|
}
|
|
449
405
|
|
|
450
406
|
async RotationSpeedGet(): Promise<number> {
|
|
451
407
|
if (!this.CurrentFanSpeed || this.CurrentFanSpeed === 1) {
|
|
452
|
-
this.RotationSpeed = 4;
|
|
408
|
+
this.HeaterCooler.RotationSpeed = 4;
|
|
453
409
|
} else {
|
|
454
|
-
this.RotationSpeed = this.CurrentFanSpeed - 1;
|
|
410
|
+
this.HeaterCooler.RotationSpeed = this.CurrentFanSpeed - 1;
|
|
455
411
|
}
|
|
456
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get RotationSpeed: ${this.RotationSpeed}`);
|
|
457
|
-
return this.RotationSpeed;
|
|
412
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
|
|
413
|
+
return this.HeaterCooler.RotationSpeed;
|
|
458
414
|
}
|
|
459
415
|
|
|
460
416
|
async RotationSpeedSet(value: CharacteristicValue): Promise<void> {
|
|
@@ -463,37 +419,35 @@ export class AirConditioner extends irdeviceBase {
|
|
|
463
419
|
} else {
|
|
464
420
|
this.CurrentFanSpeed = Number(value) + 1;
|
|
465
421
|
}
|
|
466
|
-
this.RotationSpeed = value;
|
|
422
|
+
this.HeaterCooler.RotationSpeed = value;
|
|
467
423
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}` +
|
|
468
|
-
`Set RotationSpeed: ${this.RotationSpeed}, CurrentFanSpeed: ${this.CurrentFanSpeed}`);
|
|
424
|
+
`Set RotationSpeed: ${this.HeaterCooler.RotationSpeed}, CurrentFanSpeed: ${this.CurrentFanSpeed}`);
|
|
469
425
|
this.pushAirConditionerStatusChanges();
|
|
470
426
|
}
|
|
471
427
|
|
|
472
428
|
async ActiveSet(value: CharacteristicValue): Promise<void> {
|
|
473
429
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
|
|
474
430
|
|
|
475
|
-
this.Active = value;
|
|
476
|
-
if (this.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
477
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.Active}`);
|
|
431
|
+
this.HeaterCooler.Active = value;
|
|
432
|
+
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
433
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.HeaterCooler.Active}`);
|
|
478
434
|
if (this.disablePushOn) {
|
|
479
435
|
this.pushAirConditionerStatusChanges();
|
|
480
436
|
} else {
|
|
481
437
|
this.pushAirConditionerOnChanges();
|
|
482
438
|
}
|
|
483
439
|
} else {
|
|
484
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
|
|
440
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.HeaterCooler.Active}`);
|
|
485
441
|
this.pushAirConditionerOffChanges();
|
|
486
442
|
}
|
|
487
443
|
}
|
|
488
444
|
|
|
489
445
|
async TargetHeaterCoolerStateGet(): Promise<CharacteristicValue> {
|
|
490
|
-
const targetState = this.TargetHeaterCoolerState || this.accessory.context.TargetHeaterCoolerState;
|
|
491
|
-
this.TargetHeaterCoolerState = this.ValidValues.includes(targetState) ? targetState : this.ValidValues[0];
|
|
492
|
-
this.debugLog(
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
);
|
|
496
|
-
return this.TargetHeaterCoolerState;
|
|
446
|
+
const targetState = this.HeaterCooler.TargetHeaterCoolerState || this.accessory.context.TargetHeaterCoolerState;
|
|
447
|
+
this.HeaterCooler.TargetHeaterCoolerState = this.ValidValues.includes(targetState) ? targetState : this.ValidValues[0];
|
|
448
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get (${this.getTargetHeaterCoolerStateName()}) TargetHeaterCoolerState:`
|
|
449
|
+
+ ` ${this.HeaterCooler.TargetHeaterCoolerState}, ValidValues: ${this.ValidValues}, hide_automode: ${this.hide_automode}`);
|
|
450
|
+
return this.HeaterCooler.TargetHeaterCoolerState;
|
|
497
451
|
}
|
|
498
452
|
|
|
499
453
|
async TargetHeaterCoolerStateSet(value: CharacteristicValue): Promise<void> {
|
|
@@ -505,7 +459,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
505
459
|
this.TargetHeaterCoolerStateCOOL();
|
|
506
460
|
} else {
|
|
507
461
|
this.errorLog(
|
|
508
|
-
`${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
|
|
462
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState},` +
|
|
509
463
|
` hide_automode: ${this.hide_automode} `,
|
|
510
464
|
);
|
|
511
465
|
}
|
|
@@ -513,23 +467,26 @@ export class AirConditioner extends irdeviceBase {
|
|
|
513
467
|
}
|
|
514
468
|
|
|
515
469
|
async TargetHeaterCoolerStateAUTO(): Promise<void> {
|
|
516
|
-
this.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
470
|
+
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
517
471
|
this.CurrentMode = 1;
|
|
518
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (AUTO)
|
|
472
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (AUTO)`
|
|
473
|
+
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
519
474
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
520
475
|
}
|
|
521
476
|
|
|
522
477
|
async TargetHeaterCoolerStateCOOL(): Promise<void> {
|
|
523
|
-
this.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.COOL;
|
|
478
|
+
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.COOL;
|
|
524
479
|
this.CurrentMode = 2;
|
|
525
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (COOL)
|
|
480
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (COOL)`
|
|
481
|
+
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
526
482
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
527
483
|
}
|
|
528
484
|
|
|
529
485
|
async TargetHeaterCoolerStateHEAT(): Promise<void> {
|
|
530
|
-
this.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
486
|
+
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
531
487
|
this.CurrentMode = 5;
|
|
532
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (HEAT)
|
|
488
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (HEAT)`
|
|
489
|
+
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
533
490
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
534
491
|
}
|
|
535
492
|
|
|
@@ -537,15 +494,15 @@ export class AirConditioner extends irdeviceBase {
|
|
|
537
494
|
await this.UpdateCurrentHeaterCoolerState();
|
|
538
495
|
this.debugLog(
|
|
539
496
|
`${this.device.remoteType}: ${this.accessory.displayName}` +
|
|
540
|
-
` Get (${this.getTargetHeaterCoolerStateName()}) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
497
|
+
` Get (${this.getTargetHeaterCoolerStateName()}) CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`,
|
|
541
498
|
);
|
|
542
499
|
|
|
543
|
-
return this.CurrentHeaterCoolerState;
|
|
500
|
+
return this.HeaterCooler.CurrentHeaterCoolerState;
|
|
544
501
|
}
|
|
545
502
|
|
|
546
503
|
|
|
547
504
|
private getTargetHeaterCoolerStateName(): string {
|
|
548
|
-
switch (this.TargetHeaterCoolerState) {
|
|
505
|
+
switch (this.HeaterCooler.TargetHeaterCoolerState) {
|
|
549
506
|
case this.hap.Characteristic.TargetHeaterCoolerState.AUTO:
|
|
550
507
|
return 'AUTO';
|
|
551
508
|
case this.hap.Characteristic.TargetHeaterCoolerState.HEAT:
|
|
@@ -553,36 +510,36 @@ export class AirConditioner extends irdeviceBase {
|
|
|
553
510
|
case this.hap.Characteristic.TargetHeaterCoolerState.COOL:
|
|
554
511
|
return 'COOL';
|
|
555
512
|
default:
|
|
556
|
-
return this.TargetHeaterCoolerState.toString();
|
|
513
|
+
return this.HeaterCooler.TargetHeaterCoolerState.toString();
|
|
557
514
|
}
|
|
558
515
|
}
|
|
559
516
|
|
|
560
517
|
async ThresholdTemperatureGet(): Promise<CharacteristicValue> {
|
|
561
518
|
|
|
562
|
-
if (this.Active === undefined) {
|
|
563
|
-
this.Active = this.hap.Characteristic.Active.INACTIVE;
|
|
564
|
-
} else if (this.Active) {
|
|
565
|
-
this.Active;
|
|
519
|
+
if (this.HeaterCooler.Active === undefined) {
|
|
520
|
+
this.HeaterCooler.Active = this.hap.Characteristic.Active.INACTIVE;
|
|
521
|
+
} else if (this.HeaterCooler.Active) {
|
|
522
|
+
this.HeaterCooler.Active;
|
|
566
523
|
} else {
|
|
567
|
-
this.Active = this.accessory.context.Active;
|
|
524
|
+
this.HeaterCooler.Active = this.accessory.context.Active;
|
|
568
525
|
}
|
|
569
526
|
|
|
570
|
-
if (this.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
|
|
571
|
-
this.CurrentTemperature = 24;
|
|
527
|
+
if (this.HeaterCooler.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
|
|
528
|
+
this.HeaterCooler.CurrentTemperature = 24;
|
|
572
529
|
} else {
|
|
573
|
-
this.CurrentTemperature = this.CurrentTemperature || this.accessory.context.CurrentTemperature;
|
|
530
|
+
this.HeaterCooler.CurrentTemperature = this.HeaterCooler.CurrentTemperature || this.accessory.context.CurrentTemperature;
|
|
574
531
|
}
|
|
575
532
|
|
|
576
|
-
if (this.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
|
|
577
|
-
this.ThresholdTemperature = 24;
|
|
533
|
+
if (this.HeaterCooler.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
|
|
534
|
+
this.HeaterCooler.ThresholdTemperature = 24;
|
|
578
535
|
} else {
|
|
579
|
-
this.ThresholdTemperature = this.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
|
|
536
|
+
this.HeaterCooler.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
|
|
580
537
|
}
|
|
581
538
|
|
|
582
|
-
if (this.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
|
|
583
|
-
this.RotationSpeed = 4;
|
|
539
|
+
if (this.HeaterCooler.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
|
|
540
|
+
this.HeaterCooler.RotationSpeed = 4;
|
|
584
541
|
} else {
|
|
585
|
-
this.RotationSpeed = this.RotationSpeed || this.accessory.context.RotationSpeed;
|
|
542
|
+
this.HeaterCooler.RotationSpeed = this.HeaterCooler.RotationSpeed || this.accessory.context.RotationSpeed;
|
|
586
543
|
}
|
|
587
544
|
|
|
588
545
|
if (this.device.irair?.hide_automode) {
|
|
@@ -624,20 +581,20 @@ export class AirConditioner extends irdeviceBase {
|
|
|
624
581
|
}
|
|
625
582
|
|
|
626
583
|
if (this.meter) {
|
|
627
|
-
if (this.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
|
|
628
|
-
this.CurrentRelativeHumidity = 0;
|
|
584
|
+
if (this.HumiditySensor!.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
|
|
585
|
+
this.HumiditySensor!.CurrentRelativeHumidity = 0;
|
|
629
586
|
} else {
|
|
630
|
-
this.CurrentRelativeHumidity = this.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
|
|
587
|
+
this.HumiditySensor!.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
|
|
631
588
|
}
|
|
632
589
|
}
|
|
633
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get ThresholdTemperature: ${this.ThresholdTemperature}`);
|
|
634
|
-
return this.ThresholdTemperature;
|
|
590
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
591
|
+
return this.HeaterCooler.ThresholdTemperature;
|
|
635
592
|
}
|
|
636
593
|
|
|
637
594
|
async ThresholdTemperatureSet(value: CharacteristicValue): Promise<void> {
|
|
638
|
-
this.ThresholdTemperature = value;
|
|
595
|
+
this.HeaterCooler.ThresholdTemperature = value;
|
|
639
596
|
this.debugLog(
|
|
640
|
-
`${this.device.remoteType}: ${this.accessory.displayName} Set ThresholdTemperature: ${this.ThresholdTemperature},` +
|
|
597
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Set ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature},` +
|
|
641
598
|
` ThresholdTemperatureCached: ${this.accessory.context.ThresholdTemperature}`,
|
|
642
599
|
);
|
|
643
600
|
this.pushAirConditionerStatusChanges();
|
|
@@ -645,83 +602,127 @@ export class AirConditioner extends irdeviceBase {
|
|
|
645
602
|
|
|
646
603
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
647
604
|
// Active
|
|
648
|
-
if (this.Active === undefined) {
|
|
649
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
605
|
+
if (this.HeaterCooler.Active === undefined) {
|
|
606
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.HeaterCooler.Active}`);
|
|
650
607
|
} else {
|
|
651
|
-
this.accessory.context.Active = this.Active;
|
|
652
|
-
this.
|
|
653
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
608
|
+
this.accessory.context.Active = this.HeaterCooler.Active;
|
|
609
|
+
this.HeaterCooler.Service?.updateCharacteristic(this.hap.Characteristic.Active, this.HeaterCooler.Active);
|
|
610
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.HeaterCooler.Active}`);
|
|
654
611
|
}
|
|
655
612
|
// RotationSpeed
|
|
656
|
-
if (this.RotationSpeed === undefined) {
|
|
657
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
|
|
613
|
+
if (this.HeaterCooler.RotationSpeed === undefined) {
|
|
614
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
|
|
658
615
|
} else {
|
|
659
|
-
this.accessory.context.RotationSpeed = this.RotationSpeed;
|
|
660
|
-
this.
|
|
661
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic
|
|
616
|
+
this.accessory.context.RotationSpeed = this.HeaterCooler.RotationSpeed;
|
|
617
|
+
this.HeaterCooler.Service?.updateCharacteristic(this.hap.Characteristic.RotationSpeed, this.HeaterCooler.RotationSpeed);
|
|
618
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
619
|
+
+ ` RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
|
|
662
620
|
}
|
|
663
621
|
// CurrentTemperature
|
|
664
|
-
if (this.CurrentTemperature === undefined) {
|
|
665
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
|
|
622
|
+
if (this.HeaterCooler.CurrentTemperature === undefined) {
|
|
623
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
|
|
666
624
|
} else {
|
|
667
|
-
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
668
|
-
this.
|
|
669
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic
|
|
625
|
+
this.accessory.context.CurrentTemperature = this.HeaterCooler.CurrentTemperature;
|
|
626
|
+
this.HeaterCooler.Service?.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, this.HeaterCooler.CurrentTemperature);
|
|
627
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
628
|
+
+ ` CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
|
|
670
629
|
}
|
|
671
630
|
// CurrentRelativeHumidity
|
|
672
631
|
if (this.meter) {
|
|
673
|
-
if (this.CurrentRelativeHumidity === undefined) {
|
|
674
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}
|
|
632
|
+
if (this.HumiditySensor!.CurrentRelativeHumidity === undefined) {
|
|
633
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
634
|
+
+ ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
|
|
675
635
|
} else {
|
|
676
|
-
this.accessory.context.CurrentRelativeHumidity = this.CurrentRelativeHumidity;
|
|
677
|
-
this.
|
|
636
|
+
this.accessory.context.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity;
|
|
637
|
+
this.HeaterCooler.Service?.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity,
|
|
638
|
+
this.HumiditySensor!.CurrentRelativeHumidity);
|
|
678
639
|
this.debugLog(
|
|
679
|
-
`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic
|
|
640
|
+
`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
641
|
+
+ ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`,
|
|
680
642
|
);
|
|
681
643
|
}
|
|
682
644
|
}
|
|
683
645
|
// TargetHeaterCoolerState
|
|
684
|
-
if (this.TargetHeaterCoolerState === undefined) {
|
|
685
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
646
|
+
if (this.HeaterCooler.TargetHeaterCoolerState === undefined) {
|
|
647
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
686
648
|
} else {
|
|
687
|
-
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerState;
|
|
688
|
-
this.
|
|
689
|
-
this.debugLog(
|
|
690
|
-
|
|
691
|
-
);
|
|
649
|
+
this.accessory.context.TargetHeaterCoolerState = this.HeaterCooler.TargetHeaterCoolerState;
|
|
650
|
+
this.HeaterCooler.Service?.updateCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState, this.HeaterCooler.TargetHeaterCoolerState);
|
|
651
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
652
|
+
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
692
653
|
}
|
|
693
654
|
// CurrentHeaterCoolerState
|
|
694
|
-
if (this.CurrentHeaterCoolerState === undefined) {
|
|
695
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}
|
|
655
|
+
if (this.HeaterCooler.CurrentHeaterCoolerState === undefined) {
|
|
656
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
657
|
+
+ ` CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
|
|
696
658
|
} else {
|
|
697
|
-
this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerState;
|
|
698
|
-
this.
|
|
659
|
+
this.accessory.context.CurrentHeaterCoolerState = this.HeaterCooler.CurrentHeaterCoolerState;
|
|
660
|
+
this.HeaterCooler.Service?.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, this.HeaterCooler.CurrentHeaterCoolerState);
|
|
699
661
|
this.debugLog(
|
|
700
662
|
`${this.device.remoteType}: ${this.accessory.displayName}` +
|
|
701
|
-
` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
663
|
+
` updateCharacteristic CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`,
|
|
702
664
|
);
|
|
703
665
|
}
|
|
704
666
|
// ThresholdTemperature
|
|
705
|
-
if (this.ThresholdTemperature === undefined) {
|
|
706
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ThresholdTemperature: ${this.ThresholdTemperature}`);
|
|
667
|
+
if (this.HeaterCooler.ThresholdTemperature === undefined) {
|
|
668
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
707
669
|
} else {
|
|
708
|
-
this.accessory.context.ThresholdTemperature = this.ThresholdTemperature;
|
|
709
|
-
this.
|
|
710
|
-
this.
|
|
711
|
-
this.debugLog(
|
|
712
|
-
|
|
713
|
-
);
|
|
670
|
+
this.accessory.context.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature;
|
|
671
|
+
this.HeaterCooler.Service?.updateCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature, this.HeaterCooler.ThresholdTemperature);
|
|
672
|
+
this.HeaterCooler.Service?.updateCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature, this.HeaterCooler.ThresholdTemperature);
|
|
673
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
674
|
+
+ ` ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
714
675
|
}
|
|
715
676
|
}
|
|
716
677
|
|
|
717
678
|
async apiError({ e }: { e: any }): Promise<void> {
|
|
718
|
-
this.
|
|
719
|
-
this.
|
|
720
|
-
this.
|
|
721
|
-
this.
|
|
722
|
-
this.
|
|
723
|
-
this.
|
|
724
|
-
this.
|
|
725
|
-
this.
|
|
679
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.Active, e);
|
|
680
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.RotationSpeed, e);
|
|
681
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, e);
|
|
682
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, e);
|
|
683
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState, e);
|
|
684
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, e);
|
|
685
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature, e);
|
|
686
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature, e);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
async getAirConditionerConfigSettings(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): Promise<void> {
|
|
690
|
+
if (this.device.irair?.hide_automode) {
|
|
691
|
+
this.hide_automode = device.irair?.hide_automode;
|
|
692
|
+
accessory.context.hide_automode = this.hide_automode;
|
|
693
|
+
} else {
|
|
694
|
+
this.hide_automode = device.irair?.hide_automode;
|
|
695
|
+
accessory.context.hide_automode = this.hide_automode;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
if (this.device.irair?.set_max_heat) {
|
|
699
|
+
this.set_max_heat = device.irair?.set_max_heat;
|
|
700
|
+
accessory.context.set_max_heat = this.set_max_heat;
|
|
701
|
+
} else {
|
|
702
|
+
this.set_max_heat = 35;
|
|
703
|
+
accessory.context.set_max_heat = this.set_max_heat;
|
|
704
|
+
}
|
|
705
|
+
if (this.device.irair?.set_min_heat) {
|
|
706
|
+
this.set_min_heat = device.irair?.set_min_heat;
|
|
707
|
+
accessory.context.set_min_heat = this.set_min_heat;
|
|
708
|
+
} else {
|
|
709
|
+
this.set_min_heat = 0;
|
|
710
|
+
accessory.context.set_min_heat = this.set_min_heat;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
if (this.device.irair?.set_max_cool) {
|
|
714
|
+
this.set_max_cool = device.irair?.set_max_cool;
|
|
715
|
+
accessory.context.set_max_cool = this.set_max_cool;
|
|
716
|
+
} else {
|
|
717
|
+
this.set_max_cool = 35;
|
|
718
|
+
accessory.context.set_max_cool = this.set_max_cool;
|
|
719
|
+
}
|
|
720
|
+
if (this.device.irair?.set_min_cool) {
|
|
721
|
+
this.set_min_cool = device.irair?.set_min_cool;
|
|
722
|
+
accessory.context.set_min_cool = this.set_min_cool;
|
|
723
|
+
} else {
|
|
724
|
+
this.set_min_cool = 0;
|
|
725
|
+
accessory.context.set_min_cool = this.set_min_cool;
|
|
726
|
+
}
|
|
726
727
|
}
|
|
727
728
|
}
|