homebridge-melcloud-control 4.0.0-beta.417 → 4.0.0-beta.418

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/melcloud.js +12 -16
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.417",
4
+ "version": "4.0.0-beta.418",
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
@@ -133,13 +133,11 @@ class MelCloud extends EventEmitter {
133
133
  }
134
134
  }
135
135
 
136
-
137
136
  async connectToMelCloud() {
138
137
  if (this.logDebug) this.emit('debug', `Connecting to MELCloud`);
139
138
 
140
139
  try {
141
140
  const axiosInstanceLogin = axios.create({
142
- method: 'POST',
143
141
  baseURL: ApiUrls.BaseURL,
144
142
  timeout: 15000,
145
143
  });
@@ -154,7 +152,7 @@ class MelCloud extends EventEmitter {
154
152
  Persist: true
155
153
  };
156
154
 
157
- const accountData = await axiosInstanceLogin(ApiUrls.ClientLogin, { data: loginData });
155
+ const accountData = await axiosInstanceLogin.post(ApiUrls.ClientLogin, { data: loginData });
158
156
  const account = accountData.data;
159
157
  const accountInfo = account.LoginData;
160
158
  const contextKey = accountInfo?.ContextKey;
@@ -176,16 +174,6 @@ class MelCloud extends EventEmitter {
176
174
  return null;
177
175
  }
178
176
 
179
- this.axiosInstancePost = axios.create({
180
- method: 'POST',
181
- baseURL: ApiUrls.BaseURL,
182
- timeout: 15000,
183
- headers: {
184
- 'X-MitsContextKey': contextKey,
185
- 'content-type': 'application/json'
186
- }
187
- });
188
-
189
177
  await this.functions.saveData(this.accountFile, accountInfo);
190
178
  this.emit('success', `Connect to MELCloud Success`);
191
179
 
@@ -199,7 +187,6 @@ class MelCloud extends EventEmitter {
199
187
  async checkMelcloudHomeDevicesList(contextKey) {
200
188
  try {
201
189
  const axiosInstance = axios.create({
202
- method: 'GET',
203
190
  baseURL: ApiUrlsHome.BaseURL,
204
191
  timeout: 25000,
205
192
  headers: {
@@ -218,7 +205,7 @@ class MelCloud extends EventEmitter {
218
205
  });
219
206
 
220
207
  if (this.logDebug) this.emit('debug', `Scanning for devices`);
221
- const listDevicesData = await axiosInstance(ApiUrlsHome.GetUserContext);
208
+ const listDevicesData = await axiosInstance.get(ApiUrlsHome.GetUserContext);
222
209
  const buildingsList = listDevicesData.data.buildings;
223
210
  if (this.logDebug) this.emit('debug', `Buildings: ${JSON.stringify(buildingsList, null, 2)}`);
224
211
 
@@ -523,8 +510,17 @@ class MelCloud extends EventEmitter {
523
510
 
524
511
  async send(accountInfo) {
525
512
  try {
513
+ const axiosInstance = axios.create({
514
+ baseURL: ApiUrls.BaseURL,
515
+ timeout: 15000,
516
+ headers: {
517
+ 'X-MitsContextKey': this.contextKey,
518
+ 'content-type': 'application/json'
519
+ }
520
+ });
521
+
526
522
  const options = { data: accountInfo };
527
- await this.axiosInstancePost(ApiUrls.UpdateApplicationOptions, options);
523
+ await axiosInstance.post(ApiUrls.UpdateApplicationOptions, options);
528
524
  await this.functions.saveData(this.accountFile, accountInfo);
529
525
  return true;
530
526
  } catch (error) {