homebridge-melcloud-control 3.1.10 → 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/CHANGELOG.md +7 -2
- package/README.md +8 -8
- package/homebridge-ui/server.js +1 -3
- package/index.js +4 -3
- package/package.json +2 -2
- package/src/deviceata.js +353 -358
- package/src/deviceatw.js +349 -345
- package/src/deviceerv.js +205 -208
- package/src/melcloud.js +25 -25
- package/src/melcloudata.js +71 -80
- package/src/melcloudatw.js +67 -67
- package/src/melclouderv.js +45 -56
package/src/deviceerv.js
CHANGED
|
@@ -7,7 +7,7 @@ const CONSTANTS = require('./constants.json');
|
|
|
7
7
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
8
8
|
|
|
9
9
|
class DeviceErv extends EventEmitter {
|
|
10
|
-
constructor(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText,
|
|
10
|
+
constructor(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, refreshInterval, useFahrenheit) {
|
|
11
11
|
super();
|
|
12
12
|
|
|
13
13
|
Accessory = api.platformAccessory;
|
|
@@ -32,10 +32,11 @@ class DeviceErv extends EventEmitter {
|
|
|
32
32
|
this.deviceId = deviceId;
|
|
33
33
|
this.deviceName = deviceName;
|
|
34
34
|
this.deviceTypeText = deviceTypeText;
|
|
35
|
-
this.accountFile = accountFile;
|
|
36
35
|
this.devicesFile = devicesFile;
|
|
37
36
|
this.refreshInterval = refreshInterval;
|
|
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() {
|
|
@@ -105,13 +100,12 @@ class DeviceErv extends EventEmitter {
|
|
|
105
100
|
//melcloud device
|
|
106
101
|
this.melCloudErv = new MelCloudErv({
|
|
107
102
|
contextKey: this.contextKey,
|
|
108
|
-
accountFile: this.accountFile,
|
|
109
103
|
devicesFile: this.devicesFile,
|
|
110
104
|
deviceId: this.deviceId,
|
|
111
105
|
debugLog: this.enableDebugMode
|
|
112
106
|
});
|
|
113
107
|
|
|
114
|
-
this.melCloudErv.on('externalIntegrations', (deviceData
|
|
108
|
+
this.melCloudErv.on('externalIntegrations', (deviceData) => {
|
|
115
109
|
try {
|
|
116
110
|
//RESTFul server
|
|
117
111
|
const restFulEnabled = this.restFul.enable || false;
|
|
@@ -128,7 +122,7 @@ class DeviceErv extends EventEmitter {
|
|
|
128
122
|
})
|
|
129
123
|
.on('set', async (key, value) => {
|
|
130
124
|
try {
|
|
131
|
-
await this.setOverExternalIntegration('RESTFul',
|
|
125
|
+
await this.setOverExternalIntegration('RESTFul', deviceData, key, value);
|
|
132
126
|
} catch (error) {
|
|
133
127
|
this.emit('warn', `RESTFul set error: ${error}.`);
|
|
134
128
|
};
|
|
@@ -141,7 +135,7 @@ class DeviceErv extends EventEmitter {
|
|
|
141
135
|
});
|
|
142
136
|
}
|
|
143
137
|
const restFul0 = this.restFulConnected ? this.restFul1.update('info', deviceData) : false;
|
|
144
|
-
const restFul1 = this.restFulConnected ? this.restFul1.update('state',
|
|
138
|
+
const restFul1 = this.restFulConnected ? this.restFul1.update('state', deviceData.Device) : false;
|
|
145
139
|
}
|
|
146
140
|
|
|
147
141
|
//MQTT client
|
|
@@ -167,7 +161,7 @@ class DeviceErv extends EventEmitter {
|
|
|
167
161
|
})
|
|
168
162
|
.on('set', async (key, value) => {
|
|
169
163
|
try {
|
|
170
|
-
await this.setOverExternalIntegration('MQTT',
|
|
164
|
+
await this.setOverExternalIntegration('MQTT', deviceData, key, value);
|
|
171
165
|
} catch (error) {
|
|
172
166
|
this.emit('warn', `MQTT set error: ${error}.`);
|
|
173
167
|
};
|
|
@@ -180,13 +174,17 @@ class DeviceErv extends EventEmitter {
|
|
|
180
174
|
});
|
|
181
175
|
}
|
|
182
176
|
const mqtt0 = this.mqttConnected ? this.mqtt1.emit('publish', `Info`, deviceData) : false;
|
|
183
|
-
const mqtt1 = this.mqttConnected ? this.mqtt1.emit('publish', `State`,
|
|
177
|
+
const mqtt1 = this.mqttConnected ? this.mqtt1.emit('publish', `State`, deviceData.Device) : false;
|
|
184
178
|
}
|
|
185
179
|
} catch (error) {
|
|
186
180
|
this.emit('warn', `External integration start error: ${error.message || error}.`);
|
|
187
181
|
};
|
|
188
182
|
})
|
|
189
183
|
.on('deviceInfo', (manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
|
|
184
|
+
if (!this.displayDeviceInfo) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
190
188
|
if (!this.disableLogDeviceInfo) {
|
|
191
189
|
this.emit('devInfo', `---- ${this.deviceTypeText}: ${this.deviceName} ----`);
|
|
192
190
|
this.emit('devInfo', `Account: ${this.accountName}`);
|
|
@@ -203,11 +201,9 @@ class DeviceErv extends EventEmitter {
|
|
|
203
201
|
this.model = modelIndoor ? modelIndoor : modelOutdoor ? modelOutdoor : `${deviceTypeText} ${this.deviceId}`;
|
|
204
202
|
this.serialNumber = serialNumber;
|
|
205
203
|
this.firmwareRevision = firmwareAppVersion;
|
|
206
|
-
|
|
207
|
-
//device info
|
|
208
|
-
|
|
204
|
+
this.displayDeviceInfo = false;
|
|
209
205
|
})
|
|
210
|
-
.on('deviceState', async (deviceData
|
|
206
|
+
.on('deviceState', async (deviceData) => {
|
|
211
207
|
//device info
|
|
212
208
|
const displayMode = this.displayMode;
|
|
213
209
|
const hasCoolOperationMode = deviceData.Device.HasCoolOperationMode ?? false;
|
|
@@ -236,35 +232,36 @@ class DeviceErv extends EventEmitter {
|
|
|
236
232
|
const presetsOnServer = deviceData.Presets ?? [];
|
|
237
233
|
|
|
238
234
|
//device state
|
|
239
|
-
const
|
|
240
|
-
const
|
|
241
|
-
const
|
|
242
|
-
const
|
|
243
|
-
const
|
|
244
|
-
const
|
|
245
|
-
const
|
|
246
|
-
const
|
|
247
|
-
const
|
|
248
|
-
const
|
|
249
|
-
const
|
|
250
|
-
const
|
|
251
|
-
const
|
|
252
|
-
const temperatureUnit = CONSTANTS.TemperatureDisplayUnits[useFahrenheit];
|
|
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;
|
|
248
|
+
const temperatureUnit = CONSTANTS.TemperatureDisplayUnits[this.useFahrenheit];
|
|
253
249
|
|
|
254
250
|
//set temperature
|
|
255
251
|
const targetTemperature = hasCoolOperationMode || hasHeatOperationMode ? setTemperature : 20;
|
|
256
252
|
|
|
257
253
|
//accessory
|
|
258
254
|
this.accessory.presetsOnServer = presetsOnServer;
|
|
259
|
-
this.accessory.power = power;
|
|
260
|
-
this.accessory.offline = offline;
|
|
255
|
+
this.accessory.power = power ? 1 : 0;
|
|
256
|
+
this.accessory.offline = offline ?? false;
|
|
261
257
|
this.accessory.roomTemperature = roomTemperature;
|
|
262
258
|
this.accessory.outdoorTemperature = outdoorTemperature;
|
|
263
259
|
this.accessory.supplyTemperature = supplyTemperature;
|
|
264
260
|
this.accessory.setTemperature = targetTemperature;
|
|
265
261
|
this.accessory.setFanSpeed = setFanSpeed;
|
|
262
|
+
this.accessory.lockPhysicalControl = 0;
|
|
266
263
|
this.accessory.temperatureIncrement = temperatureIncrement;
|
|
267
|
-
this.accessory.useFahrenheit = useFahrenheit;
|
|
264
|
+
this.accessory.useFahrenheit = this.useFahrenheit;
|
|
268
265
|
this.accessory.temperatureUnit = temperatureUnit;
|
|
269
266
|
this.accessory.hasAutomaticFanSpeed = hasAutomaticFanSpeed;
|
|
270
267
|
this.accessory.hasOutdoorTemperature = hasOutdoorTemperature;
|
|
@@ -331,6 +328,7 @@ class DeviceErv extends EventEmitter {
|
|
|
331
328
|
this.accessory.operationModeSetPropsValidValues = hasAutoVentilationMode ? (hasBypassVentilationMode ? [0, 1, 2] : [0, 2]) : (hasBypassVentilationMode ? [1, 2] : [2]);
|
|
332
329
|
|
|
333
330
|
//fan speed mode
|
|
331
|
+
this.accessory.fanSpeedSetPropsMaxValue = 2;
|
|
334
332
|
switch (numberOfFanSpeeds) {
|
|
335
333
|
case 2: //Fan speed mode 2
|
|
336
334
|
this.accessory.fanSpeed = hasAutomaticFanSpeed ? [3, 1, 2][setFanSpeed] : [0, 1, 2][setFanSpeed];
|
|
@@ -349,13 +347,13 @@ class DeviceErv extends EventEmitter {
|
|
|
349
347
|
//update characteristics
|
|
350
348
|
if (this.melCloudService) {
|
|
351
349
|
this.melCloudService
|
|
352
|
-
.updateCharacteristic(Characteristic.Active, power
|
|
350
|
+
.updateCharacteristic(Characteristic.Active, this.accessory.power)
|
|
353
351
|
.updateCharacteristic(Characteristic.CurrentHeaterCoolerState, this.accessory.currentOperationMode)
|
|
354
352
|
.updateCharacteristic(Characteristic.TargetHeaterCoolerState, this.accessory.targetOperationMode)
|
|
355
353
|
.updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
|
|
356
354
|
.updateCharacteristic(Characteristic.RotationSpeed, this.accessory.fanSpeed)
|
|
357
355
|
.updateCharacteristic(Characteristic.LockPhysicalControls, this.accessory.lockPhysicalControl)
|
|
358
|
-
.updateCharacteristic(Characteristic.TemperatureDisplayUnits, useFahrenheit);
|
|
356
|
+
.updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.accessory.useFahrenheit);
|
|
359
357
|
const updateHOM = hasHeatOperationMode ? this.melCloudService.updateCharacteristic(Characteristic.HeatingThresholdTemperature, targetTemperature) : false;
|
|
360
358
|
const updateCOM = hasCoolOperationMode ? this.melCloudService.updateCharacteristic(Characteristic.CoolingThresholdTemperature, targetTemperature) : false;
|
|
361
359
|
};
|
|
@@ -408,9 +406,12 @@ class DeviceErv extends EventEmitter {
|
|
|
408
406
|
.updateCharacteristic(Characteristic.TargetHeatingCoolingState, this.accessory.targetOperationMode)
|
|
409
407
|
.updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
|
|
410
408
|
.updateCharacteristic(Characteristic.TargetTemperature, targetTemperature)
|
|
411
|
-
.updateCharacteristic(Characteristic.TemperatureDisplayUnits, useFahrenheit);
|
|
409
|
+
.updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.accessory.useFahrenheit);
|
|
412
410
|
};
|
|
413
411
|
break;
|
|
412
|
+
default:
|
|
413
|
+
this.emit('warn', `Unknown display mode: ${displayMode}`);
|
|
414
|
+
return;
|
|
414
415
|
};
|
|
415
416
|
|
|
416
417
|
//update temperature sensors
|
|
@@ -459,8 +460,7 @@ class DeviceErv extends EventEmitter {
|
|
|
459
460
|
if (this.presetsConfigured.length > 0) {
|
|
460
461
|
for (let i = 0; i < this.presetsConfigured.length; i++) {
|
|
461
462
|
const preset = this.presetsConfigured[i];
|
|
462
|
-
const
|
|
463
|
-
const presetData = presetsOnServer[index];
|
|
463
|
+
const presetData = presetsOnServer.find(p => p.ID === preset.Id);
|
|
464
464
|
|
|
465
465
|
preset.state = presetData ? (presetData.Power === power
|
|
466
466
|
&& presetData.SetTemperature === targetTemperature
|
|
@@ -566,7 +566,7 @@ class DeviceErv extends EventEmitter {
|
|
|
566
566
|
}
|
|
567
567
|
|
|
568
568
|
try {
|
|
569
|
-
const accessory = await this.prepareAccessory(this.accountInfo,
|
|
569
|
+
const accessory = await this.prepareAccessory(this.accountInfo, deviceData, this.deviceId, this.deviceTypeText, this.deviceName, this.accountName);
|
|
570
570
|
this.emit('publishAccessory', accessory);
|
|
571
571
|
this.startPrepareAccessory = false;
|
|
572
572
|
} catch (error) {
|
|
@@ -584,8 +584,6 @@ class DeviceErv extends EventEmitter {
|
|
|
584
584
|
})
|
|
585
585
|
.on('error', async (error) => {
|
|
586
586
|
this.emit('error', error);
|
|
587
|
-
await new Promise(resolve => setTimeout(resolve, 15000));
|
|
588
|
-
await this.melCloudErv.impulseGenerator.start([{ name: 'checkState', sampling: this.refreshInterval }]);
|
|
589
587
|
});
|
|
590
588
|
|
|
591
589
|
//check state
|
|
@@ -600,64 +598,64 @@ class DeviceErv extends EventEmitter {
|
|
|
600
598
|
};
|
|
601
599
|
};
|
|
602
600
|
|
|
603
|
-
async setOverExternalIntegration(integration,
|
|
601
|
+
async setOverExternalIntegration(integration, deviceData, key, value) {
|
|
604
602
|
try {
|
|
605
603
|
let set = false
|
|
606
604
|
switch (key) {
|
|
607
605
|
case 'Power':
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
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);
|
|
611
609
|
break;
|
|
612
610
|
case 'OperationMode':
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
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);
|
|
616
614
|
break;
|
|
617
615
|
case 'VentilationMode':
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
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);
|
|
621
619
|
break;
|
|
622
620
|
case 'SetTemperature':
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
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);
|
|
626
624
|
break;
|
|
627
625
|
case 'DefaultCoolingSetTemperature':
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
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);
|
|
631
629
|
break;
|
|
632
630
|
case 'DefaultHeatingSetTemperature':
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
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);
|
|
636
634
|
break;
|
|
637
635
|
case 'NightPurgeMode':
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
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);
|
|
641
639
|
break;
|
|
642
640
|
case 'SetFanSpeed':
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
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);
|
|
646
644
|
break;
|
|
647
645
|
case 'HideRoomTemperature':
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
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);
|
|
651
649
|
break;
|
|
652
650
|
case 'HideSupplyTemperature':
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
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);
|
|
656
654
|
break;
|
|
657
655
|
case 'HideOutdoorTemperature':
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
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);
|
|
661
659
|
break;
|
|
662
660
|
default:
|
|
663
661
|
this.emit('warn', `${integration}, received key: ${key}, value: ${value}`);
|
|
@@ -670,7 +668,7 @@ class DeviceErv extends EventEmitter {
|
|
|
670
668
|
}
|
|
671
669
|
|
|
672
670
|
//prepare accessory
|
|
673
|
-
async prepareAccessory(accountInfo,
|
|
671
|
+
async prepareAccessory(accountInfo, deviceData, deviceId, deviceTypeText, deviceName, accountName) {
|
|
674
672
|
try {
|
|
675
673
|
//accessory
|
|
676
674
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare accessory`) : false;
|
|
@@ -716,9 +714,9 @@ class DeviceErv extends EventEmitter {
|
|
|
716
714
|
})
|
|
717
715
|
.onSet(async (state) => {
|
|
718
716
|
try {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
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);
|
|
722
720
|
const info = this.disableLogInfo ? false : this.emit('message', `Set power: ${state ? 'ON' : 'OFF'}`);
|
|
723
721
|
} catch (error) {
|
|
724
722
|
this.emit('warn', `Set power error: ${error}`);
|
|
@@ -743,21 +741,21 @@ class DeviceErv extends EventEmitter {
|
|
|
743
741
|
try {
|
|
744
742
|
switch (value) {
|
|
745
743
|
case 0: //AUTO - AUTO
|
|
746
|
-
|
|
747
|
-
|
|
744
|
+
deviceData.Device.VentilationMode = hasAutoVentilationMode ? 2 : 0;
|
|
745
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.VentilationMode;
|
|
748
746
|
break;
|
|
749
747
|
case 1: //HEAT - LOSSNAY
|
|
750
|
-
|
|
751
|
-
|
|
748
|
+
deviceData.Device.VentilationMode = 0;
|
|
749
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.VentilationMode;
|
|
752
750
|
break;
|
|
753
751
|
case 2: //COOL - BYPASS
|
|
754
|
-
|
|
755
|
-
|
|
752
|
+
deviceData.Device.VentilationMode = hasBypassVentilationMode ? 1 : 0;
|
|
753
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.VentilationMode;
|
|
756
754
|
break;
|
|
757
755
|
};
|
|
758
756
|
|
|
759
|
-
await this.melCloudErv.send(
|
|
760
|
-
const operationModeText = CONSTANTS.Ventilation.VentilationMode[
|
|
757
|
+
await this.melCloudErv.send(deviceData);
|
|
758
|
+
const operationModeText = CONSTANTS.Ventilation.VentilationMode[deviceData.Device.VentilationMode];
|
|
761
759
|
const info = this.disableLogInfo ? false : this.emit('message', `Set operation mode: ${operationModeText}`);
|
|
762
760
|
} catch (error) {
|
|
763
761
|
this.emit('warn', `Set operation mode error: ${error}`);
|
|
@@ -778,21 +776,21 @@ class DeviceErv extends EventEmitter {
|
|
|
778
776
|
let fanSpeedModeText = 0; //AUTO, 1, 2, 3, 4, OFF
|
|
779
777
|
switch (ataNumberOfFanSpeeds) {
|
|
780
778
|
case 2: //Fan speed mode 2
|
|
781
|
-
|
|
779
|
+
deviceData.Device.SetFanSpeed = ataHasAutomaticFanSpeed ? [0, 1, 2, 0][value] : [1, 1, 2][value];
|
|
782
780
|
fanSpeedModeText = ataHasAutomaticFanSpeed ? [5, 1, 2, 0][value] : [5, 1, 2][value];
|
|
783
781
|
break;
|
|
784
782
|
case 3: //Fan speed mode 3
|
|
785
|
-
|
|
783
|
+
deviceData.Device.SetFanSpeed = ataHasAutomaticFanSpeed ? [0, 1, 2, 3, 0][value] : [1, 1, 2, 3][value];
|
|
786
784
|
fanSpeedModeText = ataHasAutomaticFanSpeed ? [5, 1, 2, 3, 0][value] : [5, 1, 2, 3][value];
|
|
787
785
|
break;
|
|
788
786
|
case 4: //Fan speed mode 4
|
|
789
|
-
|
|
787
|
+
deviceData.Device.SetFanSpeed = ataHasAutomaticFanSpeed ? [0, 1, 2, 3, 4, 0][value] : [1, 1, 2, 3, 4][value];
|
|
790
788
|
fanSpeedModeText = ataHasAutomaticFanSpeed ? [5, 1, 2, 3, 4, 0][value] : [5, 1, 2, 3, 4][value];
|
|
791
789
|
break;
|
|
792
790
|
};
|
|
793
791
|
|
|
794
|
-
|
|
795
|
-
await this.melCloudErv.send(
|
|
792
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.SetFanSpeed;
|
|
793
|
+
await this.melCloudErv.send(deviceData);
|
|
796
794
|
const info = this.disableLogInfo ? false : this.emit('message', `Set fan speed mode: ${CONSTANTS.Ventilation.FanSpeed[fanSpeedModeText]}`);
|
|
797
795
|
} catch (error) {
|
|
798
796
|
this.emit('warn', `Set fan speed mode error: ${error}`);
|
|
@@ -822,9 +820,9 @@ class DeviceErv extends EventEmitter {
|
|
|
822
820
|
})
|
|
823
821
|
.onSet(async (value) => {
|
|
824
822
|
try {
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
await this.melCloudErv.send(
|
|
823
|
+
deviceData.Device.SetTemperature = value;
|
|
824
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.SetTemperature;
|
|
825
|
+
await this.melCloudErv.send(deviceData);
|
|
828
826
|
const info = this.disableLogInfo ? false : this.emit('message', `Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
829
827
|
} catch (error) {
|
|
830
828
|
this.emit('warn', `Set heating threshold temperature error: ${error}`);
|
|
@@ -845,9 +843,9 @@ class DeviceErv extends EventEmitter {
|
|
|
845
843
|
})
|
|
846
844
|
.onSet(async (value) => {
|
|
847
845
|
try {
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
await this.melCloudErv.send(
|
|
846
|
+
deviceData.Device.SetTemperature = value;
|
|
847
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.SetTemperature;
|
|
848
|
+
await this.melCloudErv.send(deviceData);
|
|
851
849
|
const info = this.disableLogInfo ? false : this.emit('message', `Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
852
850
|
} catch (error) {
|
|
853
851
|
this.emit('warn', `Set cooling threshold temperature error: ${error}`);
|
|
@@ -863,9 +861,9 @@ class DeviceErv extends EventEmitter {
|
|
|
863
861
|
// .onSet(async (value) => {
|
|
864
862
|
// try {
|
|
865
863
|
// value = value ? true : false;
|
|
866
|
-
//
|
|
867
|
-
//
|
|
868
|
-
// await this.melCloudErv.send(
|
|
864
|
+
// deviceData.Device = deviceData.Device;
|
|
865
|
+
// deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Prohibit;
|
|
866
|
+
// await this.melCloudErv.send(deviceData);
|
|
869
867
|
// const info = this.disableLogInfo ? false : this.emit('message', `Set local physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
|
|
870
868
|
// } catch (error) {
|
|
871
869
|
// this.emit('warn', `Set lock physical controls error: ${error}`);
|
|
@@ -908,28 +906,28 @@ class DeviceErv extends EventEmitter {
|
|
|
908
906
|
try {
|
|
909
907
|
switch (value) {
|
|
910
908
|
case 0: //OFF - POWER OFF
|
|
911
|
-
|
|
912
|
-
|
|
909
|
+
deviceData.Device.Power = false;
|
|
910
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power;
|
|
913
911
|
break;
|
|
914
912
|
case 1: //HEAT - LOSSNAY
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
913
|
+
deviceData.Device.Power = true;
|
|
914
|
+
deviceData.Device.VentilationMode = 0;
|
|
915
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power + CONSTANTS.Ventilation.EffectiveFlags.VentilationMode;
|
|
918
916
|
break;
|
|
919
917
|
case 2: //COOL - BYPASS
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
918
|
+
deviceData.Device.Power = true;
|
|
919
|
+
deviceData.Device.VentilationMode = hasBypassVentilationMode ? 1 : 0;
|
|
920
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power + CONSTANTS.Ventilation.EffectiveFlags.VentilationMode;
|
|
923
921
|
break;
|
|
924
922
|
case 3: //AUTO - AUTO
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
923
|
+
deviceData.Device.Power = true;
|
|
924
|
+
deviceData.Device.VentilationMode = hasAutoVentilationMode ? 2 : 0;
|
|
925
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Power + CONSTANTS.Ventilation.EffectiveFlags.VentilationMode;
|
|
928
926
|
break;
|
|
929
927
|
};
|
|
930
928
|
|
|
931
|
-
await this.melCloudErv.send(
|
|
932
|
-
const operationModeText = CONSTANTS.Ventilation.VentilationMode[
|
|
929
|
+
await this.melCloudErv.send(deviceData);
|
|
930
|
+
const operationModeText = CONSTANTS.Ventilation.VentilationMode[deviceData.Device.VentilationMode];
|
|
933
931
|
const info = this.disableLogInfo ? false : this.emit('message', `Set operation mode: ${operationModeText}`);
|
|
934
932
|
} catch (error) {
|
|
935
933
|
this.emit('warn', `Set operation mode error: ${error}`);
|
|
@@ -957,9 +955,9 @@ class DeviceErv extends EventEmitter {
|
|
|
957
955
|
})
|
|
958
956
|
.onSet(async (value) => {
|
|
959
957
|
try {
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
await this.melCloudErv.send(
|
|
958
|
+
deviceData.Device.SetTemperature = value;
|
|
959
|
+
deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.SetTemperature;
|
|
960
|
+
await this.melCloudErv.send(deviceData);
|
|
963
961
|
const info = this.disableLogInfo ? false : this.emit('message', `Set temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
964
962
|
} catch (error) {
|
|
965
963
|
this.emit('warn', `Set temperature error: ${error}`);
|
|
@@ -1111,8 +1109,7 @@ class DeviceErv extends EventEmitter {
|
|
|
1111
1109
|
|
|
1112
1110
|
for (let i = 0; i < presetsConfiguredCount; i++) {
|
|
1113
1111
|
const preset = presetsConfigured[i];
|
|
1114
|
-
const
|
|
1115
|
-
const presetData = presetsOnServer[index]
|
|
1112
|
+
const presetData = presetsOnServer.find(p => p.ID === preset.Id);
|
|
1116
1113
|
|
|
1117
1114
|
//get preset name
|
|
1118
1115
|
const presetName = preset.name;
|
|
@@ -1139,27 +1136,27 @@ class DeviceErv extends EventEmitter {
|
|
|
1139
1136
|
try {
|
|
1140
1137
|
switch (state) {
|
|
1141
1138
|
case true:
|
|
1142
|
-
previousPresets[i] =
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
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;
|
|
1149
1146
|
break;
|
|
1150
1147
|
case false:
|
|
1151
|
-
|
|
1148
|
+
deviceData.Device = previousPresets[i];
|
|
1152
1149
|
break;
|
|
1153
1150
|
};
|
|
1154
1151
|
|
|
1155
|
-
await this.melCloudErv.send(
|
|
1152
|
+
await this.melCloudErv.send(deviceData);
|
|
1156
1153
|
const info = this.disableLogInfo ? false : this.emit('message', `Set: ${presetName}`);
|
|
1157
1154
|
} catch (error) {
|
|
1158
1155
|
this.emit('warn', `Set preset error: ${error}`);
|
|
1159
1156
|
};
|
|
1160
1157
|
});
|
|
1161
1158
|
};
|
|
1162
|
-
previousPresets.push(
|
|
1159
|
+
previousPresets.push(deviceData.Device);
|
|
1163
1160
|
this.presetsServices.push(presetService);
|
|
1164
1161
|
accessory.addService(presetService);
|
|
1165
1162
|
};
|
|
@@ -1196,84 +1193,84 @@ class DeviceErv extends EventEmitter {
|
|
|
1196
1193
|
const state = button.state;
|
|
1197
1194
|
return state;
|
|
1198
1195
|
})
|
|
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
|
-
|
|
1268
|
-
|
|
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
|
+
};
|
|
1269
1266
|
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
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
|
+
};
|
|
1274
1272
|
};
|
|
1275
1273
|
});
|
|
1276
|
-
};
|
|
1277
1274
|
this.buttonsServices.push(buttonService);
|
|
1278
1275
|
accessory.addService(buttonService);
|
|
1279
1276
|
};
|