homebridge-melcloud-control 4.0.0-beta.155 → 4.0.0-beta.156

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.0.0-beta.155",
4
+ "version": "4.0.0-beta.156",
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/constants.js CHANGED
@@ -35,14 +35,18 @@ export const DeviceType = [
35
35
  export const TemperatureDisplayUnits = ["°C", "°F"];
36
36
 
37
37
  export const AirConditioner = {
38
- System: ["AIR CONDITIONER OFF", "AIR CONDITIONER ON", "AIR CONDITIONER OFFLINE"],
39
- OperationMode: ["0", "HEAT", "DRY", "COOL", "4", "5", "6", "FAN", "AUTO", "ISEE HEAT", "ISEE DRY", "ISEE COOL"],
40
- VaneVertical: ["AUTO", "UP", "UP CENTER", "CENTER", "DOWN CENTER", "DOWN", "6", "SWING"],
41
- VaneHorizontal: ["AUTO", "LEFT", "LEFT CENTER", "CENTER", "RIGHT CENTER", "RIGHT", "6", "7", "SPLIT", "9", "10", "11", "SWING"],
42
- AirDirection: ["AUTO", "SWING"],
43
- FanSpeedMapHomekit: ["AUTO", "VERY QUIT", "QUIET", "WEAK", "MIDDLE", "STRONG", "VERY STRONG", "OFF"],
44
- CurrentOperationModeHeatherCooler: ["INACTIVE", "IDLE", "HEATING", "COOLING"],
45
- CurrentOperationModeThermostat: ["INACTIVE", "HEATING", "COOLING"],
38
+ SystemMapEnumToString: { 0: "Air Conditioner Off", 1: "ir Conditioner On", 2: "ir Conditioner Offline" },
39
+ AirDirectionMapEnumToString: { 0: "Auto", 1: "Swing" },
40
+ CurrentOperationModeHeatherCoolerMapEnumToString: { 0: "Inactive", 1: "Idle", 2: "Heating", 3: "Cooling" },
41
+ CurrentOperationModeThermostatMapEnumToString: { 0: "Inactive", 1: "Heating", 2: "Cooling" },
42
+ OperationModeMapStringToEnum: { "0": 0, "Heat": 1, "Dry": 2, "Cool": 3, "4": 4, "5": 5, "6": 6, "Fan": 7, "Auto": 8, "Isee Heat": 9, "Isee Dry": 10, "Isee Cool": 11 },
43
+ OperationModeMapEnumToString: { 0: "0", 1: "Heat", 2: "Dry", 3: "Cool", 4: "4", 5: "5", 6: "6", 7: "Fan", 8: "Auto", 9: "Isee Heat", 10: "Isee Dry", 11: "Isee Cool" },
44
+ FanSpeedMapStringToEnum: { "Auto": 0, "One": 1, "Two": 2, "Three": 3, "Four": 4, "Five": 5, "0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5, },
45
+ FanSpeedMapEnumToString: { 0: "Auto", 1: "One", 2: "Two", 3: "Three", 4: "Four", 5: "Five" },
46
+ VaneVerticalDirectionMapStringToEnum: { "Auto": 0, "One": 1, "Two": 2, "Three": 3, "Four": 4, "Five": 5, "Six": 6, "Swing": 7 },
47
+ VaneVerticalDirectionMapEnumToString: { 0: "Auto", 1: "One", 2: "Two", 3: "Three", 4: "Four", 5: "Five", 6: "Six", 7: "Swing" },
48
+ VaneHorizontalDirectionMapStringToEnum: { "Auto": 0, "Left": 1, "LeftCenter": 2, "Center": 3, "RightCenter": 4, "Right": 5, "Six": 6, "Seven": 7, "Split": 8, "Nine": 9, "Ten": 10, "Eleven": 11, "Swing": 12 },
49
+ VaneHorizontalDirectionMapEnumToString: { 0: "Auto", 1: "Left", 2: "LeftCenter", 3: "Center", 4: "RightCenter", 5: "Right", 6: "Six", 7: "Seven", 8: "Split", 9: "Nine", 10: "Ten", 11: "Eleven", 12: "Swing" },
46
50
  EffectiveFlags: {
47
51
  Power: 1,
48
52
  OperationMode: 2,
@@ -63,14 +67,6 @@ export const AirConditioner = {
63
67
  HolidayMode: 131072,
64
68
  All: 281483566710825
65
69
  },
66
- OperationModeMapStringToEnum: { "0": 0, "Heat": 1, "Dry": 2, "Cool": 3, "4": 4, "5": 5, "6": 6, "Fan": 7, "Auto": 8, "Isee Heat": 9, "Isee Dry": 10, "Isee Cool": 11 },
67
- OperationModeMapEnumToString: { 0: "0", 1: "Heat", 2: "Dry", 3: "Cool", 4: "4", 5: "5", 6: "6", 7: "Fan", 8: "Auto", 9: "Isee Heat", 10: "Isee Dry", 11: "Isee Cool" },
68
- FanSpeedMapStringToEnum: { "Auto": 0, "One": 1, "Two": 2, "Three": 3, "Four": 4, "Five": 5, "0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5, },
69
- FanSpeedMapEnumToString: { 0: "Auto", 1: "One", 2: "Two", 3: "Three", 4: "Four", 5: "Five" },
70
- VaneVerticalDirectionMapStringToEnum: { "Auto": 0, "One": 1, "Two": 2, "Three": 3, "Four": 4, "Five": 5, "Six": 6, "Swing": 7 },
71
- VaneVerticalDirectionMapEnumToString: { 0: "Auto", 1: "One", 2: "Two", 3: "Three", 4: "Four", 5: "Five", 6: "Six", 7: "Swing" },
72
- VaneHorizontalDirectionMapStringToEnum: { "Auto": 0, "Left": 1, "LeftCenter": 2, "Center": 3, "RightCenter": 4, "Right": 5, "Six": 6, "Seven": 7, "Split": 8, "Nine": 9, "Ten": 10, "Eleven": 11, "Swing": 12 },
73
- VaneHorizontalDirectionMapEnumToString: { 0: "Auto", 1: "Left", 2: "LeftCenter", 3: "Center", 4: "RightCenter", 5: "Right", 6: "Six", 7: "Seven", 8: "Split", 9: "Nine", 10: "Ten", 11: "Eleven", 12: "Swing" },
74
70
  };
75
71
 
76
72
  export const HeatPump = {
package/src/deviceata.js CHANGED
@@ -331,11 +331,9 @@ class DeviceAta extends EventEmitter {
331
331
  return;
332
332
  };
333
333
 
334
- this.emit('warn', deviceData.Device.OperationMode);
335
334
  deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.OperationMode;
336
335
  await this.melCloudAta.send(this.accountType, deviceData, this.displayMode);
337
- const operationModeText = AirConditioner.OperationMode[deviceData.Device.OperationMode];
338
- if (this.logInfo) this.emit('info', `Set operation mode: ${operationModeText}`);
336
+ if (this.logInfo) this.emit('info', `Set operation mode: ${AirConditioner.OperationModeMapEnumToString[deviceData.Device.OperationMode]}`);
339
337
  } catch (error) {
340
338
  if (this.logWarn) this.emit('warn', `Set operation mode error: ${error}`);
341
339
  };
@@ -358,29 +356,24 @@ class DeviceAta extends EventEmitter {
358
356
  })
359
357
  .onSet(async (value) => {
360
358
  try {
361
- let fanSpeedModeText = '';
362
359
  const fanKey = this.accountType === 'melcloud' ? 'FanSpeed' : 'SetFanSpeed';
363
360
  switch (numberOfFanSpeeds) {
364
361
  case 2: //Fan speed mode 2
365
- fanSpeedModeText = supportsAutomaticFanSpeed ? [7, 1, 2, 0][value] : [7, 1, 2][value];
366
362
  deviceData.Device[fanKey] = supportsAutomaticFanSpeed ? [0, 1, 2, 0][value] : [1, 1, 2][value];
367
363
  break;
368
364
  case 3: //Fan speed mode 3
369
- fanSpeedModeText = supportsAutomaticFanSpeed ? [7, 1, 2, 3, 0][value] : [7, 1, 2, 3][value];
370
365
  deviceData.Device[fanKey] = supportsAutomaticFanSpeed ? [0, 1, 2, 3, 0][value] : [1, 1, 2, 3][value];
371
366
  break;
372
367
  case 4: //Fan speed mode 4
373
- fanSpeedModeText = supportsAutomaticFanSpeed ? [7, 1, 2, 3, 4, 0][value] : [7, 1, 2, 3, 4][value];
374
368
  deviceData.Device[fanKey] = supportsAutomaticFanSpeed ? [0, 1, 2, 3, 4, 0][value] : [1, 1, 2, 3, 4][value];
375
369
  break;
376
370
  case 5: //Fan speed mode 5
377
- fanSpeedModeText = supportsAutomaticFanSpeed ? [7, 1, 2, 3, 4, 5, 0][value] : [7, 1, 2, 3, 4, 5][value];
378
371
  deviceData.Device[fanKey] = supportsAutomaticFanSpeed ? [0, 1, 2, 3, 4, 5, 0][value] : [1, 1, 2, 3, 4, 5][value];
379
372
  break;
380
373
  };
381
374
  deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.SetFanSpeed;
382
375
  await this.melCloudAta.send(this.accountType, deviceData, this.displayMode);
383
- if (this.logInfo) this.emit('info', `Set fan speed mode: ${AirConditioner.FanSpeedMapHomekit[fanSpeedModeText]}`);
376
+ if (this.logInfo) this.emit('info', `Set fan speed mode: ${AirConditioner.FanSpeedMapEnumToString[deviceData.Device[fanKey]]}`);
384
377
  } catch (error) {
385
378
  if (this.logWarn) this.emit('warn', `Set fan speed mode error: ${error}`);
386
379
  };
@@ -399,7 +392,7 @@ class DeviceAta extends EventEmitter {
399
392
  deviceData.Device.VaneVerticalDirection = value ? 7 : 0;
400
393
  deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.VaneVerticalVaneHorizontal;
401
394
  await this.melCloudAta.send(this.accountType, deviceData, this.displayMode);
402
- if (this.logInfo) this.emit('info', `Set air direction mode: ${AirConditioner.AirDirection[value]}`);
395
+ if (this.logInfo) this.emit('info', `Set air direction mode: ${AirConditioner.AirDirectionMapEnumToString[value]}`);
403
396
  } catch (error) {
404
397
  if (this.logWarn) this.emit('warn', `Set vane swing mode error: ${error}`);
405
398
  };
@@ -528,7 +521,7 @@ class DeviceAta extends EventEmitter {
528
521
  };
529
522
 
530
523
  await this.melCloudAta.send(this.accountType, deviceData, this.displayMode);
531
- const operationModeText = AirConditioner.OperationMode[deviceData.Device.OperationMode];
524
+ const operationModeText = AirConditioner.OperationModeMapEnumToString[deviceData.Device.OperationMode];
532
525
  if (this.logInfo) this.emit('info', `Set operation mode: ${operationModeText}`);
533
526
  } catch (error) {
534
527
  if (this.logWarn) this.emit('warn', `Set operation mode error: ${error}`);
@@ -1327,16 +1320,16 @@ class DeviceAta extends EventEmitter {
1327
1320
  //log current state
1328
1321
  if (this.logInfo) {
1329
1322
  this.emit('info', `Power: ${power ? 'ON' : 'OFF'}`);
1330
- this.emit('info', `Target operation mode: ${AirConditioner.OperationMode[operationMode]}`);
1331
- this.emit('info', `Current operation mode: ${this.displayMode === 1 ? AirConditioner.CurrentOperationModeHeatherCooler[obj.currentOperationMode] : AirConditioner.CurrentOperationModeThermostat[obj.currentOperationMode]}`);
1323
+ this.emit('info', `Target operation mode: ${AirConditioner.OperationModeMapEnumToString[operationMode]}`);
1324
+ this.emit('info', `Current operation mode: ${this.displayMode === 1 ? AirConditioner.CurrentOperationModeHeatherCoolerMapEnumToString[obj.currentOperationMode] : AirConditioner.CurrentOperationModeThermostatMapEnumToString[obj.currentOperationMode]}`);
1332
1325
  this.emit('info', `Target temperature: ${setTemperature}${obj.temperatureUnit}`);
1333
1326
  this.emit('info', `Current temperature: ${roomTemperature}${obj.temperatureUnit}`);
1334
1327
  if (supportsOutdoorTemperature && outdoorTemperature !== null) this.emit('info', `Outdoor temperature: ${outdoorTemperature}${obj.temperatureUnit}`);
1335
- if (supportsFanSpeed) this.emit('info', `Target fan speed: ${AirConditioner.FanSpeedMapHomekit[setFanSpeed]}`);
1336
- if (supportsFanSpeed) this.emit('info', `Current fan speed: ${AirConditioner.FanSpeedMapHomekit[actualFanSpeed]}`);
1337
- if (vaneHorizontalDirection !== null) this.emit('info', `Vane horizontal: ${AirConditioner.VaneHorizontal[vaneHorizontalDirection]}`);
1338
- if (vaneVerticalDirection !== null) this.emit('info', `Vane vertical: ${AirConditioner.VaneVertical[vaneVerticalDirection]}`);
1339
- if (supportsSwingFunction) this.emit('info', `Air direction: ${AirConditioner.AirDirection[obj.currentSwingMode]}`);
1328
+ if (supportsFanSpeed) this.emit('info', `Target fan speed: ${AirConditioner.FanSpeedMapEnumToString[setFanSpeed]}`);
1329
+ if (supportsFanSpeed) this.emit('info', `Current fan speed: ${AirConditioner.FanSpeedMapEnumToString[actualFanSpeed]}`);
1330
+ if (vaneHorizontalDirection !== null) this.emit('info', `Vane horizontal: ${AirConditioner.VaneHorizontalDirectionMapEnumToString[vaneHorizontalDirection]}`);
1331
+ if (vaneVerticalDirection !== null) this.emit('info', `Vane vertical: ${AirConditioner.VaneVerticalDirectionMapEnumToString[vaneVerticalDirection]}`);
1332
+ if (supportsSwingFunction) this.emit('info', `Air direction: ${AirConditioner.AirDirectionMapEnumToString[obj.currentSwingMode]}`);
1340
1333
  this.emit('info', `Temperature display unit: ${obj.temperatureUnit}`);
1341
1334
  this.emit('info', `Lock physical controls: ${obj.lockPhysicalControl ? 'LOCKED' : 'UNLOCKED'}`);
1342
1335
  };