homebridge-melcloud-control 4.2.6-beta.13 → 4.2.6-beta.14

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 CHANGED
@@ -86,8 +86,6 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
86
86
  * Outdoor temperature.
87
87
  * Frost protection.
88
88
  * Overheat protection.
89
- * Frost protection.
90
- * Overheat protection.
91
89
  * Holiday mode.
92
90
  * Shedules control.
93
91
  * Shedule active.
@@ -255,7 +253,7 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
255
253
  | `ataDevices[].inStandbySensor` | This enable `In Standby Mode` sensor to use with automations in HomeKit app. |
256
254
  | `ataDevices[].connectSensor` | This enable `Connect State` sensor to use with automations in HomeKit app. |
257
255
  | `ataDevices[].errorSensor` | This enable `Error` sensor to use with automations in HomeKit app. |
258
- | `ataDevices[].frostProtectionSupport` | This enable extra `Frost Protectio` control and sensors to use with automations in HomeKit app. |
256
+ | `ataDevices[].frostProtectionSupport` | This enable extra `Frost Protection` control and sensors to use with automations in HomeKit app. |
259
257
  | `ataDevices[].overheatProtectionSupport` | This enable extra `Overheat Protection` control and sensors to use with automations in HomeKit app. |
260
258
  | `ataDevices[].holidayModeSupport` | This enable extra `Holiday Mode` control and sensors to use with automations in HomeKit app. |
261
259
  | `ataDevices[].refreshInterval` | Here set the background devices state refresh time in (sec), default `5s`. |
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.2.6-beta.13",
4
+ "version": "4.2.6-beta.14",
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
@@ -1469,6 +1469,9 @@ class DeviceAta extends EventEmitter {
1469
1469
  scheduleEnabled: scheduleEnabled
1470
1470
  };
1471
1471
 
1472
+ //characteristics array
1473
+ const characteristics = [];
1474
+
1472
1475
  //operating mode 0, HEAT, DRY, COOL, 4, 5, 6, FAN, AUTO, ISEE HEAT, ISEE DRY, ISEE COOL
1473
1476
  switch (this.displayType) {
1474
1477
  case 1: //Heater Cooler
@@ -1534,18 +1537,20 @@ class DeviceAta extends EventEmitter {
1534
1537
  }
1535
1538
  this.accessory = obj;
1536
1539
 
1537
- //update characteristics
1538
- this.melCloudService
1539
- ?.updateCharacteristic(Characteristic.Active, power)
1540
- .updateCharacteristic(Characteristic.CurrentHeaterCoolerState, obj.currentOperationMode)
1541
- .updateCharacteristic(Characteristic.TargetHeaterCoolerState, obj.targetOperationMode)
1542
- .updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
1543
- .updateCharacteristic(Characteristic.LockPhysicalControls, obj.lockPhysicalControl)
1544
- .updateCharacteristic(Characteristic.TemperatureDisplayUnits, obj.useFahrenheit)
1545
- .updateCharacteristic(Characteristic.CoolingThresholdTemperature, operationMode === 8 ? defaultCoolingSetTemperature : setTemperature);
1546
- if (supportsHeat) this.melCloudService?.updateCharacteristic(Characteristic.HeatingThresholdTemperature, operationMode === 8 ? defaultHeatingSetTemperature : setTemperature);
1547
- if (supportsFanSpeed) this.melCloudService?.updateCharacteristic(Characteristic.RotationSpeed, obj.currentFanSpeed);
1548
- if (supportsSwingFunction) this.melCloudService?.updateCharacteristic(Characteristic.SwingMode, obj.currentSwingMode);
1540
+ //create characteristics
1541
+ characteristics.push(
1542
+ { type: Characteristic.Active, value: power },
1543
+ { type: Characteristic.CurrentHeaterCoolerState, value: obj.currentOperationMode },
1544
+ { type: Characteristic.TargetHeaterCoolerState, value: obj.targetOperationMode },
1545
+ { type: Characteristic.CurrentTemperature, value: roomTemperature },
1546
+ { type: Characteristic.LockPhysicalControls, value: obj.lockPhysicalControl },
1547
+ { type: Characteristic.TemperatureDisplayUnits, value: obj.useFahrenheit },
1548
+ { type: Characteristic.CoolingThresholdTemperature, value: operationMode === 8 ? defaultCoolingSetTemperature : setTemperature }
1549
+ );
1550
+
1551
+ if (supportsHeat) characteristics.push({ type: Characteristic.HeatingThresholdTemperature, value: operationMode === 8 ? defaultHeatingSetTemperature : setTemperature });
1552
+ if (supportsFanSpeed) characteristics.push({ type: Characteristic.RotationSpeed, value: obj.currentFanSpeed });
1553
+ if (supportsSwingFunction) characteristics.push({ type: Characteristic.SwingMode, value: obj.currentSwingMode });
1549
1554
  break;
1550
1555
  case 2: //Thermostat
1551
1556
  // Helper for mapping target operation in DRY / FAN modes
@@ -1606,16 +1611,23 @@ class DeviceAta extends EventEmitter {
1606
1611
  obj.operationModeSetPropsValidValues = supportsAuto && supportsHeat ? [0, 1, 2, 3] : !supportsAuto && supportsHeat ? [0, 1, 2] : supportsAuto && !supportsHeat ? [0, 2, 3] : [0, 2];
1607
1612
  this.accessory = obj;
1608
1613
 
1609
- //update characteristics
1610
- this.melCloudService
1611
- ?.updateCharacteristic(Characteristic.CurrentHeatingCoolingState, obj.currentOperationMode)
1612
- .updateCharacteristic(Characteristic.TargetHeatingCoolingState, obj.targetOperationMode)
1613
- .updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
1614
- .updateCharacteristic(Characteristic.TargetTemperature, setTemperature)
1615
- .updateCharacteristic(Characteristic.TemperatureDisplayUnits, obj.useFahrenheit);
1614
+ //create characteristics
1615
+ characteristics.push(
1616
+ { type: Characteristic.CurrentHeatingCoolingState, value: obj.currentOperationMode },
1617
+ { type: Characteristic.TargetHeatingCoolingState, value: obj.targetOperationMode },
1618
+ { type: Characteristic.CurrentTemperature, value: roomTemperature },
1619
+ { type: Characteristic.TargetTemperature, value: setTemperature },
1620
+ { type: Characteristic.TemperatureDisplayUnits, value: obj.useFahrenheit }
1621
+ );
1616
1622
  break;
1617
1623
  };
1618
1624
 
1625
+ //update services
1626
+ for (const { type, value } of characteristics) {
1627
+ if (!this.functions.isValidValue(value)) continue;
1628
+ this.melCloudService?.updateCharacteristic(type, value);
1629
+ }
1630
+
1619
1631
  //other sensors
1620
1632
  this.roomTemperatureSensorService?.updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature);
1621
1633
  this.outdoorTemperatureSensorService?.updateCharacteristic(Characteristic.CurrentTemperature, outdoorTemperature);
package/src/deviceatw.js CHANGED
@@ -1671,6 +1671,9 @@ class DeviceAtw extends EventEmitter {
1671
1671
  zonesSensors: []
1672
1672
  };
1673
1673
 
1674
+ //characteristics array
1675
+ const characteristics = [];
1676
+
1674
1677
  //default values
1675
1678
  let name = 'Heat Pump'
1676
1679
  let operationModeZone = 0;
@@ -1787,15 +1790,17 @@ class DeviceAtw extends EventEmitter {
1787
1790
  break;
1788
1791
  };
1789
1792
 
1790
- //update characteristics
1791
- this.melCloudServices?.[i]
1792
- ?.updateCharacteristic(Characteristic.Active, power)
1793
- .updateCharacteristic(Characteristic.CurrentHeaterCoolerState, currentOperationMode)
1794
- .updateCharacteristic(Characteristic.TargetHeaterCoolerState, targetOperationMode)
1795
- .updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
1796
- .updateCharacteristic(Characteristic.LockPhysicalControls, lockPhysicalControl)
1797
- .updateCharacteristic(Characteristic.TemperatureDisplayUnits, obj.useFahrenheit);
1798
- if (heatCoolModes === 0 || heatCoolModes === 2) this.melCloudServices?.[i]?.updateCharacteristic(Characteristic.CoolingThresholdTemperature, setTemperature);
1793
+ //create characteristics
1794
+ characteristics.push(
1795
+ { type: Characteristic.Active, value: power },
1796
+ { type: Characteristic.CurrentHeaterCoolerState, value: currentOperationMode },
1797
+ { type: Characteristic.TargetHeaterCoolerState, value: targetOperationMode },
1798
+ { type: Characteristic.CurrentTemperature, value: roomTemperature },
1799
+ { type: Characteristic.LockPhysicalControls, value: lockPhysicalControl },
1800
+ { type: Characteristic.TemperatureDisplayUnits, value: obj.useFahrenheit }
1801
+ );
1802
+
1803
+ if (heatCoolModes === 0 || heatCoolModes === 2) characteristics.push({ type: Characteristic.CoolingThresholdTemperature, value: setTemperature });
1799
1804
  break;
1800
1805
  case 2: //Thermostat
1801
1806
  switch (i) {
@@ -1891,16 +1896,23 @@ class DeviceAtw extends EventEmitter {
1891
1896
  break;
1892
1897
  };
1893
1898
 
1894
- //update characteristics
1895
- this.melCloudServices?.[i]
1896
- ?.updateCharacteristic(Characteristic.CurrentHeatingCoolingState, currentOperationMode)
1897
- .updateCharacteristic(Characteristic.TargetHeatingCoolingState, targetOperationMode)
1898
- .updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
1899
- .updateCharacteristic(Characteristic.TargetTemperature, setTemperature)
1900
- .updateCharacteristic(Characteristic.TemperatureDisplayUnits, obj.useFahrenheit);
1899
+ //create characteristics
1900
+ characteristics.push(
1901
+ { type: Characteristic.CurrentHeatingCoolingState, value: currentOperationMode },
1902
+ { type: Characteristic.TargetHeatingCoolingState, value: targetOperationMode },
1903
+ { type: Characteristic.CurrentTemperature, value: roomTemperature },
1904
+ { type: Characteristic.TargetTemperature, value: setTemperature },
1905
+ { type: Characteristic.TemperatureDisplayUnits, value: obj.useFahrenheit }
1906
+ );
1901
1907
  break;
1902
1908
  };
1903
1909
 
1910
+ //update services
1911
+ for (const { type, value } of characteristics) {
1912
+ if (!this.functions.isValidValue(value)) continue;
1913
+ this.melCloudService?.[i]?.updateCharacteristic(type, value);
1914
+ }
1915
+
1904
1916
  //add every zone to array
1905
1917
  const zone = {
1906
1918
  name: name,
package/src/deviceerv.js CHANGED
@@ -1257,6 +1257,9 @@ class DeviceErv extends EventEmitter {
1257
1257
  scheduleEnabled: scheduleEnabled
1258
1258
  };
1259
1259
 
1260
+ //characteristics array
1261
+ const characteristics = [];
1262
+
1260
1263
  //ventilation mode - 0, HEAT, 2, COOL, 4, 5, 6, FAN, AUTO
1261
1264
  switch (this.displayType) {
1262
1265
  case 1: //Heater Cooler
@@ -1313,17 +1316,19 @@ class DeviceErv extends EventEmitter {
1313
1316
  }
1314
1317
  this.accessory = obj;
1315
1318
 
1316
- //update characteristics
1317
- this.melCloudService
1318
- ?.updateCharacteristic(Characteristic.Active, power)
1319
- .updateCharacteristic(Characteristic.CurrentHeaterCoolerState, obj.currentOperationMode)
1320
- .updateCharacteristic(Characteristic.TargetHeaterCoolerState, obj.targetOperationMode)
1321
- .updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
1322
- .updateCharacteristic(Characteristic.RotationSpeed, obj.fanSpeed)
1323
- .updateCharacteristic(Characteristic.LockPhysicalControls, obj.lockPhysicalControl)
1324
- .updateCharacteristic(Characteristic.TemperatureDisplayUnits, obj.useFahrenheit);
1325
- if (supportsCoolOperationMode) this.melCloudService?.updateCharacteristic(Characteristic.CoolingThresholdTemperature, defaultCoolingSetTemperature);
1326
- if (supportsHeatOperationMode) this.melCloudService?.updateCharacteristic(Characteristic.HeatingThresholdTemperature, defaultHeatingSetTemperature);
1319
+ //create characteristics
1320
+ characteristics.push(
1321
+ { type: Characteristic.Active, value: power },
1322
+ { type: Characteristic.CurrentHeaterCoolerState, value: obj.currentOperationMode },
1323
+ { type: Characteristic.TargetHeaterCoolerState, value: obj.targetOperationMode },
1324
+ { type: Characteristic.CurrentTemperature, value: roomTemperature },
1325
+ { type: Characteristic.RotationSpeed, value: obj.fanSpeed },
1326
+ { type: Characteristic.LockPhysicalControls, value: obj.lockPhysicalControl },
1327
+ { type: Characteristic.TemperatureDisplayUnits, value: obj.useFahrenheit },
1328
+ );
1329
+
1330
+ if (supportsCoolOperationMode) characteristics.push({ type: Characteristic.CoolingThresholdTemperature, value: defaultCoolingSetTemperature });
1331
+ if (supportsHeatOperationMode) characteristics.push({ type: Characteristic.HeatingThresholdTemperature, value: defaultHeatingSetTemperature });
1327
1332
  break;
1328
1333
  case 2: //Thermostat
1329
1334
  //operation mode - 0, HEAT, 2, COOL, 4, 5, 6, FAN, AUTO
@@ -1369,9 +1374,24 @@ class DeviceErv extends EventEmitter {
1369
1374
  .updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
1370
1375
  .updateCharacteristic(Characteristic.TargetTemperature, setTemperature)
1371
1376
  .updateCharacteristic(Characteristic.TemperatureDisplayUnits, obj.useFahrenheit);
1377
+
1378
+ //create characteristics
1379
+ characteristics.push(
1380
+ { type: Characteristic.CurrentHeatingCoolingState, value: obj.currentOperationMode },
1381
+ { type: Characteristic.TargetHeatingCoolingState, value: obj.targetOperationMode },
1382
+ { type: Characteristic.CurrentTemperature, value: roomTemperature },
1383
+ { type: Characteristic.TargetTemperature, value: setTemperature },
1384
+ { type: Characteristic.TemperatureDisplayUnits, value: obj.useFahrenheit },
1385
+ );
1372
1386
  break;
1373
1387
  };
1374
1388
 
1389
+ //update services
1390
+ for (const { type, value } of characteristics) {
1391
+ if (!this.functions.isValidValue(value)) continue;
1392
+ this.melCloudService?.updateCharacteristic(type, value);
1393
+ }
1394
+
1375
1395
  //update temperature sensors
1376
1396
  this.roomTemperatureSensorService?.updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature);
1377
1397
  this.outdoorTemperatureSensorService?.updateCharacteristic(Characteristic.CurrentTemperature, outdoorTemperature);
package/src/functions.js CHANGED
@@ -156,5 +156,9 @@ class Functions extends EventEmitter {
156
156
  }
157
157
  }
158
158
 
159
+ isValidValue(v) {
160
+ return v !== undefined && v !== null && !(typeof v === 'number' && Number.isNaN(v));
161
+ }
162
+
159
163
  }
160
164
  export default Functions