homebridge-melcloud-control 4.2.4 → 4.2.5-beta.0
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 +1 -1
- package/src/melcloud.js +1 -1
- package/src/melcloudata.js +13 -11
- package/src/melcloudatw.js +11 -9
- package/src/melclouderv.js +11 -9
- package/src/melcloudhome.js +1 -1
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.
|
|
4
|
+
"version": "4.2.5-beta.0",
|
|
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
|
@@ -101,7 +101,6 @@ class MelCloud extends EventEmitter {
|
|
|
101
101
|
// Zamiana ID na string
|
|
102
102
|
allDevices.forEach(device => {
|
|
103
103
|
device.DeviceID = String(device.DeviceID);
|
|
104
|
-
device.Headers = this.headers;
|
|
105
104
|
});
|
|
106
105
|
|
|
107
106
|
if (this.logDebug) this.emit('debug', `Found ${allDevices.length} devices in building: ${building.Name || 'Unnamed'}`);
|
|
@@ -117,6 +116,7 @@ class MelCloud extends EventEmitter {
|
|
|
117
116
|
devicesList.State = true;
|
|
118
117
|
devicesList.Info = `Found ${devicesCount} devices`;
|
|
119
118
|
devicesList.Devices = devices;
|
|
119
|
+
devicesList.Headers = this.headers;
|
|
120
120
|
|
|
121
121
|
await this.functions.saveData(this.devicesFile, devicesList);
|
|
122
122
|
if (this.logDebug) this.emit('debug', `${devicesCount} devices saved`);
|
package/src/melcloudata.js
CHANGED
|
@@ -23,6 +23,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
23
23
|
|
|
24
24
|
//set default values
|
|
25
25
|
this.deviceData = {};
|
|
26
|
+
this.headers = {};
|
|
26
27
|
|
|
27
28
|
//lock flag
|
|
28
29
|
this.locks = true;
|
|
@@ -52,6 +53,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
52
53
|
try {
|
|
53
54
|
//read device info from file
|
|
54
55
|
const devicesData = await this.functions.readData(this.devicesFile, true);
|
|
56
|
+
this.headers = devicesData.Headers;
|
|
55
57
|
const scenes = devicesData.Scenes ?? [];
|
|
56
58
|
const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
57
59
|
|
|
@@ -165,7 +167,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
165
167
|
method: 'POST',
|
|
166
168
|
baseURL: ApiUrls.BaseURL,
|
|
167
169
|
timeout: 10000,
|
|
168
|
-
headers:
|
|
170
|
+
headers: this.headers,
|
|
169
171
|
data: payload
|
|
170
172
|
});
|
|
171
173
|
this.updateData(deviceData);
|
|
@@ -193,7 +195,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
193
195
|
};
|
|
194
196
|
method = 'POST';
|
|
195
197
|
path = ApiUrlsHome.PostProtectionFrost;
|
|
196
|
-
|
|
198
|
+
this.headers.Referer = ApiUrlsHome.Referers.PostProtectionFrost.replace('deviceid', deviceData.DeviceID);
|
|
197
199
|
break;
|
|
198
200
|
case 'overheatprotection':
|
|
199
201
|
payload = {
|
|
@@ -204,7 +206,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
204
206
|
};
|
|
205
207
|
method = 'POST';
|
|
206
208
|
path = ApiUrlsHome.PostProtectionOverheat;
|
|
207
|
-
|
|
209
|
+
this.headers.Referer = ApiUrlsHome.Referers.PostProtectionOverheat.replace('deviceid', deviceData.DeviceID);
|
|
208
210
|
break;
|
|
209
211
|
case 'holidaymode':
|
|
210
212
|
payload = {
|
|
@@ -215,19 +217,19 @@ class MelCloudAta extends EventEmitter {
|
|
|
215
217
|
};
|
|
216
218
|
method = 'POST';
|
|
217
219
|
path = ApiUrlsHome.PostHolidayMode;
|
|
218
|
-
|
|
220
|
+
this.headers.Referer = ApiUrlsHome.Referers.PostHolidayMode.replace('deviceid', deviceData.DeviceID);
|
|
219
221
|
break;
|
|
220
222
|
case 'schedule':
|
|
221
223
|
payload = { enabled: deviceData.ScheduleEnabled };
|
|
222
224
|
method = 'PUT';
|
|
223
225
|
path = ApiUrlsHome.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
|
|
224
|
-
|
|
226
|
+
this.headers.Referer = ApiUrlsHome.Referers.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
|
|
225
227
|
break;
|
|
226
228
|
case 'scene':
|
|
227
229
|
method = 'PUT';
|
|
228
230
|
const state = flagData.Enabled ? 'Enable' : 'Disable';
|
|
229
231
|
path = ApiUrlsHome.PutScene[state].replace('sceneid', flagData.Id);
|
|
230
|
-
|
|
232
|
+
this.headers.Referer = ApiUrlsHome.Referers.GetPutScenes;
|
|
231
233
|
break;
|
|
232
234
|
default:
|
|
233
235
|
payload = {
|
|
@@ -242,18 +244,18 @@ class MelCloudAta extends EventEmitter {
|
|
|
242
244
|
};
|
|
243
245
|
method = 'PUT';
|
|
244
246
|
path = ApiUrlsHome.PutAta.replace('deviceid', deviceData.DeviceID);
|
|
245
|
-
|
|
247
|
+
this.headers.Referer = ApiUrlsHome.Referers.PutDeviceSettings
|
|
246
248
|
break
|
|
247
249
|
}
|
|
248
250
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(
|
|
251
|
+
this.headers['Content-Type'] = 'application/json; charset=utf-8';
|
|
252
|
+
this.headers.Origin = ApiUrlsHome.Origin;
|
|
253
|
+
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(this.headers, null, 2)}`);
|
|
252
254
|
await axios(path, {
|
|
253
255
|
method: method,
|
|
254
256
|
baseURL: ApiUrlsHome.BaseURL,
|
|
255
257
|
timeout: 10000,
|
|
256
|
-
headers:
|
|
258
|
+
headers: this.headers,
|
|
257
259
|
data: payload
|
|
258
260
|
});
|
|
259
261
|
this.updateData(deviceData);
|
package/src/melcloudatw.js
CHANGED
|
@@ -23,6 +23,7 @@ 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
29
|
this.locks = true;
|
|
@@ -52,6 +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);
|
|
56
|
+
this.headers = devicesData.Headers;
|
|
55
57
|
const scenes = devicesData.Scenes ?? [];
|
|
56
58
|
const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
57
59
|
|
|
@@ -171,7 +173,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
171
173
|
method: 'POST',
|
|
172
174
|
baseURL: ApiUrls.BaseURL,
|
|
173
175
|
timeout: 10000,
|
|
174
|
-
headers:
|
|
176
|
+
headers: this.headers,
|
|
175
177
|
data: payload
|
|
176
178
|
});
|
|
177
179
|
this.updateData(deviceData);
|
|
@@ -187,19 +189,19 @@ class MelCloudAtw extends EventEmitter {
|
|
|
187
189
|
};
|
|
188
190
|
method = 'POST';
|
|
189
191
|
path = ApiUrlsHome.PostHolidayMode;
|
|
190
|
-
|
|
192
|
+
this.headers.Referer = ApiUrlsHome.Referers.PostHolidayMode.replace('deviceid', deviceData.DeviceID);
|
|
191
193
|
break;
|
|
192
194
|
case 'schedule':
|
|
193
195
|
payload = { enabled: deviceData.ScheduleEnabled };
|
|
194
196
|
method = 'PUT';
|
|
195
197
|
path = ApiUrlsHome.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
|
|
196
|
-
|
|
198
|
+
this.headers.Referer = ApiUrlsHome.Referers.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
|
|
197
199
|
break;
|
|
198
200
|
case 'scene':
|
|
199
201
|
method = 'PUT';
|
|
200
202
|
const state = flagData.Enabled ? 'Enable' : 'Disable';
|
|
201
203
|
path = ApiUrlsHome.PutScene[state].replace('sceneid', flagData.Id);
|
|
202
|
-
|
|
204
|
+
this.headers.Referer = ApiUrlsHome.Referers.GetPutScenes;
|
|
203
205
|
break;
|
|
204
206
|
default:
|
|
205
207
|
payload = {
|
|
@@ -219,18 +221,18 @@ class MelCloudAtw extends EventEmitter {
|
|
|
219
221
|
};
|
|
220
222
|
method = 'PUT';
|
|
221
223
|
path = ApiUrlsHome.PutAtw.replace('deviceid', deviceData.DeviceID);
|
|
222
|
-
|
|
224
|
+
this.headers.Referer = ApiUrlsHome.Referers.PutDeviceSettings
|
|
223
225
|
break
|
|
224
226
|
}
|
|
225
227
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(
|
|
228
|
+
this.headers['Content-Type'] = 'application/json; charset=utf-8';
|
|
229
|
+
this.headers.Origin = ApiUrlsHome.Origin;
|
|
230
|
+
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(this.headers, null, 2)}`);
|
|
229
231
|
await axios(path, {
|
|
230
232
|
method: method,
|
|
231
233
|
baseURL: ApiUrlsHome.BaseURL,
|
|
232
234
|
timeout: 10000,
|
|
233
|
-
headers:
|
|
235
|
+
headers: this.headers,
|
|
234
236
|
data: payload
|
|
235
237
|
});
|
|
236
238
|
this.updateData(deviceData);
|
package/src/melclouderv.js
CHANGED
|
@@ -23,6 +23,7 @@ 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
29
|
this.locks = true;
|
|
@@ -52,6 +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);
|
|
56
|
+
this.headers = devicesData.Headers;
|
|
55
57
|
const scenes = devicesData.Scenes ?? [];
|
|
56
58
|
const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
57
59
|
|
|
@@ -174,7 +176,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
174
176
|
method: 'POST',
|
|
175
177
|
baseURL: ApiUrls.BaseURL,
|
|
176
178
|
timeout: 10000,
|
|
177
|
-
headers:
|
|
179
|
+
headers: this.headers,
|
|
178
180
|
data: payload
|
|
179
181
|
});
|
|
180
182
|
this.updateData(deviceData);
|
|
@@ -202,19 +204,19 @@ class MelCloudErv extends EventEmitter {
|
|
|
202
204
|
};
|
|
203
205
|
method = 'POST';
|
|
204
206
|
path = ApiUrlsHome.PostHolidayMode;
|
|
205
|
-
|
|
207
|
+
this.headers.Referer = ApiUrlsHome.Referers.PostHolidayMode.replace('deviceid', deviceData.DeviceID);
|
|
206
208
|
break;
|
|
207
209
|
case 'schedule':
|
|
208
210
|
payload = { enabled: deviceData.ScheduleEnabled };
|
|
209
211
|
method = 'PUT';
|
|
210
212
|
path = ApiUrlsHome.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
|
|
211
|
-
|
|
213
|
+
this.headers.Referer = ApiUrlsHome.Referers.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
|
|
212
214
|
break;
|
|
213
215
|
case 'scene':
|
|
214
216
|
method = 'PUT';
|
|
215
217
|
const state = flagData.Enabled ? 'Enable' : 'Disable';
|
|
216
218
|
path = ApiUrlsHome.PutScene[state].replace('sceneid', flagData.Id);
|
|
217
|
-
|
|
219
|
+
this.headers.Referer = ApiUrlsHome.Referers.GetPutScenes;
|
|
218
220
|
break;
|
|
219
221
|
default:
|
|
220
222
|
payload = {
|
|
@@ -226,18 +228,18 @@ class MelCloudErv extends EventEmitter {
|
|
|
226
228
|
};
|
|
227
229
|
method = 'PUT';
|
|
228
230
|
path = ApiUrlsHome.PutErv.replace('deviceid', deviceData.DeviceID);
|
|
229
|
-
|
|
231
|
+
this.headers.Referer = ApiUrlsHome.Referers.PutDeviceSettings
|
|
230
232
|
break
|
|
231
233
|
}
|
|
232
234
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(
|
|
235
|
+
this.headers['Content-Type'] = 'application/json; charset=utf-8';
|
|
236
|
+
this.headers.Origin = ApiUrlsHome.Origin;
|
|
237
|
+
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(this.headers, null, 2)}`);
|
|
236
238
|
await axios(path, {
|
|
237
239
|
method: method,
|
|
238
240
|
baseURL: ApiUrlsHome.BaseURL,
|
|
239
241
|
timeout: 10000,
|
|
240
|
-
headers:
|
|
242
|
+
headers: this.headers,
|
|
241
243
|
data: payload
|
|
242
244
|
});
|
|
243
245
|
this.updateData(deviceData);
|
package/src/melcloudhome.js
CHANGED
|
@@ -189,7 +189,6 @@ class MelCloud extends EventEmitter {
|
|
|
189
189
|
DeviceName: GivenDisplayName,
|
|
190
190
|
SerialNumber: Id,
|
|
191
191
|
Device: deviceObject,
|
|
192
|
-
Headers: this.headers
|
|
193
192
|
};
|
|
194
193
|
};
|
|
195
194
|
|
|
@@ -212,6 +211,7 @@ class MelCloud extends EventEmitter {
|
|
|
212
211
|
devicesList.Info = `Found ${devicesCount} devices`;
|
|
213
212
|
devicesList.Devices = devices;
|
|
214
213
|
devicesList.Scenes = scenes;
|
|
214
|
+
devicesList.Headers = this.headers;
|
|
215
215
|
|
|
216
216
|
await this.functions.saveData(this.devicesFile, devicesList);
|
|
217
217
|
if (this.logDebug) this.emit('debug', `${devicesCount} devices saved`);
|