homebridge-melcloud-control 4.2.3-beta.30 → 4.2.3-beta.32

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.30",
4
+ "version": "4.2.3-beta.32",
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/constants.js CHANGED
@@ -36,9 +36,10 @@ export const ApiUrlsHome = {
36
36
  PostHolidayMode: "https://melcloudhome.com/ata/deviceid/holidaymode",
37
37
  PostProtectionFrost: "https://melcloudhome.com/ata/deviceid/frostprotection",
38
38
  PostProtectionOverheat: "https://melcloudhome.com/ata/deviceid/overheatprotection",
39
- PutDeviceSettings: "https://melcloudhome.com/dashboard",
39
+ PutDashboard: "https://melcloudhome.com/dashboard",
40
40
  PutScheduleEnabled: "https://melcloudhome.com/ata/deviceid/schedule",
41
- }
41
+ },
42
+ Origin: "https://melcloudhome.com"
42
43
  };
43
44
 
44
45
  export const DeviceType = [
@@ -131,6 +131,7 @@ class MelCloudAta extends EventEmitter {
131
131
  let method = null
132
132
  let payload = {};
133
133
  let path = '';
134
+ let origin = '';
134
135
  let referer = '';
135
136
  switch (accountType) {
136
137
  case "melcloud":
@@ -192,7 +193,8 @@ class MelCloudAta extends EventEmitter {
192
193
  };
193
194
  method = 'POST';
194
195
  path = ApiUrlsHome.PostProtectionFrost;
195
- referer = ApiUrlsHome.Referers.PostProtectionFrost.replace('deviceid', deviceData.DeviceID);
196
+ deviceData.Headers.Origin = ApiUrlsHome.Origin;
197
+ deviceData.Headers.Referer = ApiUrlsHome.Referers.PostProtectionFrost.replace('deviceid', deviceData.DeviceID);
196
198
  break;
197
199
  case 'overheatprotection':
198
200
  payload = {
@@ -203,7 +205,8 @@ class MelCloudAta extends EventEmitter {
203
205
  };
204
206
  method = 'POST';
205
207
  path = ApiUrlsHome.PostProtectionOverheat;
206
- referer = ApiUrlsHome.Referers.PostProtectionOverheat.replace('deviceid', deviceData.DeviceID);
208
+ deviceData.Headers.Origin = ApiUrlsHome.Origin;
209
+ deviceData.Headers.Referer = ApiUrlsHome.Referers.PostProtectionOverheat.replace('deviceid', deviceData.DeviceID);
207
210
  break;
208
211
  case 'holidaymode':
209
212
  payload = {
@@ -214,13 +217,15 @@ class MelCloudAta extends EventEmitter {
214
217
  };
215
218
  method = 'POST';
216
219
  path = ApiUrlsHome.PostHolidayMode;
217
- referer = ApiUrlsHome.Referers.PostHolidayMode.replace('deviceid', deviceData.DeviceID);
220
+ deviceData.Headers.Origin = ApiUrlsHome.Origin;
221
+ deviceData.Headers.Referer = ApiUrlsHome.Referers.PostHolidayMode.replace('deviceid', deviceData.DeviceID);
218
222
  break;
219
223
  case 'schedule':
220
224
  payload = { enabled: deviceData.ScheduleEnabled };
221
225
  method = 'PUT';
222
226
  path = ApiUrlsHome.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
223
- referer = ApiUrlsHome.Referers.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
227
+ deviceData.Headers.Origin = ApiUrlsHome.Origin;
228
+ deviceData.Headers.Referer = ApiUrlsHome.Referers.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
224
229
  break;
225
230
  default:
226
231
  payload = {
@@ -233,11 +238,10 @@ class MelCloudAta extends EventEmitter {
233
238
  };
234
239
  method = 'PUT';
235
240
  path = ApiUrlsHome.PutAta.replace('deviceid', deviceData.DeviceID);
236
- referer = ApiUrlsHome.Referers.PutDeviceSettings
241
+ deviceData.Headers.Referer = ApiUrlsHome.Referers.PutDashboard
237
242
  break
238
243
  }
239
244
 
240
- deviceData.Headers.Referer = referer;
241
245
  if (!this.logDebug) this.emit('warn', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(deviceData.Headers, null, 2)}`);
242
246
  await axios(path, {
243
247
  method: method,
@@ -56,7 +56,7 @@ class MelCloudAtw extends EventEmitter {
56
56
 
57
57
  if (this.accountType === 'melcloudhome') {
58
58
  }
59
-
59
+
60
60
  const safeConfig = {
61
61
  ...deviceData,
62
62
  Headers: 'removed',
@@ -138,6 +138,8 @@ class MelCloudAtw extends EventEmitter {
138
138
  let method = null
139
139
  let payload = {};
140
140
  let path = '';
141
+ let origin = '';
142
+ let referer = '';
141
143
  switch (accountType) {
142
144
  case "melcloud":
143
145
  deviceData.Device.EffectiveFlags = effectiveFlags;
@@ -177,14 +179,23 @@ class MelCloudAtw extends EventEmitter {
177
179
  case "melcloudhome":
178
180
  switch (effectiveFlags) {
179
181
  case 'holidaymode':
180
- payload = { enabled: deviceData.HolidayMode.Enabled, startDate: deviceData.HolidayMode.StartDate, endDate: deviceData.HolidayMode.EndDate, units: { "ATW": [deviceData.DeviceID] } };
182
+ payload = {
183
+ enabled: deviceData.HolidayMode.Enabled,
184
+ startDate: deviceData.HolidayMode.StartDate,
185
+ endDate: deviceData.HolidayMode.EndDate,
186
+ units: { "ATW": [deviceData.DeviceID] }
187
+ };
181
188
  method = 'POST';
182
189
  path = ApiUrlsHome.PostHolidayMode;
190
+ deviceData.Headers.Origin = ApiUrlsHome.Origin;
191
+ deviceData.Headers.Referer = ApiUrlsHome.Referers.PostHolidayMode.replace('deviceid', deviceData.DeviceID);
183
192
  break;
184
193
  case 'schedule':
185
194
  payload = { enabled: deviceData.ScheduleEnabled };
186
195
  method = 'PUT';
187
- path = ApiUrlsHome.PutScheduleEnable.replace('deviceid', deviceData.DeviceID);
196
+ path = ApiUrlsHome.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
197
+ deviceData.Headers.Origin = ApiUrlsHome.Origin;
198
+ deviceData.Headers.Referer = ApiUrlsHome.Referers.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
188
199
  break;
189
200
  default:
190
201
  payload = {
@@ -203,11 +214,12 @@ class MelCloudAtw extends EventEmitter {
203
214
  EcoHotWater: deviceData.Device.EcoHotWater,
204
215
  };
205
216
  method = 'PUT';
206
- path = ApiUrlsHome.SetAtw.replace('deviceid', deviceData.DeviceID);
217
+ path = ApiUrlsHome.PutAtw.replace('deviceid', deviceData.DeviceID);
218
+ deviceData.Headers.Referer = ApiUrlsHome.Referers.PutDashboard
207
219
  break
208
220
  }
209
221
 
210
- if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
222
+ if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(deviceData.Headers, null, 2)}`);
211
223
  await axios(path, {
212
224
  method: method,
213
225
  baseURL: ApiUrlsHome.BaseURL,
@@ -125,6 +125,8 @@ class MelCloudErv extends EventEmitter {
125
125
  let method = null
126
126
  let payload = {};
127
127
  let path = '';
128
+ let origin = '';
129
+ let referer = '';
128
130
  switch (accountType) {
129
131
  case "melcloud":
130
132
  //set target temp based on display mode and ventilation mode
@@ -191,14 +193,23 @@ class MelCloudErv extends EventEmitter {
191
193
 
192
194
  switch (effectiveFlags) {
193
195
  case 'holidaymode':
194
- payload = { enabled: deviceData.HolidayMode.Enabled, startDate: deviceData.HolidayMode.StartDate, endDate: deviceData.HolidayMode.EndDate, units: { "ERV": [deviceData.DeviceID] } };
196
+ payload = {
197
+ enabled: deviceData.HolidayMode.Enabled,
198
+ startDate: deviceData.HolidayMode.StartDate,
199
+ endDate: deviceData.HolidayMode.EndDate,
200
+ units: { "ATW": [deviceData.DeviceID] }
201
+ };
195
202
  method = 'POST';
196
203
  path = ApiUrlsHome.PostHolidayMode;
204
+ deviceData.Headers.Origin = ApiUrlsHome.Origin;
205
+ deviceData.Headers.Referer = ApiUrlsHome.Referers.PostHolidayMode.replace('deviceid', deviceData.DeviceID);
197
206
  break;
198
207
  case 'schedule':
199
208
  payload = { enabled: deviceData.ScheduleEnabled };
200
209
  method = 'PUT';
201
- path = ApiUrlsHome.PutScheduleEnable.replace('deviceid', deviceData.DeviceID);
210
+ path = ApiUrlsHome.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
211
+ deviceData.Headers.Origin = ApiUrlsHome.Origin;
212
+ deviceData.Headers.Referer = ApiUrlsHome.Referers.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
202
213
  break;
203
214
  default:
204
215
  payload = {
@@ -209,11 +220,12 @@ class MelCloudErv extends EventEmitter {
209
220
  VentilationMode: Ventilation.VentilationModeMapEnumToString[deviceData.Device.VentilationMode],
210
221
  };
211
222
  method = 'PUT';
212
- path = ApiUrlsHome.SetErv.replace('deviceid', deviceData.DeviceID);
223
+ path = ApiUrlsHome.PutErv.replace('deviceid', deviceData.DeviceID);
224
+ deviceData.Headers.Referer = ApiUrlsHome.Referers.PutDashboard
213
225
  break
214
226
  }
215
227
 
216
- if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
228
+ if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(deviceData.Headers, null, 2)}`);
217
229
  await axios(path, {
218
230
  method: method,
219
231
  baseURL: ApiUrlsHome.BaseURL,