@switchbot/homebridge-switchbot 2.0.0-beta.19 → 2.0.0-beta.20
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 +6 -1
- package/README.md +1 -2
- package/config.schema.json +51 -32
- package/dist/device/bot.d.ts +32 -29
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +549 -575
- package/dist/device/bot.js.map +1 -1
- package/dist/device/colorbulb.d.ts +33 -15
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +426 -341
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +16 -9
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +246 -208
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +21 -18
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +449 -449
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.d.ts +22 -20
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +346 -324
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/lock.d.ts +22 -10
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +257 -178
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +21 -14
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +287 -239
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +23 -10
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +308 -190
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +17 -10
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +225 -193
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +24 -17
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +270 -267
- package/dist/device/plug.js.map +1 -1
- package/dist/device/striplight.d.ts +36 -14
- package/dist/device/striplight.d.ts.map +1 -1
- package/dist/device/striplight.js +447 -299
- package/dist/device/striplight.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +7 -14
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +177 -169
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +3 -5
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +72 -57
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +3 -4
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +47 -33
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +3 -4
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +66 -48
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +3 -4
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +48 -47
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +3 -4
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +47 -33
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +10 -11
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +64 -48
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +7 -12
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +52 -41
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +6 -11
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +52 -42
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +0 -4
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +44 -66
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +3 -3
- package/dist/settings.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/device/bot.ts +551 -589
- package/src/device/colorbulb.ts +441 -375
- package/src/device/contact.ts +249 -213
- package/src/device/curtain.ts +452 -461
- package/src/device/humidifier.ts +358 -365
- package/src/device/lock.ts +263 -179
- package/src/device/meter.ts +302 -253
- package/src/device/meterplus.ts +319 -194
- package/src/device/motion.ts +230 -199
- package/src/device/plug.ts +273 -274
- package/src/device/striplight.ts +460 -316
- package/src/irdevice/airconditioner.ts +181 -183
- package/src/irdevice/airpurifier.ts +70 -60
- package/src/irdevice/camera.ts +46 -36
- package/src/irdevice/fan.ts +64 -49
- package/src/irdevice/light.ts +47 -51
- package/src/irdevice/other.ts +46 -36
- package/src/irdevice/tv.ts +64 -51
- package/src/irdevice/vacuumcleaner.ts +52 -45
- package/src/irdevice/waterheater.ts +50 -45
- package/src/platform.ts +44 -68
- package/src/settings.ts +3 -3
|
@@ -17,19 +17,12 @@ export class AirConditioner {
|
|
|
17
17
|
|
|
18
18
|
// Characteristic Values
|
|
19
19
|
Active!: CharacteristicValue;
|
|
20
|
-
ActiveCached!: CharacteristicValue;
|
|
21
20
|
RotationSpeed!: CharacteristicValue;
|
|
22
|
-
RotationSpeedCached!: CharacteristicValue;
|
|
23
21
|
CurrentTemperature!: CharacteristicValue;
|
|
24
|
-
CurrentTemperatureCached!: CharacteristicValue;
|
|
25
22
|
TargetHeaterCoolerState!: CharacteristicValue;
|
|
26
|
-
TargetHeaterCoolerStateCached!: CharacteristicValue;
|
|
27
23
|
CurrentHeaterCoolerState!: CharacteristicValue;
|
|
28
|
-
CurrentHeaterCoolerStateCached!: CharacteristicValue;
|
|
29
24
|
HeatingThresholdTemperature!: CharacteristicValue;
|
|
30
|
-
HeatingThresholdTemperatureCached!: CharacteristicValue;
|
|
31
25
|
CoolingThresholdTemperature!: CharacteristicValue;
|
|
32
|
-
CoolingThresholdTemperatureCached!: CharacteristicValue;
|
|
33
26
|
|
|
34
27
|
// Others
|
|
35
28
|
state!: string;
|
|
@@ -46,7 +39,6 @@ export class AirConditioner {
|
|
|
46
39
|
deviceLogging!: string;
|
|
47
40
|
hide_automode?: boolean;
|
|
48
41
|
pushOn?: boolean;
|
|
49
|
-
OpenAPI?: boolean;
|
|
50
42
|
|
|
51
43
|
private readonly valid12 = [1, 2];
|
|
52
44
|
private readonly valid012 = [0, 1, 2];
|
|
@@ -56,30 +48,17 @@ export class AirConditioner {
|
|
|
56
48
|
this.logs(device);
|
|
57
49
|
this.config(device);
|
|
58
50
|
this.pushOnChanges(device);
|
|
59
|
-
|
|
60
|
-
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
61
|
-
} else {
|
|
62
|
-
this.Active = this.accessory.context.Active;
|
|
63
|
-
}
|
|
64
|
-
if (this.CurrentTemperature === undefined) {
|
|
65
|
-
this.CurrentTemperature = 24;
|
|
66
|
-
} else {
|
|
67
|
-
this.CurrentTemperature = this.accessory.context.CurrentTemperature;
|
|
68
|
-
}
|
|
69
|
-
if (device.irair?.hide_automode) {
|
|
70
|
-
this.hide_automode = device.irair?.hide_automode;
|
|
71
|
-
this.accessory.context.hide_automode = this.hide_automode;
|
|
72
|
-
} else {
|
|
73
|
-
this.hide_automode = device.irair?.hide_automode;
|
|
74
|
-
this.accessory.context.hide_automode = this.hide_automode;
|
|
75
|
-
}
|
|
51
|
+
this.context(device);
|
|
76
52
|
|
|
77
53
|
// set accessory information
|
|
78
54
|
accessory
|
|
79
55
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
80
56
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
81
57
|
.setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
|
|
82
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
58
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
59
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision(accessory, device))
|
|
60
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
61
|
+
.updateValue(this.FirmwareRevision(accessory, device));
|
|
83
62
|
|
|
84
63
|
// get the Television service if it exists, otherwise create a new Television service
|
|
85
64
|
// you can create multiple services for each accessory
|
|
@@ -238,9 +217,9 @@ export class AirConditioner {
|
|
|
238
217
|
|
|
239
218
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
240
219
|
this.CurrentTemperatureUndefined();
|
|
241
|
-
if (this.CurrentTemperature < this.
|
|
220
|
+
if (this.CurrentTemperature < this.accessory.context.CurrentTemperature) {
|
|
242
221
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
243
|
-
} else if (this.CurrentTemperature > this.
|
|
222
|
+
} else if (this.CurrentTemperature > this.accessory.context.CurrentTemperature) {
|
|
244
223
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
245
224
|
}
|
|
246
225
|
} else {
|
|
@@ -256,7 +235,7 @@ export class AirConditioner {
|
|
|
256
235
|
}
|
|
257
236
|
|
|
258
237
|
async pushChanges(body): Promise<void> {
|
|
259
|
-
if (this.OpenAPI) {
|
|
238
|
+
if (this.device.connectionType === 'OpenAPI') {
|
|
260
239
|
try {
|
|
261
240
|
// Make Push On request to the API
|
|
262
241
|
const t = Date.now();
|
|
@@ -283,7 +262,7 @@ export class AirConditioner {
|
|
|
283
262
|
},
|
|
284
263
|
};
|
|
285
264
|
const req = https.request(options, res => {
|
|
286
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
|
|
265
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges statusCode: ${res.statusCode}`);
|
|
287
266
|
this.statusCode({ res });
|
|
288
267
|
res.on('data', d => {
|
|
289
268
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} d: ${d}`);
|
|
@@ -295,133 +274,33 @@ export class AirConditioner {
|
|
|
295
274
|
req.write(body);
|
|
296
275
|
req.end();
|
|
297
276
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges: ${superStringify(req)}`);
|
|
298
|
-
this.
|
|
299
|
-
this.
|
|
300
|
-
this.
|
|
301
|
-
this.
|
|
302
|
-
this.accessory.context.
|
|
303
|
-
this.CoolingThresholdTemperature = this.CurrentTemperatureCached;
|
|
304
|
-
this.CoolingThresholdTemperatureCached = this.CurrentTemperatureCached;
|
|
305
|
-
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
|
|
277
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
278
|
+
this.HeatingThresholdTemperature = this.CurrentTemperature;
|
|
279
|
+
this.CoolingThresholdTemperature = this.CurrentTemperature;
|
|
280
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperature;
|
|
281
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperature;
|
|
306
282
|
this.updateHomeKitCharacteristics();
|
|
307
283
|
} catch (e: any) {
|
|
308
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges`);
|
|
309
|
-
if (this.deviceLogging.includes('debug')) {
|
|
310
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges,`
|
|
311
|
-
+ ` Error Message: ${superStringify(e.message)}`);
|
|
312
|
-
}
|
|
313
284
|
this.apiError(e);
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
|
|
319
|
-
switch (res.statusCode) {
|
|
320
|
-
case 151:
|
|
321
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
322
|
-
break;
|
|
323
|
-
case 152:
|
|
324
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device not found.`);
|
|
325
|
-
break;
|
|
326
|
-
case 160:
|
|
327
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command is not supported.`);
|
|
328
|
-
break;
|
|
329
|
-
case 161:
|
|
330
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline.`);
|
|
331
|
-
break;
|
|
332
|
-
case 171:
|
|
333
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
334
|
-
break;
|
|
335
|
-
case 190:
|
|
336
|
-
this.errorLog(
|
|
337
|
-
`${this.device.remoteType}: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
|
|
338
|
-
` with server, Or command: ${superStringify(res)} format is invalid`,
|
|
285
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,`
|
|
286
|
+
+ ` Error Message: ${superStringify(e.message)}`,
|
|
339
287
|
);
|
|
340
|
-
|
|
341
|
-
case 100:
|
|
342
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent.`);
|
|
343
|
-
break;
|
|
344
|
-
default:
|
|
345
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode.`);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
async updateHomeKitCharacteristics(): Promise<void> {
|
|
350
|
-
if (this.Active === undefined) {
|
|
351
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
352
|
-
} else {
|
|
353
|
-
this.coolerService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
|
|
354
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
355
|
-
}
|
|
356
|
-
if (this.RotationSpeed === undefined) {
|
|
357
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
|
|
358
|
-
} else {
|
|
359
|
-
this.coolerService?.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed);
|
|
360
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`);
|
|
361
|
-
}
|
|
362
|
-
if (this.CurrentTemperature === undefined) {
|
|
363
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
|
|
364
|
-
} else {
|
|
365
|
-
this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
|
|
366
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
|
|
367
|
-
}
|
|
368
|
-
if (this.TargetHeaterCoolerState === undefined) {
|
|
369
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
370
|
-
} else {
|
|
371
|
-
this.coolerService?.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.TargetHeaterCoolerState);
|
|
372
|
-
this.debugLog(
|
|
373
|
-
`${this.device.remoteType}: ${this.accessory.displayName}` + ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
374
|
-
);
|
|
375
|
-
}
|
|
376
|
-
if (this.CurrentHeaterCoolerState === undefined) {
|
|
377
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
378
|
-
} else {
|
|
379
|
-
this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
|
|
380
|
-
this.debugLog(
|
|
381
|
-
`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
382
|
-
+ ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
if (this.HeatingThresholdTemperature === undefined) {
|
|
386
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
288
|
+
}
|
|
387
289
|
} else {
|
|
388
|
-
this.
|
|
389
|
-
this.
|
|
390
|
-
`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
391
|
-
+ ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`,
|
|
392
|
-
);
|
|
290
|
+
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
291
|
+
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
393
292
|
}
|
|
394
|
-
if (this.CoolingThresholdTemperature === undefined) {
|
|
395
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
396
|
-
} else {
|
|
397
|
-
this.coolerService?.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, this.CoolingThresholdTemperature);
|
|
398
|
-
this.debugLog(
|
|
399
|
-
`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
400
|
-
+ ` updateCharacteristic CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`,
|
|
401
|
-
);
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
async apiError(e: any): Promise<void> {
|
|
406
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
407
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.RotationSpeed, e);
|
|
408
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
|
|
409
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, e);
|
|
410
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, e);
|
|
411
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, e);
|
|
412
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, e);
|
|
413
|
-
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
414
293
|
}
|
|
415
294
|
|
|
416
295
|
async CurrentTemperatureGet(): Promise<CharacteristicValue> {
|
|
417
296
|
if (this.CurrentTemperature === undefined) {
|
|
418
297
|
this.CurrentTemperature = 24;
|
|
419
|
-
this.
|
|
298
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
420
299
|
} else {
|
|
421
|
-
this.
|
|
300
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
422
301
|
}
|
|
423
302
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`);
|
|
424
|
-
this.accessory.context.CurrentTemperature = this.
|
|
303
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
425
304
|
return this.CurrentTemperature;
|
|
426
305
|
}
|
|
427
306
|
|
|
@@ -434,8 +313,7 @@ export class AirConditioner {
|
|
|
434
313
|
this.RotationSpeed = this.CurrentFanSpeed - 1;
|
|
435
314
|
}
|
|
436
315
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get RotationSpeed: ${this.RotationSpeed}`);
|
|
437
|
-
this.
|
|
438
|
-
this.accessory.context.RotationSpeed = this.RotationSpeedCached;
|
|
316
|
+
this.accessory.context.RotationSpeed = this.RotationSpeed;
|
|
439
317
|
return this.RotationSpeed;
|
|
440
318
|
}
|
|
441
319
|
|
|
@@ -446,18 +324,14 @@ export class AirConditioner {
|
|
|
446
324
|
this.CurrentFanSpeed = Number(value) + 1;
|
|
447
325
|
}
|
|
448
326
|
this.RotationSpeed = this.CurrentFanSpeed;
|
|
449
|
-
this.
|
|
450
|
-
this.accessory.context.RotationSpeed = this.RotationSpeedCached;
|
|
327
|
+
this.accessory.context.RotationSpeed = this.RotationSpeed;
|
|
451
328
|
this.pushAirConditionerStatusChanges();
|
|
452
329
|
}
|
|
453
330
|
|
|
454
331
|
async ActiveSet(value: CharacteristicValue): Promise<void> {
|
|
455
332
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
|
|
456
|
-
|
|
457
333
|
this.Active = value;
|
|
458
|
-
this.
|
|
459
|
-
this.accessory.context.Active = this.ActiveCached;
|
|
460
|
-
|
|
334
|
+
this.accessory.context.Active = this.Active;
|
|
461
335
|
if (value === this.platform.Characteristic.Active.INACTIVE) {
|
|
462
336
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
|
|
463
337
|
this.pushAirConditionerOffChanges();
|
|
@@ -491,8 +365,7 @@ export class AirConditioner {
|
|
|
491
365
|
` ValidValues: ${this.ValidValues}`,
|
|
492
366
|
);
|
|
493
367
|
}
|
|
494
|
-
this.
|
|
495
|
-
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerStateCached;
|
|
368
|
+
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerState;
|
|
496
369
|
return this.TargetHeaterCoolerState;
|
|
497
370
|
}
|
|
498
371
|
|
|
@@ -522,8 +395,7 @@ export class AirConditioner {
|
|
|
522
395
|
);
|
|
523
396
|
}
|
|
524
397
|
}
|
|
525
|
-
this.
|
|
526
|
-
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerStateCached;
|
|
398
|
+
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerState;
|
|
527
399
|
this.pushAirConditionerStatusChanges();
|
|
528
400
|
}
|
|
529
401
|
|
|
@@ -551,11 +423,11 @@ export class AirConditioner {
|
|
|
551
423
|
async CurrentHeaterCoolerStateGet(): Promise<CharacteristicValue> {
|
|
552
424
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
553
425
|
this.CurrentTemperatureUndefined();
|
|
554
|
-
if (this.CurrentTemperature < this.
|
|
426
|
+
if (this.CurrentTemperature < this.accessory.context.CurrentTemperature) {
|
|
555
427
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
556
428
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
557
429
|
+` Get (COOLLING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
558
|
-
} else if (this.CurrentTemperature > this.
|
|
430
|
+
} else if (this.CurrentTemperature > this.accessory.context.CurrentTemperature) {
|
|
559
431
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
560
432
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
561
433
|
+` Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
@@ -565,51 +437,46 @@ export class AirConditioner {
|
|
|
565
437
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
566
438
|
+` Get (INACTIVE) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
567
439
|
}
|
|
568
|
-
this.
|
|
569
|
-
this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerStateCached;
|
|
440
|
+
this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerState;
|
|
570
441
|
return this.CurrentHeaterCoolerState;
|
|
571
442
|
}
|
|
572
443
|
|
|
573
444
|
async HeatingThresholdTemperatureGet(): Promise<CharacteristicValue> {
|
|
574
445
|
this.CurrentTemperatureUndefined;
|
|
575
|
-
this.CurrentTemperature = this.
|
|
576
|
-
this.HeatingThresholdTemperature = this.
|
|
577
|
-
this.
|
|
578
|
-
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
|
|
446
|
+
this.CurrentTemperature = this.accessory.context.CurrentTemperature;
|
|
447
|
+
this.HeatingThresholdTemperature = this.accessory.context.CurrentTemperature;
|
|
448
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperature;
|
|
579
449
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
580
450
|
return this.HeatingThresholdTemperature;
|
|
581
451
|
}
|
|
582
452
|
|
|
583
453
|
async HeatingThresholdTemperatureSet(value: CharacteristicValue): Promise<void> {
|
|
584
|
-
this.
|
|
454
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
585
455
|
this.CurrentTemperature = value;
|
|
586
|
-
this.
|
|
587
|
-
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
|
|
456
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperature;
|
|
588
457
|
this.debugLog(
|
|
589
458
|
`${this.device.remoteType}: ${this.accessory.displayName} Set HeatingThresholdTemperature: ${this.HeatingThresholdTemperature},` +
|
|
590
|
-
` CurrentTemperatureCached: ${this.
|
|
459
|
+
` CurrentTemperatureCached: ${this.accessory.context.CurrentTemperature}`,
|
|
591
460
|
);
|
|
592
461
|
this.pushAirConditionerStatusChanges();
|
|
593
462
|
}
|
|
594
463
|
|
|
595
464
|
async CoolingThresholdTemperatureGet(): Promise<CharacteristicValue> {
|
|
596
465
|
this.CurrentTemperatureUndefined;
|
|
597
|
-
this.CurrentTemperature = this.
|
|
598
|
-
this.CoolingThresholdTemperature = this.
|
|
599
|
-
this.
|
|
600
|
-
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
|
|
466
|
+
this.CurrentTemperature = this.accessory.context.CurrentTemperature;
|
|
467
|
+
this.CoolingThresholdTemperature = this.accessory.context.CurrentTemperature;
|
|
468
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperature;
|
|
601
469
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
602
470
|
return this.CoolingThresholdTemperature;
|
|
603
471
|
}
|
|
604
472
|
|
|
605
473
|
async CoolingThresholdTemperatureSet(value: CharacteristicValue): Promise<void> {
|
|
606
|
-
this.
|
|
474
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
607
475
|
this.CurrentTemperature = value;
|
|
608
|
-
this.
|
|
609
|
-
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
|
|
476
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperature;
|
|
610
477
|
this.debugLog(
|
|
611
478
|
`${this.device.remoteType}: ${this.accessory.displayName} Set CoolingThresholdTemperature: ${this.CoolingThresholdTemperature},` +
|
|
612
|
-
` CurrentTemperatureCached: ${this.
|
|
479
|
+
` CurrentTemperatureCached: ${this.accessory.context.CurrentTemperature}`,
|
|
613
480
|
);
|
|
614
481
|
this.pushAirConditionerStatusChanges();
|
|
615
482
|
}
|
|
@@ -618,18 +485,149 @@ export class AirConditioner {
|
|
|
618
485
|
if (this.CurrentTemperature === undefined) {
|
|
619
486
|
this.CurrentTemperature = 24;
|
|
620
487
|
}
|
|
621
|
-
if (this.
|
|
488
|
+
if (this.accessory.context.CurrentTemperature === undefined) {
|
|
622
489
|
this.CurrentTemperature = 30;
|
|
623
490
|
}
|
|
624
491
|
}
|
|
625
492
|
|
|
626
|
-
async
|
|
627
|
-
if (
|
|
628
|
-
this.
|
|
493
|
+
async updateHomeKitCharacteristics(): Promise<void> {
|
|
494
|
+
if (this.Active === undefined) {
|
|
495
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
496
|
+
} else {
|
|
497
|
+
this.accessory.context.Active = this.Active;
|
|
498
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
|
|
499
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
500
|
+
}
|
|
501
|
+
if (this.RotationSpeed === undefined) {
|
|
502
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
|
|
503
|
+
} else {
|
|
504
|
+
this.accessory.context.RotationSpeed = this.RotationSpeed;
|
|
505
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed);
|
|
506
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`);
|
|
507
|
+
}
|
|
508
|
+
if (this.CurrentTemperature === undefined) {
|
|
509
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
|
|
510
|
+
} else {
|
|
511
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
512
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
|
|
513
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
|
|
514
|
+
}
|
|
515
|
+
if (this.TargetHeaterCoolerState === undefined) {
|
|
516
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
517
|
+
} else {
|
|
518
|
+
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerState;
|
|
519
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.TargetHeaterCoolerState);
|
|
520
|
+
this.debugLog(
|
|
521
|
+
`${this.device.remoteType}: ${this.accessory.displayName}` + ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
522
|
+
);
|
|
523
|
+
}
|
|
524
|
+
if (this.CurrentHeaterCoolerState === undefined) {
|
|
525
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
526
|
+
} else {
|
|
527
|
+
this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerState;
|
|
528
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
|
|
529
|
+
this.debugLog(
|
|
530
|
+
`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
531
|
+
+ ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
532
|
+
);
|
|
533
|
+
}
|
|
534
|
+
if (this.HeatingThresholdTemperature === undefined) {
|
|
535
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
536
|
+
} else {
|
|
537
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperature;
|
|
538
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.HeatingThresholdTemperature);
|
|
539
|
+
this.debugLog(
|
|
540
|
+
`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
541
|
+
+ ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`,
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
if (this.CoolingThresholdTemperature === undefined) {
|
|
545
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
546
|
+
} else {
|
|
547
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperature;
|
|
548
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, this.CoolingThresholdTemperature);
|
|
549
|
+
this.debugLog(
|
|
550
|
+
`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
551
|
+
+ ` updateCharacteristic CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`,
|
|
552
|
+
);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
|
|
557
|
+
switch (res.statusCode) {
|
|
558
|
+
case 151:
|
|
559
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
560
|
+
break;
|
|
561
|
+
case 152:
|
|
562
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device not found.`);
|
|
563
|
+
break;
|
|
564
|
+
case 160:
|
|
565
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command is not supported.`);
|
|
566
|
+
break;
|
|
567
|
+
case 161:
|
|
568
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline.`);
|
|
569
|
+
break;
|
|
570
|
+
case 171:
|
|
571
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
572
|
+
break;
|
|
573
|
+
case 190:
|
|
574
|
+
this.errorLog(
|
|
575
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
|
|
576
|
+
` with server, Or command: ${superStringify(res)} format is invalid`,
|
|
577
|
+
);
|
|
578
|
+
break;
|
|
579
|
+
case 100:
|
|
580
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent.`);
|
|
581
|
+
break;
|
|
582
|
+
default:
|
|
583
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode.`);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
async apiError(e: any): Promise<void> {
|
|
588
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
589
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.RotationSpeed, e);
|
|
590
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
|
|
591
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, e);
|
|
592
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, e);
|
|
593
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, e);
|
|
594
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, e);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
FirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): string {
|
|
598
|
+
let FirmwareRevision: string;
|
|
599
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
600
|
+
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
601
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
602
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
603
|
+
if (accessory.context.FirmwareRevision) {
|
|
604
|
+
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
605
|
+
} else if (device.firmware) {
|
|
606
|
+
FirmwareRevision = device.firmware;
|
|
629
607
|
} else {
|
|
630
|
-
|
|
608
|
+
FirmwareRevision = this.platform.version;
|
|
609
|
+
}
|
|
610
|
+
return FirmwareRevision;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
async context(device: irdevice & irDevicesConfig) {
|
|
614
|
+
if (this.Active === undefined) {
|
|
615
|
+
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
616
|
+
} else {
|
|
617
|
+
this.Active = this.accessory.context.Active;
|
|
618
|
+
}
|
|
619
|
+
if (this.CurrentTemperature === undefined) {
|
|
620
|
+
this.CurrentTemperature = 24;
|
|
621
|
+
} else {
|
|
622
|
+
this.CurrentTemperature = this.accessory.context.CurrentTemperature;
|
|
623
|
+
}
|
|
624
|
+
if (device.irair?.hide_automode) {
|
|
625
|
+
this.hide_automode = device.irair?.hide_automode;
|
|
626
|
+
this.accessory.context.hide_automode = this.hide_automode;
|
|
627
|
+
} else {
|
|
628
|
+
this.hide_automode = device.irair?.hide_automode;
|
|
629
|
+
this.accessory.context.hide_automode = this.hide_automode;
|
|
631
630
|
}
|
|
632
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using OpenAPI: ${this.OpenAPI}`);
|
|
633
631
|
}
|
|
634
632
|
|
|
635
633
|
async config(device: irdevice & irDevicesConfig): Promise<void> {
|
|
@@ -640,8 +638,8 @@ export class AirConditioner {
|
|
|
640
638
|
if (device.logging !== undefined) {
|
|
641
639
|
config['logging'] = device.logging;
|
|
642
640
|
}
|
|
643
|
-
if (device.
|
|
644
|
-
config['
|
|
641
|
+
if (device.connectionType !== undefined) {
|
|
642
|
+
config['connectionType'] = device.connectionType;
|
|
645
643
|
}
|
|
646
644
|
if (Object.entries(config).length !== 0) {
|
|
647
645
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
|