homebridge-melcloud-control 4.2.3-beta.34 → 4.2.3-beta.35

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.34",
4
+ "version": "4.2.3-beta.35",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -131,8 +131,6 @@ class MelCloudAta extends EventEmitter {
131
131
  let method = null
132
132
  let payload = {};
133
133
  let path = '';
134
- let origin = '';
135
- let referer = '';
136
134
  switch (accountType) {
137
135
  case "melcloud":
138
136
 
@@ -207,13 +205,20 @@ class MelCloudAta extends EventEmitter {
207
205
  deviceData.Headers.Referer = ApiUrlsHome.Referers.PostProtectionOverheat.replace('deviceid', deviceData.DeviceID);
208
206
  break;
209
207
  case 'holidaymode':
208
+ const formatDateNoSeconds = (date) => {
209
+ const d = new Date(date);
210
+ const pad = (n) => n.toString().padStart(2, '0');
211
+ return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
212
+ };
213
+
214
+ // przykład użycia
210
215
  payload = {
211
216
  enabled: deviceData.HolidayMode.Enabled,
212
- startDate: deviceData.HolidayMode.StartDate,
213
- endDate: deviceData.HolidayMode.EndDate,
217
+ startDate: formatDateNoSeconds(deviceData.HolidayMode.StartDate),
218
+ endDate: formatDateNoSeconds(deviceData.HolidayMode.EndDate),
214
219
  units: { "ATA": [deviceData.DeviceID] }
215
220
  };
216
- method = 'PUT';
221
+ method = 'POST';
217
222
  path = ApiUrlsHome.PostHolidayMode;
218
223
  deviceData.Headers.Referer = ApiUrlsHome.Referers.PostHolidayMode.replace('deviceid', deviceData.DeviceID);
219
224
  break;
@@ -138,8 +138,6 @@ class MelCloudAtw extends EventEmitter {
138
138
  let method = null
139
139
  let payload = {};
140
140
  let path = '';
141
- let origin = '';
142
- let referer = '';
143
141
  switch (accountType) {
144
142
  case "melcloud":
145
143
  deviceData.Device.EffectiveFlags = effectiveFlags;
@@ -219,6 +217,8 @@ class MelCloudAtw extends EventEmitter {
219
217
  break
220
218
  }
221
219
 
220
+ deviceData.Headers['Content-Type'] = 'application/json; charset=utf-8';
221
+ deviceData.Headers.Origin = ApiUrlsHome.Origin;
222
222
  if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(deviceData.Headers, null, 2)}`);
223
223
  await axios(path, {
224
224
  method: method,
@@ -125,8 +125,6 @@ class MelCloudErv extends EventEmitter {
125
125
  let method = null
126
126
  let payload = {};
127
127
  let path = '';
128
- let origin = '';
129
- let referer = '';
130
128
  switch (accountType) {
131
129
  case "melcloud":
132
130
  //set target temp based on display mode and ventilation mode
@@ -225,6 +223,8 @@ class MelCloudErv extends EventEmitter {
225
223
  break
226
224
  }
227
225
 
226
+ deviceData.Headers['Content-Type'] = 'application/json; charset=utf-8';
227
+ deviceData.Headers.Origin = ApiUrlsHome.Origin;
228
228
  if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(deviceData.Headers, null, 2)}`);
229
229
  await axios(path, {
230
230
  method: method,