homebridge-melcloud-control 3.1.11 → 3.1.16
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/README.md +8 -8
- package/package.json +2 -2
- package/src/deviceata.js +346 -350
- package/src/deviceatw.js +342 -337
- package/src/deviceerv.js +197 -199
- package/src/melcloudata.js +70 -60
- package/src/melcloudatw.js +66 -47
- package/src/melclouderv.js +44 -36
package/src/deviceata.js
CHANGED
|
@@ -38,6 +38,7 @@ class DeviceAta extends EventEmitter {
|
|
|
38
38
|
this.refreshInterval = refreshInterval;
|
|
39
39
|
this.useFahrenheit = useFahrenheit;
|
|
40
40
|
this.startPrepareAccessory = true;
|
|
41
|
+
this.displayDeviceInfo = true;
|
|
41
42
|
|
|
42
43
|
//external integrations
|
|
43
44
|
this.restFul = account.restFul ?? {};
|
|
@@ -72,10 +73,10 @@ class DeviceAta extends EventEmitter {
|
|
|
72
73
|
this.buttonsConfigured = [];
|
|
73
74
|
for (const button of this.buttons) {
|
|
74
75
|
const buttonName = button.name ?? false;
|
|
75
|
-
const buttonMode = button.mode ??
|
|
76
|
+
const buttonMode = button.mode ?? -1;
|
|
76
77
|
const buttonDisplayType = button.displayType ?? 0;
|
|
77
78
|
const buttonNamePrefix = button.namePrefix ?? false;
|
|
78
|
-
if (buttonName && buttonMode && buttonDisplayType > 0) {
|
|
79
|
+
if (buttonName && buttonMode >= 0 && buttonDisplayType > 0) {
|
|
79
80
|
const buttonServiceType = ['', Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][buttonDisplayType];
|
|
80
81
|
const buttonCharacteristicType = ['', Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][buttonDisplayType];
|
|
81
82
|
button.namePrefix = buttonNamePrefix;
|
|
@@ -94,11 +95,6 @@ class DeviceAta extends EventEmitter {
|
|
|
94
95
|
this.accessory.currentOperationMode = 0;
|
|
95
96
|
this.accessory.targetOperationMode = 0;
|
|
96
97
|
this.accessory.fanSpeed = 0;
|
|
97
|
-
|
|
98
|
-
this.accessory.operationModeSetPropsMinValue = 0;
|
|
99
|
-
this.accessory.operationModeSetPropsMaxValue = 3;
|
|
100
|
-
this.accessory.operationModeSetPropsValidValues = [0];
|
|
101
|
-
this.accessory.fanSpeedSetPropsMaxValue = 2;
|
|
102
98
|
};
|
|
103
99
|
|
|
104
100
|
async start() {
|
|
@@ -111,7 +107,7 @@ class DeviceAta extends EventEmitter {
|
|
|
111
107
|
debugLog: this.enableDebugMode
|
|
112
108
|
});
|
|
113
109
|
|
|
114
|
-
this.melCloudAta.on('externalIntegrations', (deviceData
|
|
110
|
+
this.melCloudAta.on('externalIntegrations', (deviceData) => {
|
|
115
111
|
try {
|
|
116
112
|
//RESTFul server
|
|
117
113
|
const restFulEnabled = this.restFul.enable || false;
|
|
@@ -128,7 +124,7 @@ class DeviceAta extends EventEmitter {
|
|
|
128
124
|
})
|
|
129
125
|
.on('set', async (key, value) => {
|
|
130
126
|
try {
|
|
131
|
-
await this.setOverExternalIntegration('RESTFul',
|
|
127
|
+
await this.setOverExternalIntegration('RESTFul', deviceData, key, value);
|
|
132
128
|
} catch (error) {
|
|
133
129
|
this.emit('warn', `RESTFul set error: ${error}.`);
|
|
134
130
|
};
|
|
@@ -141,7 +137,7 @@ class DeviceAta extends EventEmitter {
|
|
|
141
137
|
});
|
|
142
138
|
}
|
|
143
139
|
const restFul0 = this.restFulConnected ? this.restFul1.update('info', deviceData) : false;
|
|
144
|
-
const restFul1 = this.restFulConnected ? this.restFul1.update('state',
|
|
140
|
+
const restFul1 = this.restFulConnected ? this.restFul1.update('state', deviceData.Device) : false;
|
|
145
141
|
}
|
|
146
142
|
|
|
147
143
|
//MQTT client
|
|
@@ -167,7 +163,7 @@ class DeviceAta extends EventEmitter {
|
|
|
167
163
|
})
|
|
168
164
|
.on('set', async (key, value) => {
|
|
169
165
|
try {
|
|
170
|
-
await this.setOverExternalIntegration('MQTT',
|
|
166
|
+
await this.setOverExternalIntegration('MQTT', deviceData, key, value);
|
|
171
167
|
} catch (error) {
|
|
172
168
|
this.emit('warn', `MQTT set error: ${error}.`);
|
|
173
169
|
};
|
|
@@ -180,7 +176,7 @@ class DeviceAta extends EventEmitter {
|
|
|
180
176
|
});
|
|
181
177
|
}
|
|
182
178
|
const mqtt0 = this.mqttConnected ? this.mqtt1.emit('publish', `Info`, deviceData) : false;
|
|
183
|
-
const mqtt1 = this.mqttConnected ? this.mqtt1.emit('publish', `State`,
|
|
179
|
+
const mqtt1 = this.mqttConnected ? this.mqtt1.emit('publish', `State`, deviceData.Device) : false;
|
|
184
180
|
}
|
|
185
181
|
|
|
186
182
|
} catch (error) {
|
|
@@ -188,6 +184,10 @@ class DeviceAta extends EventEmitter {
|
|
|
188
184
|
};
|
|
189
185
|
})
|
|
190
186
|
.on('deviceInfo', (manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
|
|
187
|
+
if (!this.displayDeviceInfo) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
191
|
if (!this.disableLogDeviceInfo) {
|
|
192
192
|
this.emit('devInfo', `---- ${this.deviceTypeText}: ${this.deviceName} ----`);
|
|
193
193
|
this.emit('devInfo', `Account: ${this.accountName}`);
|
|
@@ -204,8 +204,9 @@ class DeviceAta extends EventEmitter {
|
|
|
204
204
|
this.model = modelIndoor ? modelIndoor : modelOutdoor ? modelOutdoor : `${this.deviceTypeText} ${this.deviceId}`;
|
|
205
205
|
this.serialNumber = serialNumber;
|
|
206
206
|
this.firmwareRevision = firmwareAppVersion;
|
|
207
|
+
this.displayDeviceInfo = false;
|
|
207
208
|
})
|
|
208
|
-
.on('deviceState', async (deviceData
|
|
209
|
+
.on('deviceState', async (deviceData) => {
|
|
209
210
|
//device info
|
|
210
211
|
const displayMode = this.displayMode;
|
|
211
212
|
const hasAutomaticFanSpeed = deviceData.Device.HasAutomaticFanSpeed ?? false;
|
|
@@ -228,29 +229,29 @@ class DeviceAta extends EventEmitter {
|
|
|
228
229
|
const presetsOnServer = deviceData.Presets ?? [];
|
|
229
230
|
|
|
230
231
|
//device state
|
|
231
|
-
const power =
|
|
232
|
-
const offline =
|
|
233
|
-
const inStandbyMode =
|
|
234
|
-
const roomTemperature =
|
|
235
|
-
const setTemperature =
|
|
236
|
-
const
|
|
237
|
-
const operationMode =
|
|
238
|
-
const vaneHorizontal =
|
|
239
|
-
const vaneVertical =
|
|
240
|
-
const hideVaneControls =
|
|
241
|
-
const hideDryModeControl =
|
|
242
|
-
const prohibitSetTemperature =
|
|
243
|
-
const prohibitOperationMode =
|
|
244
|
-
const prohibitPower =
|
|
232
|
+
const power = deviceData.Device.Power ?? false;
|
|
233
|
+
const offline = deviceData.Device.Offline ?? false;
|
|
234
|
+
const inStandbyMode = deviceData.Device.InStandbyMode ?? false;
|
|
235
|
+
const roomTemperature = deviceData.Device.RoomTemperature;
|
|
236
|
+
const setTemperature = deviceData.Device.SetTemperature;
|
|
237
|
+
const fanSpeed = deviceData.Device.FanSpeed;
|
|
238
|
+
const operationMode = deviceData.Device.OperationMode;
|
|
239
|
+
const vaneHorizontal = deviceData.Device.VaneHorizontalDirection;
|
|
240
|
+
const vaneVertical = deviceData.Device.VaneVerticalDirection;
|
|
241
|
+
const hideVaneControls = deviceData.Device.HideVaneControls;
|
|
242
|
+
const hideDryModeControl = deviceData.Device.HideDryModeControl;
|
|
243
|
+
const prohibitSetTemperature = deviceData.Device.ProhibitSetTemperature ?? false;
|
|
244
|
+
const prohibitOperationMode = deviceData.Device.ProhibitOperationMode ?? false;
|
|
245
|
+
const prohibitPower = deviceData.Device.ProhibitPower ?? false;
|
|
245
246
|
|
|
246
247
|
//accessory
|
|
247
248
|
this.accessory.presetsOnServer = presetsOnServer;
|
|
248
249
|
this.accessory.power = power ? 1 : 0;
|
|
249
|
-
this.accessory.offline = offline;
|
|
250
|
+
this.accessory.offline = offline ?? false;
|
|
250
251
|
this.accessory.roomTemperature = roomTemperature;
|
|
251
252
|
this.accessory.outdoorTemperature = outdoorTemperature;
|
|
252
253
|
this.accessory.setTemperature = setTemperature;
|
|
253
|
-
this.accessory.
|
|
254
|
+
this.accessory.fanSpeed = fanSpeed;
|
|
254
255
|
this.accessory.vaneHorizontal = vaneHorizontal;
|
|
255
256
|
this.accessory.vaneVertical = vaneVertical;
|
|
256
257
|
this.accessory.swingMode = swingFunction && vaneHorizontal === 12 && vaneVertical === 7 ? 1 : 0;
|
|
@@ -327,25 +328,26 @@ class DeviceAta extends EventEmitter {
|
|
|
327
328
|
|
|
328
329
|
//fan speed mode
|
|
329
330
|
if (modelSupportsFanSpeed) {
|
|
331
|
+
this.accessory.fanSpeedSetPropsMaxValue = 2;
|
|
330
332
|
switch (numberOfFanSpeeds) {
|
|
331
333
|
case 2: //Fan speed mode 2
|
|
332
|
-
this.accessory.fanSpeed = hasAutomaticFanSpeed ? [3, 1, 2][
|
|
334
|
+
this.accessory.fanSpeed = hasAutomaticFanSpeed ? [3, 1, 2][fanSpeed] : [0, 1, 2][fanSpeed];
|
|
333
335
|
this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 3 : 2;
|
|
334
336
|
break;
|
|
335
337
|
case 3: //Fan speed mode 3
|
|
336
|
-
this.accessory.fanSpeed = hasAutomaticFanSpeed ? [4, 1, 2, 3][
|
|
338
|
+
this.accessory.fanSpeed = hasAutomaticFanSpeed ? [4, 1, 2, 3][fanSpeed] : [0, 1, 2, 3][fanSpeed];
|
|
337
339
|
this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 4 : 3;
|
|
338
340
|
break;
|
|
339
341
|
case 4: //Fan speed mode 4
|
|
340
|
-
this.accessory.fanSpeed = hasAutomaticFanSpeed ? [5, 1, 2, 3, 4][
|
|
342
|
+
this.accessory.fanSpeed = hasAutomaticFanSpeed ? [5, 1, 2, 3, 4][fanSpeed] : [0, 1, 2, 3, 4][fanSpeed];
|
|
341
343
|
this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 5 : 4;
|
|
342
344
|
break;
|
|
343
345
|
case 5: //Fan speed mode 5
|
|
344
|
-
this.accessory.fanSpeed = hasAutomaticFanSpeed ? [6, 1, 2, 3, 4, 5][
|
|
346
|
+
this.accessory.fanSpeed = hasAutomaticFanSpeed ? [6, 1, 2, 3, 4, 5][fanSpeed] : [0, 1, 2, 3, 4, 5][fanSpeed];
|
|
345
347
|
this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 6 : 5;
|
|
346
348
|
break;
|
|
347
349
|
case 6: //Fan speed mode 6
|
|
348
|
-
this.accessory.fanSpeed = hasAutomaticFanSpeed ? [7, 1, 2, 3, 4, 5, 6][
|
|
350
|
+
this.accessory.fanSpeed = hasAutomaticFanSpeed ? [7, 1, 2, 3, 4, 5, 6][fanSpeed] : [0, 1, 2, 3, 4, 5, 6][fanSpeed];
|
|
349
351
|
this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 7 : 6;
|
|
350
352
|
break;
|
|
351
353
|
};
|
|
@@ -433,6 +435,9 @@ class DeviceAta extends EventEmitter {
|
|
|
433
435
|
.updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.accessory.useFahrenheit);
|
|
434
436
|
};
|
|
435
437
|
break;
|
|
438
|
+
default:
|
|
439
|
+
this.emit('warn', `Unknown display mode: ${displayMode}`);
|
|
440
|
+
return;
|
|
436
441
|
};
|
|
437
442
|
|
|
438
443
|
if (this.roomTemperatureSensorService) {
|
|
@@ -449,15 +454,14 @@ class DeviceAta extends EventEmitter {
|
|
|
449
454
|
if (this.presetsConfigured.length > 0) {
|
|
450
455
|
for (let i = 0; i < this.presetsConfigured.length; i++) {
|
|
451
456
|
const preset = this.presetsConfigured[i];
|
|
452
|
-
const
|
|
453
|
-
const presetData = presetsOnServer[index];
|
|
457
|
+
const presetData = presetsOnServer.find(p => p.ID === preset.Id);
|
|
454
458
|
|
|
455
459
|
preset.state = presetData ? (presetData.Power === power
|
|
456
460
|
&& presetData.SetTemperature === setTemperature
|
|
457
461
|
&& presetData.OperationMode === operationMode
|
|
458
462
|
&& presetData.VaneHorizontal === vaneHorizontal
|
|
459
463
|
&& presetData.VaneVertical === vaneVertical
|
|
460
|
-
&& presetData.FanSpeed ===
|
|
464
|
+
&& presetData.FanSpeed === fanSpeed) : false;
|
|
461
465
|
|
|
462
466
|
if (this.presetsServices) {
|
|
463
467
|
const characteristicType = preset.characteristicType;
|
|
@@ -546,25 +550,25 @@ class DeviceAta extends EventEmitter {
|
|
|
546
550
|
button.state = power ? (hideVaneControls === true) : false;
|
|
547
551
|
break;
|
|
548
552
|
case 30: //FAN SPEED MODE AUTO
|
|
549
|
-
button.state = power ? (
|
|
553
|
+
button.state = power ? (fanSpeed === 0) : false;
|
|
550
554
|
break;
|
|
551
555
|
case 31: //FAN SPEED MODE 1
|
|
552
|
-
button.state = power ? (
|
|
556
|
+
button.state = power ? (fanSpeed === 1) : false;
|
|
553
557
|
break;
|
|
554
558
|
case 32: //FAN SPEED MODE 2
|
|
555
|
-
button.state = power ? (
|
|
559
|
+
button.state = power ? (fanSpeed === 2) : false;
|
|
556
560
|
break;
|
|
557
561
|
case 33: //FAN SPEED MODE 3
|
|
558
|
-
button.state = power ? (
|
|
562
|
+
button.state = power ? (fanSpeed === 3) : false;
|
|
559
563
|
break;
|
|
560
564
|
case 34: //FAN SPEED MODE 4
|
|
561
|
-
button.state = power ? (
|
|
565
|
+
button.state = power ? (fanSpeed === 4) : false;
|
|
562
566
|
break;
|
|
563
567
|
case 35: //FAN SPEED MODE 5
|
|
564
|
-
button.state = power ? (
|
|
568
|
+
button.state = power ? (fanSpeed === 5) : false;
|
|
565
569
|
break;
|
|
566
570
|
case 36: //FAN SPEED MODE 6
|
|
567
|
-
button.state = power ? (
|
|
571
|
+
button.state = power ? (fanSpeed === 6) : false;
|
|
568
572
|
break;
|
|
569
573
|
case 37: //PHYSICAL LOCK CONTROLS ALL
|
|
570
574
|
button.state = (this.accessory.lockPhysicalControl === 1);
|
|
@@ -602,7 +606,7 @@ class DeviceAta extends EventEmitter {
|
|
|
602
606
|
const info0 = hasOutdoorTemperature && this.accessory.outdoorTemperature !== null ? this.emit('message', `Outdoor temperature: ${roomTemperature}${temperatureUnit}`) : false;
|
|
603
607
|
const info1 = displayMode === 0 ? this.emit('message', `Heating threshold temperature: ${setTemperature}${temperatureUnit}`) : false;
|
|
604
608
|
const info2 = displayMode === 0 ? this.emit('message', `Cooling threshold temperature: ${setTemperature}${temperatureUnit}`) : false;
|
|
605
|
-
const info3 = modelSupportsFanSpeed ? this.emit('message', `Fan speed mode: ${CONSTANTS.AirConditioner.FanSpeed[
|
|
609
|
+
const info3 = modelSupportsFanSpeed ? this.emit('message', `Fan speed mode: ${CONSTANTS.AirConditioner.FanSpeed[fanSpeed]}`) : false;
|
|
606
610
|
const info4 = swingFunction ? this.emit('message', `Vane swing mode: ${CONSTANTS.AirConditioner.AirDirection[this.accessory.swingMode ? 6 : 0]}`) : false;
|
|
607
611
|
this.emit('message', `Temperature display unit: ${temperatureUnit}`);
|
|
608
612
|
this.emit('message', `Lock physical controls: ${this.accessory.lockPhysicalControl ? 'LOCKED' : 'UNLOCKED'}`);
|
|
@@ -614,7 +618,7 @@ class DeviceAta extends EventEmitter {
|
|
|
614
618
|
}
|
|
615
619
|
|
|
616
620
|
try {
|
|
617
|
-
const accessory = await this.prepareAccessory(this.accountInfo,
|
|
621
|
+
const accessory = await this.prepareAccessory(this.accountInfo, deviceData, this.deviceId, this.deviceTypeText, this.deviceName, this.accountName);
|
|
618
622
|
this.emit('publishAccessory', accessory);
|
|
619
623
|
this.startPrepareAccessory = false;
|
|
620
624
|
} catch (error) {
|
|
@@ -632,16 +636,13 @@ class DeviceAta extends EventEmitter {
|
|
|
632
636
|
})
|
|
633
637
|
.on('error', async (error) => {
|
|
634
638
|
this.emit('error', error);
|
|
635
|
-
this.melCloudAta.impulseGenerator.stop();
|
|
636
|
-
await new Promise(resolve => setTimeout(resolve, 15000));
|
|
637
|
-
this.melCloudAta.impulseGenerator.start([{ name: 'checkState', sampling: this.refreshInterval }]);
|
|
638
639
|
});
|
|
639
640
|
|
|
640
641
|
//check state
|
|
641
642
|
await this.melCloudAta.checkState();
|
|
642
643
|
|
|
643
644
|
//start impule generator
|
|
644
|
-
this.melCloudAta.impulseGenerator.start([{ name: 'checkState', sampling: this.refreshInterval }]);
|
|
645
|
+
await this.melCloudAta.impulseGenerator.start([{ name: 'checkState', sampling: this.refreshInterval }]);
|
|
645
646
|
|
|
646
647
|
return true;
|
|
647
648
|
} catch (error) {
|
|
@@ -649,74 +650,74 @@ class DeviceAta extends EventEmitter {
|
|
|
649
650
|
};
|
|
650
651
|
};
|
|
651
652
|
|
|
652
|
-
async setOverExternalIntegration(integration,
|
|
653
|
+
async setOverExternalIntegration(integration, deviceData, key, value) {
|
|
653
654
|
try {
|
|
654
655
|
let set = false
|
|
655
656
|
switch (key) {
|
|
656
657
|
case 'Power':
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
set = await this.melCloudAta.send(
|
|
658
|
+
deviceData.Device[key] = value;
|
|
659
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power;
|
|
660
|
+
set = await this.melCloudAta.send(deviceData);
|
|
660
661
|
break;
|
|
661
662
|
case 'OperationMode':
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
set = await this.melCloudAta.send(
|
|
663
|
+
deviceData.Device[key] = value;
|
|
664
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.OperationMode;
|
|
665
|
+
set = await this.melCloudAta.send(deviceData);
|
|
665
666
|
break;
|
|
666
667
|
case 'SetTemperature':
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
set = await this.melCloudAta.send(
|
|
668
|
+
deviceData.Device[key] = value;
|
|
669
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.SetTemperature;
|
|
670
|
+
set = await this.melCloudAta.send(deviceData);
|
|
670
671
|
break;
|
|
671
672
|
case 'DefaultCoolingSetTemperature':
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
set = await this.melCloudAta.send(
|
|
673
|
+
deviceData.Device[key] = value;
|
|
674
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.SetTemperature;
|
|
675
|
+
set = await this.melCloudAta.send(deviceData);
|
|
675
676
|
break;
|
|
676
677
|
case 'DefaultHeatingSetTemperature':
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
set = await this.melCloudAta.send(
|
|
678
|
+
deviceData.Device[key] = value;
|
|
679
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.SetTemperature;
|
|
680
|
+
set = await this.melCloudAta.send(deviceData);
|
|
680
681
|
break;
|
|
681
682
|
case 'SetFanSpeed':
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
set = await this.melCloudAta.send(
|
|
683
|
+
deviceData.Device[key] = value;
|
|
684
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.SetFanSpeed;
|
|
685
|
+
set = await this.melCloudAta.send(deviceData);
|
|
685
686
|
break;
|
|
686
|
-
case '
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
set = await this.melCloudAta.send(
|
|
687
|
+
case 'VaneHorizontalDirection':
|
|
688
|
+
deviceData.Device[key] = value;
|
|
689
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.VaneHorizontal;
|
|
690
|
+
set = await this.melCloudAta.send(deviceData);
|
|
690
691
|
break;
|
|
691
|
-
case '
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
set = await this.melCloudAta.send(
|
|
692
|
+
case 'VaneVerticalDirection':
|
|
693
|
+
deviceData.Device[key] = value;
|
|
694
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.VaneVertical;
|
|
695
|
+
set = await this.melCloudAta.send(deviceData);
|
|
695
696
|
break;
|
|
696
697
|
case 'HideVaneControls':
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
set = await this.melCloudAta.send(
|
|
698
|
+
deviceData.Device[key] = value;
|
|
699
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Prohibit;
|
|
700
|
+
set = await this.melCloudAta.send(deviceData);
|
|
700
701
|
break;
|
|
701
702
|
case 'HideDryModeControl':
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
await this.melCloudAta.send(
|
|
703
|
+
deviceData.Device[key] = value;
|
|
704
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Prohibit;
|
|
705
|
+
await this.melCloudAta.send(deviceData);
|
|
705
706
|
break;
|
|
706
707
|
case 'ProhibitSetTemperature':
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
set = await this.melCloudAta.send(
|
|
708
|
+
deviceData.Device[key] = value;
|
|
709
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Prohibit;
|
|
710
|
+
set = await this.melCloudAta.send(deviceData);
|
|
710
711
|
break;
|
|
711
712
|
case 'ProhibitOperationMode':
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
await this.melCloudAta.send(
|
|
713
|
+
deviceData.Device[key] = value;
|
|
714
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Prohibit;
|
|
715
|
+
await this.melCloudAta.send(deviceData);
|
|
715
716
|
break;
|
|
716
717
|
case 'ProhibitPower':
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
set = await this.melCloudAta.send(
|
|
718
|
+
deviceData.Device[key] = value;
|
|
719
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Prohibit;
|
|
720
|
+
set = await this.melCloudAta.send(deviceData);
|
|
720
721
|
break;
|
|
721
722
|
default:
|
|
722
723
|
this.emit('warn', `${integration}, received key: ${key}, value: ${value}`);
|
|
@@ -729,7 +730,7 @@ class DeviceAta extends EventEmitter {
|
|
|
729
730
|
}
|
|
730
731
|
|
|
731
732
|
//prepare accessory
|
|
732
|
-
async prepareAccessory(accountInfo,
|
|
733
|
+
async prepareAccessory(accountInfo, deviceData, deviceId, deviceTypeText, deviceName, accountName) {
|
|
733
734
|
try {
|
|
734
735
|
//accessory
|
|
735
736
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare accessory`) : false;
|
|
@@ -747,23 +748,19 @@ class DeviceAta extends EventEmitter {
|
|
|
747
748
|
.setCharacteristic(Characteristic.FirmwareRevision, this.firmwareRevision);
|
|
748
749
|
|
|
749
750
|
//melcloud services
|
|
750
|
-
const presetsOnServer = this.accessory.presetsOnServer;
|
|
751
751
|
const displayMode = this.displayMode;
|
|
752
752
|
const temperatureSensor = this.temperatureSensor;
|
|
753
753
|
const temperatureSensorOutdoor = this.temperatureSensorOutdoor;
|
|
754
|
-
const presetsConfigured = this.presetsConfigured;
|
|
755
|
-
const presetsConfiguredCount = this.presetsConfiguredCount;
|
|
756
|
-
const buttonsConfigured = this.buttonsConfigured;
|
|
757
|
-
const buttonsConfiguredCount = this.buttonsConfiguredCount;
|
|
758
754
|
const hasAutomaticFanSpeed = this.accessory.hasAutomaticFanSpeed;
|
|
759
755
|
const modelSupportsFanSpeed = this.accessory.modelSupportsFanSpeed;
|
|
760
756
|
const modelSupportsDry = this.accessory.modelSupportsDry;
|
|
761
757
|
const numberOfFanSpeeds = this.accessory.numberOfFanSpeeds;
|
|
762
758
|
const swingFunction = this.accessory.swingFunction;
|
|
763
759
|
const hasOutdoorTemperature = this.accessory.hasOutdoorTemperature;
|
|
764
|
-
const
|
|
765
|
-
const
|
|
766
|
-
const
|
|
760
|
+
const presetsOnServer = this.accessory.presetsOnServer;
|
|
761
|
+
const autoDryFanMode = [deviceData.Device.OperationMode, 8, modelSupportsDry ? 2 : 8, 7][this.autoDryFanMode]; //NONE, AUTO - 8, DRY - 2, FAN - 7
|
|
762
|
+
const heatDryFanMode = [deviceData.Device.OperationMode, 1, modelSupportsDry ? 2 : 1, 7][this.heatDryFanMode]; //NONE, HEAT - 1, DRY - 2, FAN - 7
|
|
763
|
+
const coolDryFanMode = [deviceData.Device.OperationMode, 3, modelSupportsDry ? 2 : 3, 7][this.coolDryFanMode]; //NONE, COOL - 3, DRY - 2, FAN - 7
|
|
767
764
|
const serviceName = `${deviceTypeText} ${accessoryName}`;
|
|
768
765
|
|
|
769
766
|
switch (displayMode) {
|
|
@@ -777,9 +774,9 @@ class DeviceAta extends EventEmitter {
|
|
|
777
774
|
})
|
|
778
775
|
.onSet(async (state) => {
|
|
779
776
|
try {
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
await this.melCloudAta.send(
|
|
777
|
+
deviceData.Device.Power = [false, true][state];
|
|
778
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power;
|
|
779
|
+
await this.melCloudAta.send(deviceData);
|
|
783
780
|
const info = this.disableLogInfo ? false : this.emit('message', `Set power: ${state ? 'ON' : 'OFF'}`);
|
|
784
781
|
} catch (error) {
|
|
785
782
|
this.emit('warn', `Set power error: ${error}`);
|
|
@@ -804,21 +801,21 @@ class DeviceAta extends EventEmitter {
|
|
|
804
801
|
try {
|
|
805
802
|
switch (value) {
|
|
806
803
|
case 0: //AUTO - AUTO
|
|
807
|
-
|
|
808
|
-
|
|
804
|
+
deviceData.Device.OperationMode = autoDryFanMode;
|
|
805
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.OperationMode;
|
|
809
806
|
break;
|
|
810
807
|
case 1: //HEAT - HEAT
|
|
811
|
-
|
|
812
|
-
|
|
808
|
+
deviceData.Device.OperationMode = heatDryFanMode;
|
|
809
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.OperationMode;
|
|
813
810
|
break;
|
|
814
811
|
case 2: //COOL - COOL
|
|
815
|
-
|
|
816
|
-
|
|
812
|
+
deviceData.Device.OperationMode = coolDryFanMode;
|
|
813
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.OperationMode;
|
|
817
814
|
break;
|
|
818
815
|
};
|
|
819
816
|
|
|
820
|
-
await this.melCloudAta.send(
|
|
821
|
-
const operationModeText = CONSTANTS.AirConditioner.DriveMode[
|
|
817
|
+
await this.melCloudAta.send(deviceData);
|
|
818
|
+
const operationModeText = CONSTANTS.AirConditioner.DriveMode[deviceData.Device.OperationMode];
|
|
822
819
|
const info = this.disableLogInfo ? false : this.emit('message', `Set operation mode: ${operationModeText}`);
|
|
823
820
|
} catch (error) {
|
|
824
821
|
this.emit('warn', `Set operation mode error: ${error}`);
|
|
@@ -840,29 +837,29 @@ class DeviceAta extends EventEmitter {
|
|
|
840
837
|
let fanSpeedModeText = 0; //AUTO, 1, 2, 3, 4, 5, 6, OFF
|
|
841
838
|
switch (numberOfFanSpeeds) {
|
|
842
839
|
case 2: //Fan speed mode 2
|
|
843
|
-
|
|
840
|
+
deviceData.Device.FanSpeed = hasAutomaticFanSpeed ? [0, 1, 2, 0][value] : [1, 1, 2][value];
|
|
844
841
|
fanSpeedModeText = hasAutomaticFanSpeed ? [7, 1, 2, 0][value] : [7, 1, 2][value];
|
|
845
842
|
break;
|
|
846
843
|
case 3: //Fan speed mode 3
|
|
847
|
-
|
|
844
|
+
deviceData.Device.FanSpeed = hasAutomaticFanSpeed ? [0, 1, 2, 3, 0][value] : [1, 1, 2, 3][value];
|
|
848
845
|
fanSpeedModeText = hasAutomaticFanSpeed ? [7, 1, 2, 3, 0][value] : [7, 1, 2, 3][value];
|
|
849
846
|
break;
|
|
850
847
|
case 4: //Fan speed mode 4
|
|
851
|
-
|
|
848
|
+
deviceData.Device.FanSpeed = hasAutomaticFanSpeed ? [0, 1, 2, 3, 4, 0][value] : [1, 1, 2, 3, 4][value];
|
|
852
849
|
fanSpeedModeText = hasAutomaticFanSpeed ? [7, 1, 2, 3, 4, 0][value] : [7, 1, 2, 3, 4][value];
|
|
853
850
|
break;
|
|
854
851
|
case 5: //Fan speed mode 5
|
|
855
|
-
|
|
852
|
+
deviceData.Device.FanSpeed = hasAutomaticFanSpeed ? [0, 1, 2, 3, 4, 5, 0][value] : [1, 1, 2, 3, 4, 5][value];
|
|
856
853
|
fanSpeedModeText = hasAutomaticFanSpeed ? [7, 1, 2, 3, 4, 5, 0][value] : [7, 1, 2, 3, 4, 5][value];
|
|
857
854
|
break;
|
|
858
855
|
case 6: //Fan speed mode 6
|
|
859
|
-
|
|
856
|
+
deviceData.Device.FanSpeed = hasAutomaticFanSpeed ? [0, 1, 2, 3, 4, 5, 6, 0][value] : [1, 1, 2, 3, 4, 5, 6][value];
|
|
860
857
|
fanSpeedModeText = hasAutomaticFanSpeed ? [7, 1, 2, 3, 4, 5, 6, 0][value] : [7, 1, 2, 3, 4, 5, 6][value];
|
|
861
858
|
break;
|
|
862
859
|
};
|
|
863
860
|
|
|
864
|
-
|
|
865
|
-
await this.melCloudAta.send(
|
|
861
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.SetFanSpeed;
|
|
862
|
+
await this.melCloudAta.send(deviceData);
|
|
866
863
|
const info = this.disableLogInfo ? false : this.emit('message', `Set fan speed mode: ${CONSTANTS.AirConditioner.FanSpeed[fanSpeedModeText]}`);
|
|
867
864
|
} catch (error) {
|
|
868
865
|
this.emit('warn', `Set fan speed mode error: ${error}`);
|
|
@@ -878,10 +875,10 @@ class DeviceAta extends EventEmitter {
|
|
|
878
875
|
})
|
|
879
876
|
.onSet(async (value) => {
|
|
880
877
|
try {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
await this.melCloudAta.send(
|
|
878
|
+
deviceData.Device.VaneHorizontal = value ? 12 : 0;
|
|
879
|
+
deviceData.Device.VaneVertical = value ? 7 : 0;
|
|
880
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.VaneHorizontal + CONSTANTS.AirConditioner.EffectiveFlags.VaneVertical;
|
|
881
|
+
await this.melCloudAta.send(deviceData);
|
|
885
882
|
const info = this.disableLogInfo ? false : this.emit('message', `Set vane swing mode: ${CONSTANTS.AirConditioner.AirDirection[value ? 6 : 0]}`);
|
|
886
883
|
} catch (error) {
|
|
887
884
|
this.emit('warn', `Set vane swing mode error: ${error}`);
|
|
@@ -910,9 +907,9 @@ class DeviceAta extends EventEmitter {
|
|
|
910
907
|
})
|
|
911
908
|
.onSet(async (value) => {
|
|
912
909
|
try {
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
await this.melCloudAta.send(
|
|
910
|
+
deviceData.Device.SetTemperature = value;
|
|
911
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.SetTemperature;
|
|
912
|
+
await this.melCloudAta.send(deviceData);
|
|
916
913
|
const info = this.disableLogInfo ? false : this.emit('message', `Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
917
914
|
} catch (error) {
|
|
918
915
|
this.emit('warn', `Set heating threshold temperature error: ${error}`);
|
|
@@ -930,9 +927,9 @@ class DeviceAta extends EventEmitter {
|
|
|
930
927
|
})
|
|
931
928
|
.onSet(async (value) => {
|
|
932
929
|
try {
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
await this.melCloudAta.send(
|
|
930
|
+
deviceData.Device.SetTemperature = value;
|
|
931
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.SetTemperature;
|
|
932
|
+
await this.melCloudAta.send(deviceData);
|
|
936
933
|
const info = this.disableLogInfo ? false : this.emit('message', `Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
937
934
|
} catch (error) {
|
|
938
935
|
this.emit('warn', `Set cooling threshold temperature error: ${error}`);
|
|
@@ -946,11 +943,11 @@ class DeviceAta extends EventEmitter {
|
|
|
946
943
|
.onSet(async (value) => {
|
|
947
944
|
try {
|
|
948
945
|
value = value ? true : false;
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
await this.melCloudAta.send(
|
|
946
|
+
deviceData.Device.ProhibitSetTemperature = value;
|
|
947
|
+
deviceData.Device.ProhibitOperationMode = value;
|
|
948
|
+
deviceData.Device.ProhibitPower = value;
|
|
949
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Prohibit;
|
|
950
|
+
await this.melCloudAta.send(deviceData);
|
|
954
951
|
const info = this.disableLogInfo ? false : this.emit('message', `Set local physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
|
|
955
952
|
} catch (error) {
|
|
956
953
|
this.emit('warn', `Set lock physical controls error: ${error}`);
|
|
@@ -994,28 +991,28 @@ class DeviceAta extends EventEmitter {
|
|
|
994
991
|
try {
|
|
995
992
|
switch (value) {
|
|
996
993
|
case 0: //OFF - POWER OFF
|
|
997
|
-
|
|
998
|
-
|
|
994
|
+
deviceData.Device.Power = false;
|
|
995
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power;
|
|
999
996
|
break;
|
|
1000
997
|
case 1: //HEAT - HEAT
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
998
|
+
deviceData.Device.Power = true;
|
|
999
|
+
deviceData.Device.OperationMode = heatDryFanMode;
|
|
1000
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.OperationMode;
|
|
1004
1001
|
break;
|
|
1005
1002
|
case 2: //COOL - COOL
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1003
|
+
deviceData.Device.Power = true;
|
|
1004
|
+
deviceData.Device.OperationMode = coolDryFanMode;
|
|
1005
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.OperationMode;
|
|
1009
1006
|
break;
|
|
1010
1007
|
case 3: //AUTO - AUTO
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1008
|
+
deviceData.Device.Power = true;
|
|
1009
|
+
deviceData.Device.OperationMode = autoDryFanMode;
|
|
1010
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.OperationMode;
|
|
1014
1011
|
break;
|
|
1015
1012
|
};
|
|
1016
1013
|
|
|
1017
|
-
await this.melCloudAta.send(
|
|
1018
|
-
const operationModeText = CONSTANTS.AirConditioner.DriveMode[
|
|
1014
|
+
await this.melCloudAta.send(deviceData);
|
|
1015
|
+
const operationModeText = CONSTANTS.AirConditioner.DriveMode[deviceData.Device.OperationMode];
|
|
1019
1016
|
const info = this.disableLogInfo ? false : this.emit('message', `Set operation mode: ${operationModeText}`);
|
|
1020
1017
|
} catch (error) {
|
|
1021
1018
|
this.emit('warn', `Set operation mode error: ${error}`);
|
|
@@ -1043,9 +1040,9 @@ class DeviceAta extends EventEmitter {
|
|
|
1043
1040
|
})
|
|
1044
1041
|
.onSet(async (value) => {
|
|
1045
1042
|
try {
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
await this.melCloudAta.send(
|
|
1043
|
+
deviceData.Device.SetTemperature = value;
|
|
1044
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.SetTemperature;
|
|
1045
|
+
await this.melCloudAta.send(deviceData);
|
|
1049
1046
|
const info = this.disableLogInfo ? false : this.emit('message', `Set temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
1050
1047
|
} catch (error) {
|
|
1051
1048
|
this.emit('warn', `Set temperature error: ${error}`);
|
|
@@ -1106,15 +1103,14 @@ class DeviceAta extends EventEmitter {
|
|
|
1106
1103
|
};
|
|
1107
1104
|
|
|
1108
1105
|
//presets services
|
|
1109
|
-
if (presetsConfiguredCount > 0) {
|
|
1106
|
+
if (this.presetsConfiguredCount > 0) {
|
|
1110
1107
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare presets services`) : false;
|
|
1111
1108
|
this.presetsServices = [];
|
|
1112
1109
|
const previousPresets = [];
|
|
1113
1110
|
|
|
1114
|
-
for (let i = 0; i < presetsConfiguredCount; i++) {
|
|
1115
|
-
const preset = presetsConfigured[i];
|
|
1116
|
-
const
|
|
1117
|
-
const presetData = presetsOnServer[index];
|
|
1111
|
+
for (let i = 0; i < this.presetsConfiguredCount; i++) {
|
|
1112
|
+
const preset = this.presetsConfigured[i];
|
|
1113
|
+
const presetData = presetsOnServer.find(p => p.ID === preset.Id);
|
|
1118
1114
|
|
|
1119
1115
|
//get preset name
|
|
1120
1116
|
const presetName = preset.name;
|
|
@@ -1141,40 +1137,40 @@ class DeviceAta extends EventEmitter {
|
|
|
1141
1137
|
try {
|
|
1142
1138
|
switch (state) {
|
|
1143
1139
|
case true:
|
|
1144
|
-
previousPresets[i] =
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1140
|
+
previousPresets[i] = deviceData.Device;
|
|
1141
|
+
deviceData.Device.SetTemperature = presetData.SetTemperature;
|
|
1142
|
+
deviceData.Device.Power = presetData.Power;
|
|
1143
|
+
deviceData.Device.OperationMode = presetData.OperationMode;
|
|
1144
|
+
deviceData.Device.VaneHorizontal = presetData.VaneHorizontal;
|
|
1145
|
+
deviceData.Device.VaneVertical = presetData.VaneVertical;
|
|
1146
|
+
deviceData.Device.SetFanSpeed = presetData.FanSpeed;
|
|
1147
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power;
|
|
1152
1148
|
break;
|
|
1153
1149
|
case false:
|
|
1154
|
-
|
|
1150
|
+
deviceData.Device = previousPresets[i];
|
|
1155
1151
|
break;
|
|
1156
1152
|
};
|
|
1157
1153
|
|
|
1158
|
-
await this.melCloudAta.send(
|
|
1154
|
+
await this.melCloudAta.send(deviceData);
|
|
1159
1155
|
const info = this.disableLogInfo ? false : this.emit('message', `Set: ${presetName}`);
|
|
1160
1156
|
} catch (error) {
|
|
1161
1157
|
this.emit('warn', `Set preset error: ${error}`);
|
|
1162
1158
|
};
|
|
1163
1159
|
});
|
|
1164
1160
|
};
|
|
1165
|
-
previousPresets.push(
|
|
1161
|
+
previousPresets.push(deviceData.Device);
|
|
1166
1162
|
this.presetsServices.push(presetService);
|
|
1167
1163
|
accessory.addService(presetService);
|
|
1168
1164
|
};
|
|
1169
1165
|
};
|
|
1170
1166
|
|
|
1171
1167
|
//buttons services
|
|
1172
|
-
if (buttonsConfiguredCount > 0) {
|
|
1168
|
+
if (this.buttonsConfiguredCount > 0) {
|
|
1173
1169
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare buttons/sensors services`) : false;
|
|
1174
1170
|
this.buttonsServices = [];
|
|
1175
1171
|
|
|
1176
|
-
for (let i = 0; i < buttonsConfiguredCount; i++) {
|
|
1177
|
-
const button = buttonsConfigured[i];
|
|
1172
|
+
for (let i = 0; i < this.buttonsConfiguredCount; i++) {
|
|
1173
|
+
const button = this.buttonsConfigured[i];
|
|
1178
1174
|
|
|
1179
1175
|
//get button mode
|
|
1180
1176
|
const mode = button.mode;
|
|
@@ -1199,190 +1195,190 @@ class DeviceAta extends EventEmitter {
|
|
|
1199
1195
|
const state = button.state;
|
|
1200
1196
|
return state;
|
|
1201
1197
|
})
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1198
|
+
.onSet(async (state) => {
|
|
1199
|
+
if (displayType > 0 && displayType < 3) {
|
|
1200
|
+
try {
|
|
1201
|
+
switch (mode) {
|
|
1202
|
+
case 0: //POWER ON,OFF
|
|
1203
|
+
deviceData.Device.Power = state;
|
|
1204
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power;
|
|
1205
|
+
break;
|
|
1206
|
+
case 1: //OPERATING MODE HEAT
|
|
1207
|
+
deviceData.Device.Power = true;
|
|
1208
|
+
deviceData.Device.OperationMode = 1;
|
|
1209
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.OperationMode;
|
|
1210
|
+
break;
|
|
1211
|
+
case 2: //OPERATING MODE DRY
|
|
1212
|
+
deviceData.Device.Power = true;
|
|
1213
|
+
deviceData.Device.OperationMode = 2;
|
|
1214
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.OperationMode;
|
|
1215
|
+
break
|
|
1216
|
+
case 3: //OPERATING MODE COOL
|
|
1217
|
+
deviceData.Device.Power = true;
|
|
1218
|
+
deviceData.Device.OperationMode = 3;
|
|
1219
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.OperationMode;
|
|
1220
|
+
break;
|
|
1221
|
+
case 4: //OPERATING MODE FAN
|
|
1222
|
+
deviceData.Device.Power = true;
|
|
1223
|
+
deviceData.Device.OperationMode = 7;
|
|
1224
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.OperationMode;
|
|
1225
|
+
break;
|
|
1226
|
+
case 5: //OPERATING MODE AUTO
|
|
1227
|
+
deviceData.Device.Power = true;
|
|
1228
|
+
deviceData.Device.OperationMode = 8;
|
|
1229
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.OperationMode;
|
|
1230
|
+
break;
|
|
1231
|
+
case 6: //OPERATING MODE PURIFY
|
|
1232
|
+
deviceData.Device.Power = true;
|
|
1233
|
+
deviceData.Device.OperationMode = 9;
|
|
1234
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.OperationMode;
|
|
1235
|
+
break;
|
|
1236
|
+
case 7: //OPERATING MODE DRY CONTROL HIDE
|
|
1237
|
+
deviceData.Device.HideDryModeControl = state;
|
|
1238
|
+
break;
|
|
1239
|
+
case 10: //VANE H SWING MODE AUTO
|
|
1240
|
+
deviceData.Device.Power = true;
|
|
1241
|
+
deviceData.Device.VaneHorizontal = 0;
|
|
1242
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.VaneHorizontal;
|
|
1243
|
+
break;
|
|
1244
|
+
case 11: //VANE H SWING MODE 1
|
|
1245
|
+
deviceData.Device.Power = true;
|
|
1246
|
+
deviceData.Device.VaneHorizontal = 1;
|
|
1247
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.VaneHorizontal;
|
|
1248
|
+
break;
|
|
1249
|
+
case 12: //VANE H SWING MODE 2
|
|
1250
|
+
deviceData.Device.Power = true;
|
|
1251
|
+
deviceData.Device.VaneHorizontal = 2;
|
|
1252
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.VaneHorizontal;
|
|
1253
|
+
break;
|
|
1254
|
+
case 13: //VANE H SWING MODE 3
|
|
1255
|
+
deviceData.Device.Power = true;
|
|
1256
|
+
deviceData.Device.VaneHorizontal = 3;
|
|
1257
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.VaneHorizontal;
|
|
1258
|
+
break;
|
|
1259
|
+
case 14: //VANE H SWING MODE 4
|
|
1260
|
+
deviceData.Device.Power = true;
|
|
1261
|
+
deviceData.Device.VaneHorizontal = 4;
|
|
1262
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.VaneHorizontal;
|
|
1263
|
+
break;
|
|
1264
|
+
case 15: //VANE H SWING MODE 5
|
|
1265
|
+
deviceData.Device.Power = true;
|
|
1266
|
+
deviceData.Device.VaneHorizontal = 5;
|
|
1267
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.VaneHorizontal;
|
|
1268
|
+
break;
|
|
1269
|
+
case 16: //VANE H SWING MODE SPLIT
|
|
1270
|
+
deviceData.Device.Power = true;
|
|
1271
|
+
deviceData.Device.VaneHorizontal = 8;
|
|
1272
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.VaneHorizontal;
|
|
1273
|
+
break;
|
|
1274
|
+
case 17: //VANE H SWING MODE SWING
|
|
1275
|
+
deviceData.Device.Power = true;
|
|
1276
|
+
deviceData.Device.VaneHorizontal = 12;
|
|
1277
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.VaneHorizontal;
|
|
1278
|
+
break;
|
|
1279
|
+
case 20: //VANE V SWING MODE AUTO
|
|
1280
|
+
deviceData.Device.Power = true;
|
|
1281
|
+
deviceData.Device.VaneVertical = 0;
|
|
1282
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.VaneVertical;
|
|
1283
|
+
break;
|
|
1284
|
+
case 21: //VANE V SWING MODE 1
|
|
1285
|
+
deviceData.Device.Power = true;
|
|
1286
|
+
deviceData.Device.VaneVertical = 1;
|
|
1287
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.VaneVertical;
|
|
1288
|
+
break;
|
|
1289
|
+
case 22: //VANE V SWING MODE 2
|
|
1290
|
+
deviceData.Device.Power = true;
|
|
1291
|
+
deviceData.Device.VaneVertical = 2;
|
|
1292
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.VaneVertical;
|
|
1293
|
+
break;
|
|
1294
|
+
case 23: //VANE V SWING MODE 3
|
|
1295
|
+
deviceData.Device.Power = true;
|
|
1296
|
+
deviceData.Device.VaneVertical = 3;
|
|
1297
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.VaneVertical;
|
|
1298
|
+
break;
|
|
1299
|
+
case 24: //VANE V SWING MODE 4
|
|
1300
|
+
deviceData.Device.Power = true;
|
|
1301
|
+
deviceData.Device.VaneVertical = 4;
|
|
1302
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.VaneVertical;
|
|
1303
|
+
break;
|
|
1304
|
+
case 25: //VANE V SWING MODE 5
|
|
1305
|
+
deviceData.Device.Power = true;
|
|
1306
|
+
deviceData.Device.VaneVertical = 5;
|
|
1307
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.VaneVertical;
|
|
1308
|
+
break;
|
|
1309
|
+
case 26: //VANE V SWING MODE SWING
|
|
1310
|
+
deviceData.Device.Power = true;
|
|
1311
|
+
deviceData.Device.VaneVertical = 7;
|
|
1312
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.VaneVertical;
|
|
1313
|
+
break;
|
|
1314
|
+
case 27: //VANE H/V CONTROLS HIDE
|
|
1315
|
+
deviceData.Device.HideVaneControls = state;
|
|
1316
|
+
break;
|
|
1317
|
+
case 30: //FAN SPEED MODE AUTO
|
|
1318
|
+
deviceData.Device.Power = true;
|
|
1319
|
+
deviceData.Device.SetFanSpeed = 0;
|
|
1320
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.SetFanSpeed;
|
|
1321
|
+
break;
|
|
1322
|
+
case 31: //FAN SPEED MODE 1
|
|
1323
|
+
deviceData.Device.Power = true;
|
|
1324
|
+
deviceData.Device.SetFanSpeed = 1;
|
|
1325
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.SetFanSpeed;
|
|
1326
|
+
break;
|
|
1327
|
+
case 32: //FAN SPEED MODE 2
|
|
1328
|
+
deviceData.Device.Power = true;
|
|
1329
|
+
deviceData.Device.SetFanSpeed = 2;
|
|
1330
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.SetFanSpeed;
|
|
1331
|
+
break;
|
|
1332
|
+
case 33: //FAN SPEED MODE 3
|
|
1333
|
+
deviceData.Device.Power = true;
|
|
1334
|
+
deviceData.Device.SetFanSpeed = 3;
|
|
1335
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.SetFanSpeed;
|
|
1336
|
+
break;
|
|
1337
|
+
case 34: //FAN MODE 4
|
|
1338
|
+
deviceData.Device.Power = true;
|
|
1339
|
+
deviceData.Device.SetFanSpeed = 4;
|
|
1340
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.SetFanSpeed;
|
|
1341
|
+
break;
|
|
1342
|
+
case 35: //FAN SPEED MODE 5
|
|
1343
|
+
deviceData.Device.Power = true;
|
|
1344
|
+
deviceData.Device.SetFanSpeed = 5;
|
|
1345
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.SetFanSpeed;
|
|
1346
|
+
break;
|
|
1347
|
+
case 36: //FAN SPEED MODE 6
|
|
1348
|
+
deviceData.Device.Power = true;
|
|
1349
|
+
deviceData.Device.SetFanSpeed = 6;
|
|
1350
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.SetFanSpeed;
|
|
1351
|
+
break;
|
|
1352
|
+
case 37: //PHYSICAL LOCK CONTROLS
|
|
1353
|
+
deviceData.Device.ProhibitSetTemperature = state;
|
|
1354
|
+
deviceData.Device.ProhibitOperationMode = state;
|
|
1355
|
+
deviceData.Device.ProhibitPower = state;
|
|
1356
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Prohibit;
|
|
1357
|
+
break;
|
|
1358
|
+
case 38: //PHYSICAL LOCK CONTROLS POWER
|
|
1359
|
+
deviceData.Device.ProhibitPower = state;
|
|
1360
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Prohibit;
|
|
1361
|
+
break;
|
|
1362
|
+
case 39: //PHYSICAL LOCK CONTROLS MODE
|
|
1363
|
+
deviceData.Device.ProhibitOperationMode = state;
|
|
1364
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Prohibit;
|
|
1365
|
+
break;
|
|
1366
|
+
case 40: //PHYSICAL LOCK CONTROLS TEMP
|
|
1367
|
+
deviceData.Device.ProhibitSetTemperature = state;
|
|
1368
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Prohibit;
|
|
1369
|
+
break;
|
|
1370
|
+
default:
|
|
1371
|
+
this.emit('message', `Unknown button mode: ${mode}`);
|
|
1372
|
+
break;
|
|
1373
|
+
};
|
|
1378
1374
|
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1375
|
+
await this.melCloudAta.send(deviceData);
|
|
1376
|
+
const info = this.disableLogInfo ? false : this.emit('message', `Set: ${buttonName}`);
|
|
1377
|
+
} catch (error) {
|
|
1378
|
+
this.emit('warn', `Set button error: ${error}`);
|
|
1379
|
+
};
|
|
1383
1380
|
};
|
|
1384
1381
|
});
|
|
1385
|
-
};
|
|
1386
1382
|
this.buttonsServices.push(buttonService);
|
|
1387
1383
|
accessory.addService(buttonService);
|
|
1388
1384
|
};
|