homebridge-melcloud-control 3.8.3-beta.8 → 3.8.3
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 -0
- package/package.json +1 -1
- package/src/deviceata.js +299 -276
- package/src/deviceatw.js +120 -135
- package/src/deviceerv.js +162 -174
- package/src/melcloudata.js +0 -1
- package/src/melcloudatw.js +0 -1
- package/src/melclouderv.js +0 -1
package/src/deviceata.js
CHANGED
|
@@ -44,10 +44,6 @@ class DeviceAta extends EventEmitter {
|
|
|
44
44
|
this.mqtt = mqtt;
|
|
45
45
|
this.mqttConnected = false;
|
|
46
46
|
|
|
47
|
-
//variables
|
|
48
|
-
this.useFahrenheit = useFahrenheit ? 1 : 0;
|
|
49
|
-
this.temperatureUnit = TemperatureDisplayUnits[this.useFahrenheit];
|
|
50
|
-
|
|
51
47
|
//function
|
|
52
48
|
this.melCloud = melCloud; //function
|
|
53
49
|
|
|
@@ -61,9 +57,9 @@ class DeviceAta extends EventEmitter {
|
|
|
61
57
|
|
|
62
58
|
const presetyServiceType = ['', Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][displayType];
|
|
63
59
|
const presetCharacteristicType = ['', Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][displayType];
|
|
60
|
+
preset.name = preset.name || 'Preset'
|
|
64
61
|
preset.serviceType = presetyServiceType;
|
|
65
62
|
preset.characteristicType = presetCharacteristicType;
|
|
66
|
-
preset.name = preset.name || 'Preset'
|
|
67
63
|
preset.state = false;
|
|
68
64
|
preset.previousSettings = {};
|
|
69
65
|
this.presetsConfigured.push(preset);
|
|
@@ -80,9 +76,9 @@ class DeviceAta extends EventEmitter {
|
|
|
80
76
|
|
|
81
77
|
const buttonServiceType = ['', Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][displayType];
|
|
82
78
|
const buttonCharacteristicType = ['', Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][displayType];
|
|
79
|
+
button.name = button.name || 'Button'
|
|
83
80
|
button.serviceType = buttonServiceType;
|
|
84
81
|
button.characteristicType = buttonCharacteristicType;
|
|
85
|
-
button.name = button.name || 'Button'
|
|
86
82
|
button.state = false;
|
|
87
83
|
button.previousValue = null;
|
|
88
84
|
this.buttonsConfigured.push(button);;
|
|
@@ -93,7 +89,9 @@ class DeviceAta extends EventEmitter {
|
|
|
93
89
|
this.deviceData = {};
|
|
94
90
|
|
|
95
91
|
//accessory
|
|
96
|
-
this.
|
|
92
|
+
this.accessory = {};
|
|
93
|
+
this.accessory.useFahrenheit = useFahrenheit ? 1 : 0;
|
|
94
|
+
this.accessory.temperatureUnit = TemperatureDisplayUnits[this.accessory.useFahrenheit];
|
|
97
95
|
};
|
|
98
96
|
|
|
99
97
|
async externalIntegrations() {
|
|
@@ -261,20 +259,19 @@ class DeviceAta extends EventEmitter {
|
|
|
261
259
|
//prepare accessory
|
|
262
260
|
async prepareAccessory(accountInfo, deviceData, deviceId, deviceTypeText, deviceName, accountName) {
|
|
263
261
|
try {
|
|
264
|
-
const
|
|
265
|
-
const
|
|
266
|
-
const
|
|
267
|
-
const
|
|
268
|
-
const
|
|
269
|
-
const
|
|
270
|
-
const
|
|
271
|
-
const
|
|
272
|
-
const
|
|
273
|
-
const
|
|
274
|
-
const
|
|
275
|
-
const
|
|
276
|
-
const
|
|
277
|
-
const coolDryFanMode = [mielHvac.operationMode, 3, modelSupportsDry ? 2 : 3, 7][this.coolDryFanMode]; //NONE, COOL - 3, DRY - 2, FAN - 7
|
|
262
|
+
const presetsOnServer = this.accessory.presets;
|
|
263
|
+
const modelSupportsHeat = this.accessory.modelSupportsHeat;
|
|
264
|
+
const modelSupportsDry = this.accessory.modelSupportsDry;
|
|
265
|
+
const modelSupportsCool = this.accessory.modelSupportsCool;
|
|
266
|
+
const modelSupportsAuto = this.accessory.modelSupportsAuto;
|
|
267
|
+
const modelSupportsFanSpeed = this.accessory.modelSupportsFanSpeed;
|
|
268
|
+
const hasAutomaticFanSpeed = this.accessory.hasAutomaticFanSpeed;
|
|
269
|
+
const hasOutdoorTemperature = this.accessory.hasOutdoorTemperature;
|
|
270
|
+
const numberOfFanSpeeds = this.accessory.numberOfFanSpeeds;
|
|
271
|
+
const swingFunction = this.accessory.swingFunction;
|
|
272
|
+
const autoDryFanMode = [this.accessory.operationMode, 8, modelSupportsDry ? 2 : 8, 7][this.autoDryFanMode]; //NONE, AUTO - 8, DRY - 2, FAN - 7
|
|
273
|
+
const heatDryFanMode = [this.accessory.operationMode, 1, modelSupportsDry ? 2 : 1, 7][this.heatDryFanMode]; //NONE, HEAT - 1, DRY - 2, FAN - 7
|
|
274
|
+
const coolDryFanMode = [this.accessory.operationMode, 3, modelSupportsDry ? 2 : 3, 7][this.coolDryFanMode]; //NONE, COOL - 3, DRY - 2, FAN - 7
|
|
278
275
|
|
|
279
276
|
//accessory
|
|
280
277
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare accessory`) : false;
|
|
@@ -297,11 +294,11 @@ class DeviceAta extends EventEmitter {
|
|
|
297
294
|
switch (this.displayMode) {
|
|
298
295
|
case 1: //Heater Cooler
|
|
299
296
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare heater/cooler service`) : false;
|
|
300
|
-
|
|
301
|
-
melCloudService.setPrimaryService(true);
|
|
302
|
-
melCloudService.getCharacteristic(Characteristic.Active)
|
|
297
|
+
this.melCloudService = new Service.HeaterCooler(serviceName, `HeaterCooler ${deviceId}`);
|
|
298
|
+
this.melCloudService.setPrimaryService(true);
|
|
299
|
+
this.melCloudService.getCharacteristic(Characteristic.Active)
|
|
303
300
|
.onGet(async () => {
|
|
304
|
-
const state =
|
|
301
|
+
const state = this.accessory.power;
|
|
305
302
|
return state;
|
|
306
303
|
})
|
|
307
304
|
.onSet(async (state) => {
|
|
@@ -309,24 +306,24 @@ class DeviceAta extends EventEmitter {
|
|
|
309
306
|
deviceData.Device.Power = [false, true][state];
|
|
310
307
|
deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.Power;
|
|
311
308
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
312
|
-
const info = this.disableLogInfo ? false : this.emit('
|
|
309
|
+
const info = this.disableLogInfo ? false : this.emit('info', `Set power: ${state ? 'ON' : 'OFF'}`);
|
|
313
310
|
} catch (error) {
|
|
314
311
|
this.emit('warn', `Set power error: ${error}`);
|
|
315
312
|
};
|
|
316
313
|
});
|
|
317
|
-
melCloudService.getCharacteristic(Characteristic.CurrentHeaterCoolerState)
|
|
314
|
+
this.melCloudService.getCharacteristic(Characteristic.CurrentHeaterCoolerState)
|
|
318
315
|
.onGet(async () => {
|
|
319
|
-
const value =
|
|
316
|
+
const value = this.accessory.currentOperationMode;
|
|
320
317
|
return value;
|
|
321
318
|
});
|
|
322
|
-
melCloudService.getCharacteristic(Characteristic.TargetHeaterCoolerState)
|
|
319
|
+
this.melCloudService.getCharacteristic(Characteristic.TargetHeaterCoolerState)
|
|
323
320
|
.setProps({
|
|
324
|
-
minValue:
|
|
325
|
-
maxValue:
|
|
326
|
-
validValues:
|
|
321
|
+
minValue: this.accessory.operationModeSetPropsMinValue,
|
|
322
|
+
maxValue: this.accessory.operationModeSetPropsMaxValue,
|
|
323
|
+
validValues: this.accessory.operationModeSetPropsValidValues
|
|
327
324
|
})
|
|
328
325
|
.onGet(async () => {
|
|
329
|
-
const value =
|
|
326
|
+
const value = this.accessory.targetOperationMode; //1 = HEAT, 2 = DRY 3 = COOL, 7 = FAN, 8 = AUTO
|
|
330
327
|
return value;
|
|
331
328
|
})
|
|
332
329
|
.onSet(async (value) => {
|
|
@@ -346,25 +343,25 @@ class DeviceAta extends EventEmitter {
|
|
|
346
343
|
deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.OperationModeSetTemperature;
|
|
347
344
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
348
345
|
const operationModeText = AirConditioner.DriveMode[deviceData.Device.OperationMode];
|
|
349
|
-
const info = this.disableLogInfo ? false : this.emit('
|
|
346
|
+
const info = this.disableLogInfo ? false : this.emit('info', `Set operation mode: ${operationModeText}`);
|
|
350
347
|
} catch (error) {
|
|
351
348
|
this.emit('warn', `Set operation mode error: ${error}`);
|
|
352
349
|
};
|
|
353
350
|
});
|
|
354
|
-
melCloudService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
351
|
+
this.melCloudService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
355
352
|
.onGet(async () => {
|
|
356
|
-
const value =
|
|
353
|
+
const value = this.accessory.roomTemperature;
|
|
357
354
|
return value;
|
|
358
355
|
});
|
|
359
356
|
if (modelSupportsFanSpeed) {
|
|
360
|
-
melCloudService.getCharacteristic(Characteristic.RotationSpeed)
|
|
357
|
+
this.melCloudService.getCharacteristic(Characteristic.RotationSpeed)
|
|
361
358
|
.setProps({
|
|
362
359
|
minValue: 0,
|
|
363
|
-
maxValue:
|
|
360
|
+
maxValue: this.accessory.fanSpeedSetPropsMaxValue,
|
|
364
361
|
minStep: 1
|
|
365
362
|
})
|
|
366
363
|
.onGet(async () => {
|
|
367
|
-
const value =
|
|
364
|
+
const value = this.accessory.fanSpeed; //AUTO, 1, 2, 3, 4, 5, 6, OFF
|
|
368
365
|
return value;
|
|
369
366
|
})
|
|
370
367
|
.onSet(async (value) => {
|
|
@@ -394,17 +391,17 @@ class DeviceAta extends EventEmitter {
|
|
|
394
391
|
};
|
|
395
392
|
deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.SetFanSpeed;
|
|
396
393
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
397
|
-
const info = this.disableLogInfo ? false : this.emit('
|
|
394
|
+
const info = this.disableLogInfo ? false : this.emit('info', `Set fan speed mode: ${AirConditioner.FanSpeed[fanSpeedModeText]}`);
|
|
398
395
|
} catch (error) {
|
|
399
396
|
this.emit('warn', `Set fan speed mode error: ${error}`);
|
|
400
397
|
};
|
|
401
398
|
});
|
|
402
399
|
};
|
|
403
400
|
if (swingFunction) {
|
|
404
|
-
melCloudService.getCharacteristic(Characteristic.SwingMode)
|
|
401
|
+
this.melCloudService.getCharacteristic(Characteristic.SwingMode)
|
|
405
402
|
.onGet(async () => {
|
|
406
403
|
//Vane Horizontal: Auto, 1, 2, 3, 4, 5, 6, 12 = Swing //Vertical: Auto, 1, 2, 3, 4, 5, 7 = Swing
|
|
407
|
-
const value =
|
|
404
|
+
const value = this.accessory.swingMode;
|
|
408
405
|
return value;
|
|
409
406
|
})
|
|
410
407
|
.onSet(async (value) => {
|
|
@@ -413,20 +410,20 @@ class DeviceAta extends EventEmitter {
|
|
|
413
410
|
deviceData.Device.VaneVertical = value ? 7 : 0;
|
|
414
411
|
deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.VaneVerticalVaneHorizontal;
|
|
415
412
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
416
|
-
const info = this.disableLogInfo ? false : this.emit('
|
|
413
|
+
const info = this.disableLogInfo ? false : this.emit('info', `Set air direction mode: ${AirConditioner.AirDirection[value]}`);
|
|
417
414
|
} catch (error) {
|
|
418
415
|
this.emit('warn', `Set vane swing mode error: ${error}`);
|
|
419
416
|
};
|
|
420
417
|
});
|
|
421
418
|
};
|
|
422
|
-
melCloudService.getCharacteristic(Characteristic.CoolingThresholdTemperature)
|
|
419
|
+
this.melCloudService.getCharacteristic(Characteristic.CoolingThresholdTemperature)
|
|
423
420
|
.setProps({
|
|
424
|
-
minValue:
|
|
425
|
-
maxValue:
|
|
426
|
-
minStep:
|
|
421
|
+
minValue: this.accessory.minTempCoolDry,
|
|
422
|
+
maxValue: this.accessory.maxTempCoolDry,
|
|
423
|
+
minStep: this.accessory.temperatureIncrement
|
|
427
424
|
})
|
|
428
425
|
.onGet(async () => {
|
|
429
|
-
const value =
|
|
426
|
+
const value = this.accessory.operationMode === 8 ? this.accessory.defaultCoolingSetTemperature : this.accessory.setTemperature;
|
|
430
427
|
return value;
|
|
431
428
|
})
|
|
432
429
|
.onSet(async (value) => {
|
|
@@ -434,20 +431,20 @@ class DeviceAta extends EventEmitter {
|
|
|
434
431
|
deviceData.Device.DefaultCoolingSetTemperature = value;
|
|
435
432
|
deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.SetTemperature;
|
|
436
433
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
437
|
-
const info = this.disableLogInfo ? false : this.emit('
|
|
434
|
+
const info = this.disableLogInfo ? false : this.emit('info', `Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
438
435
|
} catch (error) {
|
|
439
436
|
this.emit('warn', `Set cooling threshold temperature error: ${error}`);
|
|
440
437
|
};
|
|
441
438
|
});
|
|
442
439
|
if (modelSupportsHeat) {
|
|
443
|
-
melCloudService.getCharacteristic(Characteristic.HeatingThresholdTemperature)
|
|
440
|
+
this.melCloudService.getCharacteristic(Characteristic.HeatingThresholdTemperature)
|
|
444
441
|
.setProps({
|
|
445
|
-
minValue:
|
|
446
|
-
maxValue:
|
|
447
|
-
minStep:
|
|
442
|
+
minValue: this.accessory.minTempHeat,
|
|
443
|
+
maxValue: this.accessory.maxTempHeat,
|
|
444
|
+
minStep: this.accessory.temperatureIncrement
|
|
448
445
|
})
|
|
449
446
|
.onGet(async () => {
|
|
450
|
-
const value =
|
|
447
|
+
const value = this.accessory.operationMode === 8 ? this.accessory.defaultHeatingSetTemperature : this.accessory.setTemperature;
|
|
451
448
|
return value;
|
|
452
449
|
})
|
|
453
450
|
.onSet(async (value) => {
|
|
@@ -455,15 +452,15 @@ class DeviceAta extends EventEmitter {
|
|
|
455
452
|
deviceData.Device.DefaultHeatingSetTemperature = value;
|
|
456
453
|
deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.SetTemperature;
|
|
457
454
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
458
|
-
const info = this.disableLogInfo ? false : this.emit('
|
|
455
|
+
const info = this.disableLogInfo ? false : this.emit('info', `Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
459
456
|
} catch (error) {
|
|
460
457
|
this.emit('warn', `Set heating threshold temperature error: ${error}`);
|
|
461
458
|
};
|
|
462
459
|
});
|
|
463
460
|
};
|
|
464
|
-
melCloudService.getCharacteristic(Characteristic.LockPhysicalControls)
|
|
461
|
+
this.melCloudService.getCharacteristic(Characteristic.LockPhysicalControls)
|
|
465
462
|
.onGet(async () => {
|
|
466
|
-
const value =
|
|
463
|
+
const value = this.accessory.lockPhysicalControl;
|
|
467
464
|
return value;
|
|
468
465
|
})
|
|
469
466
|
.onSet(async (value) => {
|
|
@@ -474,45 +471,45 @@ class DeviceAta extends EventEmitter {
|
|
|
474
471
|
deviceData.Device.ProhibitPower = value;
|
|
475
472
|
deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.Prohibit;
|
|
476
473
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
477
|
-
const info = this.disableLogInfo ? false : this.emit('
|
|
474
|
+
const info = this.disableLogInfo ? false : this.emit('info', `Set local physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
|
|
478
475
|
} catch (error) {
|
|
479
476
|
this.emit('warn', `Set lock physical controls error: ${error}`);
|
|
480
477
|
};
|
|
481
478
|
});
|
|
482
|
-
melCloudService.getCharacteristic(Characteristic.TemperatureDisplayUnits)
|
|
479
|
+
this.melCloudService.getCharacteristic(Characteristic.TemperatureDisplayUnits)
|
|
483
480
|
.onGet(async () => {
|
|
484
|
-
const value =
|
|
481
|
+
const value = this.accessory.useFahrenheit;
|
|
485
482
|
return value;
|
|
486
483
|
})
|
|
487
484
|
.onSet(async (value) => {
|
|
488
485
|
try {
|
|
489
486
|
accountInfo.UseFahrenheit = [false, true][value];
|
|
490
487
|
await this.melCloud.send(accountInfo);
|
|
491
|
-
|
|
492
|
-
const info = this.disableLogInfo ? false : this.emit('
|
|
488
|
+
this.accessory.useFahrenheit = value;
|
|
489
|
+
const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
493
490
|
} catch (error) {
|
|
494
491
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
495
492
|
};
|
|
496
493
|
});
|
|
497
|
-
this.melCloudService
|
|
494
|
+
accessory.addService(this.melCloudService);
|
|
498
495
|
break;
|
|
499
496
|
case 2: //Thermostat
|
|
500
497
|
const debug1 = this.enableDebugMode ? this.emit('debug', `Prepare thermostat service`) : false;
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
498
|
+
this.melCloudService = new Service.Thermostat(serviceName, `Thermostat ${deviceId}`);
|
|
499
|
+
this.melCloudService.setPrimaryService(true);
|
|
500
|
+
this.melCloudService.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
|
|
504
501
|
.onGet(async () => {
|
|
505
|
-
const value =
|
|
502
|
+
const value = this.accessory.currentOperationMode;
|
|
506
503
|
return value;
|
|
507
504
|
});
|
|
508
|
-
|
|
505
|
+
this.melCloudService.getCharacteristic(Characteristic.TargetHeatingCoolingState)
|
|
509
506
|
.setProps({
|
|
510
|
-
minValue:
|
|
511
|
-
maxValue:
|
|
512
|
-
validValues:
|
|
507
|
+
minValue: this.accessory.operationModeSetPropsMinValue,
|
|
508
|
+
maxValue: this.accessory.operationModeSetPropsMaxValue,
|
|
509
|
+
validValues: this.accessory.operationModeSetPropsValidValues
|
|
513
510
|
})
|
|
514
511
|
.onGet(async () => {
|
|
515
|
-
const value =
|
|
512
|
+
const value = this.accessory.targetOperationMode; //1 = HEAT, 2 = DRY 3 = COOL, 7 = FAN, 8 = AUTO
|
|
516
513
|
return value;
|
|
517
514
|
})
|
|
518
515
|
.onSet(async (value) => {
|
|
@@ -541,24 +538,24 @@ class DeviceAta extends EventEmitter {
|
|
|
541
538
|
|
|
542
539
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
543
540
|
const operationModeText = AirConditioner.DriveMode[deviceData.Device.OperationMode];
|
|
544
|
-
const info = this.disableLogInfo ? false : this.emit('
|
|
541
|
+
const info = this.disableLogInfo ? false : this.emit('info', `Set operation mode: ${operationModeText}`);
|
|
545
542
|
} catch (error) {
|
|
546
543
|
this.emit('warn', `Set operation mode error: ${error}`);
|
|
547
544
|
};
|
|
548
545
|
});
|
|
549
|
-
|
|
546
|
+
this.melCloudService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
550
547
|
.onGet(async () => {
|
|
551
|
-
const value =
|
|
548
|
+
const value = this.accessory.roomTemperature;
|
|
552
549
|
return value;
|
|
553
550
|
});
|
|
554
|
-
|
|
551
|
+
this.melCloudService.getCharacteristic(Characteristic.TargetTemperature)
|
|
555
552
|
.setProps({
|
|
556
|
-
minValue:
|
|
557
|
-
maxValue:
|
|
558
|
-
minStep:
|
|
553
|
+
minValue: this.accessory.minTempHeat,
|
|
554
|
+
maxValue: this.accessory.maxTempHeat,
|
|
555
|
+
minStep: this.accessory.temperatureIncrement
|
|
559
556
|
})
|
|
560
557
|
.onGet(async () => {
|
|
561
|
-
const value =
|
|
558
|
+
const value = this.accessory.setTemperature;
|
|
562
559
|
return value;
|
|
563
560
|
})
|
|
564
561
|
.onSet(async (value) => {
|
|
@@ -566,32 +563,32 @@ class DeviceAta extends EventEmitter {
|
|
|
566
563
|
deviceData.Device.SetTemperature = value;
|
|
567
564
|
deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.SetTemperature;
|
|
568
565
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
569
|
-
const info = this.disableLogInfo ? false : this.emit('
|
|
566
|
+
const info = this.disableLogInfo ? false : this.emit('info', `Set temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
570
567
|
} catch (error) {
|
|
571
568
|
this.emit('warn', `Set temperature error: ${error}`);
|
|
572
569
|
};
|
|
573
570
|
});
|
|
574
|
-
|
|
571
|
+
this.melCloudService.getCharacteristic(Characteristic.TemperatureDisplayUnits)
|
|
575
572
|
.onGet(async () => {
|
|
576
|
-
const value =
|
|
573
|
+
const value = this.accessory.useFahrenheit;
|
|
577
574
|
return value;
|
|
578
575
|
})
|
|
579
576
|
.onSet(async (value) => {
|
|
580
577
|
try {
|
|
581
578
|
accountInfo.UseFahrenheit = [false, true][value];
|
|
582
579
|
await this.melCloud.send(accountInfo);
|
|
583
|
-
|
|
584
|
-
const info = this.disableLogInfo ? false : this.emit('
|
|
580
|
+
this.accessory.useFahrenheit = value;
|
|
581
|
+
const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
585
582
|
} catch (error) {
|
|
586
583
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
587
584
|
};
|
|
588
585
|
});
|
|
589
|
-
this.
|
|
586
|
+
accessory.addService(this.melCloudService);
|
|
590
587
|
break;
|
|
591
588
|
};
|
|
592
589
|
|
|
593
590
|
//temperature sensor services
|
|
594
|
-
if (this.temperatureSensor &&
|
|
591
|
+
if (this.temperatureSensor && this.accessory.roomTemperature !== null) {
|
|
595
592
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare room temperature sensor service`) : false;
|
|
596
593
|
this.roomTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Room`, `Room Temperature Sensor ${deviceId}`);
|
|
597
594
|
this.roomTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
@@ -603,13 +600,13 @@ class DeviceAta extends EventEmitter {
|
|
|
603
600
|
minStep: 0.5
|
|
604
601
|
})
|
|
605
602
|
.onGet(async () => {
|
|
606
|
-
const state =
|
|
603
|
+
const state = this.accessory.roomTemperature;
|
|
607
604
|
return state;
|
|
608
605
|
})
|
|
609
606
|
accessory.addService(this.roomTemperatureSensorService);
|
|
610
607
|
};
|
|
611
608
|
|
|
612
|
-
if (this.temperatureSensorOutdoor && hasOutdoorTemperature &&
|
|
609
|
+
if (this.temperatureSensorOutdoor && hasOutdoorTemperature && this.accessory.outdoorTemperature !== null) {
|
|
613
610
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare outdoor temperature sensor service`) : false;
|
|
614
611
|
this.outdoorTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Outdoor`, `Outdoor Temperature Sensor ${deviceId}`);
|
|
615
612
|
this.outdoorTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
@@ -621,7 +618,7 @@ class DeviceAta extends EventEmitter {
|
|
|
621
618
|
minStep: 0.5
|
|
622
619
|
})
|
|
623
620
|
.onGet(async () => {
|
|
624
|
-
const state =
|
|
621
|
+
const state = this.accessory.outdoorTemperature;
|
|
625
622
|
return state;
|
|
626
623
|
})
|
|
627
624
|
accessory.addService(this.outdoorTemperatureSensorService);
|
|
@@ -676,7 +673,7 @@ class DeviceAta extends EventEmitter {
|
|
|
676
673
|
};
|
|
677
674
|
|
|
678
675
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
679
|
-
const info = this.disableLogInfo ? false : this.emit('
|
|
676
|
+
const info = this.disableLogInfo ? false : this.emit('info', `${state ? 'Set:' : 'Unset:'} ${name}`);
|
|
680
677
|
} catch (error) {
|
|
681
678
|
this.emit('warn', `Set preset error: ${error}`);
|
|
682
679
|
};
|
|
@@ -911,12 +908,12 @@ class DeviceAta extends EventEmitter {
|
|
|
911
908
|
deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.Prohibit;
|
|
912
909
|
break;
|
|
913
910
|
default:
|
|
914
|
-
this.emit('
|
|
911
|
+
this.emit('warn', `Unknown button mode: ${mode}`);
|
|
915
912
|
break;
|
|
916
913
|
};
|
|
917
914
|
|
|
918
915
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
919
|
-
const info = this.disableLogInfo ? false : this.emit('
|
|
916
|
+
const info = this.disableLogInfo ? false : this.emit('info', `${state ? `Set: ${name}` : `Unset: ${name}, Set: ${button.previousValue}`}`);
|
|
920
917
|
} catch (error) {
|
|
921
918
|
this.emit('warn', `Set button error: ${error}`);
|
|
922
919
|
};
|
|
@@ -969,125 +966,153 @@ class DeviceAta extends EventEmitter {
|
|
|
969
966
|
.on('deviceState', async (deviceData) => {
|
|
970
967
|
this.deviceData = deviceData;
|
|
971
968
|
|
|
969
|
+
//presets
|
|
970
|
+
const presetsOnServer = deviceData.Presets ?? [];
|
|
971
|
+
|
|
972
|
+
//device control
|
|
973
|
+
const hideVaneControls = deviceData.HideVaneControls ?? false;
|
|
974
|
+
const hideDryModeControl = deviceData.HideDryModeControl ?? false;
|
|
975
|
+
|
|
976
|
+
//device info
|
|
977
|
+
const hasAutomaticFanSpeed = deviceData.Device.HasAutomaticFanSpeed ?? false;
|
|
978
|
+
const airDirectionFunction = deviceData.Device.AirDirectionFunction ?? false;
|
|
979
|
+
const swingFunction = deviceData.Device.SwingFunction ?? false;
|
|
980
|
+
const hasOutdoorTemperature = deviceData.Device.HasOutdoorTemperature ?? false;
|
|
981
|
+
const numberOfFanSpeeds = deviceData.Device.NumberOfFanSpeeds ?? 0;
|
|
982
|
+
const modelSupportsFanSpeed = deviceData.Device.ModelSupportsFanSpeed ?? false;
|
|
983
|
+
const modelSupportsAuto1 = deviceData.Device.ModelSupportsAuto ?? false;
|
|
984
|
+
const modelSupportsAuto = this.autoDryFanMode >= 1 && modelSupportsAuto1
|
|
985
|
+
const modelSupportsHeat1 = deviceData.Device.ModelSupportsHeat ?? false;
|
|
986
|
+
const modelSupportsHeat = this.heatDryFanMode >= 1 && modelSupportsHeat1;
|
|
987
|
+
const modelSupportsDry = deviceData.Device.ModelSupportsDry ?? false;
|
|
988
|
+
const modelSupportsCool = this.coolDryFanMode >= 1;
|
|
989
|
+
const minTempHeat = 10;
|
|
990
|
+
const maxTempHeat = 31;
|
|
991
|
+
const minTempCoolDry = 16;
|
|
992
|
+
const maxTempCoolDry = 31;
|
|
993
|
+
|
|
994
|
+
//device state
|
|
995
|
+
const power = deviceData.Device.Power ?? false;
|
|
996
|
+
const inStandbyMode = deviceData.Device.InStandbyMode ?? false;
|
|
997
|
+
const roomTemperature = deviceData.Device.RoomTemperature;
|
|
998
|
+
const setTemperature = deviceData.Device.SetTemperature ?? 20;
|
|
999
|
+
const defaultHeatingSetTemperature = deviceData.Device.DefaultHeatingSetTemperature ?? 20;
|
|
1000
|
+
const defaultCoolingSetTemperature = deviceData.Device.DefaultCoolingSetTemperature ?? 23;
|
|
1001
|
+
const actualFanSpeed = deviceData.Device.ActualFanSpeed;
|
|
1002
|
+
const automaticFanSpeed = deviceData.Device.AutomaticFanSpeed;
|
|
1003
|
+
const fanSpeed = deviceData.Device.FanSpeed ?? 0;
|
|
1004
|
+
const operationMode = deviceData.Device.OperationMode;
|
|
1005
|
+
const vaneVerticalDirection = deviceData.Device.VaneVerticalDirection;
|
|
1006
|
+
const vaneVerticalSwing = deviceData.Device.VaneVerticalSwing;
|
|
1007
|
+
const vaneHorizontalDirection = deviceData.Device.VaneHorizontalDirection;
|
|
1008
|
+
const vaneHorizontalSwing = deviceData.Device.VaneHorizontalSwing;
|
|
1009
|
+
const prohibitSetTemperature = deviceData.Device.ProhibitSetTemperature ?? false;
|
|
1010
|
+
const prohibitOperationMode = deviceData.Device.ProhibitOperationMode ?? false;
|
|
1011
|
+
const prohibitPower = deviceData.Device.ProhibitPower ?? false;
|
|
1012
|
+
const temperatureIncrement = deviceData.Device.TemperatureIncrement ?? 1;
|
|
1013
|
+
const outdoorTemperature = deviceData.Device.OutdoorTemperature;
|
|
1014
|
+
|
|
972
1015
|
//accessory
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
vaneVerticalDirection: deviceData.Device.VaneVerticalDirection,
|
|
1005
|
-
vaneHorizontalSwing: deviceData.Device.VaneHorizontalSwing,
|
|
1006
|
-
vaneHorizontalDirection: deviceData.Device.VaneHorizontalDirection,
|
|
1007
|
-
swingMode: deviceData.Device.SwingFunction && deviceData.Device.VaneHorizontalDirection === 12 && deviceData.Device.VaneVerticalDirection === 7 ? 1 : 0,
|
|
1008
|
-
lockPhysicalControl: deviceData.Device.ProhibitSetTemperature && deviceData.Device.ProhibitOperationMode && deviceData.Device.ProhibitPower ? 1 : 0,
|
|
1009
|
-
useFahrenheit: this.useFahrenheit,
|
|
1010
|
-
temperatureUnit: this.temperatureUnit,
|
|
1011
|
-
temperatureIncrement: deviceData.Device.TemperatureIncrement ?? 1,
|
|
1012
|
-
hideVaneControls: deviceData.HideVaneControls ?? false,
|
|
1013
|
-
hideDryModeControl: deviceData.HideDryModeControl ?? false,
|
|
1014
|
-
prohibitSetTemperature: deviceData.Device.ProhibitSetTemperature ?? false,
|
|
1015
|
-
prohibitOperationMode: deviceData.Device.ProhibitOperationMode ?? false,
|
|
1016
|
-
prohibitPower: deviceData.Device.ProhibitPower ?? false,
|
|
1017
|
-
operationModeSetPropsMinValue: 0,
|
|
1018
|
-
operationModeSetPropsMaxValue: 3,
|
|
1019
|
-
operationModeSetPropsValidValues: [0, 1, 2],
|
|
1020
|
-
fanSpeedSetPropsMaxValue: 6
|
|
1021
|
-
};
|
|
1016
|
+
this.accessory.presets = presetsOnServer;
|
|
1017
|
+
this.accessory.hasAutomaticFanSpeed = hasAutomaticFanSpeed;
|
|
1018
|
+
this.accessory.airDirectionFunction = airDirectionFunction;
|
|
1019
|
+
this.accessory.swingFunction = swingFunction;
|
|
1020
|
+
this.accessory.hasOutdoorTemperature = hasOutdoorTemperature;
|
|
1021
|
+
this.accessory.numberOfFanSpeeds = numberOfFanSpeeds;
|
|
1022
|
+
this.accessory.modelSupportsFanSpeed = modelSupportsFanSpeed;
|
|
1023
|
+
this.accessory.modelSupportsAuto = modelSupportsAuto;
|
|
1024
|
+
this.accessory.modelSupportsHeat = modelSupportsHeat;
|
|
1025
|
+
this.accessory.modelSupportsDry = modelSupportsDry;
|
|
1026
|
+
this.accessory.modelSupportsCool = modelSupportsCool;
|
|
1027
|
+
this.accessory.minTempHeat = minTempHeat;
|
|
1028
|
+
this.accessory.maxTempHeat = maxTempHeat;
|
|
1029
|
+
this.accessory.minTempCoolDry = minTempCoolDry;
|
|
1030
|
+
this.accessory.maxTempCoolDry = maxTempCoolDry;
|
|
1031
|
+
|
|
1032
|
+
this.accessory.power = power ? 1 : 0;
|
|
1033
|
+
this.accessory.inStandbyMode = inStandbyMode;
|
|
1034
|
+
this.accessory.operationMode = operationMode;
|
|
1035
|
+
this.accessory.roomTemperature = roomTemperature;
|
|
1036
|
+
this.accessory.outdoorTemperature = outdoorTemperature;
|
|
1037
|
+
this.accessory.setTemperature = setTemperature;
|
|
1038
|
+
this.accessory.defaultHeatingSetTemperature = defaultHeatingSetTemperature;
|
|
1039
|
+
this.accessory.defaultCoolingSetTemperature = defaultCoolingSetTemperature;
|
|
1040
|
+
this.accessory.actualFanSpeed = actualFanSpeed;
|
|
1041
|
+
this.accessory.automaticFanSpeed = automaticFanSpeed;
|
|
1042
|
+
this.accessory.vaneVerticalSwing = vaneVerticalSwing;
|
|
1043
|
+
this.accessory.vaneHorizontalSwing = vaneHorizontalSwing;
|
|
1044
|
+
this.accessory.swingMode = swingFunction && vaneHorizontalDirection === 12 && vaneVerticalDirection === 7 ? 1 : 0;
|
|
1045
|
+
this.accessory.lockPhysicalControl = prohibitSetTemperature && prohibitOperationMode && prohibitPower ? 1 : 0;
|
|
1046
|
+
this.accessory.temperatureIncrement = temperatureIncrement;
|
|
1022
1047
|
|
|
1023
1048
|
//operating mode 0, HEAT, DRY, COOL, 4, 5, 6, FAN, AUTO, ISEE HEAT, ISEE DRY, ISEE COOL
|
|
1024
1049
|
switch (this.displayMode) {
|
|
1025
1050
|
case 1: //Heater Cooler
|
|
1026
|
-
switch (
|
|
1051
|
+
switch (operationMode) {
|
|
1027
1052
|
case 1: //HEAT
|
|
1028
|
-
|
|
1029
|
-
|
|
1053
|
+
this.accessory.currentOperationMode = roomTemperature > setTemperature ? 1 : 2; //INACTIVE, IDLE, HEATING, COOLING
|
|
1054
|
+
this.accessory.targetOperationMode = 1; //AUTO, HEAT, COOL
|
|
1030
1055
|
break;
|
|
1031
1056
|
case 2: //DRY
|
|
1032
|
-
|
|
1033
|
-
|
|
1057
|
+
this.accessory.currentOperationMode = 1;
|
|
1058
|
+
this.accessory.targetOperationMode = this.autoDryFanMode === 2 ? 0 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : this.accessory.targetOperationMode ?? 0;
|
|
1034
1059
|
break;
|
|
1035
1060
|
case 3: //COOL
|
|
1036
|
-
|
|
1037
|
-
|
|
1061
|
+
this.accessory.currentOperationMode = roomTemperature < setTemperature ? 1 : 3;
|
|
1062
|
+
this.accessory.targetOperationMode = 2;
|
|
1038
1063
|
break;
|
|
1039
1064
|
case 7: //FAN
|
|
1040
|
-
|
|
1041
|
-
|
|
1065
|
+
this.accessory.currentOperationMode = 1;
|
|
1066
|
+
this.accessory.targetOperationMode = this.autoDryFanMode === 3 ? 0 : this.heatDryFanMode === 3 ? 1 : this.coolDryFanMode === 3 ? 2 : this.accessory.targetOperationMode ?? 0;
|
|
1042
1067
|
break;
|
|
1043
1068
|
case 8: //AUTO
|
|
1044
|
-
|
|
1045
|
-
|
|
1069
|
+
this.accessory.currentOperationMode = roomTemperature > setTemperature ? 3 : roomTemperature < setTemperature ? 2 : 1;
|
|
1070
|
+
this.accessory.targetOperationMode = 0;
|
|
1046
1071
|
break;
|
|
1047
1072
|
case 9: //ISEE HEAT
|
|
1048
|
-
|
|
1049
|
-
|
|
1073
|
+
this.accessory.currentOperationMode = roomTemperature > setTemperature ? 1 : 2
|
|
1074
|
+
this.accessory.targetOperationMode = 1;
|
|
1050
1075
|
break;
|
|
1051
1076
|
case 10: //ISEE DRY
|
|
1052
|
-
|
|
1053
|
-
|
|
1077
|
+
this.accessory.currentOperationMode = 1;
|
|
1078
|
+
this.accessory.targetOperationMode = this.autoDryFanMode === 2 ? 0 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : this.accessory.targetOperationMode ?? 0;
|
|
1054
1079
|
break;
|
|
1055
1080
|
case 11: //ISEE COOL;
|
|
1056
|
-
|
|
1057
|
-
|
|
1081
|
+
this.accessory.currentOperationMode = roomTemperature < setTemperature ? 1 : 3;
|
|
1082
|
+
this.accessory.targetOperationMode = 2;
|
|
1058
1083
|
break;
|
|
1059
1084
|
default:
|
|
1060
|
-
this.emit('warn', `Unknown operating mode: ${
|
|
1085
|
+
this.emit('warn', `Unknown operating mode: ${operationMode}`);
|
|
1061
1086
|
return
|
|
1062
1087
|
};
|
|
1063
1088
|
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1089
|
+
this.accessory.currentOperationMode = !power ? 0 : inStandbyMode ? 1 : this.accessory.currentOperationMode;
|
|
1090
|
+
this.accessory.operationModeSetPropsMinValue = modelSupportsAuto && modelSupportsHeat ? 0 : !modelSupportsAuto && modelSupportsHeat ? 1 : modelSupportsAuto && !modelSupportsHeat ? 0 : 2;
|
|
1091
|
+
this.accessory.operationModeSetPropsMaxValue = 2
|
|
1092
|
+
this.accessory.operationModeSetPropsValidValues = modelSupportsAuto && modelSupportsHeat ? [0, 1, 2] : !modelSupportsAuto && modelSupportsHeat ? [1, 2] : modelSupportsAuto && !modelSupportsHeat ? [0, 2] : [2];
|
|
1068
1093
|
|
|
1069
1094
|
//fan speed mode
|
|
1070
|
-
if (
|
|
1071
|
-
switch (
|
|
1095
|
+
if (modelSupportsFanSpeed) {
|
|
1096
|
+
switch (numberOfFanSpeeds) {
|
|
1072
1097
|
case 2: //Fan speed mode 2
|
|
1073
|
-
|
|
1074
|
-
|
|
1098
|
+
this.accessory.fanSpeed = hasAutomaticFanSpeed ? [3, 1, 2][fanSpeed] : [0, 1, 2][fanSpeed];
|
|
1099
|
+
this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 3 : 2;
|
|
1075
1100
|
break;
|
|
1076
1101
|
case 3: //Fan speed mode 3
|
|
1077
|
-
|
|
1078
|
-
|
|
1102
|
+
this.accessory.fanSpeed = hasAutomaticFanSpeed ? [4, 1, 2, 3][fanSpeed] : [0, 1, 2, 3][fanSpeed];
|
|
1103
|
+
this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 4 : 3;
|
|
1079
1104
|
break;
|
|
1080
1105
|
case 4: //Fan speed mode 4
|
|
1081
|
-
|
|
1082
|
-
|
|
1106
|
+
this.accessory.fanSpeed = hasAutomaticFanSpeed ? [5, 1, 2, 3, 4][fanSpeed] : [0, 1, 2, 3, 4][fanSpeed];
|
|
1107
|
+
this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 5 : 4;
|
|
1083
1108
|
break;
|
|
1084
1109
|
case 5: //Fan speed mode 5
|
|
1085
|
-
|
|
1086
|
-
|
|
1110
|
+
this.accessory.fanSpeed = hasAutomaticFanSpeed ? [6, 1, 2, 3, 4, 5][fanSpeed] : [0, 1, 2, 3, 4, 5][fanSpeed];
|
|
1111
|
+
this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 6 : 5;
|
|
1087
1112
|
break;
|
|
1088
1113
|
case 6: //Fan speed mode 6
|
|
1089
|
-
|
|
1090
|
-
|
|
1114
|
+
this.accessory.fanSpeed = hasAutomaticFanSpeed ? [7, 1, 2, 3, 4, 5, 6][fanSpeed] : [0, 1, 2, 3, 4, 5, 6][fanSpeed];
|
|
1115
|
+
this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 7 : 6;
|
|
1091
1116
|
break;
|
|
1092
1117
|
};
|
|
1093
1118
|
};
|
|
@@ -1095,98 +1120,96 @@ class DeviceAta extends EventEmitter {
|
|
|
1095
1120
|
//update characteristics
|
|
1096
1121
|
if (this.melCloudService) {
|
|
1097
1122
|
this.melCloudService
|
|
1098
|
-
.updateCharacteristic(Characteristic.Active,
|
|
1099
|
-
.updateCharacteristic(Characteristic.CurrentHeaterCoolerState,
|
|
1100
|
-
.updateCharacteristic(Characteristic.TargetHeaterCoolerState,
|
|
1101
|
-
.updateCharacteristic(Characteristic.CurrentTemperature,
|
|
1102
|
-
.updateCharacteristic(Characteristic.LockPhysicalControls,
|
|
1103
|
-
.updateCharacteristic(Characteristic.TemperatureDisplayUnits,
|
|
1104
|
-
.updateCharacteristic(Characteristic.CoolingThresholdTemperature,
|
|
1105
|
-
const updateDefHeat =
|
|
1106
|
-
const updateRS =
|
|
1107
|
-
const updateSM =
|
|
1123
|
+
.updateCharacteristic(Characteristic.Active, power ? 1 : 0)
|
|
1124
|
+
.updateCharacteristic(Characteristic.CurrentHeaterCoolerState, this.accessory.currentOperationMode)
|
|
1125
|
+
.updateCharacteristic(Characteristic.TargetHeaterCoolerState, this.accessory.targetOperationMode)
|
|
1126
|
+
.updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
|
|
1127
|
+
.updateCharacteristic(Characteristic.LockPhysicalControls, this.accessory.lockPhysicalControl)
|
|
1128
|
+
.updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.accessory.useFahrenheit)
|
|
1129
|
+
.updateCharacteristic(Characteristic.CoolingThresholdTemperature, defaultCoolingSetTemperature);
|
|
1130
|
+
const updateDefHeat = modelSupportsHeat ? this.melCloudService.updateCharacteristic(Characteristic.HeatingThresholdTemperature, defaultHeatingSetTemperature) : false;
|
|
1131
|
+
const updateRS = modelSupportsFanSpeed ? this.melCloudService.updateCharacteristic(Characteristic.RotationSpeed, this.accessory.fanSpeed) : false;
|
|
1132
|
+
const updateSM = swingFunction ? this.melCloudService.updateCharacteristic(Characteristic.SwingMode, this.accessory.swingMode) : false;
|
|
1108
1133
|
};
|
|
1109
1134
|
break;
|
|
1110
1135
|
case 2: //Thermostat
|
|
1111
|
-
switch (
|
|
1136
|
+
switch (operationMode) {
|
|
1112
1137
|
case 1: //HEAT
|
|
1113
|
-
|
|
1114
|
-
|
|
1138
|
+
this.accessory.currentOperationMode = roomTemperature > setTemperature ? 0 : 1; //OFF, HEATING, COOLING
|
|
1139
|
+
this.accessory.targetOperationMode = 1; //OFF, HEAT, COOL, AUTO
|
|
1115
1140
|
break;
|
|
1116
1141
|
case 2: //DRY
|
|
1117
|
-
|
|
1118
|
-
|
|
1142
|
+
this.accessory.currentOperationMode = 0;
|
|
1143
|
+
this.accessory.targetOperationMode = this.autoDryFanMode === 2 ? 3 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : this.accessory.targetOperationMode ?? 0;
|
|
1119
1144
|
break;
|
|
1120
1145
|
case 3: //COOL
|
|
1121
|
-
|
|
1122
|
-
|
|
1146
|
+
this.accessory.currentOperationMode = roomTemperature < setTemperature ? 0 : 2;
|
|
1147
|
+
this.accessory.targetOperationMode = 2;
|
|
1123
1148
|
break;
|
|
1124
1149
|
case 7: //FAN
|
|
1125
|
-
|
|
1126
|
-
|
|
1150
|
+
this.accessory.currentOperationMode = 0;
|
|
1151
|
+
this.accessory.targetOperationMode = this.autoDryFanMode === 3 ? 3 : this.heatDryFanMode === 3 ? 1 : this.coolDryFanMode === 3 ? 2 : this.accessory.targetOperationMode ?? 0;
|
|
1127
1152
|
break;
|
|
1128
1153
|
case 8: //AUTO
|
|
1129
|
-
|
|
1130
|
-
|
|
1154
|
+
this.accessory.currentOperationMode = roomTemperature < setTemperature ? 1 : roomTemperature > setTemperature ? 2 : 0;
|
|
1155
|
+
this.accessory.targetOperationMode = 3;
|
|
1131
1156
|
break;
|
|
1132
1157
|
case 9: //ISEE HEAT
|
|
1133
|
-
|
|
1134
|
-
|
|
1158
|
+
this.accessory.currentOperationMode = roomTemperature > setTemperature ? 0 : 1;
|
|
1159
|
+
this.accessory.targetOperationMode = 1;
|
|
1135
1160
|
break;
|
|
1136
1161
|
case 10: //ISEE DRY
|
|
1137
|
-
|
|
1138
|
-
|
|
1162
|
+
this.accessory.currentOperationMode = 0;
|
|
1163
|
+
this.accessory.targetOperationMode = this.autoDryFanMode === 2 ? 3 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : this.accessory.targetOperationMode ?? 0;
|
|
1139
1164
|
break;
|
|
1140
1165
|
case 11: //ISEE COOL;
|
|
1141
|
-
|
|
1142
|
-
|
|
1166
|
+
this.accessory.currentOperationMode = roomTemperature < setTemperature ? 0 : 2;
|
|
1167
|
+
this.accessory.targetOperationMode = 2;
|
|
1143
1168
|
break;
|
|
1144
1169
|
default:
|
|
1145
|
-
this.emit('warn', `Unknown operating mode: ${
|
|
1170
|
+
this.emit('warn', `Unknown operating mode: ${operationMode}`);
|
|
1146
1171
|
break;
|
|
1147
1172
|
};
|
|
1148
1173
|
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1174
|
+
this.accessory.currentOperationMode = !power ? 0 : this.accessory.currentOperationMode;
|
|
1175
|
+
this.accessory.targetOperationMode = !power ? 0 : this.accessory.targetOperationMode;
|
|
1176
|
+
this.accessory.operationModeSetPropsMinValue = 0
|
|
1177
|
+
this.accessory.operationModeSetPropsMaxValue = modelSupportsAuto && modelSupportsHeat ? 3 : !modelSupportsAuto && modelSupportsHeat ? 2 : modelSupportsAuto && !modelSupportsHeat ? 3 : 2;
|
|
1178
|
+
this.accessory.operationModeSetPropsValidValues = modelSupportsAuto && modelSupportsHeat ? [0, 1, 2, 3] : !modelSupportsAuto && modelSupportsHeat ? [0, 1, 2] : modelSupportsAuto && !modelSupportsHeat ? [0, 2, 3] : [0, 2];
|
|
1154
1179
|
|
|
1155
1180
|
//update characteristics
|
|
1156
|
-
if (this.
|
|
1157
|
-
this.
|
|
1158
|
-
.updateCharacteristic(Characteristic.CurrentHeatingCoolingState,
|
|
1159
|
-
.updateCharacteristic(Characteristic.TargetHeatingCoolingState,
|
|
1160
|
-
.updateCharacteristic(Characteristic.CurrentTemperature,
|
|
1161
|
-
.updateCharacteristic(Characteristic.TargetTemperature,
|
|
1162
|
-
.updateCharacteristic(Characteristic.TemperatureDisplayUnits,
|
|
1181
|
+
if (this.melCloudService) {
|
|
1182
|
+
this.melCloudService
|
|
1183
|
+
.updateCharacteristic(Characteristic.CurrentHeatingCoolingState, this.accessory.currentOperationMode)
|
|
1184
|
+
.updateCharacteristic(Characteristic.TargetHeatingCoolingState, this.accessory.targetOperationMode)
|
|
1185
|
+
.updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
|
|
1186
|
+
.updateCharacteristic(Characteristic.TargetTemperature, setTemperature)
|
|
1187
|
+
.updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.accessory.useFahrenheit);
|
|
1163
1188
|
};
|
|
1164
1189
|
break;
|
|
1165
1190
|
};
|
|
1166
|
-
//add obj to mielHvac
|
|
1167
|
-
this.mielHvac = obj;
|
|
1168
1191
|
|
|
1169
1192
|
if (this.roomTemperatureSensorService) {
|
|
1170
1193
|
this.roomTemperatureSensorService
|
|
1171
|
-
.updateCharacteristic(Characteristic.CurrentTemperature,
|
|
1194
|
+
.updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
|
|
1172
1195
|
};
|
|
1173
1196
|
|
|
1174
1197
|
if (this.outdoorTemperatureSensorService) {
|
|
1175
1198
|
this.outdoorTemperatureSensorService
|
|
1176
|
-
.updateCharacteristic(Characteristic.CurrentTemperature,
|
|
1199
|
+
.updateCharacteristic(Characteristic.CurrentTemperature, outdoorTemperature)
|
|
1177
1200
|
};
|
|
1178
1201
|
|
|
1179
1202
|
//update presets state
|
|
1180
1203
|
if (this.presetsConfigured.length > 0) {
|
|
1181
1204
|
this.presetsConfigured.forEach((preset, i) => {
|
|
1182
|
-
const presetData =
|
|
1205
|
+
const presetData = presetsOnServer.find(p => p.ID === preset.Id);
|
|
1183
1206
|
|
|
1184
|
-
preset.state = presetData ? (presetData.Power ===
|
|
1185
|
-
&& presetData.SetTemperature ===
|
|
1186
|
-
&& presetData.OperationMode ===
|
|
1187
|
-
&& presetData.VaneHorizontal ===
|
|
1188
|
-
&& presetData.VaneVertical ===
|
|
1189
|
-
&& presetData.FanSpeed ===
|
|
1207
|
+
preset.state = presetData ? (presetData.Power === power
|
|
1208
|
+
&& presetData.SetTemperature === setTemperature
|
|
1209
|
+
&& presetData.OperationMode === operationMode
|
|
1210
|
+
&& presetData.VaneHorizontal === vaneHorizontalDirection
|
|
1211
|
+
&& presetData.VaneVertical === vaneVerticalDirection
|
|
1212
|
+
&& presetData.FanSpeed === fanSpeed) : false;
|
|
1190
1213
|
|
|
1191
1214
|
if (this.presetsServices) {
|
|
1192
1215
|
const characteristicType = preset.characteristicType;
|
|
@@ -1202,112 +1225,112 @@ class DeviceAta extends EventEmitter {
|
|
|
1202
1225
|
const mode = button.mode;
|
|
1203
1226
|
switch (mode) {
|
|
1204
1227
|
case 0: //POWER ON,OFF
|
|
1205
|
-
button.state = (
|
|
1228
|
+
button.state = (power === true);
|
|
1206
1229
|
break;
|
|
1207
1230
|
case 1: //OPERATING MODE HEAT
|
|
1208
|
-
button.state =
|
|
1231
|
+
button.state = power ? (operationMode === 1 || operationMode === 9) : false;
|
|
1209
1232
|
break;
|
|
1210
1233
|
case 2: //OPERATING MODE DRY
|
|
1211
|
-
button.state =
|
|
1234
|
+
button.state = power ? (operationMode === 2 || operationMode === 10) : false;
|
|
1212
1235
|
break
|
|
1213
1236
|
case 3: //OPERATING MODE COOL
|
|
1214
|
-
button.state =
|
|
1237
|
+
button.state = power ? (operationMode === 3 || operationMode === 11) : false;
|
|
1215
1238
|
break;
|
|
1216
1239
|
case 4: //OPERATING MODE FAN
|
|
1217
|
-
button.state =
|
|
1240
|
+
button.state = power ? (operationMode === 7) : false;
|
|
1218
1241
|
break;
|
|
1219
1242
|
case 5: //OPERATING MODE AUTO
|
|
1220
|
-
button.state =
|
|
1243
|
+
button.state = power ? (operationMode === 8) : false;
|
|
1221
1244
|
break;
|
|
1222
1245
|
case 6: //OPERATING MODE PURIFY
|
|
1223
|
-
button.state =
|
|
1246
|
+
button.state = power ? (operationMode === 12) : false;
|
|
1224
1247
|
break;
|
|
1225
1248
|
case 7: //OPERATING MODE DRY CONTROL HIDE
|
|
1226
|
-
button.state =
|
|
1249
|
+
button.state = power ? (hideDryModeControl === true) : false;
|
|
1227
1250
|
break;
|
|
1228
1251
|
case 10: //VANE H SWING MODE AUTO
|
|
1229
|
-
button.state =
|
|
1252
|
+
button.state = power ? (vaneHorizontalDirection === 0) : false;
|
|
1230
1253
|
break;
|
|
1231
1254
|
case 11: //VANE H SWING MODE 1
|
|
1232
|
-
button.state =
|
|
1255
|
+
button.state = power ? (vaneHorizontalDirection === 1) : false;
|
|
1233
1256
|
break;
|
|
1234
1257
|
case 12: //VANE H SWING MODE 2
|
|
1235
|
-
button.state =
|
|
1258
|
+
button.state = power ? (vaneHorizontalDirection === 2) : false;
|
|
1236
1259
|
break;
|
|
1237
1260
|
case 13: //VANE H SWING MODE 3
|
|
1238
|
-
button.state =
|
|
1261
|
+
button.state = power ? (vaneHorizontalDirection === 3) : false;
|
|
1239
1262
|
break;
|
|
1240
1263
|
case 14: //VANE H SWING MODE 4
|
|
1241
|
-
button.state =
|
|
1264
|
+
button.state = power ? (vaneHorizontalDirection === 4) : false;
|
|
1242
1265
|
break;
|
|
1243
1266
|
case 15: //VANE H SWING MODE 5
|
|
1244
|
-
button.state =
|
|
1267
|
+
button.state = power ? (vaneHorizontalDirection === 5) : false;
|
|
1245
1268
|
break;
|
|
1246
1269
|
case 16: //VANE H SWING MODE SPLIT
|
|
1247
|
-
button.state =
|
|
1270
|
+
button.state = power ? (vaneHorizontalDirection === 8) : false;
|
|
1248
1271
|
break;
|
|
1249
1272
|
case 17: //VANE H SWING MODE SWING
|
|
1250
|
-
button.state =
|
|
1273
|
+
button.state = power ? (vaneHorizontalDirection === 12) : false;
|
|
1251
1274
|
break;
|
|
1252
1275
|
case 20: //VANE V SWING MODE AUTO
|
|
1253
|
-
button.state =
|
|
1276
|
+
button.state = power ? (vaneVerticalDirection === 0) : false;
|
|
1254
1277
|
break;
|
|
1255
1278
|
case 21: //VANE V SWING MODE 1
|
|
1256
|
-
button.state =
|
|
1279
|
+
button.state = power ? (vaneVerticalDirection === 1) : false;
|
|
1257
1280
|
break;
|
|
1258
1281
|
case 22: //VANE V SWING MODE 2
|
|
1259
|
-
button.state =
|
|
1282
|
+
button.state = power ? (vaneVerticalDirection === 2) : false;
|
|
1260
1283
|
break;
|
|
1261
1284
|
case 23: //VANE V SWING MODE 3
|
|
1262
|
-
button.state =
|
|
1285
|
+
button.state = power ? (vaneVerticalDirection === 3) : false;
|
|
1263
1286
|
break;
|
|
1264
1287
|
case 24: //VANE V SWING MODE 4
|
|
1265
|
-
button.state =
|
|
1288
|
+
button.state = power ? (vaneVerticalDirection === 4) : false;
|
|
1266
1289
|
break;
|
|
1267
1290
|
case 25: //VANE V SWING MODE 5
|
|
1268
|
-
button.state =
|
|
1291
|
+
button.state = power ? (vaneVerticalDirection === 5) : false;
|
|
1269
1292
|
break;
|
|
1270
1293
|
case 26: //VANE V SWING MODE SWING
|
|
1271
|
-
button.state =
|
|
1294
|
+
button.state = power ? (vaneVerticalDirection === 7) : false;
|
|
1272
1295
|
break;
|
|
1273
1296
|
case 27: //VANE H/V CONTROLS HIDE
|
|
1274
|
-
button.state =
|
|
1297
|
+
button.state = power ? (hideVaneControls === true) : false;
|
|
1275
1298
|
break;
|
|
1276
1299
|
case 30: //FAN SPEED MODE AUTO
|
|
1277
|
-
button.state =
|
|
1300
|
+
button.state = power ? (fanSpeed === 0) : false;
|
|
1278
1301
|
break;
|
|
1279
1302
|
case 31: //FAN SPEED MODE 1
|
|
1280
|
-
button.state =
|
|
1303
|
+
button.state = power ? (fanSpeed === 1) : false;
|
|
1281
1304
|
break;
|
|
1282
1305
|
case 32: //FAN SPEED MODE 2
|
|
1283
|
-
button.state =
|
|
1306
|
+
button.state = power ? (fanSpeed === 2) : false;
|
|
1284
1307
|
break;
|
|
1285
1308
|
case 33: //FAN SPEED MODE 3
|
|
1286
|
-
button.state =
|
|
1309
|
+
button.state = power ? (fanSpeed === 3) : false;
|
|
1287
1310
|
break;
|
|
1288
1311
|
case 34: //FAN SPEED MODE 4
|
|
1289
|
-
button.state =
|
|
1312
|
+
button.state = power ? (fanSpeed === 4) : false;
|
|
1290
1313
|
break;
|
|
1291
1314
|
case 35: //FAN SPEED MODE 5
|
|
1292
|
-
button.state =
|
|
1315
|
+
button.state = power ? (fanSpeed === 5) : false;
|
|
1293
1316
|
break;
|
|
1294
1317
|
case 36: //FAN SPEED MODE 6
|
|
1295
|
-
button.state =
|
|
1318
|
+
button.state = power ? (fanSpeed === 6) : false;
|
|
1296
1319
|
break;
|
|
1297
1320
|
case 37: //PHYSICAL LOCK CONTROLS ALL
|
|
1298
|
-
button.state = (
|
|
1321
|
+
button.state = (this.accessory.lockPhysicalControl === 1);
|
|
1299
1322
|
break;
|
|
1300
1323
|
case 38: //PHYSICAL LOCK CONTROLS POWER
|
|
1301
|
-
button.state = (
|
|
1324
|
+
button.state = (prohibitPower === true);
|
|
1302
1325
|
break;
|
|
1303
1326
|
case 39: //PHYSICAL LOCK CONTROLS MODE
|
|
1304
|
-
button.state = (
|
|
1327
|
+
button.state = (prohibitOperationMode === true);
|
|
1305
1328
|
break;
|
|
1306
1329
|
case 40: //PHYSICAL LOCK CONTROLS TEMP
|
|
1307
|
-
button.state = (
|
|
1330
|
+
button.state = (prohibitSetTemperature === true);
|
|
1308
1331
|
break;
|
|
1309
1332
|
default: //Unknown button
|
|
1310
|
-
this.emit('
|
|
1333
|
+
this.emit('warn', `Unknown button mode: ${mode} detected`);
|
|
1311
1334
|
break;
|
|
1312
1335
|
};
|
|
1313
1336
|
|
|
@@ -1322,19 +1345,19 @@ class DeviceAta extends EventEmitter {
|
|
|
1322
1345
|
|
|
1323
1346
|
//log current state
|
|
1324
1347
|
if (!this.disableLogInfo) {
|
|
1325
|
-
this.emit('
|
|
1326
|
-
this.emit('
|
|
1327
|
-
this.emit('
|
|
1328
|
-
this.emit('
|
|
1329
|
-
this.emit('
|
|
1330
|
-
const info =
|
|
1331
|
-
const info3 =
|
|
1332
|
-
const info4 =
|
|
1333
|
-
const info5 =
|
|
1334
|
-
const info6 =
|
|
1335
|
-
const info7 =
|
|
1336
|
-
this.emit('
|
|
1337
|
-
this.emit('
|
|
1348
|
+
this.emit('info', `Power: ${power ? 'ON' : 'OFF'}`);
|
|
1349
|
+
this.emit('info', `Target operation mode: ${AirConditioner.DriveMode[operationMode]}`);
|
|
1350
|
+
this.emit('info', `Current operation mode: ${this.displayMode === 1 ? AirConditioner.CurrentOperationModeHeatherCooler[this.accessory.currentOperationMode] : AirConditioner.CurrentOperationModeThermostat[this.accessory.currentOperationMode]}`);
|
|
1351
|
+
this.emit('info', `Target temperature: ${setTemperature}${this.accessory.temperatureUnit}`);
|
|
1352
|
+
this.emit('info', `Current temperature: ${roomTemperature}${this.accessory.temperatureUnit}`);
|
|
1353
|
+
const info = hasOutdoorTemperature && outdoorTemperature !== null ? this.emit('info', `Outdoor temperature: ${outdoorTemperature}${this.accessory.temperatureUnit}`) : false;
|
|
1354
|
+
const info3 = modelSupportsFanSpeed ? this.emit('info', `Target fan speed: ${AirConditioner.FanSpeed[fanSpeed]}`) : false;
|
|
1355
|
+
const info4 = modelSupportsFanSpeed ? this.emit('info', `Current fan speed: ${AirConditioner.FanSpeed[actualFanSpeed]}`) : false;
|
|
1356
|
+
const info5 = vaneHorizontalDirection !== null ? this.emit('info', `Vane horizontal: ${AirConditioner.HorizontalVane[vaneHorizontalDirection] ?? vaneHorizontalDirection}`) : false;
|
|
1357
|
+
const info6 = vaneVerticalDirection !== null ? this.emit('info', `Vane vertical: ${AirConditioner.VerticalVane[vaneVerticalDirection] ?? vaneVerticalDirection}`) : false;
|
|
1358
|
+
const info7 = swingFunction ? this.emit('info', `Air direction: ${AirConditioner.AirDirection[this.accessory.swingMode]}`) : false;
|
|
1359
|
+
this.emit('info', `Temperature display unit: ${this.accessory.temperatureUnit}`);
|
|
1360
|
+
this.emit('info', `Lock physical controls: ${this.accessory.lockPhysicalControl ? 'LOCKED' : 'UNLOCKED'}`);
|
|
1338
1361
|
};
|
|
1339
1362
|
|
|
1340
1363
|
//prepare accessory
|