homebridge-melcloud-control 4.3.5-beta.28 → 4.3.5-beta.29

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/index.js CHANGED
@@ -120,18 +120,18 @@ class MelCloudPlatform {
120
120
  if (logLevel.success) log.success(`${accountName}, ${accountInfo.Info}`);
121
121
 
122
122
  //check devices list
123
- let devicesList;
123
+ let melcloudDevicesList;
124
124
  try {
125
- devicesList = await melcloud.checkDevicesList();
126
- if (!devicesList.State) {
127
- if (logLevel.warn) log.warn(`${accountName}, ${devicesList.Info}`);
125
+ melcloudDevicesList = await melcloud.checkDevicesList();
126
+ if (!melcloudDevicesList.State) {
127
+ if (logLevel.warn) log.warn(`${accountName}, ${melcloudDevicesList.Info}`);
128
128
  return;
129
129
  }
130
130
  } catch (error) {
131
131
  if (logLevel.error) log.error(`${accountName}, Check devices list error: ${error.message ?? error}`);
132
132
  return;
133
133
  }
134
- if (logLevel.debug) log.info(devicesList.Info);
134
+ if (logLevel.debug) log.info(melcloudDevicesList.Info);
135
135
 
136
136
  //start account impulse generator
137
137
  await melcloud.impulseGenerator.state(true, timmers, false);
@@ -146,7 +146,7 @@ class MelCloudPlatform {
146
146
  for (const [index, device] of devices.entries()) {
147
147
  //chack device from config exist on melcloud
148
148
  const displayType = device.displayType > 0;
149
- const deviceExistInMelCloud = devicesList.Devices.some(dev => dev.DeviceID === device.id);
149
+ const deviceExistInMelCloud = melcloudDevicesList.Devices.some(dev => dev.DeviceID === device.id);
150
150
  if (!deviceExistInMelCloud || !displayType) continue;
151
151
 
152
152
  device.id = String(device.id);
@@ -180,15 +180,15 @@ class MelCloudPlatform {
180
180
  let configuredDevice;
181
181
  switch (deviceType) {
182
182
  case 0: //ATA
183
- configuredDevice = new DeviceAta(api, account, device, defaultTempsFile, accountInfo, accountFile, melcloud, devicesList);
183
+ configuredDevice = new DeviceAta(api, account, device, defaultTempsFile, accountInfo, accountFile, melcloud, melcloudDevicesList);
184
184
  break;
185
185
  case 1: //ATW
186
- configuredDevice = new DeviceAtw(api, account, device, defaultTempsFile, accountInfo, accountFile, melcloud);
186
+ configuredDevice = new DeviceAtw(api, account, device, defaultTempsFile, accountInfo, accountFile, melcloud, melcloudDevicesList);
187
187
  break;
188
188
  case 2:
189
189
  break;
190
190
  case 3: //ERV
191
- configuredDevice = new DeviceErv(api, account, device, defaultTempsFile, accountInfo, accountFile, melcloud);
191
+ configuredDevice = new DeviceErv(api, account, device, defaultTempsFile, accountInfo, accountFile, melcloud, melcloudDevicesList);
192
192
  break;
193
193
  default:
194
194
  if (logLevel.warn) log.warn(`${accountName}, ${deviceTypeString}, ${deviceName}, unknown device: ${deviceType}.`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.3.5-beta.28",
4
+ "version": "4.3.5-beta.29",
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
@@ -1321,7 +1321,7 @@ class DeviceAta extends EventEmitter {
1321
1321
  async start() {
1322
1322
  try {
1323
1323
  //melcloud device
1324
- this.melCloudAta = new MelCloudAta(this.account, this.device, this.defaultTempsFile, this.accountFile, this.melcloud, this.melcloudDevicesList)
1324
+ this.melCloudAta = new MelCloudAta(this.account, this.device, this.defaultTempsFile, this.accountFile, this.melcloud)
1325
1325
  .on('deviceInfo', (modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
1326
1326
  if (this.logDeviceInfo && this.displayDeviceInfo) {
1327
1327
  this.emit('devInfo', `---- ${this.deviceTypeString}: ${this.deviceName} ----`);
@@ -1878,7 +1878,7 @@ class DeviceAta extends EventEmitter {
1878
1878
  if (this.restFul.enable || this.mqtt.enable) await this.externalIntegrations();
1879
1879
 
1880
1880
  //check state
1881
- await this.melCloudAta.checkState();
1881
+ await this.melCloudAta.checkState(this.melcloudDevicesList);
1882
1882
 
1883
1883
  //prepare accessory
1884
1884
  await new Promise(r => setTimeout(r, 5000));
package/src/deviceatw.js CHANGED
@@ -7,7 +7,7 @@ import { TemperatureDisplayUnits, HeatPump } from './constants.js';
7
7
  let Accessory, Characteristic, Service, Categories, AccessoryUUID;
8
8
 
9
9
  class DeviceAtw extends EventEmitter {
10
- constructor(api, account, device, defaultTempsFile, accountInfo, accountFile, melcloud) {
10
+ constructor(api, account, device, defaultTempsFile, accountInfo, accountFile, melcloud, melcloudDevicesList) {
11
11
  super();
12
12
 
13
13
  Accessory = api.platformAccessory;
@@ -18,6 +18,7 @@ class DeviceAtw extends EventEmitter {
18
18
 
19
19
  //account config
20
20
  this.melcloud = melcloud;
21
+ this.melcloudDevicesList = melcloudDevicesList;
21
22
  this.account = account;
22
23
  this.accountType = account.type;
23
24
  this.accountName = account.name;
@@ -1566,7 +1567,7 @@ class DeviceAtw extends EventEmitter {
1566
1567
  async start() {
1567
1568
  try {
1568
1569
  //melcloud device
1569
- this.melCloudAtw = new MelCloudAtw(this.account, this.device, this.defaultTempsFile, this.accountFile, this.melcloud, this.melcloudDevices)
1570
+ this.melCloudAtw = new MelCloudAtw(this.account, this.device, this.defaultTempsFile, this.accountFile, this.melcloud)
1570
1571
  .on('deviceInfo', (modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion, supportsHotWaterTank, supportsZone2) => {
1571
1572
  if (this.logDeviceInfo && this.displayDeviceInfo) {
1572
1573
  this.emit('devInfo', `---- ${this.deviceTypeString}: ${this.deviceName} ----`);
@@ -2305,8 +2306,11 @@ class DeviceAtw extends EventEmitter {
2305
2306
  //start external integrations
2306
2307
  if (this.restFul.enable || this.mqtt.enable) await this.externalIntegrations();
2307
2308
 
2309
+ //check state
2310
+ await this.melCloudAta.checkState(this.melcloudDevicesList);
2311
+
2308
2312
  //prepare accessory
2309
- await new Promise(r => setTimeout(r, 1000));
2313
+ await new Promise(r => setTimeout(r, 1000));
2310
2314
  const accessory = await this.prepareAccessory();
2311
2315
  return accessory;
2312
2316
  } catch (error) {
package/src/deviceerv.js CHANGED
@@ -7,7 +7,7 @@ import { TemperatureDisplayUnits, Ventilation } from './constants.js';
7
7
  let Accessory, Characteristic, Service, Categories, AccessoryUUID;
8
8
 
9
9
  class DeviceErv extends EventEmitter {
10
- constructor(api, account, device, defaultTempsFile, accountInfo, accountFile, melcloud) {
10
+ constructor(api, account, device, defaultTempsFile, accountInfo, accountFile, melcloud, melcloudDevicesList) {
11
11
  super();
12
12
 
13
13
  Accessory = api.platformAccessory;
@@ -18,6 +18,7 @@ class DeviceErv extends EventEmitter {
18
18
 
19
19
  //account config
20
20
  this.melcloud = melcloud;
21
+ this.melcloudDevicesList = melcloudDevicesList;
21
22
  this.account = account;
22
23
  this.accountType = account.type;
23
24
  this.accountName = account.name;
@@ -1579,6 +1580,9 @@ class DeviceErv extends EventEmitter {
1579
1580
  //start external integrations
1580
1581
  if (this.restFul.enable || this.mqtt.enable) await this.externalIntegrations();
1581
1582
 
1583
+ //check state
1584
+ await this.melCloudAta.checkState(this.melcloudDevicesList);
1585
+
1582
1586
  //prepare accessory
1583
1587
  await new Promise(r => setTimeout(r, 1000));
1584
1588
  const accessory = await this.prepareAccessory();
@@ -4,7 +4,7 @@ import Functions from './functions.js';
4
4
  import { ApiUrls, ApiUrlsHome, AirConditioner } from './constants.js';
5
5
 
6
6
  class MelCloudAta extends EventEmitter {
7
- constructor(account, device, defaultTempsFile, accountFile, melcloud, melcloudDevicesList) {
7
+ constructor(account, device, defaultTempsFile, accountFile, melcloud) {
8
8
  super();
9
9
  this.accountType = account.type;
10
10
  this.logSuccess = account.log?.success;
@@ -167,13 +167,12 @@ class MelCloudAta extends EventEmitter {
167
167
  };
168
168
  };
169
169
 
170
- async checkState() {
170
+ async checkState(devicesData) {
171
171
  try {
172
- const devicesList = this.melcloudDevicesList;
173
- const deviceInMelcloud = devicesList.Devices.find(device => device.DeviceID === this.deviceId);
174
- deviceInMelcloud.Scenes = devicesList.Scenes ?? [];
175
- this.headers = devicesList.Headers;
176
- this.updateState(deviceInMelcloud);
172
+ this.headers = devicesData.Headers;
173
+ const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
174
+ deviceData.Scenes = devicesData.Scenes ?? [];
175
+ await this.updateState(deviceData);
177
176
 
178
177
  return true;
179
178
  } catch (error) {
@@ -16,6 +16,7 @@ class MelCloudAtw extends EventEmitter {
16
16
  this.deviceId = device.id;
17
17
  this.defaultTempsFile = defaultTempsFile;
18
18
  this.accountFile = accountFile;
19
+ this.melcloudDevicesList = melcloudDevicesList;
19
20
  this.functions = new Functions(this.logWarn, this.logError, this.logDebug)
20
21
  .on('warn', warn => this.emit('warn', warn))
21
22
  .on('error', error => this.emit('error', error))
@@ -156,6 +157,19 @@ class MelCloudAtw extends EventEmitter {
156
157
  };
157
158
  };
158
159
 
160
+ async checkState(devicesData) {
161
+ try {
162
+ this.headers = devicesData.Headers;
163
+ const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
164
+ deviceData.Scenes = devicesData.Scenes ?? [];
165
+ await this.updateState(deviceData);
166
+
167
+ return true;
168
+ } catch (error) {
169
+ throw new Error(`Chaeck state error: ${error.message}`);
170
+ };
171
+ }
172
+
159
173
  async send(accountType, displayType, deviceData, flag, flagData) {
160
174
  try {
161
175
 
@@ -16,6 +16,7 @@ class MelCloudErv extends EventEmitter {
16
16
  this.deviceId = device.id;
17
17
  this.defaultTempsFile = defaultTempsFile;
18
18
  this.accountFile = accountFile;
19
+ this.melcloudDevicesList = melcloudDevicesList;
19
20
  this.functions = new Functions(this.logWarn, this.logError, this.logDebug)
20
21
  .on('warn', warn => this.emit('warn', warn))
21
22
  .on('error', error => this.emit('error', error))
@@ -159,6 +160,19 @@ class MelCloudErv extends EventEmitter {
159
160
  };
160
161
  };
161
162
 
163
+ async checkState(devicesData) {
164
+ try {
165
+ this.headers = devicesData.Headers;
166
+ const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
167
+ deviceData.Scenes = devicesData.Scenes ?? [];
168
+ await this.updateState(deviceData);
169
+
170
+ return true;
171
+ } catch (error) {
172
+ throw new Error(`Chaeck state error: ${error.message}`);
173
+ };
174
+ }
175
+
162
176
  async send(accountType, displayType, deviceData, flag, flagData) {
163
177
  try {
164
178
  let method = null