homebridge-melcloud-control 4.4.0-beta.0 → 4.4.0-beta.10
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/package.json +1 -1
- package/src/deviceata.js +18 -10
- package/src/functions.js +20 -34
- package/src/melcloudata.js +11 -6
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.4.0-beta.
|
|
4
|
+
"version": "4.4.0-beta.10",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
package/src/deviceata.js
CHANGED
|
@@ -758,8 +758,10 @@ class DeviceAta extends EventEmitter {
|
|
|
758
758
|
})
|
|
759
759
|
.onSet(async (value) => {
|
|
760
760
|
try {
|
|
761
|
-
deviceData.FrostProtection.Max
|
|
762
|
-
|
|
761
|
+
let { min, max } = await this.functions.adjustTempProtection(deviceData.FrostProtection.Min, deviceData.FrostProtection.Max, value, 4, 14, 6, 16);
|
|
762
|
+
deviceData.FrostProtection.Min = min;
|
|
763
|
+
deviceData.FrostProtection.Max = max;
|
|
764
|
+
if (this.logInfo) this.emit('info', `Set frost protection max. temperature: ${max}${this.accessory.temperatureUnit}`);
|
|
763
765
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'frostprotection');
|
|
764
766
|
} catch (error) {
|
|
765
767
|
if (this.logWarn) this.emit('warn', `Set frost protection max. temperature error: ${error}`);
|
|
@@ -777,8 +779,10 @@ class DeviceAta extends EventEmitter {
|
|
|
777
779
|
})
|
|
778
780
|
.onSet(async (value) => {
|
|
779
781
|
try {
|
|
780
|
-
deviceData.FrostProtection.Min
|
|
781
|
-
|
|
782
|
+
let { min, max } = await this.functions.adjustTempProtection(deviceData.FrostProtection.Min, deviceData.FrostProtection.Max, value, 4, 14, 6, 16);
|
|
783
|
+
deviceData.FrostProtection.Min = min;
|
|
784
|
+
deviceData.FrostProtection.Max = max;
|
|
785
|
+
if (this.logInfo) this.emit('info', `Set frost protection min. temperature: ${min}${this.accessory.temperatureUnit}`);
|
|
782
786
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'frostprotection');
|
|
783
787
|
} catch (error) {
|
|
784
788
|
if (this.logWarn) this.emit('warn', `Set frost protection min. temperature error: ${error}`);
|
|
@@ -873,8 +877,10 @@ class DeviceAta extends EventEmitter {
|
|
|
873
877
|
})
|
|
874
878
|
.onSet(async (value) => {
|
|
875
879
|
try {
|
|
876
|
-
deviceData.OverheatProtection.Max
|
|
877
|
-
|
|
880
|
+
let { min, max } = await this.functions.adjustTempProtection(deviceData.OverheatProtection.Min, deviceData.OverheatProtection.Max, value, 31, 38, 33, 40);
|
|
881
|
+
deviceData.OverheatProtection.Min = min;
|
|
882
|
+
deviceData.OverheatProtection.Max = max;
|
|
883
|
+
if (this.logInfo) this.emit('info', `Set overheat protection max. temperature: ${max}${this.accessory.temperatureUnit}`);
|
|
878
884
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'overheatprotection');
|
|
879
885
|
} catch (error) {
|
|
880
886
|
if (this.logWarn) this.emit('warn', `Set overheat protection max. temperature error: ${error}`);
|
|
@@ -892,8 +898,10 @@ class DeviceAta extends EventEmitter {
|
|
|
892
898
|
})
|
|
893
899
|
.onSet(async (value) => {
|
|
894
900
|
try {
|
|
895
|
-
deviceData.OverheatProtection.Min
|
|
896
|
-
|
|
901
|
+
let { min, max } = await this.functions.adjustTempProtection(deviceData.OverheatProtection.Min, deviceData.OverheatProtection.Max, value, 31, 38, 33, 40);
|
|
902
|
+
deviceData.OverheatProtection.Min = min;
|
|
903
|
+
deviceData.OverheatProtection.Max = max;
|
|
904
|
+
if (this.logInfo) this.emit('info', `Set overheat protection min. temperature: ${min}${this.accessory.temperatureUnit}`);
|
|
897
905
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'overheatprotection');
|
|
898
906
|
} catch (error) {
|
|
899
907
|
if (this.logWarn) this.emit('warn', `Set overheat protection min. temperature error: ${error}`);
|
|
@@ -1767,7 +1775,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1767
1775
|
if (this.frostProtectionSupport && frostProtection.Enabled !== null) {
|
|
1768
1776
|
this.frostProtectionControlService?.updateCharacteristic(Characteristic.Active, frostProtection.Enabled);
|
|
1769
1777
|
this.frostProtectionControlService?.updateCharacteristic(Characteristic.CurrentHeaterCoolerState, frostProtection.Active ? 2 : 1);
|
|
1770
|
-
this.frostProtectionControlService?.updateCharacteristic(Characteristic.TargetHeaterCoolerState,
|
|
1778
|
+
this.frostProtectionControlService?.updateCharacteristic(Characteristic.TargetHeaterCoolerState, 0);
|
|
1771
1779
|
this.frostProtectionControlService?.updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature);
|
|
1772
1780
|
this.frostProtectionControlService?.updateCharacteristic(Characteristic.CoolingThresholdTemperature, frostProtection.Max);
|
|
1773
1781
|
this.frostProtectionControlService?.updateCharacteristic(Characteristic.HeatingThresholdTemperature, frostProtection.Min);
|
|
@@ -1779,7 +1787,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1779
1787
|
if (this.overheatProtectionSupport && overheatProtection.Enabled !== null) {
|
|
1780
1788
|
this.overheatProtectionControlService?.updateCharacteristic(Characteristic.Active, overheatProtection.Enabled);
|
|
1781
1789
|
this.overheatProtectionControlService?.updateCharacteristic(Characteristic.CurrentHeaterCoolerState, overheatProtection.Active ? 2 : 1);
|
|
1782
|
-
this.overheatProtectionControlService?.updateCharacteristic(Characteristic.TargetHeaterCoolerState,
|
|
1790
|
+
this.overheatProtectionControlService?.updateCharacteristic(Characteristic.TargetHeaterCoolerState, 0);
|
|
1783
1791
|
this.overheatProtectionControlService?.updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature);
|
|
1784
1792
|
this.overheatProtectionControlService?.updateCharacteristic(Characteristic.CoolingThresholdTemperature, overheatProtection.Max);
|
|
1785
1793
|
this.overheatProtectionControlService?.updateCharacteristic(Characteristic.HeatingThresholdTemperature, overheatProtection.Min);
|
package/src/functions.js
CHANGED
|
@@ -238,47 +238,33 @@ class Functions extends EventEmitter {
|
|
|
238
238
|
);
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
async
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
if (
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
// Otherwise lower min
|
|
254
|
-
const newMin = max - 2;
|
|
255
|
-
min = Math.max(newMin, 4);
|
|
241
|
+
async adjustTempProtectionSingle(oldMin, oldMax, newValue, minRangeMin, maxRangeMin, minRangeMax, maxRangeMax) {
|
|
242
|
+
let min = oldMin;
|
|
243
|
+
let max = oldMax;
|
|
244
|
+
|
|
245
|
+
// Wykryj, którą wartość zmieniono
|
|
246
|
+
if (newValue !== oldMin) {
|
|
247
|
+
// użytkownik zmienił MIN
|
|
248
|
+
min = Math.min(Math.max(newValue, minRangeMin), maxRangeMin);
|
|
249
|
+
|
|
250
|
+
if (max - min < 2) {
|
|
251
|
+
// podnieś MAX, ale nie przekraczając maxRangeMax
|
|
252
|
+
max = Math.min(min + 2, maxRangeMax);
|
|
256
253
|
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
254
|
+
} else if (newValue !== oldMax) {
|
|
255
|
+
// użytkownik zmienił MAX
|
|
256
|
+
max = Math.min(Math.max(newValue, minRangeMax), maxRangeMax);
|
|
261
257
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
max = Math.min(Math.max(max, 33), 40);
|
|
266
|
-
|
|
267
|
-
// Ensure difference of at least 2 degrees
|
|
268
|
-
if (max - min < 2) {
|
|
269
|
-
// Try increasing max if possible
|
|
270
|
-
const newMax = min + 2;
|
|
271
|
-
if (newMax <= 18) {
|
|
272
|
-
max = newMax;
|
|
273
|
-
} else {
|
|
274
|
-
// Otherwise lower min
|
|
275
|
-
const newMin = max - 2;
|
|
276
|
-
min = Math.max(newMin, 4);
|
|
258
|
+
if (max - min < 2) {
|
|
259
|
+
// obniż MIN, ale nie przekraczając minRangeMin
|
|
260
|
+
min = Math.max(max - 2, minRangeMin);
|
|
277
261
|
}
|
|
278
262
|
}
|
|
279
263
|
|
|
280
264
|
return { min, max };
|
|
281
265
|
}
|
|
266
|
+
|
|
267
|
+
|
|
282
268
|
}
|
|
283
269
|
|
|
284
270
|
export default Functions
|
package/src/melcloudata.js
CHANGED
|
@@ -240,22 +240,20 @@ class MelCloudAta extends EventEmitter {
|
|
|
240
240
|
case "melcloudhome":
|
|
241
241
|
switch (flag) {
|
|
242
242
|
case 'frostprotection':
|
|
243
|
-
let { frostMin, frostMax } = await this.functions.normalizeFrostProtection(deviceData.FrostProtection.Min, deviceData.FrostProtection.Max);
|
|
244
243
|
payload = {
|
|
245
244
|
enabled: deviceData.FrostProtection.Enabled,
|
|
246
|
-
min:
|
|
247
|
-
max:
|
|
245
|
+
min: deviceData.FrostProtection.Min,
|
|
246
|
+
max: deviceData.FrostProtection.Max,
|
|
248
247
|
units: { ATA: [deviceData.DeviceID] }
|
|
249
248
|
};
|
|
250
249
|
method = 'POST';
|
|
251
250
|
path = ApiUrlsHome.PostProtectionFrost;
|
|
252
251
|
break;
|
|
253
252
|
case 'overheatprotection':
|
|
254
|
-
let { overMin, overMax } = await this.functions.normalizeOverheatProtection(deviceData.OverheatProtection.Min, deviceData.OverheatProtection.Max);
|
|
255
253
|
payload = {
|
|
256
254
|
enabled: deviceData.OverheatProtection.Enabled,
|
|
257
|
-
min:
|
|
258
|
-
max:
|
|
255
|
+
min: deviceData.OverheatProtection.Min,
|
|
256
|
+
max: deviceData.OverheatProtection.Max,
|
|
259
257
|
units: { ATA: [deviceData.DeviceID] }
|
|
260
258
|
};
|
|
261
259
|
method = 'POST';
|
|
@@ -311,6 +309,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
311
309
|
//send payload
|
|
312
310
|
if (this.logDebug) this.emit('debug', `Send data: ${JSON.stringify(payload, null, 2)}`);
|
|
313
311
|
await this.client(path, { method: method, data: payload });
|
|
312
|
+
this.update(deviceData);
|
|
314
313
|
|
|
315
314
|
return true;
|
|
316
315
|
default:
|
|
@@ -320,6 +319,12 @@ class MelCloudAta extends EventEmitter {
|
|
|
320
319
|
throw new Error(`Send data error: ${error.message}`);
|
|
321
320
|
}
|
|
322
321
|
}
|
|
322
|
+
|
|
323
|
+
update(deviceData) {
|
|
324
|
+
setTimeout(() => {
|
|
325
|
+
this.emit('deviceState', deviceData)
|
|
326
|
+
}, 500);
|
|
327
|
+
}
|
|
323
328
|
}
|
|
324
329
|
|
|
325
330
|
export default MelCloudAta;
|