@switchbot/homebridge-switchbot 1.8.3-beta.0 → 1.9.0
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/.eslintrc +1 -1
- package/.vscode/settings.json +1 -1
- package/CHANGELOG.md +8 -0
- package/config.schema.json +9 -0
- package/dist/devices/bots.d.ts +37 -34
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +196 -243
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +50 -50
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +131 -145
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +29 -27
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +115 -138
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +31 -29
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +176 -211
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +33 -33
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +189 -214
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +31 -30
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +100 -124
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +26 -25
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +102 -120
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +23 -23
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +63 -81
- package/dist/devices/plugs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -22
- package/dist/index.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +6 -6
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +79 -105
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +5 -5
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +42 -56
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +5 -5
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +27 -31
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +5 -5
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +38 -45
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +5 -5
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +33 -37
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +5 -5
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +29 -34
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +5 -5
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +76 -91
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +5 -5
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +27 -31
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +5 -5
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +27 -31
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/platform.d.ts +12 -12
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +172 -241
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +2 -1
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +4 -4
- package/dist/settings.js.map +1 -1
- package/package.json +71 -72
- package/src/devices/bots.ts +455 -929
- package/src/devices/colorbulb.ts +246 -473
- package/src/devices/contact.ts +208 -381
- package/src/devices/curtains.ts +321 -613
- package/src/devices/humidifiers.ts +323 -594
- package/src/devices/meters.ts +186 -331
- package/src/devices/motion.ts +184 -327
- package/src/devices/plugs.ts +107 -175
- package/src/index.ts +5 -5
- package/src/irdevices/airconditioners.ts +149 -360
- package/src/irdevices/airpurifiers.ts +80 -178
- package/src/irdevices/cameras.ts +51 -109
- package/src/irdevices/fans.ts +77 -174
- package/src/irdevices/lights.ts +57 -110
- package/src/irdevices/others.ts +62 -137
- package/src/irdevices/tvs.ts +124 -249
- package/src/irdevices/vacuumcleaners.ts +52 -112
- package/src/irdevices/waterheaters.ts +53 -115
- package/src/platform.ts +357 -768
- package/src/settings.ts +24 -17
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AxiosResponse } from
|
|
2
|
-
import { SwitchBotPlatform } from
|
|
3
|
-
import { irDevicesConfig, DeviceURL, irdevice, payload } from
|
|
4
|
-
import { CharacteristicValue, PlatformAccessory, Service } from
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { SwitchBotPlatform } from '../platform';
|
|
3
|
+
import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
|
|
4
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -72,19 +72,15 @@ export class AirConditioner {
|
|
|
72
72
|
// set accessory information
|
|
73
73
|
accessory
|
|
74
74
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
75
|
-
.setCharacteristic(this.platform.Characteristic.Manufacturer,
|
|
75
|
+
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
76
76
|
.setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
|
|
77
|
-
.setCharacteristic(
|
|
78
|
-
this.platform.Characteristic.SerialNumber,
|
|
79
|
-
device.deviceId!,
|
|
80
|
-
);
|
|
77
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
|
|
81
78
|
|
|
82
79
|
// get the Television service if it exists, otherwise create a new Television service
|
|
83
80
|
// you can create multiple services for each accessory
|
|
84
81
|
(this.service =
|
|
85
82
|
accessory.getService(this.platform.Service.HeaterCooler) ||
|
|
86
|
-
accessory.addService(this.platform.Service.HeaterCooler)),
|
|
87
|
-
`${accessory.displayName} Air Conditioner`;
|
|
83
|
+
accessory.addService(this.platform.Service.HeaterCooler)), `${accessory.displayName} Air Conditioner`;
|
|
88
84
|
|
|
89
85
|
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
90
86
|
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
@@ -92,15 +88,10 @@ export class AirConditioner {
|
|
|
92
88
|
|
|
93
89
|
// set the service name, this is what is displayed as the default name on the Home app
|
|
94
90
|
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
95
|
-
this.service.setCharacteristic(
|
|
96
|
-
this.platform.Characteristic.Name,
|
|
97
|
-
accessory.displayName,
|
|
98
|
-
);
|
|
91
|
+
this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
99
92
|
|
|
100
93
|
// handle on / off events using the Active characteristic
|
|
101
|
-
this.service
|
|
102
|
-
.getCharacteristic(this.platform.Characteristic.Active)
|
|
103
|
-
.onSet(this.ActiveSet.bind(this));
|
|
94
|
+
this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
|
|
104
95
|
|
|
105
96
|
this.service
|
|
106
97
|
.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
|
|
@@ -116,21 +107,13 @@ export class AirConditioner {
|
|
|
116
107
|
if (this.hide_automode) {
|
|
117
108
|
this.TargetHeaterCoolerState = 1 || 2;
|
|
118
109
|
this.ValidValues = [1, 2];
|
|
119
|
-
this.debugLog(
|
|
120
|
-
`
|
|
121
|
-
this.accessory.displayName
|
|
122
|
-
} ValidValues: ${JSON.stringify(this.ValidValues)},` +
|
|
123
|
-
` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
124
|
-
);
|
|
110
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} ValidValues: ${JSON.stringify(this.ValidValues)},`
|
|
111
|
+
+ ` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
125
112
|
} else {
|
|
126
113
|
this.TargetHeaterCoolerState = 0 || 1 || 2;
|
|
127
114
|
this.ValidValues = [0, 1, 2];
|
|
128
|
-
this.debugLog(
|
|
129
|
-
`
|
|
130
|
-
this.accessory.displayName
|
|
131
|
-
} ValidValues: ${JSON.stringify(this.ValidValues)},` +
|
|
132
|
-
` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
133
|
-
);
|
|
115
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} ValidValues: ${JSON.stringify(this.ValidValues)},`
|
|
116
|
+
+ ` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
134
117
|
}
|
|
135
118
|
this.service
|
|
136
119
|
.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState)
|
|
@@ -142,16 +125,13 @@ export class AirConditioner {
|
|
|
142
125
|
})
|
|
143
126
|
.onSet(this.TargetHeaterCoolerStateSet.bind(this));
|
|
144
127
|
|
|
145
|
-
this.service
|
|
146
|
-
.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
|
|
128
|
+
this.service.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
|
|
147
129
|
.onGet(async () => {
|
|
148
130
|
return this.CurrentHeaterCoolerStateGet();
|
|
149
131
|
});
|
|
150
132
|
|
|
151
133
|
this.service
|
|
152
|
-
.getCharacteristic(
|
|
153
|
-
this.platform.Characteristic.HeatingThresholdTemperature,
|
|
154
|
-
)
|
|
134
|
+
.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
|
|
155
135
|
.setProps({
|
|
156
136
|
minValue: 16,
|
|
157
137
|
maxValue: 30,
|
|
@@ -163,9 +143,7 @@ export class AirConditioner {
|
|
|
163
143
|
.onSet(this.HeatingThresholdTemperatureSet.bind(this));
|
|
164
144
|
|
|
165
145
|
this.service
|
|
166
|
-
.getCharacteristic(
|
|
167
|
-
this.platform.Characteristic.CoolingThresholdTemperature,
|
|
168
|
-
)
|
|
146
|
+
.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature)
|
|
169
147
|
.setProps({
|
|
170
148
|
minValue: 16,
|
|
171
149
|
maxValue: 30,
|
|
@@ -211,9 +189,9 @@ export class AirConditioner {
|
|
|
211
189
|
|
|
212
190
|
async pushAirConditionerOffChanges() {
|
|
213
191
|
const payload = {
|
|
214
|
-
commandType:
|
|
215
|
-
parameter:
|
|
216
|
-
command:
|
|
192
|
+
commandType: 'command',
|
|
193
|
+
parameter: 'default',
|
|
194
|
+
command: 'turnOff',
|
|
217
195
|
} as any;
|
|
218
196
|
await this.pushChanges(payload);
|
|
219
197
|
}
|
|
@@ -221,22 +199,18 @@ export class AirConditioner {
|
|
|
221
199
|
async pushAirConditionerStatusChanges() {
|
|
222
200
|
if (!this.Busy) {
|
|
223
201
|
this.Busy = true;
|
|
224
|
-
this.CurrentHeaterCoolerState =
|
|
225
|
-
this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
202
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
226
203
|
}
|
|
227
204
|
clearTimeout(this.Timeout);
|
|
228
205
|
|
|
229
206
|
// Make a new Timeout set to go off in 1000ms (1 second)
|
|
230
|
-
this.Timeout = setTimeout(
|
|
231
|
-
this.pushAirConditionerDetailsChanges.bind(this),
|
|
232
|
-
1500,
|
|
233
|
-
);
|
|
207
|
+
this.Timeout = setTimeout(this.pushAirConditionerDetailsChanges.bind(this), 1500);
|
|
234
208
|
}
|
|
235
209
|
|
|
236
210
|
async pushAirConditionerDetailsChanges() {
|
|
237
211
|
const payload = {
|
|
238
|
-
commandType:
|
|
239
|
-
command:
|
|
212
|
+
commandType: 'command',
|
|
213
|
+
command: 'setAll',
|
|
240
214
|
} as any;
|
|
241
215
|
|
|
242
216
|
this.CurrentTemperatureUndefined();
|
|
@@ -247,31 +221,27 @@ export class AirConditioner {
|
|
|
247
221
|
this.CurrentFanSpeed = 1;
|
|
248
222
|
}
|
|
249
223
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
250
|
-
this.state =
|
|
224
|
+
this.state = 'on';
|
|
251
225
|
} else {
|
|
252
|
-
this.state =
|
|
226
|
+
this.state = 'off';
|
|
253
227
|
}
|
|
254
228
|
if (this.CurrentMode === 1) {
|
|
255
229
|
this.CurrentTemperature = 25;
|
|
256
|
-
this.debugLog(
|
|
257
|
-
`
|
|
258
|
-
` CurrentTemperature: ${this.CurrentTemperature}`,
|
|
259
|
-
);
|
|
230
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},`
|
|
231
|
+
+ ` CurrentTemperature: ${this.CurrentTemperature}`);
|
|
260
232
|
}
|
|
261
233
|
payload.parameter = `${this.CurrentTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
|
|
262
234
|
|
|
235
|
+
|
|
263
236
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
264
237
|
this.CurrentTemperatureUndefined();
|
|
265
238
|
if (this.CurrentTemperature < this.CurrentTemperatureCached) {
|
|
266
|
-
this.CurrentHeaterCoolerState =
|
|
267
|
-
this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
239
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
268
240
|
} else if (this.CurrentTemperature > this.CurrentTemperatureCached) {
|
|
269
|
-
this.CurrentHeaterCoolerState =
|
|
270
|
-
this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
241
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
271
242
|
}
|
|
272
243
|
} else {
|
|
273
|
-
this.CurrentHeaterCoolerState =
|
|
274
|
-
this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
244
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
275
245
|
}
|
|
276
246
|
|
|
277
247
|
await this.pushChanges(payload);
|
|
@@ -279,224 +249,122 @@ export class AirConditioner {
|
|
|
279
249
|
|
|
280
250
|
public async pushChanges(payload: payload) {
|
|
281
251
|
try {
|
|
282
|
-
this.infoLog(
|
|
283
|
-
`
|
|
284
|
-
` parameter: [${payload.parameter}], commandType: ${payload.commandType}`,
|
|
285
|
-
);
|
|
252
|
+
this.infoLog(`Air Conditioner: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
|
|
253
|
+
+ ` parameter: [${payload.parameter}], commandType: ${payload.commandType}`);
|
|
286
254
|
|
|
287
255
|
// Make the API request
|
|
288
|
-
const push: any = await this.platform.axios.post(
|
|
289
|
-
|
|
290
|
-
payload,
|
|
291
|
-
);
|
|
292
|
-
this.debugLog(
|
|
293
|
-
`Air Conditioner: ${
|
|
294
|
-
this.accessory.displayName
|
|
295
|
-
} pushChanges: ${JSON.stringify(push.data)}`,
|
|
296
|
-
);
|
|
256
|
+
const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
|
|
257
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
|
|
297
258
|
this.statusCode(push);
|
|
298
259
|
this.CurrentTemperatureCached = this.CurrentTemperature;
|
|
299
260
|
this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
|
|
300
261
|
this.HeatingThresholdTemperature = this.CurrentTemperatureCached;
|
|
301
262
|
this.HeatingThresholdTemperatureCached = this.CurrentTemperatureCached;
|
|
302
|
-
this.accessory.context.HeatingThresholdTemperature =
|
|
303
|
-
this.HeatingThresholdTemperatureCached;
|
|
263
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
|
|
304
264
|
this.CoolingThresholdTemperature = this.CurrentTemperatureCached;
|
|
305
265
|
this.CoolingThresholdTemperatureCached = this.CurrentTemperatureCached;
|
|
306
|
-
this.accessory.context.CoolingThresholdTemperature =
|
|
307
|
-
this.CoolingThresholdTemperatureCached;
|
|
266
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
|
|
308
267
|
this.updateHomeKitCharacteristics();
|
|
309
268
|
} catch (e: any) {
|
|
310
|
-
this.errorLog(
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
this.errorLog(
|
|
315
|
-
`Air Conditioner: ${this.accessory.displayName} failed pushChanges,` +
|
|
316
|
-
` Error Message: ${JSON.stringify(e.message)}`,
|
|
317
|
-
);
|
|
269
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges`);
|
|
270
|
+
if (this.deviceLogging === 'debug') {
|
|
271
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,`
|
|
272
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
318
273
|
}
|
|
319
274
|
if (this.platform.debugMode) {
|
|
320
|
-
this.errorLog(
|
|
321
|
-
`
|
|
322
|
-
` Error: ${JSON.stringify(e)}`,
|
|
323
|
-
);
|
|
275
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,`
|
|
276
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
324
277
|
}
|
|
325
278
|
this.apiError(e);
|
|
326
279
|
}
|
|
327
280
|
}
|
|
328
281
|
|
|
329
|
-
statusCode(push: AxiosResponse<{ statusCode: number }>) {
|
|
282
|
+
statusCode(push: AxiosResponse<{ statusCode: number; }>) {
|
|
330
283
|
switch (push.data.statusCode) {
|
|
331
284
|
case 151:
|
|
332
|
-
this.errorLog(
|
|
333
|
-
`Air Conditioner: ${this.accessory.displayName} Command not supported by this device type.`,
|
|
334
|
-
);
|
|
285
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
335
286
|
break;
|
|
336
287
|
case 152:
|
|
337
|
-
this.errorLog(
|
|
338
|
-
`Air Conditioner: ${this.accessory.displayName} Device not found.`,
|
|
339
|
-
);
|
|
288
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device not found.`);
|
|
340
289
|
break;
|
|
341
290
|
case 160:
|
|
342
|
-
this.errorLog(
|
|
343
|
-
`Air Conditioner: ${this.accessory.displayName} Command is not supported.`,
|
|
344
|
-
);
|
|
291
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Command is not supported.`);
|
|
345
292
|
break;
|
|
346
293
|
case 161:
|
|
347
|
-
this.errorLog(
|
|
348
|
-
`Air Conditioner: ${this.accessory.displayName} Device is offline.`,
|
|
349
|
-
);
|
|
294
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device is offline.`);
|
|
350
295
|
break;
|
|
351
296
|
case 171:
|
|
352
|
-
this.errorLog(
|
|
353
|
-
`Air Conditioner: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`,
|
|
354
|
-
);
|
|
297
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
355
298
|
break;
|
|
356
299
|
case 190:
|
|
357
|
-
this.errorLog(
|
|
358
|
-
`
|
|
359
|
-
` with server, Or command: ${JSON.stringify(
|
|
360
|
-
push.data,
|
|
361
|
-
)} format is invalid`,
|
|
362
|
-
);
|
|
300
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device internal error due to device states not synchronized`
|
|
301
|
+
+ ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
363
302
|
break;
|
|
364
303
|
case 100:
|
|
365
|
-
this.debugLog(
|
|
366
|
-
`Air Conditioner: ${this.accessory.displayName} Command successfully sent.`,
|
|
367
|
-
);
|
|
304
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Command successfully sent.`);
|
|
368
305
|
break;
|
|
369
306
|
default:
|
|
370
|
-
this.debugLog(
|
|
371
|
-
`Air Conditioner: ${this.accessory.displayName} Unknown statusCode.`,
|
|
372
|
-
);
|
|
307
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Unknown statusCode.`);
|
|
373
308
|
}
|
|
374
309
|
}
|
|
375
310
|
|
|
376
311
|
updateHomeKitCharacteristics() {
|
|
377
312
|
if (this.Active === undefined) {
|
|
378
|
-
this.debugLog(
|
|
379
|
-
`Air Conditioner: ${this.accessory.displayName} Active: ${this.Active}`,
|
|
380
|
-
);
|
|
313
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
381
314
|
} else {
|
|
382
|
-
this.service?.updateCharacteristic(
|
|
383
|
-
|
|
384
|
-
this.Active,
|
|
385
|
-
);
|
|
386
|
-
this.debugLog(
|
|
387
|
-
`Air Conditioner: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`,
|
|
388
|
-
);
|
|
315
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
|
|
316
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
389
317
|
}
|
|
390
318
|
if (this.RotationSpeed === undefined) {
|
|
391
|
-
this.debugLog(
|
|
392
|
-
`Air Conditioner: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`,
|
|
393
|
-
);
|
|
319
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
|
|
394
320
|
} else {
|
|
395
|
-
this.service?.updateCharacteristic(
|
|
396
|
-
|
|
397
|
-
this.RotationSpeed,
|
|
398
|
-
);
|
|
399
|
-
this.debugLog(
|
|
400
|
-
`Air Conditioner: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`,
|
|
401
|
-
);
|
|
321
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed);
|
|
322
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`);
|
|
402
323
|
}
|
|
403
324
|
if (this.CurrentTemperature === undefined) {
|
|
404
|
-
this.debugLog(
|
|
405
|
-
`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`,
|
|
406
|
-
);
|
|
325
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
|
|
407
326
|
} else {
|
|
408
|
-
this.service?.updateCharacteristic(
|
|
409
|
-
|
|
410
|
-
this.CurrentTemperature,
|
|
411
|
-
);
|
|
412
|
-
this.debugLog(
|
|
413
|
-
`Air Conditioner: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`,
|
|
414
|
-
);
|
|
327
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
|
|
328
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
|
|
415
329
|
}
|
|
416
330
|
if (this.TargetHeaterCoolerState === undefined) {
|
|
417
|
-
this.debugLog(
|
|
418
|
-
`Air Conditioner: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
419
|
-
);
|
|
331
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
420
332
|
} else {
|
|
421
|
-
this.service?.updateCharacteristic(
|
|
422
|
-
|
|
423
|
-
this.TargetHeaterCoolerState
|
|
424
|
-
);
|
|
425
|
-
this.debugLog(
|
|
426
|
-
`Air Conditioner: ${this.accessory.displayName}` +
|
|
427
|
-
` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
428
|
-
);
|
|
333
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.TargetHeaterCoolerState);
|
|
334
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
|
|
335
|
+
+ ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
429
336
|
}
|
|
430
337
|
if (this.CurrentHeaterCoolerState === undefined) {
|
|
431
|
-
this.debugLog(
|
|
432
|
-
`Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
433
|
-
);
|
|
338
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
434
339
|
} else {
|
|
435
|
-
this.service?.updateCharacteristic(
|
|
436
|
-
|
|
437
|
-
this.CurrentHeaterCoolerState
|
|
438
|
-
);
|
|
439
|
-
this.debugLog(
|
|
440
|
-
`Air Conditioner: ${this.accessory.displayName}` +
|
|
441
|
-
` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
442
|
-
);
|
|
340
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
|
|
341
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
|
|
342
|
+
+ ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
443
343
|
}
|
|
444
344
|
if (this.HeatingThresholdTemperature === undefined) {
|
|
445
|
-
this.debugLog(
|
|
446
|
-
`Air Conditioner: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`,
|
|
447
|
-
);
|
|
345
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
448
346
|
} else {
|
|
449
|
-
this.service?.updateCharacteristic(
|
|
450
|
-
|
|
451
|
-
this.HeatingThresholdTemperature
|
|
452
|
-
);
|
|
453
|
-
this.debugLog(
|
|
454
|
-
`Air Conditioner: ${this.accessory.displayName}` +
|
|
455
|
-
` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`,
|
|
456
|
-
);
|
|
347
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.HeatingThresholdTemperature);
|
|
348
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
|
|
349
|
+
+ ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
457
350
|
}
|
|
458
351
|
if (this.CoolingThresholdTemperature === undefined) {
|
|
459
|
-
this.debugLog(
|
|
460
|
-
`Air Conditioner: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`,
|
|
461
|
-
);
|
|
352
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
462
353
|
} else {
|
|
463
|
-
this.service?.updateCharacteristic(
|
|
464
|
-
|
|
465
|
-
this.CoolingThresholdTemperature
|
|
466
|
-
);
|
|
467
|
-
this.debugLog(
|
|
468
|
-
`Air Conditioner: ${this.accessory.displayName}` +
|
|
469
|
-
` updateCharacteristic CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`,
|
|
470
|
-
);
|
|
354
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, this.CoolingThresholdTemperature);
|
|
355
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
|
|
356
|
+
+ ` updateCharacteristic CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
471
357
|
}
|
|
472
358
|
}
|
|
473
359
|
|
|
474
360
|
public apiError(e: any) {
|
|
475
361
|
this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
476
|
-
this.service.updateCharacteristic(
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
);
|
|
480
|
-
this.service.updateCharacteristic(
|
|
481
|
-
|
|
482
|
-
e,
|
|
483
|
-
);
|
|
484
|
-
this.service.updateCharacteristic(
|
|
485
|
-
this.platform.Characteristic.TargetHeaterCoolerState,
|
|
486
|
-
e,
|
|
487
|
-
);
|
|
488
|
-
this.service.updateCharacteristic(
|
|
489
|
-
this.platform.Characteristic.CurrentHeaterCoolerState,
|
|
490
|
-
e,
|
|
491
|
-
);
|
|
492
|
-
this.service.updateCharacteristic(
|
|
493
|
-
this.platform.Characteristic.HeatingThresholdTemperature,
|
|
494
|
-
e,
|
|
495
|
-
);
|
|
496
|
-
this.service.updateCharacteristic(
|
|
497
|
-
this.platform.Characteristic.CoolingThresholdTemperature,
|
|
498
|
-
e,
|
|
499
|
-
);
|
|
362
|
+
this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, e);
|
|
363
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
|
|
364
|
+
this.service.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, e);
|
|
365
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, e);
|
|
366
|
+
this.service.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, e);
|
|
367
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, e);
|
|
500
368
|
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
501
369
|
}
|
|
502
370
|
|
|
@@ -507,9 +375,7 @@ export class AirConditioner {
|
|
|
507
375
|
} else {
|
|
508
376
|
this.CurrentTemperatureCached = this.CurrentTemperature;
|
|
509
377
|
}
|
|
510
|
-
this.debugLog(
|
|
511
|
-
`Air Conditioner: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`,
|
|
512
|
-
);
|
|
378
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`);
|
|
513
379
|
this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
|
|
514
380
|
return this.CurrentTemperature;
|
|
515
381
|
}
|
|
@@ -522,9 +388,7 @@ export class AirConditioner {
|
|
|
522
388
|
} else {
|
|
523
389
|
this.RotationSpeed = this.CurrentFanSpeed - 1;
|
|
524
390
|
}
|
|
525
|
-
this.debugLog(
|
|
526
|
-
`Air Conditioner: ${this.accessory.displayName} Get RotationSpeed: ${this.RotationSpeed}`,
|
|
527
|
-
);
|
|
391
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get RotationSpeed: ${this.RotationSpeed}`);
|
|
528
392
|
this.RotationSpeedCached = this.RotationSpeed;
|
|
529
393
|
this.accessory.context.RotationSpeed = this.RotationSpeedCached;
|
|
530
394
|
return this.RotationSpeed;
|
|
@@ -542,53 +406,38 @@ export class AirConditioner {
|
|
|
542
406
|
this.pushAirConditionerStatusChanges();
|
|
543
407
|
}
|
|
544
408
|
|
|
545
|
-
ActiveSet(value: CharacteristicValue)
|
|
546
|
-
this.debugLog(
|
|
547
|
-
`Air Conditioner: ${this.accessory.displayName} Set Active: ${value}`,
|
|
548
|
-
);
|
|
409
|
+
ActiveSet(value: CharacteristicValue) {
|
|
410
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set Active: ${value}`);
|
|
549
411
|
|
|
550
412
|
this.Active = value;
|
|
551
413
|
this.ActiveCached = this.Active;
|
|
552
414
|
this.accessory.context.Active = this.ActiveCached;
|
|
553
415
|
|
|
554
416
|
if (value === this.platform.Characteristic.Active.INACTIVE) {
|
|
555
|
-
this.debugLog(
|
|
556
|
-
`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`,
|
|
557
|
-
);
|
|
417
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
|
|
558
418
|
this.pushAirConditionerOffChanges();
|
|
559
419
|
} else {
|
|
560
|
-
this.debugLog(
|
|
561
|
-
`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.Active}`,
|
|
562
|
-
);
|
|
420
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.Active}`);
|
|
563
421
|
this.pushAirConditionerStatusChanges();
|
|
564
422
|
}
|
|
565
423
|
}
|
|
566
424
|
|
|
567
425
|
TargetHeaterCoolerStateGet() {
|
|
568
426
|
if (this.ValidValues === [0, 1, 2]) {
|
|
569
|
-
this.TargetHeaterCoolerState =
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
`Air Conditioner: ${this.accessory.displayName} Get (AUTO) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
|
|
573
|
-
` ValidValues: ${this.ValidValues}`,
|
|
574
|
-
);
|
|
427
|
+
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
428
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (AUTO) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},`
|
|
429
|
+
+ ` ValidValues: ${this.ValidValues}`);
|
|
575
430
|
} else if (this.ValidValues === [1, 2]) {
|
|
576
|
-
this.TargetHeaterCoolerState =
|
|
577
|
-
this.platform.Characteristic.TargetHeaterCoolerState.
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
`Air Conditioner: ${this.accessory.displayName} Get (COOL/HEAT) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
|
|
581
|
-
` ValidValues: ${this.ValidValues}`,
|
|
582
|
-
);
|
|
431
|
+
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.COOL
|
|
432
|
+
|| this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
433
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (COOL/HEAT) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},`
|
|
434
|
+
+ ` ValidValues: ${this.ValidValues}`);
|
|
583
435
|
} else {
|
|
584
|
-
this.debugLog(
|
|
585
|
-
`
|
|
586
|
-
` ValidValues: ${this.ValidValues}`,
|
|
587
|
-
);
|
|
436
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},`
|
|
437
|
+
+ ` ValidValues: ${this.ValidValues}`);
|
|
588
438
|
}
|
|
589
439
|
this.TargetHeaterCoolerStateCached = this.TargetHeaterCoolerState;
|
|
590
|
-
this.accessory.context.TargetHeaterCoolerState =
|
|
591
|
-
this.TargetHeaterCoolerStateCached;
|
|
440
|
+
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerStateCached;
|
|
592
441
|
return this.TargetHeaterCoolerState;
|
|
593
442
|
}
|
|
594
443
|
|
|
@@ -596,102 +445,66 @@ export class AirConditioner {
|
|
|
596
445
|
if (this.hide_automode) {
|
|
597
446
|
if (value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT) {
|
|
598
447
|
this.TargetHeaterCoolerStateHEAT();
|
|
599
|
-
} else if (
|
|
600
|
-
value === this.platform.Characteristic.TargetHeaterCoolerState.COOL
|
|
601
|
-
) {
|
|
448
|
+
} else if (value === this.platform.Characteristic.TargetHeaterCoolerState.COOL) {
|
|
602
449
|
this.TargetHeaterCoolerStateCOOL();
|
|
603
450
|
} else {
|
|
604
|
-
this.errorLog(
|
|
605
|
-
`
|
|
606
|
-
` hide_automode: ${this.hide_automode} `,
|
|
607
|
-
);
|
|
451
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},`
|
|
452
|
+
+ ` hide_automode: ${this.hide_automode} `);
|
|
608
453
|
}
|
|
609
454
|
} else {
|
|
610
455
|
if (value === this.platform.Characteristic.TargetHeaterCoolerState.AUTO) {
|
|
611
456
|
this.TargetHeaterCoolerStateAUTO();
|
|
612
|
-
} else if (
|
|
613
|
-
value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT
|
|
614
|
-
) {
|
|
457
|
+
} else if (value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT) {
|
|
615
458
|
this.TargetHeaterCoolerStateHEAT();
|
|
616
|
-
} else if (
|
|
617
|
-
value === this.platform.Characteristic.TargetHeaterCoolerState.COOL
|
|
618
|
-
) {
|
|
459
|
+
} else if (value === this.platform.Characteristic.TargetHeaterCoolerState.COOL) {
|
|
619
460
|
this.TargetHeaterCoolerStateCOOL();
|
|
620
461
|
} else {
|
|
621
|
-
this.errorLog(
|
|
622
|
-
`
|
|
623
|
-
` hide_automode: ${this.hide_automode} `,
|
|
624
|
-
);
|
|
462
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},`
|
|
463
|
+
+ ` hide_automode: ${this.hide_automode} `);
|
|
625
464
|
}
|
|
626
465
|
}
|
|
627
466
|
this.TargetHeaterCoolerStateCached = this.TargetHeaterCoolerState;
|
|
628
|
-
this.accessory.context.TargetHeaterCoolerState =
|
|
629
|
-
this.TargetHeaterCoolerStateCached;
|
|
467
|
+
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerStateCached;
|
|
630
468
|
this.pushAirConditionerStatusChanges();
|
|
631
469
|
}
|
|
632
470
|
|
|
633
471
|
private TargetHeaterCoolerStateAUTO() {
|
|
634
|
-
this.TargetHeaterCoolerState =
|
|
635
|
-
this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
472
|
+
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
636
473
|
this.CurrentMode = 1;
|
|
637
|
-
this.debugLog(
|
|
638
|
-
|
|
639
|
-
);
|
|
640
|
-
this.debugLog(
|
|
641
|
-
`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`,
|
|
642
|
-
);
|
|
474
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set (AUTO) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
475
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
643
476
|
}
|
|
644
477
|
|
|
645
478
|
private TargetHeaterCoolerStateCOOL() {
|
|
646
|
-
this.TargetHeaterCoolerState =
|
|
647
|
-
this.platform.Characteristic.TargetHeaterCoolerState.COOL;
|
|
479
|
+
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.COOL;
|
|
648
480
|
this.CurrentMode = 2;
|
|
649
|
-
this.debugLog(
|
|
650
|
-
|
|
651
|
-
);
|
|
652
|
-
this.debugLog(
|
|
653
|
-
`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`,
|
|
654
|
-
);
|
|
481
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set (COOL) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
482
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
655
483
|
}
|
|
656
484
|
|
|
657
485
|
private TargetHeaterCoolerStateHEAT() {
|
|
658
|
-
this.TargetHeaterCoolerState =
|
|
659
|
-
this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
486
|
+
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
660
487
|
this.CurrentMode = 5;
|
|
661
|
-
this.debugLog(
|
|
662
|
-
|
|
663
|
-
);
|
|
664
|
-
this.debugLog(
|
|
665
|
-
`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`,
|
|
666
|
-
);
|
|
488
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set (HEAT) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
489
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
667
490
|
}
|
|
668
491
|
|
|
669
492
|
CurrentHeaterCoolerStateGet() {
|
|
670
493
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
671
494
|
this.CurrentTemperatureUndefined();
|
|
672
495
|
if (this.CurrentTemperature < this.CurrentTemperatureCached) {
|
|
673
|
-
this.CurrentHeaterCoolerState =
|
|
674
|
-
|
|
675
|
-
this.debugLog(
|
|
676
|
-
`Air Conditioner: ${this.accessory.displayName} Get (COOLLING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
677
|
-
);
|
|
496
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
497
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (COOLLING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
678
498
|
} else if (this.CurrentTemperature > this.CurrentTemperatureCached) {
|
|
679
|
-
this.CurrentHeaterCoolerState =
|
|
680
|
-
|
|
681
|
-
this.debugLog(
|
|
682
|
-
`Air Conditioner: ${this.accessory.displayName} Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
683
|
-
);
|
|
499
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
500
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
684
501
|
}
|
|
685
502
|
} else {
|
|
686
|
-
this.CurrentHeaterCoolerState =
|
|
687
|
-
|
|
688
|
-
this.debugLog(
|
|
689
|
-
`Air Conditioner: ${this.accessory.displayName} Get (INACTIVE) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
690
|
-
);
|
|
503
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
504
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (INACTIVE) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
691
505
|
}
|
|
692
506
|
this.CurrentHeaterCoolerStateCached = this.CurrentHeaterCoolerState;
|
|
693
|
-
this.accessory.context.CurrentHeaterCoolerState =
|
|
694
|
-
this.CurrentHeaterCoolerStateCached;
|
|
507
|
+
this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerStateCached;
|
|
695
508
|
return this.CurrentHeaterCoolerState;
|
|
696
509
|
}
|
|
697
510
|
|
|
@@ -700,11 +513,8 @@ export class AirConditioner {
|
|
|
700
513
|
this.CurrentTemperature = this.CurrentTemperatureCached;
|
|
701
514
|
this.HeatingThresholdTemperature = this.CurrentTemperatureCached;
|
|
702
515
|
this.HeatingThresholdTemperatureCached = this.HeatingThresholdTemperature;
|
|
703
|
-
this.accessory.context.HeatingThresholdTemperature =
|
|
704
|
-
|
|
705
|
-
this.debugLog(
|
|
706
|
-
`Air Conditioner: ${this.accessory.displayName} Get HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`,
|
|
707
|
-
);
|
|
516
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
|
|
517
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
708
518
|
return this.HeatingThresholdTemperature;
|
|
709
519
|
}
|
|
710
520
|
|
|
@@ -712,25 +522,20 @@ export class AirConditioner {
|
|
|
712
522
|
this.CurrentTemperatureCached = this.CurrentTemperature;
|
|
713
523
|
this.CurrentTemperature = value;
|
|
714
524
|
this.HeatingThresholdTemperatureCached = this.HeatingThresholdTemperature;
|
|
715
|
-
this.accessory.context.HeatingThresholdTemperature =
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
`Air Conditioner: ${this.accessory.displayName} Set HeatingThresholdTemperature: ${this.HeatingThresholdTemperature},` +
|
|
719
|
-
` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`,
|
|
720
|
-
);
|
|
525
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
|
|
526
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set HeatingThresholdTemperature: ${this.HeatingThresholdTemperature},`
|
|
527
|
+
+ ` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`);
|
|
721
528
|
this.pushAirConditionerStatusChanges();
|
|
722
529
|
}
|
|
723
530
|
|
|
531
|
+
|
|
724
532
|
private CoolingThresholdTemperatureGet() {
|
|
725
533
|
this.CurrentTemperatureUndefined;
|
|
726
534
|
this.CurrentTemperature = this.CurrentTemperatureCached;
|
|
727
535
|
this.CoolingThresholdTemperature = this.CurrentTemperatureCached;
|
|
728
536
|
this.CoolingThresholdTemperatureCached = this.CoolingThresholdTemperature;
|
|
729
|
-
this.accessory.context.CoolingThresholdTemperature =
|
|
730
|
-
|
|
731
|
-
this.debugLog(
|
|
732
|
-
`Air Conditioner: ${this.accessory.displayName} Get CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`,
|
|
733
|
-
);
|
|
537
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
|
|
538
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
734
539
|
return this.CoolingThresholdTemperature;
|
|
735
540
|
}
|
|
736
541
|
|
|
@@ -738,12 +543,9 @@ export class AirConditioner {
|
|
|
738
543
|
this.CurrentTemperatureCached = this.CurrentTemperature;
|
|
739
544
|
this.CurrentTemperature = value;
|
|
740
545
|
this.CoolingThresholdTemperatureCached = this.CoolingThresholdTemperature;
|
|
741
|
-
this.accessory.context.CoolingThresholdTemperature =
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
`Air Conditioner: ${this.accessory.displayName} Set CoolingThresholdTemperature: ${this.CoolingThresholdTemperature},` +
|
|
745
|
-
` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`,
|
|
746
|
-
);
|
|
546
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
|
|
547
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set CoolingThresholdTemperature: ${this.CoolingThresholdTemperature},`
|
|
548
|
+
+ ` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`);
|
|
747
549
|
this.pushAirConditionerStatusChanges();
|
|
748
550
|
}
|
|
749
551
|
|
|
@@ -762,45 +564,32 @@ export class AirConditioner {
|
|
|
762
564
|
config = device.irair;
|
|
763
565
|
}
|
|
764
566
|
if (device.logging !== undefined) {
|
|
765
|
-
config[
|
|
567
|
+
config['logging'] = device.logging;
|
|
766
568
|
}
|
|
767
569
|
if (Object.entries(config).length !== 0) {
|
|
768
|
-
this.warnLog(
|
|
769
|
-
`Air Conditioner: ${
|
|
770
|
-
this.accessory.displayName
|
|
771
|
-
} Config: ${JSON.stringify(config)}`,
|
|
772
|
-
);
|
|
570
|
+
this.warnLog(`Air Conditioner: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
773
571
|
}
|
|
774
572
|
}
|
|
775
573
|
|
|
776
574
|
logs(device: irdevice & irDevicesConfig) {
|
|
777
575
|
if (this.platform.debugMode) {
|
|
778
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
779
|
-
this.debugLog(
|
|
780
|
-
`Air Conditioner: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`,
|
|
781
|
-
);
|
|
576
|
+
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
577
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
782
578
|
} else if (device.logging) {
|
|
783
579
|
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
784
|
-
this.debugLog(
|
|
785
|
-
`Air Conditioner: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`,
|
|
786
|
-
);
|
|
580
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
787
581
|
} else if (this.platform.config.options?.logging) {
|
|
788
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
789
|
-
|
|
790
|
-
this.debugLog(
|
|
791
|
-
`Air Conditioner: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`,
|
|
792
|
-
);
|
|
582
|
+
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
583
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
793
584
|
} else {
|
|
794
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
795
|
-
this.debugLog(
|
|
796
|
-
`Air Conditioner: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`,
|
|
797
|
-
);
|
|
585
|
+
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
586
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
798
587
|
}
|
|
799
588
|
}
|
|
800
589
|
|
|
801
590
|
/**
|
|
802
|
-
|
|
803
|
-
|
|
591
|
+
* Logging for Device
|
|
592
|
+
*/
|
|
804
593
|
infoLog(...log: any[]) {
|
|
805
594
|
if (this.enablingDeviceLogging()) {
|
|
806
595
|
this.platform.log.info(String(...log));
|
|
@@ -821,8 +610,8 @@ export class AirConditioner {
|
|
|
821
610
|
|
|
822
611
|
debugLog(...log: any[]) {
|
|
823
612
|
if (this.enablingDeviceLogging()) {
|
|
824
|
-
if (this.deviceLogging ===
|
|
825
|
-
this.platform.log.info(
|
|
613
|
+
if (this.deviceLogging === 'debug') {
|
|
614
|
+
this.platform.log.info('[DEBUG]', String(...log));
|
|
826
615
|
} else {
|
|
827
616
|
this.platform.log.debug(String(...log));
|
|
828
617
|
}
|
|
@@ -830,6 +619,6 @@ export class AirConditioner {
|
|
|
830
619
|
}
|
|
831
620
|
|
|
832
621
|
enablingDeviceLogging(): boolean {
|
|
833
|
-
return this.deviceLogging
|
|
622
|
+
return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
|
|
834
623
|
}
|
|
835
624
|
}
|