homebridge-melcloud-control 4.10.1 → 4.10.2

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 CHANGED
@@ -24,6 +24,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
24
24
  - For plugin < v4.6.0 use Homebridge UI <= v5.5.0
25
25
  - For plugin >= v4.6.0 use Homebridge UI >= v5.13.0
26
26
 
27
+ # [4.10.2] - (18.04.2026)
28
+
29
+ ## Changes
30
+
31
+ - fix [#243](https://github.com/grzegorz914/homebridge-melcloud-control/issues/243)
32
+ - cleanup
33
+
27
34
  # [4.10.1] - (17.04.2026)
28
35
 
29
36
  ## Changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.10.1",
4
+ "version": "4.10.2",
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
@@ -25,6 +25,7 @@ class DeviceAta extends EventEmitter {
25
25
  this.logInfo = account.log?.info || false;
26
26
  this.logWarn = account.log?.warn || false;
27
27
  this.logDebug = account.log?.debug || false;
28
+ this.logError = account.log?.error || false;
28
29
 
29
30
  //device config
30
31
  this.device = device;
@@ -192,7 +193,6 @@ class DeviceAta extends EventEmitter {
192
193
  async setOverExternalIntegration(integration, deviceData, key, value) {
193
194
  try {
194
195
  const accountTypeMelCloud = this.accountTypeMelCloud;
195
- let set = false
196
196
  let payload = {};
197
197
  let flag = null;
198
198
  switch (key) {
@@ -240,7 +240,7 @@ class DeviceAta extends EventEmitter {
240
240
  break;
241
241
  case 'ProhibitPower':
242
242
  if (!accountTypeMelCloud) return;
243
- payload.prohibitOperationMode = value;
243
+ payload.prohibitPower = value;
244
244
  flag = AirConditioner.EffectiveFlags.Prohibit;
245
245
  break;
246
246
  case 'FrostProtection':
@@ -271,8 +271,7 @@ class DeviceAta extends EventEmitter {
271
271
  return;
272
272
  };
273
273
 
274
- set = await this.melCloudAta.send(this.accountType, this.displayType, deviceData, payload, flag);
275
- return set;
274
+ return await this.melCloudAta.send(this.accountType, this.displayType, deviceData, payload, flag);
276
275
  } catch (error) {
277
276
  throw new Error(`${integration} set key: ${key}, value: ${value}, error: ${error.message ?? error}`);
278
277
  };
@@ -937,7 +936,7 @@ class DeviceAta extends EventEmitter {
937
936
  try {
938
937
  const payload = { enabled: state };
939
938
  if (this.logInfo) this.emit('info', `Holiday mode: ${state ? 'Enabled' : 'Disabled'}`);
940
- await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, payload, 'holidaymode');
939
+ await this.melCloudAta.send(this.accountType, this.displayType, deviceData, payload, 'holidaymode');
941
940
  } catch (error) {
942
941
  if (this.logWarn) this.emit('warn', `Set holiday mode error: ${error}`);
943
942
  };
@@ -1086,7 +1085,7 @@ class DeviceAta extends EventEmitter {
1086
1085
  const payload = { enabled: state };
1087
1086
  const scheduleData = schedulesOnServer.find(s => s.Id === schedule.id);
1088
1087
  if (this.logInfo) this.emit('info', `Schedules: ${state ? 'Enabled' : 'Disabled'}`);
1089
- await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, payload, 'schedule', scheduleData);
1088
+ await this.melCloudAta.send(this.accountType, this.displayType, deviceData, payload, 'schedule', scheduleData);
1090
1089
  } catch (error) {
1091
1090
  if (this.logWarn) this.emit('warn', `Set schedules error: ${error}`);
1092
1091
  };
@@ -1200,16 +1199,16 @@ class DeviceAta extends EventEmitter {
1200
1199
  //get name prefix
1201
1200
  const namePrefix = button.namePrefix;
1202
1201
 
1203
- const serviceName = namePrefix ? `${accessoryName} ${name}` : name;
1202
+ const serviceName1 = namePrefix ? `${accessoryName} ${name}` : name;
1204
1203
  const serviceType = button.serviceType;
1205
1204
  const characteristicType = button.characteristicType;
1206
1205
 
1207
1206
  //control
1208
1207
  if (button.displayType > 3) {
1209
1208
  if (this.logDebug) this.emit('debug', `Prepare button control ${name} service`);
1210
- const buttonControlService = new Service.Switch(serviceName, `buttonControlService${deviceId} ${i}`);
1209
+ const buttonControlService = new Service.Switch(serviceName1, `buttonControlService${deviceId} ${i}`);
1211
1210
  buttonControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1212
- buttonControlService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
1211
+ buttonControlService.setCharacteristic(Characteristic.ConfiguredName, serviceName1);
1213
1212
  buttonControlService.getCharacteristic(Characteristic.On)
1214
1213
  .onGet(async () => {
1215
1214
  const state = button.state;
@@ -1403,7 +1402,7 @@ class DeviceAta extends EventEmitter {
1403
1402
 
1404
1403
  //sensor
1405
1404
  if (button.displayType < 7) {
1406
- if (this.logDebug) this.emit('debug', `Prepare scene control sensor ${name} service`);
1405
+ this.emit('debug', `Prepare button control sensor ${name} service`);
1407
1406
  const buttonControlSensorService = new serviceType(serviceName, `buttonControlSensorService${deviceId} ${i}`);
1408
1407
  buttonControlSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1409
1408
  buttonControlSensorService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
package/src/deviceatw.js CHANGED
@@ -25,6 +25,7 @@ class DeviceAtw extends EventEmitter {
25
25
  this.logInfo = account.log?.info || false;
26
26
  this.logWarn = account.log?.warn || false;
27
27
  this.logDebug = account.log?.debug || false;
28
+ this.logError = account.log?.error || false;
28
29
 
29
30
  //device config
30
31
  this.device = device;
@@ -197,7 +198,6 @@ class DeviceAtw extends EventEmitter {
197
198
  async setOverExternalIntegration(integration, deviceData, key, value) {
198
199
  try {
199
200
  const accountTypeMelCloud = this.accountTypeMelCloud;
200
- let set = false
201
201
  let payload = {};
202
202
  let flag = null;
203
203
  switch (key) {
@@ -289,8 +289,7 @@ class DeviceAtw extends EventEmitter {
289
289
  return;
290
290
  };
291
291
 
292
- set = await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, payload, flag);
293
- return set;
292
+ return await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, payload, flag);
294
293
  } catch (error) {
295
294
  throw new Error(`${integration} set key: ${key}, value: ${value}, error: ${error.message ?? error}`);
296
295
  };
@@ -704,6 +703,7 @@ class DeviceAtw extends EventEmitter {
704
703
  };
705
704
  });
706
705
  this.melCloudServices.push(melCloudService);
706
+ accessory.addService(melCloudService);
707
707
  break;
708
708
  case 2: //Thermostat
709
709
  if (this.logDebug) this.emit('debug', `Prepare thermostat ${zoneName} service`);
@@ -931,14 +931,12 @@ class DeviceAtw extends EventEmitter {
931
931
  };
932
932
  });
933
933
  this.melCloudServices.push(melCloudServiceT);
934
+ accessory.addService(melCloudServiceT);
934
935
  break;
935
936
  default:
936
937
  if (this.logWarn) this.emit('warn', `Received unknown display type: ${this.displayType}`);
937
938
  return;
938
939
  };
939
-
940
- //add service to accessory
941
- accessory.addService(this.melCloudServices);
942
940
  });
943
941
  }
944
942
 
@@ -1188,7 +1186,7 @@ class DeviceAtw extends EventEmitter {
1188
1186
  try {
1189
1187
  const payload = { enabled: state ? true : false, min: deviceData.FrostProtection.Min, max: deviceData.FrostProtection.Max };
1190
1188
  if (this.logInfo) this.emit('info', `Frost protection: ${state ? 'Enabled' : 'Disabled'}`);
1191
- await this.melCloudAta.send(this.accountType, this.displayType, deviceData, payload, 'frostprotection');
1189
+ await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, payload, 'frostprotection');
1192
1190
  } catch (error) {
1193
1191
  if (this.logWarn) this.emit('warn', `Set frost protection error: ${error}`);
1194
1192
  };
@@ -1212,7 +1210,7 @@ class DeviceAtw extends EventEmitter {
1212
1210
  try {
1213
1211
  const payload = { enabled: true, min: deviceData.FrostProtection.Min, max: deviceData.FrostProtection.Max };
1214
1212
  if (this.logInfo) this.emit('info', `Frost protection: Enabled`);
1215
- await this.melCloudAta.send(this.accountType, this.displayType, deviceData, payload, 'frostprotection');
1213
+ await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, payload, 'frostprotection');
1216
1214
  } catch (error) {
1217
1215
  if (this.logWarn) this.emit('warn', `Set frost protection error: ${error}`);
1218
1216
  };
@@ -1237,7 +1235,7 @@ class DeviceAtw extends EventEmitter {
1237
1235
  let { min, max } = await this.functions.adjustTempProtection(deviceData.FrostProtection.Min, deviceData.FrostProtection.Max, value, 'max', 4, 14, 6, 16);
1238
1236
  const payload = { enabled: deviceData.FrostProtection.Enabled, min: min, max: max };
1239
1237
  if (this.logInfo) this.emit('info', `Set frost protection max. temperature: ${max}${this.accessory.temperatureUnit}`);
1240
- await this.melCloudAta.send(this.accountType, this.displayType, deviceData, payload, 'frostprotection');
1238
+ await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, payload, 'frostprotection');
1241
1239
  } catch (error) {
1242
1240
  if (this.logWarn) this.emit('warn', `Set frost protection max. temperature error: ${error}`);
1243
1241
  };
@@ -1257,7 +1255,7 @@ class DeviceAtw extends EventEmitter {
1257
1255
  let { min, max } = await this.functions.adjustTempProtection(deviceData.FrostProtection.Min, deviceData.FrostProtection.Max, value, 'min', 4, 14, 6, 16);
1258
1256
  const payload = { enabled: deviceData.FrostProtection.Enabled, min: min, max: max };
1259
1257
  if (this.logInfo) this.emit('info', `Set frost protection min. temperature: ${min}${this.accessory.temperatureUnit}`);
1260
- await this.melCloudAta.send(this.accountType, this.displayType, deviceData, payload, 'frostprotection');
1258
+ await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, payload, 'frostprotection');
1261
1259
  } catch (error) {
1262
1260
  if (this.logWarn) this.emit('warn', `Set frost protection min. temperature error: ${error}`);
1263
1261
  };
@@ -1406,7 +1404,7 @@ class DeviceAtw extends EventEmitter {
1406
1404
  };
1407
1405
 
1408
1406
  if (this.logInfo) this.emit('info', `Preset ${name}: ${state ? 'Set' : 'Unset'}`);
1409
- await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, payload, AirConditioner.EffectiveFlags.Presets);
1407
+ await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, payload, HeatPump.EffectiveFlags.Presets);
1410
1408
  } catch (error) {
1411
1409
  if (this.logWarn) this.emit('warn', `Set preset error: ${error}`);
1412
1410
  };
@@ -1570,7 +1568,7 @@ class DeviceAtw extends EventEmitter {
1570
1568
  if (this.logDebug) this.emit('debug', `Prepare buttons / sensors services`);
1571
1569
  this.buttonControlServices = [];
1572
1570
  this.buttonControlSensorServices = [];
1573
- this.buttons.lengthforEach((button, i) => {
1571
+ this.buttons.forEach((button, i) => {
1574
1572
  //get mode
1575
1573
  const mode = button.mode;
1576
1574
 
@@ -1596,7 +1594,7 @@ class DeviceAtw extends EventEmitter {
1596
1594
  return state;
1597
1595
  })
1598
1596
  .onSet(async (state) => {
1599
- if (displayType > 0 && displayType < 3) {
1597
+ if (this.displayType > 0 && this.displayType < 3) {
1600
1598
  try {
1601
1599
  const payload = {};
1602
1600
  let flag = null;
@@ -2052,7 +2050,7 @@ class DeviceAtw extends EventEmitter {
2052
2050
  state = true;
2053
2051
  operationModeRaw = operationModeZone2;
2054
2052
  currentOperationMode = !power ? 0 : (idleZone2 ? 1 : [2, 2, 2, 3, 3, 3, 1][operationModeZone2]); //INACTIVE, IDLE, HEATING, COOLING
2055
- if (operationModeZone1 < 6) targetOperationMode = [1, 1, 0, 2, 2, 0][operationModeZone2]; //AUTO, HEAT, COOL
2053
+ if (operationModeZone2 < 6) targetOperationMode = [1, 1, 0, 2, 2, 0][operationModeZone2]; //AUTO, HEAT, COOL
2056
2054
 
2057
2055
  switch (this.accountType) {
2058
2056
  case 'melcloud': //Melcloud
package/src/deviceerv.js CHANGED
@@ -25,6 +25,7 @@ class DeviceErv extends EventEmitter {
25
25
  this.logInfo = account.log?.info || false;
26
26
  this.logWarn = account.log?.warn || false;
27
27
  this.logDebug = account.log?.debug || false;
28
+ this.logError = account.log?.error || false;
28
29
 
29
30
  //device config
30
31
  this.device = device;
@@ -184,7 +185,6 @@ class DeviceErv extends EventEmitter {
184
185
  async setOverExternalIntegration(integration, deviceData, key, value) {
185
186
  try {
186
187
  const accountTypeMelCloud = this.accountTypeMelCloud;
187
- let set = false
188
188
  let payload = {};
189
189
  let flag = null;
190
190
  switch (key) {
@@ -236,8 +236,7 @@ class DeviceErv extends EventEmitter {
236
236
  return;
237
237
  };
238
238
 
239
- set = await this.melCloudErv.send(this.accountType, this.displayType, deviceData, payload, flag);
240
- return set;
239
+ return await this.melCloudErv.send(this.accountType, this.displayType, deviceData, payload, flag);
241
240
  } catch (error) {
242
241
  throw new Error(`${integration} set key: ${key}, value: ${value}, error: ${error.message ?? error}`);
243
242
  };
@@ -525,7 +524,7 @@ class DeviceErv extends EventEmitter {
525
524
  this.melCloudAccountData.Account.LoginData.UseFahrenheit = value ? true : false;
526
525
  const payload = this.melCloudAccountData;
527
526
  if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
528
- await this.melCloudErv.send(this.accountType, this.displayType, deviceData, payload, 'account', this.melCloudAccountData);
527
+ await this.melCloudErv.send(this.accountType, this.displayType, deviceData, payload, 'account');
529
528
  } catch (error) {
530
529
  if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
531
530
  };
@@ -708,7 +707,7 @@ class DeviceErv extends EventEmitter {
708
707
  try {
709
708
  const payload = { enabled: state };
710
709
  if (this.logInfo) this.emit('info', `Holiday mode: ${state ? 'Enabled' : 'Disabled'}`);
711
- await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, payload, 'holidaymode');
710
+ await this.melCloudErv.send(this.accountType, this.displayType, deviceData, payload, 'holidaymode');
712
711
  } catch (error) {
713
712
  if (this.logWarn) this.emit('warn', `Set holiday mode error: ${error}`);
714
713
  };
@@ -797,7 +796,7 @@ class DeviceErv extends EventEmitter {
797
796
  };
798
797
 
799
798
  if (this.logInfo) this.emit('info', `Preset ${name}: ${state ? 'Set' : 'Unset'}`);
800
- await this.melCloudErv.send(this.accountType, this.displayType, deviceData, payload, AirConditioner.EffectiveFlags.Presets);
799
+ await this.melCloudErv.send(this.accountType, this.displayType, deviceData, payload, Ventilation.EffectiveFlags.Presets);
801
800
  } catch (error) {
802
801
  if (this.logWarn) this.emit('warn', `Set preset error: ${error}`);
803
802
  };
@@ -857,7 +856,7 @@ class DeviceErv extends EventEmitter {
857
856
  const payload = { enabled: state };
858
857
  const scheduleData = schedulesOnServer.find(s => s.Id === schedule.id);
859
858
  if (this.logInfo) this.emit('info', `Schedules: ${state ? 'Enabled' : 'Disabled'}`);
860
- await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, payload, 'schedule', scheduleData);
859
+ await this.melCloudErv.send(this.accountType, this.displayType, deviceData, payload, 'schedule', scheduleData);
861
860
  } catch (error) {
862
861
  if (this.logWarn) this.emit('warn', `Set schedules error: ${error}`);
863
862
  };
@@ -930,7 +929,7 @@ class DeviceErv extends EventEmitter {
930
929
  const sceneData = scenesOnServer.find(s => s.Id === scene.id);
931
930
  const payload = { id: sceneData.Id, enabled: state };
932
931
  if (this.logInfo) this.emit('info', `Scene ${name}: ${state ? 'Set' : 'Unset'}`);
933
- await this.melCloudAta.send(this.accountType, this.displayType, deviceData, payload, 'scene');
932
+ await this.melCloudErv.send(this.accountType, this.displayType, deviceData, payload, 'scene');
934
933
  } catch (error) {
935
934
  if (this.logWarn) this.emit('warn', `Set scene error: ${error}`);
936
935
  };
@@ -1249,7 +1248,7 @@ class DeviceErv extends EventEmitter {
1249
1248
  case 2: // AUTO
1250
1249
  if (actualVentilationMode === 0) obj.currentOperationMode = 2; // HEAT
1251
1250
  if (actualVentilationMode === 1) obj.currentOperationMode = 3; // COOL
1252
- if (this.logWarn && (actualVentilationMode !== 0 || actualVentilationMode !== 1)) this.emit('warn', `Received unknown actual ventilation mode: ${actualVentilationMode}`);
1251
+ if (this.logWarn && (actualVentilationMode !== 0 && actualVentilationMode !== 1)) this.emit('warn', `Received unknown actual ventilation mode: ${actualVentilationMode}`);
1253
1252
 
1254
1253
  obj.targetOperationMode = 0; // auto
1255
1254
  break;
@@ -1313,7 +1312,7 @@ class DeviceErv extends EventEmitter {
1313
1312
  case 2: // AUTO
1314
1313
  if (actualVentilationMode === 0) obj.currentOperationMode = 1; // HEAT
1315
1314
  if (actualVentilationMode === 1) obj.currentOperationMode = 2; // COOL
1316
- if (this.logWarn && (actualVentilationMode !== 0 || actualVentilationMode !== 1)) this.emit('warn', `Received unknown actual ventilation mode: ${actualVentilationMode}`);
1315
+ if (this.logWarn && (actualVentilationMode !== 0 && actualVentilationMode !== 1)) this.emit('warn', `Received unknown actual ventilation mode: ${actualVentilationMode}`);
1317
1316
 
1318
1317
  obj.targetOperationMode = 3; // AUTO
1319
1318
  break;
@@ -1515,8 +1514,8 @@ class DeviceErv extends EventEmitter {
1515
1514
  this.emit('info', `Current ventilation mode: ${Ventilation.OperationModeMapEnumToString[actualVentilationMode]}`);
1516
1515
  this.emit('info', `Target temperature: ${setTemperature}${obj.temperatureUnit}`);
1517
1516
  if (supportsRoomTemperature) this.emit('info', `Room temperature: ${roomTemperature}${obj.temperatureUnit}`);
1518
- if (supportsSupplyTemperature) this.emit('info', `Supply temperature: ${roomTemperature}${obj.temperatureUnit}`);
1519
- if (supportsOutdoorTemperature) this.emit('info', `Outdoor temperature: ${roomTemperature}${obj.temperatureUnit}`);
1517
+ if (supportsSupplyTemperature) this.emit('info', `Supply temperature: ${supplyTemperature}${obj.temperatureUnit}`);
1518
+ if (supportsOutdoorTemperature) this.emit('info', `Outdoor temperature: ${outdoorTemperature}${obj.temperatureUnit}`);
1520
1519
  this.emit('info', `Fan speed mode: ${Ventilation.FanSpeedMapEnumToString[setFanSpeed]}`);
1521
1520
  this.emit('info', `Temperature display unit: ${obj.temperatureUnit}`);
1522
1521
  this.emit('info', `Core maintenance: ${Ventilation.CoreMaintenanceMapEnumToString[coreMaintenanceRequired]}`);
package/src/melcloud.js CHANGED
@@ -39,7 +39,7 @@ class MelCloud extends EventEmitter {
39
39
  try {
40
40
  await fn();
41
41
  } catch (error) {
42
- this.emit('error', `Inpulse generator error: ${error}`);
42
+ this.emit('error', `Impulse generator error: ${error}`);
43
43
  } finally {
44
44
  this.locks[lockKey] = false;
45
45
  }
@@ -94,7 +94,7 @@ class MelCloudAta extends EventEmitter {
94
94
  }
95
95
 
96
96
  //update state
97
- if (this.logDebug) this.emit('debug', `Web socket update unit ${this.deviceId}settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
97
+ if (this.logDebug) this.emit('debug', `Web socket update unit ${this.deviceId} settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
98
98
  await this.updateState('ws', deviceData);
99
99
  } catch (error) {
100
100
  if (this.logError) this.emit('error', `Web socket unit ${this.deviceId} process message error: ${error}`);
@@ -285,7 +285,7 @@ class MelCloudAta extends EventEmitter {
285
285
  method = 'PUT';
286
286
  path = `${ApiUrls.Home.Put.SceneEnableDisable.replace('sceneid', payload.id)}/${payload.enabled ? 'enable' : 'disable'}`;
287
287
  const scene = deviceData.Scenes.find(s => s.Id === payload.id);
288
- scene.Enabled = payload.enabled;
288
+ if (scene) scene.Enabled = payload.enabled;
289
289
  payload = {};
290
290
  break;
291
291
  default:
@@ -315,18 +315,16 @@ class MelCloudAta extends EventEmitter {
315
315
 
316
316
  method = 'PUT';
317
317
  path = ApiUrls.Home.Put.Ata.replace('deviceid', deviceData.DeviceID);
318
+ deviceData.Device = { ...deviceData.Device, ...payload };
318
319
  break;
319
320
  }
320
321
 
321
322
  //send payload
322
323
  if (this.logDebug) this.emit('debug', `Send data: ${JSON.stringify(payload, null, 2)}`);
323
324
  await this.client(path, { method: method, data: payload });
324
-
325
- //update state
326
- deviceData.Device = { ...deviceData.Device, ...payload };
327
325
  return true;
328
326
  default:
329
- if (this.logWarn) this.emit('warn', `Received unknwn account type: ${accountType}`);
327
+ if (this.logWarn) this.emit('warn', `Received unknown account type: ${accountType}`);
330
328
  return;
331
329
  }
332
330
  } catch (error) {
@@ -248,7 +248,7 @@ class MelCloudAtw extends EventEmitter {
248
248
  method = 'PUT';
249
249
  path = `${ApiUrls.Home.Put.SceneEnableDisable.replace('sceneid', payload.id)}/${payload.enabled ? 'enable' : 'disable'}`;
250
250
  const scene = deviceData.Scenes.find(s => s.Id === payload.id);
251
- scene.Enabled = payload.enabled;
251
+ if (scene) scene.Enabled = payload.enabled;
252
252
  payload = {};
253
253
  break;
254
254
  default:
@@ -265,17 +265,15 @@ class MelCloudAtw extends EventEmitter {
265
265
 
266
266
  method = 'PUT';
267
267
  path = ApiUrls.Home.Put.Atw.replace('deviceid', deviceData.DeviceID);
268
+ deviceData.Device = { ...deviceData.Device, ...payload };
268
269
  break
269
270
  }
270
271
 
271
272
  if (this.logDebug) this.emit('debug', `Send data: ${JSON.stringify(payload, null, 2)}`);
272
273
  await this.client(path, { method: method, data: payload });
273
-
274
- //update state
275
- deviceData.Device = { ...deviceData.Device, ...payload };
276
274
  return true;
277
275
  default:
278
- if (this.logWarn) this.emit('warn', `Received unknwn account type: ${accountType}`);
276
+ if (this.logWarn) this.emit('warn', `Received unknown account type: ${accountType}`);
279
277
  return;
280
278
  }
281
279
  } catch (error) {
@@ -251,7 +251,7 @@ class MelCloudErv extends EventEmitter {
251
251
  method = 'PUT';
252
252
  path = `${ApiUrls.Home.Put.SceneEnableDisable.replace('sceneid', payload.id)}/${payload.enabled ? 'enable' : 'disable'}`;
253
253
  const scene = deviceData.Scenes.find(s => s.Id === payload.id);
254
- scene.Enabled = payload.enabled;
254
+ if (scene) scene.Enabled = payload.enabled;
255
255
  payload = {};
256
256
  break;
257
257
  default:
@@ -280,17 +280,15 @@ class MelCloudErv extends EventEmitter {
280
280
 
281
281
  method = 'PUT';
282
282
  path = ApiUrls.Home.Put.Erv.replace('deviceid', deviceData.DeviceID);
283
+ deviceData.Device = { ...deviceData.Device, ...payload };
283
284
  break
284
285
  }
285
286
 
286
287
  if (this.logDebug) this.emit('debug', `Send data: ${JSON.stringify(payload, null, 2)}`);
287
288
  await this.client(path, { method: method, data: payload });
288
-
289
- //update state
290
- deviceData.Device = { ...deviceData.Device, ...payload };
291
289
  return true;
292
290
  default:
293
- if (this.logWarn) this.emit('warn', `Received unknwn account type: ${accountType}`);
291
+ if (this.logWarn) this.emit('warn', `Received unknown account type: ${accountType}`);
294
292
  return;
295
293
  }
296
294
  } catch (error) {