homebridge-melcloud-control 4.2.3-beta.6 → 4.2.3-beta.61

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/src/deviceerv.js CHANGED
@@ -36,6 +36,7 @@ class DeviceErv extends EventEmitter {
36
36
  this.holidayModeSupport = device.holidayModeSupport || false;
37
37
  this.presets = this.accountType === 'melcloud' ? (device.presets || []).filter(preset => (preset.displayType ?? 0) > 0 && preset.id !== '0') : [];
38
38
  this.schedules = this.accountType === 'melcloudhome' ? (device.schedules || []).filter(schedule => (schedule.displayType ?? 0) > 0 && schedule.id !== '0') : [];
39
+ this.scenes = this.accountType === 'melcloudhome' ? (device.scenes || []).filter(scene => (scene.displayType ?? 0) > 0 && scene.id !== '0') : [];
39
40
  this.buttons = (device.buttonsSensors || []).filter(button => (button.displayType ?? 0) > 0);
40
41
  this.deviceId = device.id;
41
42
  this.deviceName = device.name;
@@ -165,78 +166,78 @@ class DeviceErv extends EventEmitter {
165
166
  async setOverExternalIntegration(integration, deviceData, key, value) {
166
167
  try {
167
168
  let set = false
168
- let effectiveFlags = null;
169
+ let flag = null;
169
170
  switch (key) {
170
171
  case 'Power':
171
172
  deviceData.Device[key] = value;
172
- effectiveFlags = Ventilation.EffectiveFlags.Power;
173
+ flag = Ventilation.EffectiveFlags.Power;
173
174
  break;
174
175
  case 'OperationMode':
175
176
  deviceData.Device[key] = value;
176
- effectiveFlags = Ventilation.EffectiveFlags.OperationMode;
177
+ flag = Ventilation.EffectiveFlags.OperationMode;
177
178
  break;
178
179
  case 'VentilationMode':
179
180
  deviceData.Device[key] = value;
180
- effectiveFlags = Ventilation.EffectiveFlags.VentilationMode;
181
+ flag = Ventilation.EffectiveFlags.VentilationMode;
181
182
  break;
182
183
  case 'SetTemperature':
183
184
  deviceData.Device[key] = value;
184
- effectiveFlags = Ventilation.EffectiveFlags.SetTemperature;
185
+ flag = Ventilation.EffectiveFlags.SetTemperature;
185
186
  break;
186
187
  case 'DefaultCoolingSetTemperature':
187
188
  deviceData.Device[key] = value;
188
- effectiveFlags = Ventilation.EffectiveFlags.SetTemperature;
189
+ flag = Ventilation.EffectiveFlags.SetTemperature;
189
190
  break;
190
191
  case 'DefaultHeatingSetTemperature':
191
192
  deviceData.Device[key] = value;
192
- effectiveFlags = Ventilation.EffectiveFlags.SetTemperature;
193
+ flag = Ventilation.EffectiveFlags.SetTemperature;
193
194
  break;
194
195
  case 'NightPurgeMode':
195
196
  if (this.accountType === 'melcloudhome') return;
196
197
 
197
198
  deviceData.Device[key] = value;
198
- effectiveFlags = Ventilation.EffectiveFlags.NightPurgeMode;
199
+ flag = Ventilation.EffectiveFlags.NightPurgeMode;
199
200
  break;
200
201
  case 'SetFanSpeed':
201
202
  deviceData.Device[key] = value;
202
- effectiveFlags = Ventilation.EffectiveFlags.SetFanSpeed;
203
+ flag = Ventilation.EffectiveFlags.SetFanSpeed;
203
204
  break;
204
205
  case 'HideRoomTemperature':
205
206
  if (this.accountType === 'melcloudhome') return;
206
207
 
207
208
  deviceData[key] = value;
208
- effectiveFlags = Ventilation.EffectiveFlags.Prohibit;
209
+ flag = Ventilation.EffectiveFlags.Prohibit;
209
210
  break;
210
211
  case 'HideSupplyTemperature':
211
212
  if (this.accountType === 'melcloudhome') return;
212
213
 
213
214
  deviceData[key] = value;
214
- effectiveFlags = Ventilation.EffectiveFlags.Prohibit;
215
+ flag = Ventilation.EffectiveFlags.Prohibit;
215
216
  break;
216
217
  case 'HideOutdoorTemperature':
217
218
  if (this.accountType === 'melcloudhome') return;
218
219
 
219
220
  deviceData[key] = value;
220
- effectiveFlags = Ventilation.EffectiveFlags.Prohibit;
221
+ flag = Ventilation.EffectiveFlags.Prohibit;
221
222
  break;
222
223
  case 'ScheduleEnabled':
223
224
  if (this.accountType === 'melcloud') return;
224
225
 
225
226
  deviceData.Device[key].Enabled = value;
226
- effectiveFlags = 'schedule';
227
+ flag = 'schedule';
227
228
  break;
228
229
  case 'HolidayMode':
229
230
  if (this.accountType === 'melcloud') return;
230
231
 
231
232
  deviceData.Device[key].Enabled = value;
232
- effectiveFlags = 'holidaymode';
233
+ flag = 'holidaymode';
233
234
  break;
234
235
  default:
235
236
  this.emit('warn', `${integration}, received key: ${key}, value: ${value}`);
236
237
  break;
237
238
  };
238
239
 
239
- set = await this.melCloudErv.send(this.accountType, this.displayType, deviceData, effectiveFlags);
240
+ set = await this.melCloudErv.send(this.accountType, this.displayType, deviceData, flag);
240
241
  return set;
241
242
  } catch (error) {
242
243
  throw new Error(`${integration} set key: ${key}, value: ${value}, error: ${error.message ?? error}`);
@@ -305,12 +306,10 @@ class DeviceErv extends EventEmitter {
305
306
  return state;
306
307
  })
307
308
  .onSet(async (state) => {
308
- if (!!state === this.accessory.power) return;
309
-
310
309
  try {
311
310
  deviceData.Device.Power = state ? true : false;
312
311
  await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.Power);
313
- if (this.logInfo) this.emit('info', `Set power: ${state ? 'ON' : 'OFF'}`);
312
+ if (this.logInfo) this.emit('info', `Set power: ${state ? 'On' : 'Off'}`);
314
313
  } catch (error) {
315
314
  if (this.logWarn) this.emit('warn', `Set power error: ${error}`);
316
315
  };
@@ -492,30 +491,30 @@ class DeviceErv extends EventEmitter {
492
491
  })
493
492
  .onSet(async (value) => {
494
493
  try {
495
- let effectiveFlags = null;
494
+ let flag = null;
496
495
  switch (value) {
497
496
  case 0: //OFF - POWER OFF
498
497
  deviceData.Device.Power = false;
499
- effectiveFlags = Ventilation.EffectiveFlags.Power;
498
+ flag = Ventilation.EffectiveFlags.Power;
500
499
  break;
501
500
  case 1: //HEAT - LOSSNAY
502
501
  deviceData.Device.Power = true;
503
502
  deviceData.Device.VentilationMode = 0;
504
- effectiveFlags = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
503
+ flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
505
504
  break;
506
505
  case 2: //COOL - BYPASS
507
506
  deviceData.Device.Power = true;
508
507
  deviceData.Device.VentilationMode = supportsBypassVentilationMode ? 1 : 0;
509
- effectiveFlags = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
508
+ flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
510
509
  break;
511
510
  case 3: //AUTO - AUTO
512
511
  deviceData.Device.Power = true;
513
512
  deviceData.Device.VentilationMode = supportsAutoVentilationMode ? 2 : 0;
514
- effectiveFlags = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
513
+ flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
515
514
  break;
516
515
  };
517
516
 
518
- await this.melCloudErv.send(this.accountType, this.displayType, deviceData, effectiveFlags);
517
+ await this.melCloudErv.send(this.accountType, this.displayType, deviceData, flag);
519
518
  const operationModeText = Ventilation.VentilationModeMapEnumToString[deviceData.Device.VentilationMode];
520
519
  if (this.logInfo) this.emit('info', `Set operation mode: ${operationModeText}`);
521
520
  } catch (error) {
@@ -924,68 +923,68 @@ class DeviceErv extends EventEmitter {
924
923
  })
925
924
  .onSet(async (state) => {
926
925
  try {
927
- let effectiveFlags = null;
926
+ let flag = null;
928
927
  switch (mode) {
929
928
  case 0: //POWER ON,OFF
930
929
  deviceData.Device.Power = state;
931
- effectiveFlags = Ventilation.EffectiveFlags.Power;
930
+ flag = Ventilation.EffectiveFlags.Power;
932
931
  break;
933
932
  case 1: //OPERATING MODE RECOVERY
934
933
  button.previousValue = state ? deviceData.Device.VentilationMode : button.previousValue ?? deviceData.Device.VentilationMode;
935
934
  deviceData.Device.Power = true;
936
935
  deviceData.Device.VentilationMode = state ? 0 : button.previousValue;
937
- effectiveFlags = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
936
+ flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
938
937
  break;
939
938
  case 2: //OPERATING MODE BYPASS
940
939
  button.previousValue = state ? deviceData.Device.VentilationMode : button.previousValue ?? deviceData.Device.VentilationMode;
941
940
  deviceData.Device.Power = true;
942
941
  deviceData.Device.VentilationMode = state ? 1 : button.previousValue;
943
- effectiveFlags = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
942
+ flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
944
943
  break
945
944
  case 3: //OPERATING MODE AUTO
946
945
  button.previousValue = state ? deviceData.Device.VentilationMode : button.previousValue ?? deviceData.Device.VentilationMode;
947
946
  deviceData.Device.Power = true;
948
947
  deviceData.Device.VentilationMode = state ? 2 : button.previousValue;
949
- effectiveFlags = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
948
+ flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
950
949
  break;
951
950
  case 4: //NIGHT PURGE MODE
952
951
  deviceData.Device.Power = true;
953
952
  deviceData.Device.NightPurgeMode = state;
954
- effectiveFlags = Ventilation.EffectiveFlags.Power
953
+ flag = Ventilation.EffectiveFlags.Power
955
954
  break;
956
955
  case 10: //FAN SPEED MODE AUTO
957
956
  button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
958
957
  deviceData.Device.Power = true;
959
958
  deviceData.Device.SetFanSpeed = state ? 0 : button.previousValue;
960
- effectiveFlags = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
959
+ flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
961
960
  break;
962
961
  case 11: //FAN SPEED MODE 1
963
962
  button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
964
963
  deviceData.Device.Power = true;
965
964
  deviceData.Device.SetFanSpeed = state ? 1 : button.previousValue;
966
- effectiveFlags = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
965
+ flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
967
966
  break;
968
967
  case 12: //FAN SPEED MODE 2
969
968
  button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
970
969
  deviceData.Device.Power = true;
971
970
  deviceData.Device.SetFanSpeed = state ? 2 : button.previousValue;
972
- effectiveFlags = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
971
+ flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
973
972
  break;
974
973
  case 13: //FAN SPEED MODE 3
975
974
  button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
976
975
  deviceData.Device.Power = true;
977
976
  deviceData.Device.SetFanSpeed = state ? 3 : button.previousValue;
978
- effectiveFlags = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
977
+ flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
979
978
  break;
980
979
  case 14: //FAN MODE 4
981
980
  button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
982
981
  deviceData.Device.Power = true;
983
982
  deviceData.Device.SetFanSpeed = state ? 4 : button.previousValue;
984
- effectiveFlags = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
983
+ flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
985
984
  break;
986
985
  case 15: //PHYSICAL LOCK CONTROLS
987
986
  deviceData.Device = deviceData.Device;
988
- effectiveFlags = Ventilation.EffectiveFlags.Prohibit;
987
+ flag = Ventilation.EffectiveFlags.Prohibit;
989
988
  break;
990
989
  case 16: //ROOM TEMP HIDE
991
990
  deviceData.HideRoomTemperature = state;
@@ -1001,7 +1000,7 @@ class DeviceErv extends EventEmitter {
1001
1000
  break;
1002
1001
  };
1003
1002
 
1004
- await this.melCloudErv.send(this.accountType, this.displayType, deviceData, effectiveFlags);
1003
+ await this.melCloudErv.send(this.accountType, this.displayType, deviceData, flag);
1005
1004
  if (this.logInfo) this.emit('info', `${state ? `Set: ${buttonName}` : `Unset: ${buttonName}, Set: ${button.previousValue}`}`);
1006
1005
  } catch (error) {
1007
1006
  if (this.logWarn) this.emit('warn', `Set button error: ${error}`);
@@ -1023,7 +1022,7 @@ class DeviceErv extends EventEmitter {
1023
1022
  try {
1024
1023
  //melcloud device
1025
1024
  this.melCloudErv = new MelCloudErv(this.account, this.device, this.devicesFile, this.defaultTempsFile)
1026
- .on('deviceInfo', (manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
1025
+ .on('deviceInfo', (modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
1027
1026
  if (this.logDeviceInfo && this.displayDeviceInfo) {
1028
1027
  this.emit('devInfo', `---- ${this.deviceTypeText}: ${this.deviceName} ----`);
1029
1028
  this.emit('devInfo', `Account: ${this.accountName}`);
@@ -1031,13 +1030,13 @@ class DeviceErv extends EventEmitter {
1031
1030
  if (modelOutdoor) this.emit('devInfo', `Outdoor: ${modelOutdoor}`);
1032
1031
  this.emit('devInfo', `Serial: ${serialNumber}`);
1033
1032
  this.emit('devInfo', `Firmware: ${firmwareAppVersion}`);
1034
- this.emit('devInfo', `Manufacturer: ${manufacturer}`);
1033
+ this.emit('devInfo', `Manufacturer: Mitsubishi`);
1035
1034
  this.emit('devInfo', '----------------------------------');
1036
1035
  this.displayDeviceInfo = false;
1037
1036
  }
1038
1037
 
1039
1038
  //accessory info
1040
- this.manufacturer = manufacturer;
1039
+ this.manufacturer = 'Mitsubishi';
1041
1040
  this.model = modelIndoor ? modelIndoor : modelOutdoor ? modelOutdoor : `${this.deviceTypeText} ${this.deviceId}`;
1042
1041
  this.serialNumber = serialNumber.toString();
1043
1042
  this.firmwareRevision = firmwareAppVersion.toString();
@@ -1136,7 +1135,7 @@ class DeviceErv extends EventEmitter {
1136
1135
  actualVentilationMode: actualVentilationMode,
1137
1136
  numberOfFanSpeeds: numberOfFanSpeeds,
1138
1137
  supportsFanSpeed: supportsFanSpeed,
1139
- power: power ? 1 : 0,
1138
+ power: power,
1140
1139
  inStandbyMode: inStandbyMode,
1141
1140
  operationMode: operationMode,
1142
1141
  currentOperationMode: 0,
@@ -1402,7 +1401,7 @@ class DeviceErv extends EventEmitter {
1402
1401
 
1403
1402
  //log current state
1404
1403
  if (this.logInfo) {
1405
- this.emit('info', `Power: ${power ? 'ON' : 'OFF'}`);
1404
+ this.emit('info', `Power: ${power ? 'On' : 'Off'}`);
1406
1405
  this.emit('info', `Target ventilation mode: ${Ventilation.OperationModeMapEnumToString[ventilationMode]}`);
1407
1406
  this.emit('info', `Current ventilation mode: ${Ventilation.OperationModeMapEnumToString[actualVentilationMode]}`);
1408
1407
  this.emit('info', `Target temperature: ${setTemperature}${obj.temperatureUnit}`);