@switchbot/homebridge-switchbot 1.4.1-beta.3 → 1.4.1-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -5
- package/dist/devices/bots.d.ts +1 -1
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +17 -17
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +1 -1
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +13 -8
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +1 -1
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +15 -4
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +1 -1
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +17 -7
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +1 -1
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +20 -9
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +1 -1
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +12 -4
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +1 -1
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +10 -4
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +1 -1
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +5 -4
- package/dist/devices/plugs.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +30 -14
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +298 -155
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +1 -1
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +7 -3
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +1 -1
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +4 -3
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +1 -1
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +6 -3
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +1 -1
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +4 -3
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +1 -1
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +4 -3
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +1 -1
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +5 -3
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +4 -3
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +1 -1
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +4 -3
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/package.json +1 -1
- package/src/devices/bots.ts +17 -18
- package/src/devices/colorbulb.ts +14 -9
- package/src/devices/contact.ts +16 -5
- package/src/devices/curtains.ts +17 -7
- package/src/devices/humidifiers.ts +21 -10
- package/src/devices/meters.ts +13 -5
- package/src/devices/motion.ts +11 -5
- package/src/devices/plugs.ts +6 -5
- package/src/irdevices/airconditioners.ts +307 -163
- package/src/irdevices/airpurifiers.ts +8 -4
- package/src/irdevices/cameras.ts +5 -4
- package/src/irdevices/fans.ts +7 -4
- package/src/irdevices/lights.ts +5 -4
- package/src/irdevices/others.ts +4 -3
- package/src/irdevices/tvs.ts +6 -4
- package/src/irdevices/vacuumcleaners.ts +5 -4
- package/src/irdevices/waterheaters.ts +5 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { SwitchBotPlatform } from '../platform';
|
|
3
3
|
import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
|
|
4
|
-
import { CharacteristicValue,
|
|
4
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -16,12 +16,17 @@ export class AirConditioner {
|
|
|
16
16
|
Active!: CharacteristicValue;
|
|
17
17
|
ActiveCached!: CharacteristicValue;
|
|
18
18
|
RotationSpeed!: CharacteristicValue;
|
|
19
|
-
|
|
19
|
+
RotationSpeedCached!: CharacteristicValue;
|
|
20
20
|
CurrentTemperature!: CharacteristicValue;
|
|
21
21
|
CurrentTemperatureCached!: CharacteristicValue;
|
|
22
|
-
TargetHeaterCoolerState
|
|
22
|
+
TargetHeaterCoolerState!: CharacteristicValue;
|
|
23
|
+
TargetHeaterCoolerStateCached!: CharacteristicValue;
|
|
23
24
|
CurrentHeaterCoolerState!: CharacteristicValue;
|
|
24
|
-
|
|
25
|
+
CurrentHeaterCoolerStateCached!: CharacteristicValue;
|
|
26
|
+
HeatingThresholdTemperature!: CharacteristicValue;
|
|
27
|
+
HeatingThresholdTemperatureCached!: CharacteristicValue;
|
|
28
|
+
CoolingThresholdTemperature!: CharacteristicValue;
|
|
29
|
+
CoolingThresholdTemperatureCached!: CharacteristicValue;
|
|
25
30
|
|
|
26
31
|
// Others
|
|
27
32
|
state!: string;
|
|
@@ -36,6 +41,7 @@ export class AirConditioner {
|
|
|
36
41
|
|
|
37
42
|
// Config
|
|
38
43
|
deviceLogging!: string;
|
|
44
|
+
hide_automode?: boolean;
|
|
39
45
|
|
|
40
46
|
constructor(
|
|
41
47
|
private readonly platform: SwitchBotPlatform,
|
|
@@ -54,6 +60,13 @@ export class AirConditioner {
|
|
|
54
60
|
} else {
|
|
55
61
|
this.CurrentTemperature = this.accessory.context.CurrentTemperature;
|
|
56
62
|
}
|
|
63
|
+
if (device.irair?.hide_automode) {
|
|
64
|
+
this.hide_automode = device.irair?.hide_automode;
|
|
65
|
+
this.accessory.context.hide_automode = this.hide_automode;
|
|
66
|
+
} else {
|
|
67
|
+
this.hide_automode = device.irair?.hide_automode;
|
|
68
|
+
this.accessory.context.hide_automode = this.hide_automode;
|
|
69
|
+
}
|
|
57
70
|
|
|
58
71
|
// set accessory information
|
|
59
72
|
accessory
|
|
@@ -86,25 +99,35 @@ export class AirConditioner {
|
|
|
86
99
|
maxValue: 100,
|
|
87
100
|
minStep: 0.01,
|
|
88
101
|
})
|
|
89
|
-
.onGet((
|
|
90
|
-
return this.CurrentTemperatureGet(
|
|
102
|
+
.onGet(() => {
|
|
103
|
+
return this.CurrentTemperatureGet();
|
|
91
104
|
});
|
|
92
105
|
|
|
93
|
-
if (
|
|
106
|
+
if (this.hide_automode) {
|
|
107
|
+
this.TargetHeaterCoolerState = 1 || 2;
|
|
94
108
|
this.ValidValues = [1, 2];
|
|
109
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} ValidValues: ${JSON.stringify(this.ValidValues)},`
|
|
110
|
+
+ ` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
95
111
|
} else {
|
|
112
|
+
this.TargetHeaterCoolerState = 0 || 1 || 2;
|
|
96
113
|
this.ValidValues = [0, 1, 2];
|
|
114
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} ValidValues: ${JSON.stringify(this.ValidValues)},`
|
|
115
|
+
+ ` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
97
116
|
}
|
|
98
117
|
this.service
|
|
99
118
|
.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState)
|
|
100
119
|
.setProps({
|
|
101
120
|
validValues: this.ValidValues,
|
|
102
121
|
})
|
|
122
|
+
.onGet(async () => {
|
|
123
|
+
return this.TargetHeaterCoolerStateGet();
|
|
124
|
+
})
|
|
103
125
|
.onSet(this.TargetHeaterCoolerStateSet.bind(this));
|
|
104
126
|
|
|
105
|
-
this.service.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
|
|
106
|
-
|
|
107
|
-
|
|
127
|
+
this.service.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
|
|
128
|
+
.onGet(async () => {
|
|
129
|
+
return this.CurrentHeaterCoolerStateGet();
|
|
130
|
+
});
|
|
108
131
|
|
|
109
132
|
this.service
|
|
110
133
|
.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
|
|
@@ -126,9 +149,9 @@ export class AirConditioner {
|
|
|
126
149
|
minStep: 1,
|
|
127
150
|
})
|
|
128
151
|
.onGet(() => {
|
|
129
|
-
return this.
|
|
152
|
+
return this.CoolingThresholdTemperatureGet();
|
|
130
153
|
})
|
|
131
|
-
.onSet(this.
|
|
154
|
+
.onSet(this.CoolingThresholdTemperatureSet.bind(this));
|
|
132
155
|
|
|
133
156
|
this.service
|
|
134
157
|
.getCharacteristic(this.platform.Characteristic.RotationSpeed)
|
|
@@ -153,138 +176,6 @@ export class AirConditioner {
|
|
|
153
176
|
}
|
|
154
177
|
}
|
|
155
178
|
|
|
156
|
-
private RotationSpeedSet(value: CharacteristicValue) {
|
|
157
|
-
if (value === 4) {
|
|
158
|
-
this.CurrentFanSpeed = 1;
|
|
159
|
-
} else {
|
|
160
|
-
this.CurrentFanSpeed = Number(value) + 1;
|
|
161
|
-
}
|
|
162
|
-
this.pushAirConditionerStatusChanges();
|
|
163
|
-
this.RotationSpeed = this.CurrentFanSpeed || 1;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
private RotationSpeedGet() {
|
|
167
|
-
if (!this.CurrentFanSpeed || this.CurrentFanSpeed === 1) {
|
|
168
|
-
this.RotationSpeed = 4;
|
|
169
|
-
} else {
|
|
170
|
-
this.RotationSpeed = this.CurrentFanSpeed - 1;
|
|
171
|
-
}
|
|
172
|
-
return this.RotationSpeed;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
private ActiveSet(value: CharacteristicValue) {
|
|
176
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set Active: ${value}`);
|
|
177
|
-
|
|
178
|
-
if (value === this.platform.Characteristic.Active.INACTIVE) {
|
|
179
|
-
this.pushAirConditionerOffChanges();
|
|
180
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
|
|
181
|
-
} else {
|
|
182
|
-
this.pushAirConditionerOnChanges();
|
|
183
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
|
|
184
|
-
}
|
|
185
|
-
this.Active = value;
|
|
186
|
-
this.ActiveCached = this.Active;
|
|
187
|
-
this.accessory.context.Active = this.ActiveCached;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
private updateHomeKitCharacteristics() {
|
|
191
|
-
if (this.Active === undefined) {
|
|
192
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
193
|
-
} else {
|
|
194
|
-
this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
|
|
195
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
196
|
-
}
|
|
197
|
-
if (this.RotationSpeed === undefined) {
|
|
198
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
|
|
199
|
-
} else {
|
|
200
|
-
this.service?.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed);
|
|
201
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`);
|
|
202
|
-
}
|
|
203
|
-
if (this.CurrentTemperature === undefined) {
|
|
204
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
|
|
205
|
-
} else {
|
|
206
|
-
this.service?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
|
|
207
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
|
|
208
|
-
}
|
|
209
|
-
if (this.TargetHeaterCoolerState === undefined) {
|
|
210
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
211
|
-
} else {
|
|
212
|
-
this.service?.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.TargetHeaterCoolerState);
|
|
213
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
|
|
214
|
-
+ ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
215
|
-
}
|
|
216
|
-
if (this.CurrentHeaterCoolerState === undefined) {
|
|
217
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
218
|
-
} else {
|
|
219
|
-
this.service?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
|
|
220
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
|
|
221
|
-
+ ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
222
|
-
}
|
|
223
|
-
if (this.HeatingThresholdTemperature === undefined) {
|
|
224
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
225
|
-
} else {
|
|
226
|
-
this.service?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.HeatingThresholdTemperature);
|
|
227
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
|
|
228
|
-
+ ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
private CurrentTemperatureGet(value: CharacteristicValue) {
|
|
233
|
-
value = Number(this.CurrentTemperature) || 24;
|
|
234
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Trigger Get CurrentTemperature: ${value}`);
|
|
235
|
-
|
|
236
|
-
this.service
|
|
237
|
-
.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
|
|
238
|
-
.updateValue(value);
|
|
239
|
-
|
|
240
|
-
return value;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
private TargetHeaterCoolerStateSet(value: CharacteristicValue) {
|
|
244
|
-
switch (value) {
|
|
245
|
-
case this.platform.Characteristic.TargetHeaterCoolerState.AUTO:
|
|
246
|
-
this.CurrentMode = AirConditioner.MODE_AUTO;
|
|
247
|
-
break;
|
|
248
|
-
case this.platform.Characteristic.TargetHeaterCoolerState.COOL:
|
|
249
|
-
this.CurrentMode = AirConditioner.MODE_COOL;
|
|
250
|
-
break;
|
|
251
|
-
case this.platform.Characteristic.TargetHeaterCoolerState.HEAT:
|
|
252
|
-
this.CurrentMode = AirConditioner.MODE_HEAT;
|
|
253
|
-
break;
|
|
254
|
-
default:
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
this.pushAirConditionerStatusChanges();
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
private CurrentHeaterCoolerStateGet() {
|
|
261
|
-
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
262
|
-
if ((this.CurrentTemperature || 24) < (this.LastTemperature || 30)) {
|
|
263
|
-
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
264
|
-
} else {
|
|
265
|
-
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
266
|
-
}
|
|
267
|
-
} else {
|
|
268
|
-
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
269
|
-
}
|
|
270
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
271
|
-
return this.CurrentHeaterCoolerState;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
private HeatingThresholdTemperatureGet() {
|
|
275
|
-
this.CurrentTemperature = this.CurrentTemperature || 24;
|
|
276
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
|
|
277
|
-
return this.CurrentTemperature;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
private HeatingThresholdTemperatureSet(value: CharacteristicValue) {
|
|
281
|
-
this.pushAirConditionerStatusChanges();
|
|
282
|
-
this.LastTemperature = Number(this.CurrentTemperature);
|
|
283
|
-
this.CurrentTemperature = Number(value);
|
|
284
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature},`
|
|
285
|
-
+ ` LastTemperature: ${this.LastTemperature}`);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
179
|
/**
|
|
289
180
|
* Pushes the requested changes to the SwitchBot API
|
|
290
181
|
* deviceType commandType Command command parameter Description
|
|
@@ -306,14 +197,12 @@ export class AirConditioner {
|
|
|
306
197
|
}
|
|
307
198
|
|
|
308
199
|
async pushAirConditionerOffChanges() {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
await this.pushChanges(payload);
|
|
316
|
-
}
|
|
200
|
+
const payload = {
|
|
201
|
+
commandType: 'command',
|
|
202
|
+
parameter: 'default',
|
|
203
|
+
command: 'turnOff',
|
|
204
|
+
} as any;
|
|
205
|
+
await this.pushChanges(payload);
|
|
317
206
|
}
|
|
318
207
|
|
|
319
208
|
async pushAirConditionerStatusChanges() {
|
|
@@ -333,28 +222,31 @@ export class AirConditioner {
|
|
|
333
222
|
command: 'setAll',
|
|
334
223
|
} as any;
|
|
335
224
|
|
|
336
|
-
|
|
337
|
-
this.CurrentTemperature = 24;
|
|
338
|
-
}
|
|
225
|
+
this.CurrentTemperatureUndefined();
|
|
339
226
|
if (this.CurrentMode === undefined) {
|
|
340
227
|
this.CurrentMode = 1;
|
|
341
228
|
}
|
|
342
229
|
if (this.CurrentFanSpeed === undefined) {
|
|
343
230
|
this.CurrentFanSpeed = 1;
|
|
344
231
|
}
|
|
345
|
-
this.Active = this.platform.Characteristic.Active.ACTIVE;
|
|
346
232
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
347
233
|
this.state = 'on';
|
|
348
234
|
} else {
|
|
349
235
|
this.state = 'off';
|
|
350
236
|
}
|
|
237
|
+
if (this.CurrentMode === 1) {
|
|
238
|
+
this.CurrentTemperature = 25;
|
|
239
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},`
|
|
240
|
+
+ ` CurrentTemperature: ${this.CurrentTemperature}`);
|
|
241
|
+
}
|
|
351
242
|
payload.parameter = `${this.CurrentTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
|
|
352
243
|
|
|
353
244
|
|
|
354
245
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
355
|
-
|
|
246
|
+
this.CurrentTemperatureUndefined();
|
|
247
|
+
if (this.CurrentTemperature < this.CurrentTemperatureCached) {
|
|
356
248
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
357
|
-
} else {
|
|
249
|
+
} else if (this.CurrentTemperature > this.CurrentTemperatureCached) {
|
|
358
250
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
359
251
|
}
|
|
360
252
|
} else {
|
|
@@ -371,10 +263,16 @@ export class AirConditioner {
|
|
|
371
263
|
|
|
372
264
|
// Make the API request
|
|
373
265
|
const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
|
|
374
|
-
this.
|
|
266
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
|
|
375
267
|
this.statusCode(push);
|
|
376
268
|
this.CurrentTemperatureCached = this.CurrentTemperature;
|
|
377
269
|
this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
|
|
270
|
+
this.HeatingThresholdTemperature = this.CurrentTemperatureCached;
|
|
271
|
+
this.HeatingThresholdTemperatureCached = this.CurrentTemperatureCached;
|
|
272
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
|
|
273
|
+
this.CoolingThresholdTemperature = this.CurrentTemperatureCached;
|
|
274
|
+
this.CoolingThresholdTemperatureCached = this.CurrentTemperatureCached;
|
|
275
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
|
|
378
276
|
this.updateHomeKitCharacteristics();
|
|
379
277
|
} catch (e: any) {
|
|
380
278
|
this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges`);
|
|
@@ -386,11 +284,11 @@ export class AirConditioner {
|
|
|
386
284
|
this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,`
|
|
387
285
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
388
286
|
}
|
|
389
|
-
this.apiError();
|
|
287
|
+
this.apiError(e);
|
|
390
288
|
}
|
|
391
289
|
}
|
|
392
290
|
|
|
393
|
-
|
|
291
|
+
statusCode(push: AxiosResponse<{ statusCode: number; }>) {
|
|
394
292
|
switch (push.data.statusCode) {
|
|
395
293
|
case 151:
|
|
396
294
|
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
@@ -419,8 +317,254 @@ export class AirConditioner {
|
|
|
419
317
|
}
|
|
420
318
|
}
|
|
421
319
|
|
|
422
|
-
|
|
423
|
-
|
|
320
|
+
updateHomeKitCharacteristics() {
|
|
321
|
+
if (this.Active === undefined) {
|
|
322
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
323
|
+
} else {
|
|
324
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
|
|
325
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
326
|
+
}
|
|
327
|
+
if (this.RotationSpeed === undefined) {
|
|
328
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
|
|
329
|
+
} else {
|
|
330
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed);
|
|
331
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`);
|
|
332
|
+
}
|
|
333
|
+
if (this.CurrentTemperature === undefined) {
|
|
334
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
|
|
335
|
+
} else {
|
|
336
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
|
|
337
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
|
|
338
|
+
}
|
|
339
|
+
if (this.TargetHeaterCoolerState === undefined) {
|
|
340
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
341
|
+
} else {
|
|
342
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.TargetHeaterCoolerState);
|
|
343
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
|
|
344
|
+
+ ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
345
|
+
}
|
|
346
|
+
if (this.CurrentHeaterCoolerState === undefined) {
|
|
347
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
348
|
+
} else {
|
|
349
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
|
|
350
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
|
|
351
|
+
+ ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
352
|
+
}
|
|
353
|
+
if (this.HeatingThresholdTemperature === undefined) {
|
|
354
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
355
|
+
} else {
|
|
356
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.HeatingThresholdTemperature);
|
|
357
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
|
|
358
|
+
+ ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
359
|
+
}
|
|
360
|
+
if (this.CoolingThresholdTemperature === undefined) {
|
|
361
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
362
|
+
} else {
|
|
363
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, this.CoolingThresholdTemperature);
|
|
364
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
|
|
365
|
+
+ ` updateCharacteristic CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
public apiError(e: any) {
|
|
370
|
+
this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
371
|
+
this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, e);
|
|
372
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
|
|
373
|
+
this.service.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, e);
|
|
374
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, e);
|
|
375
|
+
this.service.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, e);
|
|
376
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, e);
|
|
377
|
+
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
CurrentTemperatureGet() {
|
|
381
|
+
if (this.CurrentTemperature === undefined) {
|
|
382
|
+
this.CurrentTemperature = 24;
|
|
383
|
+
this.CurrentTemperatureCached = this.CurrentTemperature;
|
|
384
|
+
} else {
|
|
385
|
+
this.CurrentTemperatureCached = this.CurrentTemperature;
|
|
386
|
+
}
|
|
387
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`);
|
|
388
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
|
|
389
|
+
return this.CurrentTemperature;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
RotationSpeedGet() {
|
|
393
|
+
if (!this.CurrentFanSpeed) {
|
|
394
|
+
this.RotationSpeed = 4;
|
|
395
|
+
} else if (this.CurrentFanSpeed === 1) {
|
|
396
|
+
this.RotationSpeed = 4;
|
|
397
|
+
} else {
|
|
398
|
+
this.RotationSpeed = this.CurrentFanSpeed - 1;
|
|
399
|
+
}
|
|
400
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get RotationSpeed: ${this.RotationSpeed}`);
|
|
401
|
+
this.RotationSpeedCached = this.RotationSpeed;
|
|
402
|
+
this.accessory.context.RotationSpeed = this.RotationSpeedCached;
|
|
403
|
+
return this.RotationSpeed;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
RotationSpeedSet(value: CharacteristicValue) {
|
|
407
|
+
if (value === 4) {
|
|
408
|
+
this.CurrentFanSpeed = 1;
|
|
409
|
+
} else {
|
|
410
|
+
this.CurrentFanSpeed = Number(value) + 1;
|
|
411
|
+
}
|
|
412
|
+
this.RotationSpeed = this.CurrentFanSpeed;
|
|
413
|
+
this.RotationSpeedCached = this.RotationSpeed;
|
|
414
|
+
this.accessory.context.RotationSpeed = this.RotationSpeedCached;
|
|
415
|
+
this.pushAirConditionerStatusChanges();
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
ActiveSet(value: CharacteristicValue) {
|
|
419
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set Active: ${value}`);
|
|
420
|
+
|
|
421
|
+
this.Active = value;
|
|
422
|
+
this.ActiveCached = this.Active;
|
|
423
|
+
this.accessory.context.Active = this.ActiveCached;
|
|
424
|
+
|
|
425
|
+
if (value === this.platform.Characteristic.Active.INACTIVE) {
|
|
426
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
|
|
427
|
+
this.pushAirConditionerOffChanges();
|
|
428
|
+
} else {
|
|
429
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.Active}`);
|
|
430
|
+
this.pushAirConditionerStatusChanges();
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
TargetHeaterCoolerStateGet() {
|
|
435
|
+
if (this.ValidValues === [0, 1, 2]) {
|
|
436
|
+
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
437
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (AUTO) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},`
|
|
438
|
+
+ ` ValidValues: ${this.ValidValues}`);
|
|
439
|
+
} else if (this.ValidValues === [1, 2]) {
|
|
440
|
+
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.COOL
|
|
441
|
+
|| this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
442
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (COOL/HEAT) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},`
|
|
443
|
+
+ ` ValidValues: ${this.ValidValues}`);
|
|
444
|
+
} else {
|
|
445
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},`
|
|
446
|
+
+ ` ValidValues: ${this.ValidValues}`);
|
|
447
|
+
}
|
|
448
|
+
this.TargetHeaterCoolerStateCached = this.TargetHeaterCoolerState;
|
|
449
|
+
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerStateCached;
|
|
450
|
+
return this.TargetHeaterCoolerState;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
TargetHeaterCoolerStateSet(value: CharacteristicValue) {
|
|
454
|
+
if (this.hide_automode) {
|
|
455
|
+
if (value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT) {
|
|
456
|
+
this.TargetHeaterCoolerStateHEAT();
|
|
457
|
+
} else if (value === this.platform.Characteristic.TargetHeaterCoolerState.COOL) {
|
|
458
|
+
this.TargetHeaterCoolerStateCOOL();
|
|
459
|
+
} else {
|
|
460
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},`
|
|
461
|
+
+ ` hide_automode: ${this.hide_automode} `);
|
|
462
|
+
}
|
|
463
|
+
} else {
|
|
464
|
+
if (value === this.platform.Characteristic.TargetHeaterCoolerState.AUTO) {
|
|
465
|
+
this.TargetHeaterCoolerStateAUTO();
|
|
466
|
+
} else if (value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT) {
|
|
467
|
+
this.TargetHeaterCoolerStateHEAT();
|
|
468
|
+
} else if (value === this.platform.Characteristic.TargetHeaterCoolerState.COOL) {
|
|
469
|
+
this.TargetHeaterCoolerStateCOOL();
|
|
470
|
+
} else {
|
|
471
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},`
|
|
472
|
+
+ ` hide_automode: ${this.hide_automode} `);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
this.TargetHeaterCoolerStateCached = this.TargetHeaterCoolerState;
|
|
476
|
+
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerStateCached;
|
|
477
|
+
this.pushAirConditionerStatusChanges();
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
private TargetHeaterCoolerStateAUTO() {
|
|
481
|
+
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
482
|
+
this.CurrentMode = 1;
|
|
483
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set (AUTO) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
484
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
private TargetHeaterCoolerStateCOOL() {
|
|
488
|
+
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.COOL;
|
|
489
|
+
this.CurrentMode = 2;
|
|
490
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set (COOL) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
491
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
private TargetHeaterCoolerStateHEAT() {
|
|
495
|
+
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
496
|
+
this.CurrentMode = 5;
|
|
497
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set (HEAT) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
498
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
CurrentHeaterCoolerStateGet() {
|
|
502
|
+
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
503
|
+
this.CurrentTemperatureUndefined();
|
|
504
|
+
if (this.CurrentTemperature < this.CurrentTemperatureCached) {
|
|
505
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
506
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (COOLLING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
507
|
+
} else if (this.CurrentTemperature > this.CurrentTemperatureCached) {
|
|
508
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
509
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
510
|
+
}
|
|
511
|
+
} else {
|
|
512
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
513
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (INACTIVE) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
514
|
+
}
|
|
515
|
+
this.CurrentHeaterCoolerStateCached = this.CurrentHeaterCoolerState;
|
|
516
|
+
this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerStateCached;
|
|
517
|
+
return this.CurrentHeaterCoolerState;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
private HeatingThresholdTemperatureGet() {
|
|
521
|
+
this.CurrentTemperatureUndefined;
|
|
522
|
+
this.CurrentTemperature = this.CurrentTemperatureCached;
|
|
523
|
+
this.HeatingThresholdTemperature = this.CurrentTemperatureCached;
|
|
524
|
+
this.HeatingThresholdTemperatureCached = this.HeatingThresholdTemperature;
|
|
525
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
|
|
526
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
527
|
+
return this.HeatingThresholdTemperature;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
private HeatingThresholdTemperatureSet(value: CharacteristicValue) {
|
|
531
|
+
this.CurrentTemperatureCached = this.CurrentTemperature;
|
|
532
|
+
this.CurrentTemperature = value;
|
|
533
|
+
this.HeatingThresholdTemperatureCached = this.HeatingThresholdTemperature;
|
|
534
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
|
|
535
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set HeatingThresholdTemperature: ${this.HeatingThresholdTemperature},`
|
|
536
|
+
+ ` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`);
|
|
537
|
+
this.pushAirConditionerStatusChanges();
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
private CoolingThresholdTemperatureGet() {
|
|
542
|
+
this.CurrentTemperatureUndefined;
|
|
543
|
+
this.CurrentTemperature = this.CurrentTemperatureCached;
|
|
544
|
+
this.CoolingThresholdTemperature = this.CurrentTemperatureCached;
|
|
545
|
+
this.CoolingThresholdTemperatureCached = this.CoolingThresholdTemperature;
|
|
546
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
|
|
547
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
548
|
+
return this.CoolingThresholdTemperature;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
private CoolingThresholdTemperatureSet(value: CharacteristicValue) {
|
|
552
|
+
this.CurrentTemperatureCached = this.CurrentTemperature;
|
|
553
|
+
this.CurrentTemperature = value;
|
|
554
|
+
this.CoolingThresholdTemperatureCached = this.CoolingThresholdTemperature;
|
|
555
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
|
|
556
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set CoolingThresholdTemperature: ${this.CoolingThresholdTemperature},`
|
|
557
|
+
+ ` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`);
|
|
558
|
+
this.pushAirConditionerStatusChanges();
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
private CurrentTemperatureUndefined() {
|
|
562
|
+
if (this.CurrentTemperature === undefined) {
|
|
563
|
+
this.CurrentTemperature = 24;
|
|
564
|
+
}
|
|
565
|
+
if (this.CurrentTemperatureCached === undefined) {
|
|
566
|
+
this.CurrentTemperature = 30;
|
|
567
|
+
}
|
|
424
568
|
}
|
|
425
569
|
|
|
426
570
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { SwitchBotPlatform } from '../platform';
|
|
3
3
|
import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
|
|
4
|
-
import { CharacteristicValue,
|
|
4
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -248,7 +248,7 @@ export class AirPurifier {
|
|
|
248
248
|
this.errorLog(`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
249
249
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
250
250
|
}
|
|
251
|
-
this.apiError();
|
|
251
|
+
this.apiError(e);
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
|
|
@@ -281,8 +281,12 @@ export class AirPurifier {
|
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
public apiError() {
|
|
285
|
-
|
|
284
|
+
public apiError(e: any) {
|
|
285
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, e);
|
|
286
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentAirPurifierState, e);
|
|
287
|
+
this.service.updateCharacteristic(this.platform.Characteristic.TargetAirPurifierState, e);
|
|
288
|
+
this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
289
|
+
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
286
290
|
}
|
|
287
291
|
|
|
288
292
|
/**
|
package/src/irdevices/cameras.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { SwitchBotPlatform } from '../platform';
|
|
3
3
|
import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
|
|
4
|
-
import { CharacteristicValue,
|
|
4
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -140,7 +140,7 @@ export class Camera {
|
|
|
140
140
|
this.errorLog(`Camera: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
141
141
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
142
142
|
}
|
|
143
|
-
this.apiError();
|
|
143
|
+
this.apiError(e);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
|
|
@@ -173,8 +173,9 @@ export class Camera {
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
public apiError() {
|
|
177
|
-
|
|
176
|
+
public apiError(e: any) {
|
|
177
|
+
this.service.updateCharacteristic(this.platform.Characteristic.On, e);
|
|
178
|
+
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
178
179
|
}
|
|
179
180
|
|
|
180
181
|
/**
|
package/src/irdevices/fans.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { SwitchBotPlatform } from '../platform';
|
|
3
|
-
import { CharacteristicValue,
|
|
3
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
4
4
|
import { DeviceURL, irdevice, deviceStatusResponse, irDevicesConfig, payload } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -262,7 +262,7 @@ export class Fan {
|
|
|
262
262
|
this.errorLog(`Fan: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
263
263
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
264
264
|
}
|
|
265
|
-
this.apiError();
|
|
265
|
+
this.apiError(e);
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
268
|
|
|
@@ -295,8 +295,11 @@ export class Fan {
|
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
public apiError() {
|
|
299
|
-
|
|
298
|
+
public apiError(e: any) {
|
|
299
|
+
this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
300
|
+
this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, e);
|
|
301
|
+
this.service.updateCharacteristic(this.platform.Characteristic.SwingMode, e);
|
|
302
|
+
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
300
303
|
}
|
|
301
304
|
|
|
302
305
|
/**
|