homebridge-melcloud-control 4.0.0-beta.153 → 4.0.0-beta.155
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/deviceata.js +3 -2
- package/src/melcloudata.js +68 -57
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.155",
|
|
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/deviceata.js
CHANGED
|
@@ -985,6 +985,7 @@ class DeviceAta extends EventEmitter {
|
|
|
985
985
|
const maxTempCoolDryAuto = 31;
|
|
986
986
|
|
|
987
987
|
//device state
|
|
988
|
+
const fanKey = this.accountType === 'melcloud' ? 'FanSpeed' : 'SetFanSpeed';
|
|
988
989
|
const tempStepKey = this.accountType === 'melcloud' ? 'TemperatureIncrement' : 'HasHalfDegreeIncrements';
|
|
989
990
|
const power = deviceData.Device.Power ?? false;
|
|
990
991
|
const inStandbyMode = deviceData.Device.InStandbyMode ?? false;
|
|
@@ -994,7 +995,7 @@ class DeviceAta extends EventEmitter {
|
|
|
994
995
|
const defaultCoolingSetTemperature = deviceData.Device.DefaultCoolingSetTemperature ?? 23;
|
|
995
996
|
const actualFanSpeed = deviceData.Device.ActualFanSpeed;
|
|
996
997
|
const automaticFanSpeed = deviceData.Device.AutomaticFanSpeed;
|
|
997
|
-
const setFanSpeed = deviceData.Device
|
|
998
|
+
const setFanSpeed = deviceData.Device[fanKey];
|
|
998
999
|
const operationMode = deviceData.Device.OperationMode;
|
|
999
1000
|
const vaneVerticalDirection = deviceData.Device.VaneVerticalDirection;
|
|
1000
1001
|
const vaneVerticalSwing = deviceData.Device.VaneVerticalSwing;
|
|
@@ -1195,7 +1196,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1195
1196
|
&& presetData.OperationMode === operationMode
|
|
1196
1197
|
&& presetData.VaneHorizontalDirection === vaneHorizontalDirection
|
|
1197
1198
|
&& presetData.VaneVerticalDirection === vaneVerticalDirection
|
|
1198
|
-
&& presetData
|
|
1199
|
+
&& presetData[fanKey] === setFanSpeed) : false;
|
|
1199
1200
|
|
|
1200
1201
|
const characteristicType = preset.characteristicType;
|
|
1201
1202
|
this.presetsServices?.[i]?.updateCharacteristic(characteristicType, preset.state);
|
package/src/melcloudata.js
CHANGED
|
@@ -192,50 +192,53 @@ class MelCloudAta extends EventEmitter {
|
|
|
192
192
|
};
|
|
193
193
|
|
|
194
194
|
async send(accountType, deviceData, displayMode) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
195
|
+
try {
|
|
196
|
+
switch (accountType) {
|
|
197
|
+
// ----------------------------------------------------------
|
|
198
|
+
// MELCloud standard account
|
|
199
|
+
// ----------------------------------------------------------
|
|
200
|
+
case "melcloud": {
|
|
198
201
|
const axiosInstancePost = axios.create({
|
|
199
|
-
method: 'POST',
|
|
200
202
|
baseURL: ApiUrls.BaseURL,
|
|
201
203
|
timeout: 25000,
|
|
202
204
|
headers: {
|
|
203
205
|
'X-MitsContextKey': deviceData.ContextKey,
|
|
204
|
-
'
|
|
206
|
+
'Content-Type': 'application/json'
|
|
205
207
|
},
|
|
206
208
|
withCredentials: true
|
|
207
209
|
});
|
|
208
210
|
|
|
209
|
-
//
|
|
211
|
+
// Set target temperature based on display and operation mode
|
|
210
212
|
switch (displayMode) {
|
|
211
|
-
case 1: //
|
|
213
|
+
case 1: // Heater/Cooler
|
|
212
214
|
switch (deviceData.Device.OperationMode) {
|
|
213
|
-
case 1: //HEAT
|
|
214
|
-
case 9: //ISEE HEAT
|
|
215
|
+
case 1: // HEAT
|
|
216
|
+
case 9: // ISEE HEAT
|
|
215
217
|
deviceData.Device.SetTemperature = deviceData.Device.DefaultHeatingSetTemperature;
|
|
216
218
|
break;
|
|
217
|
-
case 2: //DRY
|
|
218
|
-
case 3: //COOL
|
|
219
|
-
case 10: //ISEE DRY
|
|
220
|
-
case 11: //ISEE COOL
|
|
219
|
+
case 2: // DRY
|
|
220
|
+
case 3: // COOL
|
|
221
|
+
case 10: // ISEE DRY
|
|
222
|
+
case 11: // ISEE COOL
|
|
221
223
|
deviceData.Device.SetTemperature = deviceData.Device.DefaultCoolingSetTemperature;
|
|
222
224
|
break;
|
|
223
|
-
case 7: //FAN
|
|
224
|
-
deviceData.Device.SetTemperature = deviceData.Device.SetTemperature;
|
|
225
|
+
case 7: // FAN
|
|
225
226
|
break;
|
|
226
|
-
case 8: //AUTO
|
|
227
|
-
deviceData.Device.SetTemperature =
|
|
227
|
+
case 8: // AUTO
|
|
228
|
+
deviceData.Device.SetTemperature =
|
|
229
|
+
(deviceData.Device.DefaultCoolingSetTemperature + deviceData.Device.DefaultHeatingSetTemperature) / 2;
|
|
228
230
|
break;
|
|
229
231
|
default:
|
|
230
|
-
deviceData.Device.SetTemperature = deviceData.Device.SetTemperature;
|
|
231
232
|
break;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
}
|
|
234
|
+
break;
|
|
235
|
+
|
|
236
|
+
case 2: // Thermostat
|
|
235
237
|
break;
|
|
238
|
+
|
|
236
239
|
default:
|
|
237
240
|
return;
|
|
238
|
-
}
|
|
241
|
+
}
|
|
239
242
|
|
|
240
243
|
const payload = {
|
|
241
244
|
data: {
|
|
@@ -256,20 +259,20 @@ class MelCloudAta extends EventEmitter {
|
|
|
256
259
|
HideDryModeControl: deviceData.HideDryModeControl,
|
|
257
260
|
HasPendingCommand: true
|
|
258
261
|
}
|
|
259
|
-
}
|
|
262
|
+
};
|
|
260
263
|
|
|
261
|
-
await axiosInstancePost(ApiUrls.SetAta, payload);
|
|
264
|
+
await axiosInstancePost.post(ApiUrls.SetAta, payload);
|
|
262
265
|
this.emit('deviceState', deviceData);
|
|
263
266
|
return true;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// ----------------------------------------------------------
|
|
270
|
+
// MELCloud Home account
|
|
271
|
+
// ----------------------------------------------------------
|
|
272
|
+
case "melcloudhome": {
|
|
269
273
|
const axiosInstancePut = axios.create({
|
|
270
|
-
method: 'PUT',
|
|
271
|
-
timeout: 25000,
|
|
272
274
|
baseURL: ApiUrlsHome.BaseURL,
|
|
275
|
+
timeout: 25000,
|
|
273
276
|
headers: {
|
|
274
277
|
'Accept': '*/*',
|
|
275
278
|
'Accept-Language': 'en-US,en;q=0.9',
|
|
@@ -285,30 +288,28 @@ class MelCloudAta extends EventEmitter {
|
|
|
285
288
|
}
|
|
286
289
|
});
|
|
287
290
|
|
|
288
|
-
//
|
|
291
|
+
// Set target temp
|
|
289
292
|
switch (displayMode) {
|
|
290
|
-
case 1: //
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
break;
|
|
298
|
-
};
|
|
299
|
-
case 2: //Thermostat
|
|
300
|
-
deviceData.Device.SetTemperature = deviceData.Device.SetTemperature;
|
|
293
|
+
case 1: // Heater/Cooler
|
|
294
|
+
if (deviceData.Device.OperationMode === 8) {
|
|
295
|
+
deviceData.Device.SetTemperature =
|
|
296
|
+
(deviceData.Device.DefaultCoolingSetTemperature + deviceData.Device.DefaultHeatingSetTemperature) / 2;
|
|
297
|
+
}
|
|
298
|
+
break;
|
|
299
|
+
case 2: // Thermostat
|
|
301
300
|
break;
|
|
302
301
|
default:
|
|
303
302
|
return;
|
|
304
|
-
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Convert values to strings
|
|
306
|
+
deviceData.Device.Power = String(deviceData.Device.Power ?? '');
|
|
307
|
+
deviceData.Device.SetTemperature = String(deviceData.Device.SetTemperature ?? '');
|
|
308
|
+
deviceData.Device.SetFanSpeed = String(deviceData.Device.SetFanSpeed ?? '');
|
|
309
|
+
deviceData.Device.OperationMode = AirConditioner.OperationModeMapEnumToString?.[deviceData.Device.OperationMode] ?? '';
|
|
310
|
+
deviceData.Device.VaneHorizontalDirection = AirConditioner.VaneHorizontalDirectionMapEnumToString?.[deviceData.Device.VaneHorizontalDirection] ?? '';
|
|
311
|
+
deviceData.Device.VaneVerticalDirection = AirConditioner.VaneVerticalDirectionMapEnumToString?.[deviceData.Device.VaneVerticalDirection] ?? '';
|
|
305
312
|
|
|
306
|
-
deviceData.Device.Power = deviceData.Device.Power.toString();
|
|
307
|
-
deviceData.Device.SetTemperature = deviceData.Device.SetTemperature.toString();
|
|
308
|
-
deviceData.Device.SetFanSpeed = deviceData.Device.SetFanSpeed.toString();
|
|
309
|
-
deviceData.Device.OperationMode = AirConditioner.OperationModeMapEnumToString[deviceData.Device.OperationMode];
|
|
310
|
-
deviceData.Device.VaneHorizontalDirection = AirConditioner.VaneHorizontalDirectionMapEnumToString[deviceData.Device.VaneHorizontalDirection];
|
|
311
|
-
deviceData.Device.VaneVerticalDirection = AirConditioner.VaneVerticalDirectionMapEnumToString[deviceData.Device.VaneVerticalDirection];
|
|
312
313
|
this.emit('warn', JSON.stringify(deviceData.Device, null, 2));
|
|
313
314
|
|
|
314
315
|
const payload = {
|
|
@@ -320,19 +321,29 @@ class MelCloudAta extends EventEmitter {
|
|
|
320
321
|
VaneHorizontalDirection: deviceData.Device.VaneHorizontalDirection,
|
|
321
322
|
VaneVerticalDirection: deviceData.Device.VaneVerticalDirection
|
|
322
323
|
}
|
|
323
|
-
}
|
|
324
|
+
};
|
|
324
325
|
|
|
325
326
|
this.emit('warn', JSON.stringify(payload, null, 2));
|
|
326
327
|
|
|
327
328
|
const path = ApiUrlsHome.SetAta.replace('deviceid', deviceData.DeviceID);
|
|
328
|
-
await axiosInstancePut(path, payload);
|
|
329
|
+
await axiosInstancePut.put(path, payload);
|
|
330
|
+
|
|
329
331
|
return true;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
default:
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
} catch (error) {
|
|
338
|
+
if (error.response) {
|
|
339
|
+
throw new Error(`Send data error: HTTP ${error.response.status} - ${JSON.stringify(error.response.data)}`);
|
|
340
|
+
} else if (error.request) {
|
|
341
|
+
throw new Error(`Send data error: No response received - ${error.message}`);
|
|
342
|
+
} else {
|
|
343
|
+
throw new Error(`Send data error: ${error.message}`);
|
|
344
|
+
}
|
|
335
345
|
}
|
|
336
346
|
}
|
|
347
|
+
|
|
337
348
|
};
|
|
338
349
|
export default MelCloudAta;
|