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/deviceerv.js
CHANGED
|
@@ -36,6 +36,7 @@ class DeviceErv extends EventEmitter {
|
|
|
36
36
|
this.refreshInterval = refreshInterval;
|
|
37
37
|
this.useFahrenheit = useFahrenheit;
|
|
38
38
|
this.startPrepareAccessory = true;
|
|
39
|
+
this.displayDeviceInfo = true;
|
|
39
40
|
|
|
40
41
|
//external integrations
|
|
41
42
|
this.restFul = account.restFul ?? {};
|
|
@@ -70,10 +71,10 @@ class DeviceErv extends EventEmitter {
|
|
|
70
71
|
this.buttonsConfigured = [];
|
|
71
72
|
for (const button of this.buttons) {
|
|
72
73
|
const buttonName = button.name ?? false;
|
|
73
|
-
const buttonMode = button.mode ??
|
|
74
|
+
const buttonMode = button.mode ?? -1;
|
|
74
75
|
const buttonDisplayType = button.displayType ?? 0;
|
|
75
76
|
const buttonNamePrefix = button.namePrefix ?? false;
|
|
76
|
-
if (buttonName && buttonMode && buttonDisplayType > 0) {
|
|
77
|
+
if (buttonName && buttonMode >= 0 && buttonDisplayType > 0) {
|
|
77
78
|
const buttonServiceType = ['', Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][buttonDisplayType];
|
|
78
79
|
const buttonCharacteristicType = ['', Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][buttonDisplayType];
|
|
79
80
|
button.namePrefix = buttonNamePrefix;
|
|
@@ -92,12 +93,6 @@ class DeviceErv extends EventEmitter {
|
|
|
92
93
|
this.accessory.currentOperationMode = 0;
|
|
93
94
|
this.accessory.targetOperationMode = 0;
|
|
94
95
|
this.accessory.fanSpeed = 0;
|
|
95
|
-
this.accessory.lockPhysicalControl = 0;
|
|
96
|
-
|
|
97
|
-
this.accessory.operationModeSetPropsMinValue = 0;
|
|
98
|
-
this.accessory.operationModeSetPropsMaxValue = 3;
|
|
99
|
-
this.accessory.operationModeSetPropsValidValues = [0];
|
|
100
|
-
this.accessory.fanSpeedSetPropsMaxValue = 2;
|
|
101
96
|
};
|
|
102
97
|
|
|
103
98
|
async start() {
|
|
@@ -110,7 +105,7 @@ class DeviceErv extends EventEmitter {
|
|
|
110
105
|
debugLog: this.enableDebugMode
|
|
111
106
|
});
|
|
112
107
|
|
|
113
|
-
this.melCloudErv.on('externalIntegrations', (deviceData
|
|
108
|
+
this.melCloudErv.on('externalIntegrations', (deviceData) => {
|
|
114
109
|
try {
|
|
115
110
|
//RESTFul server
|
|
116
111
|
const restFulEnabled = this.restFul.enable || false;
|
|
@@ -127,7 +122,7 @@ class DeviceErv extends EventEmitter {
|
|
|
127
122
|
})
|
|
128
123
|
.on('set', async (key, value) => {
|
|
129
124
|
try {
|
|
130
|
-
await this.setOverExternalIntegration('RESTFul',
|
|
125
|
+
await this.setOverExternalIntegration('RESTFul', deviceData, key, value);
|
|
131
126
|
} catch (error) {
|
|
132
127
|
this.emit('warn', `RESTFul set error: ${error}.`);
|
|
133
128
|
};
|
|
@@ -140,7 +135,7 @@ class DeviceErv extends EventEmitter {
|
|
|
140
135
|
});
|
|
141
136
|
}
|
|
142
137
|
const restFul0 = this.restFulConnected ? this.restFul1.update('info', deviceData) : false;
|
|
143
|
-
const restFul1 = this.restFulConnected ? this.restFul1.update('state',
|
|
138
|
+
const restFul1 = this.restFulConnected ? this.restFul1.update('state', deviceData.Device) : false;
|
|
144
139
|
}
|
|
145
140
|
|
|
146
141
|
//MQTT client
|
|
@@ -166,7 +161,7 @@ class DeviceErv extends EventEmitter {
|
|
|
166
161
|
})
|
|
167
162
|
.on('set', async (key, value) => {
|
|
168
163
|
try {
|
|
169
|
-
await this.setOverExternalIntegration('MQTT',
|
|
164
|
+
await this.setOverExternalIntegration('MQTT', deviceData, key, value);
|
|
170
165
|
} catch (error) {
|
|
171
166
|
this.emit('warn', `MQTT set error: ${error}.`);
|
|
172
167
|
};
|
|
@@ -179,13 +174,17 @@ class DeviceErv extends EventEmitter {
|
|
|
179
174
|
});
|
|
180
175
|
}
|
|
181
176
|
const mqtt0 = this.mqttConnected ? this.mqtt1.emit('publish', `Info`, deviceData) : false;
|
|
182
|
-
const mqtt1 = this.mqttConnected ? this.mqtt1.emit('publish', `State`,
|
|
177
|
+
const mqtt1 = this.mqttConnected ? this.mqtt1.emit('publish', `State`, deviceData.Device) : false;
|
|
183
178
|
}
|
|
184
179
|
} catch (error) {
|
|
185
180
|
this.emit('warn', `External integration start error: ${error.message || error}.`);
|
|
186
181
|
};
|
|
187
182
|
})
|
|
188
183
|
.on('deviceInfo', (manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
|
|
184
|
+
if (!this.displayDeviceInfo) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
189
188
|
if (!this.disableLogDeviceInfo) {
|
|
190
189
|
this.emit('devInfo', `---- ${this.deviceTypeText}: ${this.deviceName} ----`);
|
|
191
190
|
this.emit('devInfo', `Account: ${this.accountName}`);
|
|
@@ -202,11 +201,9 @@ class DeviceErv extends EventEmitter {
|
|
|
202
201
|
this.model = modelIndoor ? modelIndoor : modelOutdoor ? modelOutdoor : `${deviceTypeText} ${this.deviceId}`;
|
|
203
202
|
this.serialNumber = serialNumber;
|
|
204
203
|
this.firmwareRevision = firmwareAppVersion;
|
|
205
|
-
|
|
206
|
-
//device info
|
|
207
|
-
|
|
204
|
+
this.displayDeviceInfo = false;
|
|
208
205
|
})
|
|
209
|
-
.on('deviceState', async (deviceData
|
|
206
|
+
.on('deviceState', async (deviceData) => {
|
|
210
207
|
//device info
|
|
211
208
|
const displayMode = this.displayMode;
|
|
212
209
|
const hasCoolOperationMode = deviceData.Device.HasCoolOperationMode ?? false;
|
|
@@ -235,19 +232,19 @@ class DeviceErv extends EventEmitter {
|
|
|
235
232
|
const presetsOnServer = deviceData.Presets ?? [];
|
|
236
233
|
|
|
237
234
|
//device state
|
|
238
|
-
const
|
|
239
|
-
const
|
|
240
|
-
const
|
|
241
|
-
const
|
|
242
|
-
const
|
|
243
|
-
const
|
|
244
|
-
const
|
|
245
|
-
const
|
|
246
|
-
const
|
|
247
|
-
const
|
|
248
|
-
const
|
|
249
|
-
const
|
|
250
|
-
const
|
|
235
|
+
const power = deviceData.Device.Power;
|
|
236
|
+
const offline = deviceData.Device.Offline;
|
|
237
|
+
const roomTemperature = deviceData.Device.RoomTemperature;
|
|
238
|
+
const supplyTemperature = deviceData.Device.SupplyTemperature;
|
|
239
|
+
const outdoorTemperature = deviceData.Device.OutdoorTemperature;
|
|
240
|
+
const nightPurgeMode = deviceData.Device.NightPurgeMode;
|
|
241
|
+
const setTemperature = deviceData.Device.SetTemperature;
|
|
242
|
+
const setFanSpeed = deviceData.Device.SetFanSpeed;
|
|
243
|
+
const operationMode = deviceData.Device.OperationMode;
|
|
244
|
+
const ventilationMode = deviceData.Device.VentilationMode;
|
|
245
|
+
const hideRoomTemperature = deviceData.Device.HideRoomTemperature;
|
|
246
|
+
const hideSupplyTemperature = deviceData.Device.HideSupplyTemperature;
|
|
247
|
+
const hideOutdoorTemperature = deviceData.Device.HideOutdoorTemperature;
|
|
251
248
|
const temperatureUnit = CONSTANTS.TemperatureDisplayUnits[this.useFahrenheit];
|
|
252
249
|
|
|
253
250
|
//set temperature
|
|
@@ -256,12 +253,13 @@ class DeviceErv extends EventEmitter {
|
|
|
256
253
|
//accessory
|
|
257
254
|
this.accessory.presetsOnServer = presetsOnServer;
|
|
258
255
|
this.accessory.power = power ? 1 : 0;
|
|
259
|
-
this.accessory.offline = offline;
|
|
256
|
+
this.accessory.offline = offline ?? false;
|
|
260
257
|
this.accessory.roomTemperature = roomTemperature;
|
|
261
258
|
this.accessory.outdoorTemperature = outdoorTemperature;
|
|
262
259
|
this.accessory.supplyTemperature = supplyTemperature;
|
|
263
260
|
this.accessory.setTemperature = targetTemperature;
|
|
264
261
|
this.accessory.setFanSpeed = setFanSpeed;
|
|
262
|
+
this.accessory.lockPhysicalControl = 0;
|
|
265
263
|
this.accessory.temperatureIncrement = temperatureIncrement;
|
|
266
264
|
this.accessory.useFahrenheit = this.useFahrenheit;
|
|
267
265
|
this.accessory.temperatureUnit = temperatureUnit;
|
|
@@ -330,6 +328,7 @@ class DeviceErv extends EventEmitter {
|
|
|
330
328
|
this.accessory.operationModeSetPropsValidValues = hasAutoVentilationMode ? (hasBypassVentilationMode ? [0, 1, 2] : [0, 2]) : (hasBypassVentilationMode ? [1, 2] : [2]);
|
|
331
329
|
|
|
332
330
|
//fan speed mode
|
|
331
|
+
this.accessory.fanSpeedSetPropsMaxValue = 2;
|
|
333
332
|
switch (numberOfFanSpeeds) {
|
|
334
333
|
case 2: //Fan speed mode 2
|
|
335
334
|
this.accessory.fanSpeed = hasAutomaticFanSpeed ? [3, 1, 2][setFanSpeed] : [0, 1, 2][setFanSpeed];
|
|
@@ -410,6 +409,9 @@ class DeviceErv extends EventEmitter {
|
|
|
410
409
|
.updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.accessory.useFahrenheit);
|
|
411
410
|
};
|
|
412
411
|
break;
|
|
412
|
+
default:
|
|
413
|
+
this.emit('warn', `Unknown display mode: ${displayMode}`);
|
|
414
|
+
return;
|
|
413
415
|
};
|
|
414
416
|
|
|
415
417
|
//update temperature sensors
|
|
@@ -458,8 +460,7 @@ class DeviceErv extends EventEmitter {
|
|
|
458
460
|
if (this.presetsConfigured.length > 0) {
|
|
459
461
|
for (let i = 0; i < this.presetsConfigured.length; i++) {
|
|
460
462
|
const preset = this.presetsConfigured[i];
|
|
461
|
-
const
|
|
462
|
-
const presetData = presetsOnServer[index];
|
|
463
|
+
const presetData = presetsOnServer.find(p => p.ID === preset.Id);
|
|
463
464
|
|
|
464
465
|
preset.state = presetData ? (presetData.Power === power
|
|
465
466
|
&& presetData.SetTemperature === targetTemperature
|
|
@@ -565,7 +566,7 @@ class DeviceErv extends EventEmitter {
|
|
|
565
566
|
}
|
|
566
567
|
|
|
567
568
|
try {
|
|
568
|
-
const accessory = await this.prepareAccessory(this.accountInfo,
|
|
569
|
+
const accessory = await this.prepareAccessory(this.accountInfo, deviceData, this.deviceId, this.deviceTypeText, this.deviceName, this.accountName);
|
|
569
570
|
this.emit('publishAccessory', accessory);
|
|
570
571
|
this.startPrepareAccessory = false;
|
|
571
572
|
} catch (error) {
|
|
@@ -583,8 +584,6 @@ class DeviceErv extends EventEmitter {
|
|
|
583
584
|
})
|
|
584
585
|
.on('error', async (error) => {
|
|
585
586
|
this.emit('error', error);
|
|
586
|
-
await new Promise(resolve => setTimeout(resolve, 15000));
|
|
587
|
-
await this.melCloudErv.impulseGenerator.start([{ name: 'checkState', sampling: this.refreshInterval }]);
|
|
588
587
|
});
|
|
589
588
|
|
|
590
589
|
//check state
|
|
@@ -599,64 +598,64 @@ class DeviceErv extends EventEmitter {
|
|
|
599
598
|
};
|
|
600
599
|
};
|
|
601
600
|
|
|
602
|
-
async setOverExternalIntegration(integration,
|
|
601
|
+
async setOverExternalIntegration(integration, deviceData, key, value) {
|
|
603
602
|
try {
|
|
604
603
|
let set = false
|
|
605
604
|
switch (key) {
|
|
606
605
|
case 'Power':
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
set = await this.melCloudErv.send(
|
|
606
|
+
deviceData.Device[key] = value;
|
|
607
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power;
|
|
608
|
+
set = await this.melCloudErv.send(deviceData);
|
|
610
609
|
break;
|
|
611
610
|
case 'OperationMode':
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
set = await this.melCloudErv.send(
|
|
611
|
+
deviceData.Device[key] = value;
|
|
612
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.OperationMode;
|
|
613
|
+
set = await this.melCloudErv.send(deviceData);
|
|
615
614
|
break;
|
|
616
615
|
case 'VentilationMode':
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
set = await this.melCloudErv.send(
|
|
616
|
+
deviceData.Device[key] = value;
|
|
617
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.VentilationMode;
|
|
618
|
+
set = await this.melCloudErv.send(deviceData);
|
|
620
619
|
break;
|
|
621
620
|
case 'SetTemperature':
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
set = await this.melCloudErv.send(
|
|
621
|
+
deviceData.Device[key] = value;
|
|
622
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.SetTemperature;
|
|
623
|
+
set = await this.melCloudErv.send(deviceData);
|
|
625
624
|
break;
|
|
626
625
|
case 'DefaultCoolingSetTemperature':
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
set = await this.melCloudErv.send(
|
|
626
|
+
deviceData.Device[key] = value;
|
|
627
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.SetTemperature;
|
|
628
|
+
set = await this.melCloudErv.send(deviceData);
|
|
630
629
|
break;
|
|
631
630
|
case 'DefaultHeatingSetTemperature':
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
set = await this.melCloudErv.send(
|
|
631
|
+
deviceData.Device[key] = value;
|
|
632
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.SetTemperature;
|
|
633
|
+
set = await this.melCloudErv.send(deviceData);
|
|
635
634
|
break;
|
|
636
635
|
case 'NightPurgeMode':
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
set = await this.melCloudErv.send(
|
|
636
|
+
deviceData.Device[key] = value;
|
|
637
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.NightPurgeMode;
|
|
638
|
+
set = await this.melCloudErv.send(deviceData);
|
|
640
639
|
break;
|
|
641
640
|
case 'SetFanSpeed':
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
set = await this.melCloudErv.send(
|
|
641
|
+
deviceData.Device[key] = value;
|
|
642
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.SetFanSpeed;
|
|
643
|
+
set = await this.melCloudErv.send(deviceData);
|
|
645
644
|
break;
|
|
646
645
|
case 'HideRoomTemperature':
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
set = await this.melCloudErv.send(
|
|
646
|
+
deviceData.Device[key] = value;
|
|
647
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Prohibit;
|
|
648
|
+
set = await this.melCloudErv.send(deviceData);
|
|
650
649
|
break;
|
|
651
650
|
case 'HideSupplyTemperature':
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
set = await this.melCloudErv.send(
|
|
651
|
+
deviceData.Device[key] = value;
|
|
652
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Prohibit;
|
|
653
|
+
set = await this.melCloudErv.send(deviceData);
|
|
655
654
|
break;
|
|
656
655
|
case 'HideOutdoorTemperature':
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
set = await this.melCloudErv.send(
|
|
656
|
+
deviceData.Device[key] = value;
|
|
657
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Prohibit;
|
|
658
|
+
set = await this.melCloudErv.send(deviceData);
|
|
660
659
|
break;
|
|
661
660
|
default:
|
|
662
661
|
this.emit('warn', `${integration}, received key: ${key}, value: ${value}`);
|
|
@@ -669,7 +668,7 @@ class DeviceErv extends EventEmitter {
|
|
|
669
668
|
}
|
|
670
669
|
|
|
671
670
|
//prepare accessory
|
|
672
|
-
async prepareAccessory(accountInfo,
|
|
671
|
+
async prepareAccessory(accountInfo, deviceData, deviceId, deviceTypeText, deviceName, accountName) {
|
|
673
672
|
try {
|
|
674
673
|
//accessory
|
|
675
674
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare accessory`) : false;
|
|
@@ -715,9 +714,9 @@ class DeviceErv extends EventEmitter {
|
|
|
715
714
|
})
|
|
716
715
|
.onSet(async (state) => {
|
|
717
716
|
try {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
await this.melCloudErv.send(
|
|
717
|
+
deviceData.Device.Power = [false, true][state];
|
|
718
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power;
|
|
719
|
+
await this.melCloudErv.send(deviceData);
|
|
721
720
|
const info = this.disableLogInfo ? false : this.emit('message', `Set power: ${state ? 'ON' : 'OFF'}`);
|
|
722
721
|
} catch (error) {
|
|
723
722
|
this.emit('warn', `Set power error: ${error}`);
|
|
@@ -742,21 +741,21 @@ class DeviceErv extends EventEmitter {
|
|
|
742
741
|
try {
|
|
743
742
|
switch (value) {
|
|
744
743
|
case 0: //AUTO - AUTO
|
|
745
|
-
|
|
746
|
-
|
|
744
|
+
deviceData.Device.VentilationMode = hasAutoVentilationMode ? 2 : 0;
|
|
745
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.VentilationMode;
|
|
747
746
|
break;
|
|
748
747
|
case 1: //HEAT - LOSSNAY
|
|
749
|
-
|
|
750
|
-
|
|
748
|
+
deviceData.Device.VentilationMode = 0;
|
|
749
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.VentilationMode;
|
|
751
750
|
break;
|
|
752
751
|
case 2: //COOL - BYPASS
|
|
753
|
-
|
|
754
|
-
|
|
752
|
+
deviceData.Device.VentilationMode = hasBypassVentilationMode ? 1 : 0;
|
|
753
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.VentilationMode;
|
|
755
754
|
break;
|
|
756
755
|
};
|
|
757
756
|
|
|
758
|
-
await this.melCloudErv.send(
|
|
759
|
-
const operationModeText = CONSTANTS.Ventilation.VentilationMode[
|
|
757
|
+
await this.melCloudErv.send(deviceData);
|
|
758
|
+
const operationModeText = CONSTANTS.Ventilation.VentilationMode[deviceData.Device.VentilationMode];
|
|
760
759
|
const info = this.disableLogInfo ? false : this.emit('message', `Set operation mode: ${operationModeText}`);
|
|
761
760
|
} catch (error) {
|
|
762
761
|
this.emit('warn', `Set operation mode error: ${error}`);
|
|
@@ -777,21 +776,21 @@ class DeviceErv extends EventEmitter {
|
|
|
777
776
|
let fanSpeedModeText = 0; //AUTO, 1, 2, 3, 4, OFF
|
|
778
777
|
switch (ataNumberOfFanSpeeds) {
|
|
779
778
|
case 2: //Fan speed mode 2
|
|
780
|
-
|
|
779
|
+
deviceData.Device.SetFanSpeed = ataHasAutomaticFanSpeed ? [0, 1, 2, 0][value] : [1, 1, 2][value];
|
|
781
780
|
fanSpeedModeText = ataHasAutomaticFanSpeed ? [5, 1, 2, 0][value] : [5, 1, 2][value];
|
|
782
781
|
break;
|
|
783
782
|
case 3: //Fan speed mode 3
|
|
784
|
-
|
|
783
|
+
deviceData.Device.SetFanSpeed = ataHasAutomaticFanSpeed ? [0, 1, 2, 3, 0][value] : [1, 1, 2, 3][value];
|
|
785
784
|
fanSpeedModeText = ataHasAutomaticFanSpeed ? [5, 1, 2, 3, 0][value] : [5, 1, 2, 3][value];
|
|
786
785
|
break;
|
|
787
786
|
case 4: //Fan speed mode 4
|
|
788
|
-
|
|
787
|
+
deviceData.Device.SetFanSpeed = ataHasAutomaticFanSpeed ? [0, 1, 2, 3, 4, 0][value] : [1, 1, 2, 3, 4][value];
|
|
789
788
|
fanSpeedModeText = ataHasAutomaticFanSpeed ? [5, 1, 2, 3, 4, 0][value] : [5, 1, 2, 3, 4][value];
|
|
790
789
|
break;
|
|
791
790
|
};
|
|
792
791
|
|
|
793
|
-
|
|
794
|
-
await this.melCloudErv.send(
|
|
792
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.SetFanSpeed;
|
|
793
|
+
await this.melCloudErv.send(deviceData);
|
|
795
794
|
const info = this.disableLogInfo ? false : this.emit('message', `Set fan speed mode: ${CONSTANTS.Ventilation.FanSpeed[fanSpeedModeText]}`);
|
|
796
795
|
} catch (error) {
|
|
797
796
|
this.emit('warn', `Set fan speed mode error: ${error}`);
|
|
@@ -821,9 +820,9 @@ class DeviceErv extends EventEmitter {
|
|
|
821
820
|
})
|
|
822
821
|
.onSet(async (value) => {
|
|
823
822
|
try {
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
await this.melCloudErv.send(
|
|
823
|
+
deviceData.Device.SetTemperature = value;
|
|
824
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.SetTemperature;
|
|
825
|
+
await this.melCloudErv.send(deviceData);
|
|
827
826
|
const info = this.disableLogInfo ? false : this.emit('message', `Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
828
827
|
} catch (error) {
|
|
829
828
|
this.emit('warn', `Set heating threshold temperature error: ${error}`);
|
|
@@ -844,9 +843,9 @@ class DeviceErv extends EventEmitter {
|
|
|
844
843
|
})
|
|
845
844
|
.onSet(async (value) => {
|
|
846
845
|
try {
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
await this.melCloudErv.send(
|
|
846
|
+
deviceData.Device.SetTemperature = value;
|
|
847
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.SetTemperature;
|
|
848
|
+
await this.melCloudErv.send(deviceData);
|
|
850
849
|
const info = this.disableLogInfo ? false : this.emit('message', `Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
851
850
|
} catch (error) {
|
|
852
851
|
this.emit('warn', `Set cooling threshold temperature error: ${error}`);
|
|
@@ -862,9 +861,9 @@ class DeviceErv extends EventEmitter {
|
|
|
862
861
|
// .onSet(async (value) => {
|
|
863
862
|
// try {
|
|
864
863
|
// value = value ? true : false;
|
|
865
|
-
//
|
|
866
|
-
//
|
|
867
|
-
// await this.melCloudErv.send(
|
|
864
|
+
// deviceData.Device = deviceData.Device;
|
|
865
|
+
// deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Prohibit;
|
|
866
|
+
// await this.melCloudErv.send(deviceData);
|
|
868
867
|
// const info = this.disableLogInfo ? false : this.emit('message', `Set local physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
|
|
869
868
|
// } catch (error) {
|
|
870
869
|
// this.emit('warn', `Set lock physical controls error: ${error}`);
|
|
@@ -907,28 +906,28 @@ class DeviceErv extends EventEmitter {
|
|
|
907
906
|
try {
|
|
908
907
|
switch (value) {
|
|
909
908
|
case 0: //OFF - POWER OFF
|
|
910
|
-
|
|
911
|
-
|
|
909
|
+
deviceData.Device.Power = false;
|
|
910
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power;
|
|
912
911
|
break;
|
|
913
912
|
case 1: //HEAT - LOSSNAY
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
913
|
+
deviceData.Device.Power = true;
|
|
914
|
+
deviceData.Device.VentilationMode = 0;
|
|
915
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power + CONSTANTS.Ventilation.EffectiveFlags.VentilationMode;
|
|
917
916
|
break;
|
|
918
917
|
case 2: //COOL - BYPASS
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
918
|
+
deviceData.Device.Power = true;
|
|
919
|
+
deviceData.Device.VentilationMode = hasBypassVentilationMode ? 1 : 0;
|
|
920
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power + CONSTANTS.Ventilation.EffectiveFlags.VentilationMode;
|
|
922
921
|
break;
|
|
923
922
|
case 3: //AUTO - AUTO
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
923
|
+
deviceData.Device.Power = true;
|
|
924
|
+
deviceData.Device.VentilationMode = hasAutoVentilationMode ? 2 : 0;
|
|
925
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power + CONSTANTS.Ventilation.EffectiveFlags.VentilationMode;
|
|
927
926
|
break;
|
|
928
927
|
};
|
|
929
928
|
|
|
930
|
-
await this.melCloudErv.send(
|
|
931
|
-
const operationModeText = CONSTANTS.Ventilation.VentilationMode[
|
|
929
|
+
await this.melCloudErv.send(deviceData);
|
|
930
|
+
const operationModeText = CONSTANTS.Ventilation.VentilationMode[deviceData.Device.VentilationMode];
|
|
932
931
|
const info = this.disableLogInfo ? false : this.emit('message', `Set operation mode: ${operationModeText}`);
|
|
933
932
|
} catch (error) {
|
|
934
933
|
this.emit('warn', `Set operation mode error: ${error}`);
|
|
@@ -956,9 +955,9 @@ class DeviceErv extends EventEmitter {
|
|
|
956
955
|
})
|
|
957
956
|
.onSet(async (value) => {
|
|
958
957
|
try {
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
await this.melCloudErv.send(
|
|
958
|
+
deviceData.Device.SetTemperature = value;
|
|
959
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.SetTemperature;
|
|
960
|
+
await this.melCloudErv.send(deviceData);
|
|
962
961
|
const info = this.disableLogInfo ? false : this.emit('message', `Set temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
963
962
|
} catch (error) {
|
|
964
963
|
this.emit('warn', `Set temperature error: ${error}`);
|
|
@@ -1110,8 +1109,7 @@ class DeviceErv extends EventEmitter {
|
|
|
1110
1109
|
|
|
1111
1110
|
for (let i = 0; i < presetsConfiguredCount; i++) {
|
|
1112
1111
|
const preset = presetsConfigured[i];
|
|
1113
|
-
const
|
|
1114
|
-
const presetData = presetsOnServer[index]
|
|
1112
|
+
const presetData = presetsOnServer.find(p => p.ID === preset.Id);
|
|
1115
1113
|
|
|
1116
1114
|
//get preset name
|
|
1117
1115
|
const presetName = preset.name;
|
|
@@ -1138,27 +1136,27 @@ class DeviceErv extends EventEmitter {
|
|
|
1138
1136
|
try {
|
|
1139
1137
|
switch (state) {
|
|
1140
1138
|
case true:
|
|
1141
|
-
previousPresets[i] =
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1139
|
+
previousPresets[i] = deviceData.Device;
|
|
1140
|
+
deviceData.Device.SetTemperature = presetData.SetTemperature;
|
|
1141
|
+
deviceData.Device.Power = presetData.Power;
|
|
1142
|
+
deviceData.Device.OperationMode = presetData.OperationMode;
|
|
1143
|
+
deviceData.Device.VentilationMode = presetData.VentilationMode;
|
|
1144
|
+
deviceData.Device.SetFanSpeed = presetData.FanSpeed;
|
|
1145
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power;
|
|
1148
1146
|
break;
|
|
1149
1147
|
case false:
|
|
1150
|
-
|
|
1148
|
+
deviceData.Device = previousPresets[i];
|
|
1151
1149
|
break;
|
|
1152
1150
|
};
|
|
1153
1151
|
|
|
1154
|
-
await this.melCloudErv.send(
|
|
1152
|
+
await this.melCloudErv.send(deviceData);
|
|
1155
1153
|
const info = this.disableLogInfo ? false : this.emit('message', `Set: ${presetName}`);
|
|
1156
1154
|
} catch (error) {
|
|
1157
1155
|
this.emit('warn', `Set preset error: ${error}`);
|
|
1158
1156
|
};
|
|
1159
1157
|
});
|
|
1160
1158
|
};
|
|
1161
|
-
previousPresets.push(
|
|
1159
|
+
previousPresets.push(deviceData.Device);
|
|
1162
1160
|
this.presetsServices.push(presetService);
|
|
1163
1161
|
accessory.addService(presetService);
|
|
1164
1162
|
};
|
|
@@ -1195,84 +1193,84 @@ class DeviceErv extends EventEmitter {
|
|
|
1195
1193
|
const state = button.state;
|
|
1196
1194
|
return state;
|
|
1197
1195
|
})
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
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
|
-
|
|
1196
|
+
.onSet(async (state) => {
|
|
1197
|
+
if (displayType > 0 && displayType < 3) {
|
|
1198
|
+
try {
|
|
1199
|
+
switch (mode) {
|
|
1200
|
+
case 0: //POWER ON,OFF
|
|
1201
|
+
deviceData.Device.Power = state;
|
|
1202
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power;
|
|
1203
|
+
break;
|
|
1204
|
+
case 1: //OPERATING MODE RECOVERY
|
|
1205
|
+
deviceData.Device.Power = true;
|
|
1206
|
+
deviceData.Device.VentilationMode = 0;
|
|
1207
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power + CONSTANTS.Ventilation.EffectiveFlags.VentilationMode;
|
|
1208
|
+
break;
|
|
1209
|
+
case 2: //OPERATING MODE BYPASS
|
|
1210
|
+
deviceData.Device.Power = true;
|
|
1211
|
+
deviceData.Device.VentilationMode = 1;
|
|
1212
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power + CONSTANTS.Ventilation.EffectiveFlags.VentilationMode;
|
|
1213
|
+
break
|
|
1214
|
+
case 3: //OPERATING MODE AUTO
|
|
1215
|
+
deviceData.Device.Power = true;
|
|
1216
|
+
deviceData.Device.VentilationMode = 2;
|
|
1217
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power + CONSTANTS.Ventilation.EffectiveFlags.VentilationMode;
|
|
1218
|
+
break;
|
|
1219
|
+
case 4: //NIGHT PURGE MODE
|
|
1220
|
+
deviceData.Device.Power = true;
|
|
1221
|
+
deviceData.Device.NightPurgeMode = state;
|
|
1222
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power
|
|
1223
|
+
break;
|
|
1224
|
+
case 10: //FAN SPEED MODE AUTO
|
|
1225
|
+
deviceData.Device.Power = true;
|
|
1226
|
+
deviceData.Device.SetFanSpeed = 0;
|
|
1227
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power + CONSTANTS.Ventilation.EffectiveFlags.SetFanSpeed;
|
|
1228
|
+
break;
|
|
1229
|
+
case 11: //FAN SPEED MODE 1
|
|
1230
|
+
deviceData.Device.Power = true;
|
|
1231
|
+
deviceData.Device.SetFanSpeed = 1;
|
|
1232
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power + CONSTANTS.Ventilation.EffectiveFlags.SetFanSpeed;
|
|
1233
|
+
break;
|
|
1234
|
+
case 12: //FAN SPEED MODE 2
|
|
1235
|
+
deviceData.Device.Power = true;
|
|
1236
|
+
deviceData.Device.SetFanSpeed = 2;
|
|
1237
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power + CONSTANTS.Ventilation.EffectiveFlags.SetFanSpeed;
|
|
1238
|
+
break;
|
|
1239
|
+
case 13: //FAN SPEED MODE 3
|
|
1240
|
+
deviceData.Device.Power = true;
|
|
1241
|
+
deviceData.Device.SetFanSpeed = 3;
|
|
1242
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power + CONSTANTS.Ventilation.EffectiveFlags.SetFanSpeed;
|
|
1243
|
+
break;
|
|
1244
|
+
case 14: //FAN MODE 4
|
|
1245
|
+
deviceData.Device.Power = true;
|
|
1246
|
+
deviceData.Device.SetFanSpeed = 4;
|
|
1247
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power + CONSTANTS.Ventilation.EffectiveFlags.SetFanSpeed;
|
|
1248
|
+
break;
|
|
1249
|
+
case 15: //PHYSICAL LOCK CONTROLS
|
|
1250
|
+
deviceData.Device = deviceData.Device;
|
|
1251
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Prohibit;
|
|
1252
|
+
break;
|
|
1253
|
+
case 16: //ROOM TEMP HIDE
|
|
1254
|
+
deviceData.Device.HideRoomTemperature = state;
|
|
1255
|
+
break;
|
|
1256
|
+
case 17: //SUPPLY TEMP HIDE
|
|
1257
|
+
deviceData.Device.HideSupplyTemperature = state;
|
|
1258
|
+
break;
|
|
1259
|
+
case 18: //OUTDOOR EMP HIDE
|
|
1260
|
+
deviceData.Device.hideOutdoorTemperature = state;
|
|
1261
|
+
break;
|
|
1262
|
+
default:
|
|
1263
|
+
this.emit('message', `Unknown button mode: ${mode}`);
|
|
1264
|
+
break;
|
|
1265
|
+
};
|
|
1268
1266
|
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1267
|
+
await this.melCloudErv.send(deviceData);
|
|
1268
|
+
const info = this.disableLogInfo ? false : this.emit('message', `Set: ${buttonName}`);
|
|
1269
|
+
} catch (error) {
|
|
1270
|
+
this.emit('warn', `Set button error: ${error}`);
|
|
1271
|
+
};
|
|
1273
1272
|
};
|
|
1274
1273
|
});
|
|
1275
|
-
};
|
|
1276
1274
|
this.buttonsServices.push(buttonService);
|
|
1277
1275
|
accessory.addService(buttonService);
|
|
1278
1276
|
};
|