homebridge-melcloud-control 4.2.2 → 4.2.3-beta.1
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 +10 -10
- package/src/melcloudata.js +50 -65
- package/src/melcloudatw.js +5 -8
- package/src/melclouderv.js +5 -8
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.3-beta.1",
|
|
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
|
@@ -147,19 +147,19 @@ class MelCloud extends EventEmitter {
|
|
|
147
147
|
method: 'POST',
|
|
148
148
|
baseURL: ApiUrls.BaseURL,
|
|
149
149
|
timeout: 15000,
|
|
150
|
+
data: {
|
|
151
|
+
Email: this.user,
|
|
152
|
+
Password: this.passwd,
|
|
153
|
+
Language: this.language,
|
|
154
|
+
AppVersion: '1.34.12',
|
|
155
|
+
CaptchaChallenge: '',
|
|
156
|
+
CaptchaResponse: '',
|
|
157
|
+
Persist: true
|
|
158
|
+
}
|
|
150
159
|
});
|
|
151
160
|
|
|
152
|
-
const data = {
|
|
153
|
-
Email: this.user,
|
|
154
|
-
Password: this.passwd,
|
|
155
|
-
Language: this.language,
|
|
156
|
-
AppVersion: '1.34.12',
|
|
157
|
-
CaptchaChallenge: '',
|
|
158
|
-
CaptchaResponse: '',
|
|
159
|
-
Persist: true
|
|
160
|
-
};
|
|
161
161
|
|
|
162
|
-
const accountData = await axiosInstance(ApiUrls.ClientLogin
|
|
162
|
+
const accountData = await axiosInstance(ApiUrls.ClientLogin);
|
|
163
163
|
const account = accountData.data;
|
|
164
164
|
const loginData = account.LoginData ?? [];
|
|
165
165
|
const contextKey = loginData.ContextKey;
|
package/src/melcloudata.js
CHANGED
|
@@ -23,7 +23,6 @@ class MelCloudAta extends EventEmitter {
|
|
|
23
23
|
|
|
24
24
|
//set default values
|
|
25
25
|
this.deviceData = {};
|
|
26
|
-
this.headers = {};
|
|
27
26
|
|
|
28
27
|
//lock flags
|
|
29
28
|
this.locks = true;
|
|
@@ -58,7 +57,6 @@ class MelCloudAta extends EventEmitter {
|
|
|
58
57
|
return null;
|
|
59
58
|
}
|
|
60
59
|
const deviceData = devicesData.find(device => device.DeviceID === this.deviceId);
|
|
61
|
-
this.headers = deviceData.Headers;
|
|
62
60
|
|
|
63
61
|
if (this.accountType === 'melcloudhome') {
|
|
64
62
|
deviceData.SerialNumber = deviceData.DeviceID || '4.0.0';
|
|
@@ -77,7 +75,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
77
75
|
|
|
78
76
|
const safeConfig = {
|
|
79
77
|
...deviceData,
|
|
80
|
-
|
|
78
|
+
Headers: 'removed',
|
|
81
79
|
};
|
|
82
80
|
if (this.logDebug) this.emit('debug', `Device Data: ${JSON.stringify(safeConfig, null, 2)}`);
|
|
83
81
|
|
|
@@ -145,13 +143,6 @@ class MelCloudAta extends EventEmitter {
|
|
|
145
143
|
let path = '';
|
|
146
144
|
switch (accountType) {
|
|
147
145
|
case "melcloud":
|
|
148
|
-
const axiosInstancePost = axios.create({
|
|
149
|
-
method: 'POST',
|
|
150
|
-
baseURL: ApiUrls.BaseURL,
|
|
151
|
-
timeout: 10000,
|
|
152
|
-
headers: this.headers,
|
|
153
|
-
withCredentials: true
|
|
154
|
-
});
|
|
155
146
|
|
|
156
147
|
if (displayType === 1 && deviceData.Device.OperationMode === 8) {
|
|
157
148
|
deviceData.Device.SetTemperature = (deviceData.Device.DefaultCoolingSetTemperature + deviceData.Device.DefaultHeatingSetTemperature) / 2;
|
|
@@ -159,28 +150,34 @@ class MelCloudAta extends EventEmitter {
|
|
|
159
150
|
|
|
160
151
|
deviceData.Device.EffectiveFlags = effectiveFlags;
|
|
161
152
|
payload = {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
HasPendingCommand: true
|
|
179
|
-
}
|
|
153
|
+
DeviceID: deviceData.Device.DeviceID,
|
|
154
|
+
EffectiveFlags: deviceData.Device.EffectiveFlags,
|
|
155
|
+
Power: deviceData.Device.Power,
|
|
156
|
+
SetTemperature: deviceData.Device.SetTemperature,
|
|
157
|
+
SetFanSpeed: deviceData.Device.FanSpeed,
|
|
158
|
+
OperationMode: deviceData.Device.OperationMode,
|
|
159
|
+
VaneHorizontal: deviceData.Device.VaneHorizontalDirection,
|
|
160
|
+
VaneVertical: deviceData.Device.VaneVerticalDirection,
|
|
161
|
+
DefaultHeatingSetTemperature: deviceData.Device.DefaultHeatingSetTemperature,
|
|
162
|
+
DefaultCoolingSetTemperature: deviceData.Device.DefaultCoolingSetTemperature,
|
|
163
|
+
ProhibitSetTemperature: deviceData.Device.ProhibitSetTemperature,
|
|
164
|
+
ProhibitOperationMode: deviceData.Device.ProhibitOperationMode,
|
|
165
|
+
ProhibitPower: deviceData.Device.ProhibitPower,
|
|
166
|
+
HideVaneControls: deviceData.HideVaneControls,
|
|
167
|
+
HideDryModeControl: deviceData.HideDryModeControl,
|
|
168
|
+
HasPendingCommand: true
|
|
180
169
|
};
|
|
181
|
-
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload
|
|
170
|
+
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|
|
171
|
+
|
|
172
|
+
const axiosInstancePost = axios.create({
|
|
173
|
+
method: 'POST',
|
|
174
|
+
baseURL: ApiUrls.BaseURL,
|
|
175
|
+
timeout: 10000,
|
|
176
|
+
headers: deviceData.Headers,
|
|
177
|
+
data: payload
|
|
178
|
+
});
|
|
182
179
|
|
|
183
|
-
await axiosInstancePost(ApiUrls.SetAta
|
|
180
|
+
await axiosInstancePost(ApiUrls.SetAta);
|
|
184
181
|
this.updateData(deviceData);
|
|
185
182
|
return true;
|
|
186
183
|
case "melcloudhome":
|
|
@@ -199,59 +196,47 @@ class MelCloudAta extends EventEmitter {
|
|
|
199
196
|
switch (effectiveFlags) {
|
|
200
197
|
case 'frostprotection':
|
|
201
198
|
payload = {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
units: { "ATA": [deviceData.DeviceID] }
|
|
207
|
-
}
|
|
199
|
+
enabled: deviceData.FrostProtection.Enabled,
|
|
200
|
+
min: deviceData.FrostProtection.Min,
|
|
201
|
+
max: deviceData.FrostProtection.Max,
|
|
202
|
+
units: { "ATA": [deviceData.DeviceID] }
|
|
208
203
|
};
|
|
209
204
|
method = 'POST';
|
|
210
205
|
path = ApiUrlsHome.PostProtectionFrost;
|
|
211
206
|
break;
|
|
212
207
|
case 'overheatprotection':
|
|
213
208
|
payload = {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
units: { "ATA": [deviceData.DeviceID] }
|
|
219
|
-
}
|
|
209
|
+
enabled: deviceData.OverheatProtection.Enabled,
|
|
210
|
+
min: deviceData.OverheatProtection.Min,
|
|
211
|
+
max: deviceData.OverheatProtection.Max,
|
|
212
|
+
units: { "ATA": [deviceData.DeviceID] }
|
|
220
213
|
};
|
|
221
214
|
method = 'POST';
|
|
222
215
|
path = ApiUrlsHome.PostProtectionOverheat;
|
|
223
216
|
break;
|
|
224
217
|
case 'holidaymode':
|
|
225
218
|
payload = {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
units: { "ATA": [deviceData.DeviceID] }
|
|
231
|
-
}
|
|
219
|
+
enabled: deviceData.HolidayMode.Enabled,
|
|
220
|
+
startDate: deviceData.HolidayMode.StartDate,
|
|
221
|
+
endDate: deviceData.HolidayMode.EndDate,
|
|
222
|
+
units: { "ATA": [deviceData.DeviceID] }
|
|
232
223
|
};
|
|
233
224
|
method = 'POST';
|
|
234
225
|
path = ApiUrlsHome.PostHolidayMode;
|
|
235
226
|
break;
|
|
236
227
|
case 'schedule':
|
|
237
|
-
payload = {
|
|
238
|
-
data: {
|
|
239
|
-
enabled: deviceData.ScheduleEnabled
|
|
240
|
-
}
|
|
241
|
-
};
|
|
228
|
+
payload = { enabled: deviceData.ScheduleEnabled };
|
|
242
229
|
method = 'PUT';
|
|
243
230
|
path = ApiUrlsHome.PutScheduleEnable.replace('deviceid', deviceData.DeviceID);
|
|
244
231
|
break;
|
|
245
232
|
default:
|
|
246
233
|
payload = {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
VaneVerticalDirection: AirConditioner.VaneVerticalDirectionMapEnumToString[deviceData.Device.VaneVerticalDirection],
|
|
254
|
-
}
|
|
234
|
+
Power: deviceData.Device.Power,
|
|
235
|
+
SetTemperature: deviceData.Device.SetTemperature,
|
|
236
|
+
SetFanSpeed: String(deviceData.Device.SetFanSpeed),
|
|
237
|
+
OperationMode: AirConditioner.OperationModeMapEnumToString[deviceData.Device.OperationMode],
|
|
238
|
+
VaneHorizontalDirection: AirConditioner.VaneHorizontalDirectionMapEnumToString[deviceData.Device.VaneHorizontalDirection],
|
|
239
|
+
VaneVerticalDirection: AirConditioner.VaneVerticalDirectionMapEnumToString[deviceData.Device.VaneVerticalDirection],
|
|
255
240
|
};
|
|
256
241
|
method = 'PUT';
|
|
257
242
|
path = ApiUrlsHome.SetAta.replace('deviceid', deviceData.DeviceID);
|
|
@@ -262,12 +247,12 @@ class MelCloudAta extends EventEmitter {
|
|
|
262
247
|
method: method,
|
|
263
248
|
baseURL: ApiUrlsHome.BaseURL,
|
|
264
249
|
timeout: 10000,
|
|
265
|
-
headers:
|
|
266
|
-
|
|
250
|
+
headers: deviceData.Headers,
|
|
251
|
+
data: payload
|
|
267
252
|
});
|
|
268
253
|
|
|
269
|
-
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(
|
|
270
|
-
await axiosInstancePut(path
|
|
254
|
+
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|
|
255
|
+
await axiosInstancePut(path);
|
|
271
256
|
this.updateData(deviceData);
|
|
272
257
|
return true;
|
|
273
258
|
default:
|
package/src/melcloudatw.js
CHANGED
|
@@ -23,7 +23,6 @@ class MelCloudAtw extends EventEmitter {
|
|
|
23
23
|
|
|
24
24
|
//set default values
|
|
25
25
|
this.devicesData = {};
|
|
26
|
-
this.headers = {};
|
|
27
26
|
|
|
28
27
|
//lock flags
|
|
29
28
|
this.locks = true;
|
|
@@ -58,7 +57,6 @@ class MelCloudAtw extends EventEmitter {
|
|
|
58
57
|
return null;
|
|
59
58
|
}
|
|
60
59
|
const deviceData = devicesData.find(device => device.DeviceID === this.deviceId);
|
|
61
|
-
this.headers = deviceData.Headers;
|
|
62
60
|
|
|
63
61
|
if (this.accountType === 'melcloudhome') {
|
|
64
62
|
deviceData.SerialNumber = deviceData.DeviceID || '4.0.0';
|
|
@@ -66,7 +64,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
66
64
|
}
|
|
67
65
|
const safeConfig = {
|
|
68
66
|
...deviceData,
|
|
69
|
-
|
|
67
|
+
Headers: 'removed',
|
|
70
68
|
};
|
|
71
69
|
if (this.logDebug) this.emit('debug', `Device Data: ${JSON.stringify(safeConfig, null, 2)}`);
|
|
72
70
|
|
|
@@ -154,7 +152,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
154
152
|
method: 'POST',
|
|
155
153
|
baseURL: ApiUrls.BaseURL,
|
|
156
154
|
timeout: 10000,
|
|
157
|
-
headers:
|
|
155
|
+
headers: deviceData.Headers,
|
|
158
156
|
withCredentials: true
|
|
159
157
|
});
|
|
160
158
|
|
|
@@ -232,12 +230,11 @@ class MelCloudAtw extends EventEmitter {
|
|
|
232
230
|
method: method,
|
|
233
231
|
baseURL: ApiUrlsHome.BaseURL,
|
|
234
232
|
timeout: 10000,
|
|
235
|
-
headers:
|
|
236
|
-
withCredentials: true
|
|
233
|
+
headers: deviceData.Headers
|
|
237
234
|
});
|
|
238
235
|
|
|
239
|
-
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(
|
|
240
|
-
await axiosInstancePut(path,
|
|
236
|
+
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload.data, null, 2)}`);
|
|
237
|
+
await axiosInstancePut(path, payload);
|
|
241
238
|
this.updateData(deviceData);
|
|
242
239
|
return true;
|
|
243
240
|
default:
|
package/src/melclouderv.js
CHANGED
|
@@ -23,7 +23,6 @@ class MelCloudErv extends EventEmitter {
|
|
|
23
23
|
|
|
24
24
|
//set default values
|
|
25
25
|
this.devicesData = {};
|
|
26
|
-
this.headers = {};
|
|
27
26
|
|
|
28
27
|
//lock flags
|
|
29
28
|
this.locks = true;
|
|
@@ -58,7 +57,6 @@ class MelCloudErv extends EventEmitter {
|
|
|
58
57
|
return null;
|
|
59
58
|
}
|
|
60
59
|
const deviceData = devicesData.find(device => device.DeviceID === this.deviceId);
|
|
61
|
-
this.headers = deviceData.Headers;
|
|
62
60
|
|
|
63
61
|
if (this.accountType === 'melcloudhome') {
|
|
64
62
|
deviceData.SerialNumber = deviceData.DeviceID || '4.0.0';
|
|
@@ -71,7 +69,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
71
69
|
}
|
|
72
70
|
const safeConfig = {
|
|
73
71
|
...deviceData,
|
|
74
|
-
|
|
72
|
+
Headers: 'removed',
|
|
75
73
|
};
|
|
76
74
|
if (this.logDebug) this.emit('debug', `Device Data: ${JSON.stringify(safeConfig, null, 2)}`);
|
|
77
75
|
|
|
@@ -143,7 +141,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
143
141
|
method: 'POST',
|
|
144
142
|
baseURL: ApiUrls.BaseURL,
|
|
145
143
|
timeout: 10000,
|
|
146
|
-
headers:
|
|
144
|
+
headers: deviceData.Headers,
|
|
147
145
|
withCredentials: true
|
|
148
146
|
});
|
|
149
147
|
|
|
@@ -240,12 +238,11 @@ class MelCloudErv extends EventEmitter {
|
|
|
240
238
|
method: method,
|
|
241
239
|
baseURL: ApiUrlsHome.BaseURL,
|
|
242
240
|
timeout: 10000,
|
|
243
|
-
headers:
|
|
244
|
-
withCredentials: true
|
|
241
|
+
headers: deviceData.Headers
|
|
245
242
|
});
|
|
246
243
|
|
|
247
|
-
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(
|
|
248
|
-
await axiosInstancePut(path,
|
|
244
|
+
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload.data, null, 2)}`);
|
|
245
|
+
await axiosInstancePut(path, payload);
|
|
249
246
|
this.updateData(deviceData);
|
|
250
247
|
return true;
|
|
251
248
|
default:
|