homebridge-melcloud-control 4.2.5-beta.22 → 4.2.5-beta.24

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.5-beta.22",
4
+ "version": "4.2.5-beta.24",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -23,7 +23,7 @@ class MelCloudAta extends EventEmitter {
23
23
 
24
24
  //set default values
25
25
  this.deviceData = {};
26
- this.baseURL = this.accountType === 'melcloud' ? ApiUrls.BaseURL : ApiUrlsHome.BaseURL;
26
+ this.headers = {};
27
27
 
28
28
  //lock flag
29
29
  this.locks = false;
@@ -53,12 +53,7 @@ class MelCloudAta extends EventEmitter {
53
53
  try {
54
54
  //read device info from file
55
55
  const devicesData = await this.functions.readData(this.devicesFile, true);
56
- if (!this.logDebug) this.emit('warn', `Device Data: ${JSON.stringify(devicesData, null, 2)}`);
57
- this.axiosInstance = axios.create({
58
- baseURL: this.baseURL,
59
- timeout: 30000,
60
- headers: devicesData.Headers
61
- });
56
+ this.headers = devicesData.Headers;
62
57
 
63
58
  const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
64
59
  if (this.accountType === 'melcloudhome') {
@@ -167,7 +162,13 @@ class MelCloudAta extends EventEmitter {
167
162
  };
168
163
 
169
164
  if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
170
- await this.axiosInstance(path, { method: 'POST', data: payload });
165
+ await axios(ApiUrls.SetAta, {
166
+ method: 'POST',
167
+ baseURL: ApiUrls.BaseURL,
168
+ timeout: 30000,
169
+ headers: this.headers,
170
+ data: payload
171
+ });
171
172
  this.updateData(deviceData);
172
173
  return true;
173
174
  case "melcloudhome":
@@ -193,7 +194,7 @@ class MelCloudAta extends EventEmitter {
193
194
  };
194
195
  method = 'POST';
195
196
  path = ApiUrlsHome.PostProtectionFrost;
196
- //this.headers.Referer = ApiUrlsHome.Referers.PostProtectionFrost.replace('deviceid', deviceData.DeviceID);
197
+ this.headers.Referer = ApiUrlsHome.Referers.PostProtectionFrost.replace('deviceid', deviceData.DeviceID);
197
198
  break;
198
199
  case 'overheatprotection':
199
200
  payload = {
@@ -204,7 +205,7 @@ class MelCloudAta extends EventEmitter {
204
205
  };
205
206
  method = 'POST';
206
207
  path = ApiUrlsHome.PostProtectionOverheat;
207
- //this.headers.Referer = ApiUrlsHome.Referers.PostProtectionOverheat.replace('deviceid', deviceData.DeviceID);
208
+ this.headers.Referer = ApiUrlsHome.Referers.PostProtectionOverheat.replace('deviceid', deviceData.DeviceID);
208
209
  break;
209
210
  case 'holidaymode':
210
211
  payload = {
@@ -215,19 +216,19 @@ class MelCloudAta extends EventEmitter {
215
216
  };
216
217
  method = 'POST';
217
218
  path = ApiUrlsHome.PostHolidayMode;
218
- //this.headers.Referer = ApiUrlsHome.Referers.PostHolidayMode.replace('deviceid', deviceData.DeviceID);
219
+ this.headers.Referer = ApiUrlsHome.Referers.PostHolidayMode.replace('deviceid', deviceData.DeviceID);
219
220
  break;
220
221
  case 'schedule':
221
222
  payload = { enabled: deviceData.ScheduleEnabled };
222
223
  method = 'PUT';
223
224
  path = ApiUrlsHome.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
224
- //this.headers.Referer = ApiUrlsHome.Referers.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
225
+ this.headers.Referer = ApiUrlsHome.Referers.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
225
226
  break;
226
227
  case 'scene':
227
228
  method = 'PUT';
228
229
  const state = flagData.Enabled ? 'Enable' : 'Disable';
229
230
  path = ApiUrlsHome.PutScene[state].replace('sceneid', flagData.Id);
230
- //this.headers.Referer = ApiUrlsHome.Referers.GetPutScenes;
231
+ this.headers.Referer = ApiUrlsHome.Referers.GetPutScenes;
231
232
  break;
232
233
  default:
233
234
  payload = {
@@ -242,14 +243,20 @@ class MelCloudAta extends EventEmitter {
242
243
  };
243
244
  method = 'PUT';
244
245
  path = ApiUrlsHome.PutAta.replace('deviceid', deviceData.DeviceID);
245
- //this.headers.Referer = ApiUrlsHome.Referers.PutDeviceSettings;
246
+ this.headers.Referer = ApiUrlsHome.Referers.PutDeviceSettings;
246
247
  break
247
248
  }
248
249
 
249
- //this.headers['Content-Type'] = 'application/json; charset=utf-8';
250
- //this.headers.Origin = ApiUrlsHome.Origin;
250
+ this.headers['Content-Type'] = 'application/json; charset=utf-8';
251
+ this.headers.Origin = ApiUrlsHome.Origin;
251
252
  if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(this.headers, null, 2)}`);
252
- await this.axiosInstance(path, { method: method, data: payload });
253
+ await axios(path, {
254
+ method: method,
255
+ baseURL: ApiUrlsHome.BaseURL,
256
+ timeout: 30000,
257
+ headers: this.headers,
258
+ data: payload
259
+ });
253
260
  this.updateData(deviceData);
254
261
  return true;
255
262
  default:
@@ -267,7 +274,7 @@ class MelCloudAta extends EventEmitter {
267
274
 
268
275
  setTimeout(() => {
269
276
  this.lock = false
270
- }, 2500);
277
+ }, 5000);
271
278
  }
272
279
  };
273
280
  export default MelCloudAta;
@@ -23,9 +23,10 @@ class MelCloudAtw extends EventEmitter {
23
23
 
24
24
  //set default values
25
25
  this.devicesData = {};
26
+ this.headers = {};
26
27
 
27
28
  //lock flags
28
- this.locks = true;
29
+ this.locks = false;
29
30
  this.impulseGenerator = new ImpulseGenerator()
30
31
  .on('checkState', () => this.handleWithLock(async () => {
31
32
  await this.checkState();
@@ -52,11 +53,7 @@ class MelCloudAtw extends EventEmitter {
52
53
  try {
53
54
  //read device info from file
54
55
  const devicesData = await this.functions.readData(this.devicesFile, true);
55
- this.axiosInstance = axios.create({
56
- baseURL: this.baseURL,
57
- timeout: 30000,
58
- headers: devicesData.Headers
59
- });
56
+ this.headers = devicesData.Headers;
60
57
 
61
58
  const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
62
59
  if (this.accountType === 'melcloudhome') {
@@ -171,7 +168,13 @@ class MelCloudAtw extends EventEmitter {
171
168
  }
172
169
 
173
170
  if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
174
- await this.axiosInstance(path, { method: 'POST', data: payload });
171
+ await axios(ApiUrls.SetAtw, {
172
+ method: 'POST',
173
+ baseURL: ApiUrls.BaseURL,
174
+ timeout: 30000,
175
+ headers: this.headers,
176
+ data: payload
177
+ });
175
178
  this.updateData(deviceData);
176
179
  return true;
177
180
  case "melcloudhome":
@@ -224,7 +227,13 @@ class MelCloudAtw extends EventEmitter {
224
227
  this.headers['Content-Type'] = 'application/json; charset=utf-8';
225
228
  this.headers.Origin = ApiUrlsHome.Origin;
226
229
  if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(this.headers, null, 2)}`);
227
- await this.axiosInstance(path, { method: method, data: payload });
230
+ await axios(path, {
231
+ method: method,
232
+ baseURL: ApiUrlsHome.BaseURL,
233
+ timeout: 30000,
234
+ headers: this.headers,
235
+ data: payload
236
+ });
228
237
  this.updateData(deviceData);
229
238
  return true;
230
239
  default:
@@ -242,7 +251,7 @@ class MelCloudAtw extends EventEmitter {
242
251
 
243
252
  setTimeout(() => {
244
253
  this.lock = false
245
- }, 2500);
254
+ }, 5000);
246
255
  }
247
256
  };
248
257
  export default MelCloudAtw;
@@ -23,9 +23,10 @@ class MelCloudErv extends EventEmitter {
23
23
 
24
24
  //set default values
25
25
  this.devicesData = {};
26
+ this.headers = {};
26
27
 
27
28
  //lock flags
28
- this.locks = true;
29
+ this.locks = false;
29
30
  this.impulseGenerator = new ImpulseGenerator()
30
31
  .on('checkState', () => this.handleWithLock(async () => {
31
32
  await this.checkState();
@@ -52,11 +53,7 @@ class MelCloudErv extends EventEmitter {
52
53
  try {
53
54
  //read device info from file
54
55
  const devicesData = await this.functions.readData(this.devicesFile, true);
55
- this.axiosInstance = axios.create({
56
- baseURL: this.baseURL,
57
- timeout: 30000,
58
- headers: devicesData.Headers
59
- });
56
+ this.headers = devicesData.Headers;
60
57
 
61
58
  const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
62
59
  if (this.accountType === 'melcloudhome') {
@@ -174,7 +171,13 @@ class MelCloudErv extends EventEmitter {
174
171
  }
175
172
 
176
173
  if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
177
- await this.axiosInstance(path, { method: 'POST', data: payload });
174
+ await axios(ApiUrls.SetErv, {
175
+ method: 'POST',
176
+ baseURL: ApiUrls.BaseURL,
177
+ timeout: 30000,
178
+ headers: this.headers,
179
+ data: payload
180
+ });
178
181
  this.updateData(deviceData);
179
182
  return true;
180
183
  case "melcloudhome":
@@ -231,7 +234,13 @@ class MelCloudErv extends EventEmitter {
231
234
  this.headers['Content-Type'] = 'application/json; charset=utf-8';
232
235
  this.headers.Origin = ApiUrlsHome.Origin;
233
236
  if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(this.headers, null, 2)}`);
234
- await this.axiosInstance(path, { method: method, data: payload });
237
+ await axios(path, {
238
+ method: method,
239
+ baseURL: ApiUrlsHome.BaseURL,
240
+ timeout: 30000,
241
+ headers: this.headers,
242
+ data: payload
243
+ });
235
244
  this.updateData(deviceData);
236
245
  return true;
237
246
  default:
@@ -249,7 +258,7 @@ class MelCloudErv extends EventEmitter {
249
258
 
250
259
  setTimeout(() => {
251
260
  this.lock = false
252
- }, 2500);
261
+ }, 5000);
253
262
  }
254
263
  };
255
264
  export default MelCloudErv;