homebridge-melcloud-control 4.2.3-beta.1 → 4.2.3-beta.3

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.2.3-beta.1",
4
+ "version": "4.2.3-beta.3",
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/melcloud.js CHANGED
@@ -68,16 +68,15 @@ class MelCloud extends EventEmitter {
68
68
  'X-MitsContextKey': this.contextKey,
69
69
  'Content-Type': 'application/json'
70
70
  }
71
- const axiosInstance = axios.create({
71
+
72
+ if (this.logDebug) this.emit('debug', `Scanning for devices...`);
73
+ const listDevicesData = await axios(ApiUrls.ListDevices, {
72
74
  method: 'GET',
73
75
  baseURL: ApiUrls.BaseURL,
74
76
  timeout: 15000,
75
77
  headers: headers
76
78
  });
77
79
 
78
- if (this.logDebug) this.emit('debug', `Scanning for devices...`);
79
- const listDevicesData = await axiosInstance(ApiUrls.ListDevices);
80
-
81
80
  if (!listDevicesData || !listDevicesData.data) {
82
81
  devicesList.Info = 'Invalid or empty response from MELCloud API'
83
82
  return devicesList;
@@ -143,7 +142,7 @@ class MelCloud extends EventEmitter {
143
142
 
144
143
  try {
145
144
  const accountInfo = { State: false, Info: '', LoginData: null, ContextKey: null, UseFahrenheit: false }
146
- const axiosInstance = axios.create({
145
+ const accountData = await axios(ApiUrls.ClientLogin, {
147
146
  method: 'POST',
148
147
  baseURL: ApiUrls.BaseURL,
149
148
  timeout: 15000,
@@ -157,9 +156,6 @@ class MelCloud extends EventEmitter {
157
156
  Persist: true
158
157
  }
159
158
  });
160
-
161
-
162
- const accountData = await axiosInstance(ApiUrls.ClientLogin);
163
159
  const account = accountData.data;
164
160
  const loginData = account.LoginData ?? [];
165
161
  const contextKey = loginData.ContextKey;
@@ -210,15 +206,14 @@ class MelCloud extends EventEmitter {
210
206
  'Sec-Fetch-Site': 'same-origin',
211
207
  'X-CSRF': '1'
212
208
  };
213
- const axiosInstance = axios.create({
209
+
210
+ if (this.logDebug) this.emit('debug', `Scanning for devices`);
211
+ const listDevicesData = await axios(ApiUrlsHome.GetUserContext, {
214
212
  method: 'GET',
215
213
  baseURL: ApiUrlsHome.BaseURL,
216
214
  timeout: 25000,
217
215
  headers: headers
218
216
  });
219
-
220
- if (this.logDebug) this.emit('debug', `Scanning for devices`);
221
- const listDevicesData = await axiosInstance(ApiUrlsHome.GetUserContext);
222
217
  const buildingsList = listDevicesData.data.buildings;
223
218
  if (this.logDebug) this.emit('debug', `Buildings: ${JSON.stringify(buildingsList, null, 2)}`);
224
219
 
@@ -243,16 +243,14 @@ class MelCloudAta extends EventEmitter {
243
243
  break
244
244
  }
245
245
 
246
- const axiosInstancePut = axios.create({
246
+ if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
247
+ await axios(path, {
247
248
  method: method,
248
249
  baseURL: ApiUrlsHome.BaseURL,
249
250
  timeout: 10000,
250
251
  headers: deviceData.Headers,
251
252
  data: payload
252
253
  });
253
-
254
- if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
255
- await axiosInstancePut(path);
256
254
  this.updateData(deviceData);
257
255
  return true;
258
256
  default: