homebridge-melcloud-control 4.0.0-beta.554 → 4.0.0-beta.556

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.0.0-beta.554",
4
+ "version": "4.0.0-beta.556",
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
@@ -64,11 +64,15 @@ class MelCloud extends EventEmitter {
64
64
  async checkMelcloudDevicesList() {
65
65
  try {
66
66
  const devicesList = { State: false, Info: null, Devices: [] }
67
+ const headers = {
68
+ 'X-MitsContextKey': this.contextKey,
69
+ 'Content-Type': 'application/json'
70
+ }
67
71
  const axiosInstance = axios.create({
68
72
  method: 'GET',
69
73
  baseURL: ApiUrls.BaseURL,
70
74
  timeout: 15000,
71
- headers: { 'X-MitsContextKey': this.contextKey }
75
+ headers: headers
72
76
  });
73
77
 
74
78
  if (this.logDebug) this.emit('debug', `Scanning for devices...`);
@@ -112,7 +116,8 @@ class MelCloud extends EventEmitter {
112
116
 
113
117
  // Zamiana ID na string
114
118
  allDevices.forEach(device => {
115
- if (device.DeviceID != null) device.DeviceID = String(device.DeviceID);
119
+ device.DeviceID = String(device.DeviceID);
120
+ device.Headers = headers;
116
121
  });
117
122
 
118
123
  if (this.logDebug) this.emit('debug', `Found ${allDevices.length} devices in building: ${building.Name || 'Unnamed'}`);
@@ -121,7 +126,6 @@ class MelCloud extends EventEmitter {
121
126
 
122
127
  const devicesCount = devicesList.Devices.length;
123
128
  if (devicesCount === 0) {
124
- devicesList.State = false;
125
129
  devicesList.Info = 'No devices found'
126
130
  return devicesList;
127
131
  }
@@ -176,7 +180,6 @@ class MelCloud extends EventEmitter {
176
180
  if (this.logDebug) this.emit('debug', `MELCloud Info: ${JSON.stringify(debugData, null, 2)}`);
177
181
 
178
182
  if (!contextKey) {
179
- accountInfo.State = false;
180
183
  accountInfo.Info = 'Context key missing'
181
184
  return accountInfo;
182
185
  }
@@ -198,23 +201,24 @@ class MelCloud extends EventEmitter {
198
201
  async checkMelcloudHomeDevicesList() {
199
202
  try {
200
203
  const devicesList = { State: false, Info: null, Devices: [] }
204
+ const headers = {
205
+ 'Accept': '*/*',
206
+ 'Accept-Language': 'en-US,en;q=0.9',
207
+ 'Cookie': this.contextKey,
208
+ 'User-Agent': 'homebridge-melcloud-control/4.0.0',
209
+ 'DNT': '1',
210
+ 'Origin': 'https://melcloudhome.com',
211
+ 'Referer': 'https://melcloudhome.com/dashboard',
212
+ 'Sec-Fetch-Dest': 'empty',
213
+ 'Sec-Fetch-Mode': 'cors',
214
+ 'Sec-Fetch-Site': 'same-origin',
215
+ 'X-CSRF': '1'
216
+ };
201
217
  const axiosInstance = axios.create({
202
218
  method: 'GET',
203
219
  baseURL: ApiUrlsHome.BaseURL,
204
220
  timeout: 25000,
205
- headers: {
206
- 'Accept': '*/*',
207
- 'Accept-Language': 'en-US,en;q=0.9',
208
- 'Cookie': this.contextKey,
209
- 'User-Agent': 'homebridge-melcloud-control/4.0.0',
210
- 'DNT': '1',
211
- 'Origin': 'https://melcloudhome.com',
212
- 'Referer': 'https://melcloudhome.com/dashboard',
213
- 'Sec-Fetch-Dest': 'empty',
214
- 'Sec-Fetch-Mode': 'cors',
215
- 'Sec-Fetch-Site': 'same-origin',
216
- 'X-CSRF': '1'
217
- }
221
+ headers: headers
218
222
  });
219
223
 
220
224
  if (this.logDebug) this.emit('debug', `Scanning for devices`);
@@ -270,11 +274,11 @@ class MelCloud extends EventEmitter {
270
274
 
271
275
  return {
272
276
  ...rest,
273
- ContextKey: this.contextKey,
274
277
  Type: type,
275
278
  DeviceID: Id,
276
279
  DeviceName: GivenDisplayName,
277
- Device: deviceObject
280
+ Device: deviceObject,
281
+ Headers: headers
278
282
  };
279
283
  };
280
284
 
@@ -287,7 +291,6 @@ class MelCloud extends EventEmitter {
287
291
 
288
292
  const devicesCount = devices.length;
289
293
  if (devicesCount === 0) {
290
- devicesList.State = false;
291
294
  devicesList.Info = 'No devices found'
292
295
  return devicesList;
293
296
  }
@@ -52,7 +52,6 @@ class MelCloudAta extends EventEmitter {
52
52
  try {
53
53
  //read device info from file
54
54
  const devicesData = await this.functions.readData(this.devicesFile, true);
55
-
56
55
  if (!Array.isArray(devicesData)) {
57
56
  if (this.logWarn) this.emit('warn', `Device data not found`);
58
57
  return null;
@@ -75,8 +74,8 @@ class MelCloudAta extends EventEmitter {
75
74
  if (this.logDebug) this.emit('debug', `Device Data: ${JSON.stringify(deviceData, null, 2)}`);
76
75
 
77
76
  //device info
78
- const hideVaneControls = deviceData.HideVaneControls ?? false;
79
- const hideDryModeControl = deviceData.HideDryModeControl ?? false;
77
+ const hideVaneControls = deviceData.HideVaneControls;
78
+ const hideDryModeControl = deviceData.HideDryModeControl;
80
79
  const serialNumber = deviceData.SerialNumber;
81
80
 
82
81
  //device
@@ -147,7 +146,8 @@ class MelCloudAta extends EventEmitter {
147
146
  ProhibitOperationMode: prohibitOperationMode,
148
147
  HideVaneControls: hideVaneControls,
149
148
  HideDryModeControl: hideDryModeControl,
150
- IsInError: isInError
149
+ IsInError: isInError,
150
+ Headers: deviceData.Headers
151
151
  }
152
152
 
153
153
  //restFul
@@ -185,11 +185,8 @@ class MelCloudAta extends EventEmitter {
185
185
  const axiosInstancePost = axios.create({
186
186
  method: 'POST',
187
187
  baseURL: ApiUrls.BaseURL,
188
- timeout: 25000,
189
- headers: {
190
- 'X-MitsContextKey': deviceData.ContextKey,
191
- 'Content-Type': 'application/json'
192
- },
188
+ timeout: 10000,
189
+ headers: deviceData.Headers,
193
190
  withCredentials: true
194
191
  });
195
192
 
@@ -227,20 +224,9 @@ class MelCloudAta extends EventEmitter {
227
224
  const axiosInstancePut = axios.create({
228
225
  method: 'PUT',
229
226
  baseURL: ApiUrlsHome.BaseURL,
230
- timeout: 25000,
231
- headers: {
232
- 'Accept': '*/*',
233
- 'Accept-Language': 'en-US,en;q=0.9',
234
- 'Cookie': deviceData.ContextKey,
235
- 'User-Agent': 'homebridge-melcloud-control/4.0.0',
236
- 'DNT': '1',
237
- 'Origin': 'https://melcloudhome.com',
238
- 'Referer': 'https://melcloudhome.com/dashboard',
239
- 'Sec-Fetch-Dest': 'empty',
240
- 'Sec-Fetch-Mode': 'cors',
241
- 'Sec-Fetch-Site': 'same-origin',
242
- 'X-CSRF': '1'
243
- }
227
+ timeout: 10000,
228
+ headers: deviceData.Headers,
229
+ withCredentials: true
244
230
  });
245
231
 
246
232
  if (displayType === 1 && deviceData.Device.OperationMode === 8) {
@@ -148,7 +148,8 @@ class MelCloudAtw extends EventEmitter {
148
148
  ProhibitZone1: prohibitHeatingZone1,
149
149
  ProhibitZone2: prohibitHeatingZone2,
150
150
  ProhibitHotWater: prohibitHotWater,
151
- IsInError: isInError
151
+ IsInError: isInError,
152
+ Headers: deviceData.Headers
152
153
  }
153
154
 
154
155
  //restFul
@@ -186,11 +187,8 @@ class MelCloudAtw extends EventEmitter {
186
187
  const axiosInstancePost = axios.create({
187
188
  method: 'POST',
188
189
  baseURL: ApiUrls.BaseURL,
189
- timeout: 25000,
190
- headers: {
191
- 'X-MitsContextKey': deviceData.ContextKey,
192
- 'Content-Type': 'application/json'
193
- },
190
+ timeout: 10000,
191
+ headers: deviceData.Headers,
194
192
  withCredentials: true
195
193
  });
196
194
 
@@ -240,20 +238,9 @@ class MelCloudAtw extends EventEmitter {
240
238
  const axiosInstancePut = axios.create({
241
239
  method: 'PUT',
242
240
  baseURL: ApiUrlsHome.BaseURL,
243
- timeout: 25000,
244
- headers: {
245
- 'Accept': '*/*',
246
- 'Accept-Language': 'en-US,en;q=0.9',
247
- 'Cookie': deviceData.ContextKey,
248
- 'User-Agent': 'homebridge-melcloud-control/4.0.0',
249
- 'DNT': '1',
250
- 'Origin': 'https://melcloudhome.com',
251
- 'Referer': 'https://melcloudhome.com/dashboard',
252
- 'Sec-Fetch-Dest': 'empty',
253
- 'Sec-Fetch-Mode': 'cors',
254
- 'Sec-Fetch-Site': 'same-origin',
255
- 'X-CSRF': '1'
256
- }
241
+ timeout: 10000,
242
+ headers: deviceData.Headers,
243
+ withCredentials: true
257
244
  });
258
245
 
259
246
  if (displayType === 1 && deviceData.Device.OperationMode === 8) {
@@ -140,7 +140,8 @@ class MelCloudErv extends EventEmitter {
140
140
  HideRoomTemperature: hideRoomTemperature,
141
141
  HideSupplyTemperature: hideSupplyTemperature,
142
142
  HideOutdoorTemperature: hideOutdoorTemperature,
143
- IsInError: isInError
143
+ IsInError: isInError,
144
+ Headers: deviceData.Headers
144
145
  }
145
146
 
146
147
  //restFul
@@ -178,11 +179,8 @@ class MelCloudErv extends EventEmitter {
178
179
  const axiosInstancePost = axios.create({
179
180
  method: 'POST',
180
181
  baseURL: ApiUrls.BaseURL,
181
- timeout: 25000,
182
- headers: {
183
- 'X-MitsContextKey': deviceData.ContextKey,
184
- 'Content-Type': 'application/json'
185
- },
182
+ timeout: 10000,
183
+ headers: deviceData.Headers,
186
184
  withCredentials: true
187
185
  });
188
186
 
@@ -234,20 +232,9 @@ class MelCloudErv extends EventEmitter {
234
232
  const axiosInstancePut = axios.create({
235
233
  method: 'PUT',
236
234
  baseURL: ApiUrlsHome.BaseURL,
237
- timeout: 25000,
238
- headers: {
239
- 'Accept': '*/*',
240
- 'Accept-Language': 'en-US,en;q=0.9',
241
- 'Cookie': deviceData.ContextKey,
242
- 'User-Agent': 'homebridge-melcloud-control/4.0.0',
243
- 'DNT': '1',
244
- 'Origin': 'https://melcloudhome.com',
245
- 'Referer': 'https://melcloudhome.com/dashboard',
246
- 'Sec-Fetch-Dest': 'empty',
247
- 'Sec-Fetch-Mode': 'cors',
248
- 'Sec-Fetch-Site': 'same-origin',
249
- 'X-CSRF': '1'
250
- }
235
+ timeout: 10000,
236
+ headers: deviceData.Headers,
237
+ withCredentials: true
251
238
  });
252
239
 
253
240
  if (displayType === 1 && deviceData.Device.OperationMode === 8) {