homebridge-melcloud-control 4.3.11-beta.1 → 4.3.11-beta.3
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 +35 -33
- package/src/deviceatw.js +1 -1
- package/src/deviceerv.js +1 -1
- package/src/melcloud.js +2 -2
- package/src/melcloudata.js +4 -8
- package/src/melcloudatw.js +4 -8
- package/src/melclouderv.js +6 -8
- package/src/melcloudhome.js +2 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.3.11-beta.
|
|
4
|
+
"version": "4.3.11-beta.3",
|
|
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
|
@@ -317,6 +317,7 @@ class DeviceAta extends EventEmitter {
|
|
|
317
317
|
const supportsOutdoorTemperature = this.accessory.supportsOutdoorTemperature;
|
|
318
318
|
const numberOfFanSpeeds = this.accessory.numberOfFanSpeeds;
|
|
319
319
|
const supportsSwingFunction = this.accessory.supportsSwingFunction;
|
|
320
|
+
const supportsVideWane = this.accessory.supportsVideWane;
|
|
320
321
|
const autoDryFanMode = [this.accessory.operationMode, 8, supportsDry ? 2 : 8, 7][this.autoDryFanMode]; //NONE, AUTO - 8, DRY - 2, FAN - 7
|
|
321
322
|
const heatDryFanMode = [this.accessory.operationMode, 1, supportsDry ? 2 : 1, 7][this.heatDryFanMode]; //NONE, HEAT - 1, DRY - 2, FAN - 7
|
|
322
323
|
const coolDryFanMode = [this.accessory.operationMode, 3, supportsDry ? 2 : 3, 7][this.coolDryFanMode]; //NONE, COOL - 3, DRY - 2, FAN - 7
|
|
@@ -446,7 +447,7 @@ class DeviceAta extends EventEmitter {
|
|
|
446
447
|
})
|
|
447
448
|
.onSet(async (value) => {
|
|
448
449
|
try {
|
|
449
|
-
deviceData.Device.VaneHorizontalDirection = value ? 12 : 0;
|
|
450
|
+
if (supportsVideWane) deviceData.Device.VaneHorizontalDirection = value ? 12 : 0;
|
|
450
451
|
deviceData.Device.VaneVerticalDirection = value ? 7 : 0;
|
|
451
452
|
if (this.logInfo) this.emit('info', `Set air direction mode: ${AirConditioner.AirDirectionMapEnumToString[value]}`);
|
|
452
453
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.VaneVerticalVaneHorizontal);
|
|
@@ -1129,91 +1130,91 @@ class DeviceAta extends EventEmitter {
|
|
|
1129
1130
|
case 7: //OPERATING MODE DRY CONTROL HIDE
|
|
1130
1131
|
deviceData.HideDryModeControl = state;
|
|
1131
1132
|
break;
|
|
1132
|
-
case 10: //VANE H
|
|
1133
|
+
case 10: //VANE H MODE AUTO
|
|
1133
1134
|
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1134
1135
|
deviceData.Device.Power = true;
|
|
1135
1136
|
deviceData.Device.VaneHorizontalDirection = state ? 0 : button.previousValue;
|
|
1136
1137
|
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1137
1138
|
break;
|
|
1138
|
-
case 11: //VANE H
|
|
1139
|
+
case 11: //VANE H MODE 1
|
|
1139
1140
|
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1140
1141
|
deviceData.Device.Power = true;
|
|
1141
1142
|
deviceData.Device.VaneHorizontalDirection = state ? 1 : button.previousValue;
|
|
1142
1143
|
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1143
1144
|
break;
|
|
1144
|
-
case 12: //VANE H
|
|
1145
|
+
case 12: //VANE H MODE 2
|
|
1145
1146
|
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1146
1147
|
deviceData.Device.Power = true;
|
|
1147
1148
|
deviceData.Device.VaneHorizontalDirection = state ? 2 : button.previousValue;
|
|
1148
1149
|
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1149
1150
|
break;
|
|
1150
|
-
case 13: //VANE H
|
|
1151
|
+
case 13: //VANE H MODE 3
|
|
1151
1152
|
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1152
1153
|
deviceData.Device.Power = true;
|
|
1153
1154
|
deviceData.Device.VaneHorizontalDirection = state ? 3 : button.previousValue;
|
|
1154
1155
|
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1155
1156
|
break;
|
|
1156
|
-
case 14: //VANE H
|
|
1157
|
+
case 14: //VANE H MODE 4
|
|
1157
1158
|
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1158
1159
|
deviceData.Device.Power = true;
|
|
1159
1160
|
deviceData.Device.VaneHorizontalDirection = state ? 4 : button.previousValue;
|
|
1160
1161
|
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1161
1162
|
break;
|
|
1162
|
-
case 15: //VANE H
|
|
1163
|
+
case 15: //VANE H MODE 5
|
|
1163
1164
|
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1164
1165
|
deviceData.Device.Power = true;
|
|
1165
1166
|
deviceData.Device.VaneHorizontalDirection = state ? 5 : button.previousValue;
|
|
1166
1167
|
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1167
1168
|
break;
|
|
1168
|
-
case 16: //VANE H
|
|
1169
|
+
case 16: //VANE H MODE SPLIT
|
|
1169
1170
|
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1170
1171
|
deviceData.Device.Power = true;
|
|
1171
1172
|
deviceData.Device.VaneHorizontalDirection = state ? 8 : button.previousValue;
|
|
1172
1173
|
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1173
1174
|
break;
|
|
1174
|
-
case 17: //VANE H
|
|
1175
|
+
case 17: //VANE H MODE SWING
|
|
1175
1176
|
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1176
1177
|
deviceData.Device.Power = true;
|
|
1177
1178
|
deviceData.Device.VaneHorizontalDirection = state ? 12 : button.previousValue;
|
|
1178
1179
|
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1179
1180
|
break;
|
|
1180
|
-
case 20: //VANE V
|
|
1181
|
+
case 20: //VANE V MODE AUTO
|
|
1181
1182
|
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1182
1183
|
deviceData.Device.Power = true;
|
|
1183
1184
|
deviceData.Device.VaneVerticalDirection = state ? 0 : button.previousValue;
|
|
1184
1185
|
flag = AirConditioner.EffectiveFlags.PowerVaneVertical;
|
|
1185
1186
|
break;
|
|
1186
|
-
case 21: //VANE V
|
|
1187
|
+
case 21: //VANE V MODE 1
|
|
1187
1188
|
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1188
1189
|
deviceData.Device.Power = true;
|
|
1189
1190
|
deviceData.Device.VaneVerticalDirection = state ? 1 : button.previousValue;
|
|
1190
1191
|
flag = AirConditioner.EffectiveFlags.PowerVaneVertical;
|
|
1191
1192
|
break;
|
|
1192
|
-
case 22: //VANE V
|
|
1193
|
+
case 22: //VANE V MODE 2
|
|
1193
1194
|
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1194
1195
|
deviceData.Device.Power = true;
|
|
1195
1196
|
deviceData.Device.VaneVerticalDirection = state ? 2 : button.previousValue;
|
|
1196
1197
|
flag = AirConditioner.EffectiveFlags.PowerVaneVertical;
|
|
1197
1198
|
break;
|
|
1198
|
-
case 23: //VANE V
|
|
1199
|
+
case 23: //VANE V MODE 3
|
|
1199
1200
|
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1200
1201
|
deviceData.Device.Power = true;
|
|
1201
1202
|
deviceData.Device.VaneVerticalDirection = state ? 3 : button.previousValue;
|
|
1202
1203
|
flag = AirConditioner.EffectiveFlags.PowerVaneVertical;
|
|
1203
1204
|
break;
|
|
1204
|
-
case 24: //VANE V
|
|
1205
|
+
case 24: //VANE V MODE 4
|
|
1205
1206
|
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1206
1207
|
deviceData.Device.Power = true;
|
|
1207
1208
|
deviceData.Device.VaneVerticalDirection = state ? 4 : button.previousValue;
|
|
1208
1209
|
flag = AirConditioner.EffectiveFlags.PowerVaneVertical;
|
|
1209
1210
|
break;
|
|
1210
|
-
case 25: //VANE V
|
|
1211
|
+
case 25: //VANE V MODE 5
|
|
1211
1212
|
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1212
1213
|
deviceData.Device.Power = true;
|
|
1213
1214
|
deviceData.Device.VaneVerticalDirection = state ? 5 : button.previousValue;
|
|
1214
1215
|
flag = AirConditioner.EffectiveFlags.PowerVaneVertical;
|
|
1215
1216
|
break;
|
|
1216
|
-
case 26: //VANE V
|
|
1217
|
+
case 26: //VANE V MODE SWING
|
|
1217
1218
|
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1218
1219
|
deviceData.Device.Power = true;
|
|
1219
1220
|
deviceData.Device.VaneVerticalDirection = state ? 7 : button.previousValue;
|
|
@@ -1324,7 +1325,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1324
1325
|
async start() {
|
|
1325
1326
|
try {
|
|
1326
1327
|
//melcloud device
|
|
1327
|
-
this.melCloudAta = new MelCloudAta(this.account, this.device, this.defaultTempsFile, this.accountFile, this.melcloud)
|
|
1328
|
+
this.melCloudAta = new MelCloudAta(this.account, this.device, this.defaultTempsFile, this.accountFile, this.melcloud, this.accountInfo)
|
|
1328
1329
|
.on('deviceInfo', (modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
|
|
1329
1330
|
if (this.logDeviceInfo && this.displayDeviceInfo) {
|
|
1330
1331
|
this.emit('devInfo', `---- ${this.deviceTypeString}: ${this.deviceName} ----`);
|
|
@@ -1425,6 +1426,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1425
1426
|
const outdoorTemperature = deviceData.Device.OutdoorTemperature;
|
|
1426
1427
|
const isConnected = accountTypeMelcloud ? !deviceData.Device[connectKey] : deviceData.Device[connectKey];
|
|
1427
1428
|
const isInError = deviceData.Device[errorKey];
|
|
1429
|
+
const currentSwingMode = supportsSwingFunction ? (supportsWideVane ? vaneHorizontalDirection === 12 && vaneVerticalDirection === 7 ? 1 : 0 : vaneVerticalDirection === 7 ? 1 : 0) : 0;
|
|
1428
1430
|
|
|
1429
1431
|
//accessory
|
|
1430
1432
|
const obj = {
|
|
@@ -1461,7 +1463,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1461
1463
|
automaticFanSpeed: automaticFanSpeed,
|
|
1462
1464
|
vaneVerticalSwing: vaneVerticalSwing,
|
|
1463
1465
|
vaneHorizontalSwing: vaneHorizontalSwing,
|
|
1464
|
-
currentSwingMode:
|
|
1466
|
+
currentSwingMode: currentSwingMode,
|
|
1465
1467
|
lockPhysicalControl: prohibitSetTemperature && prohibitOperationMode && prohibitPower ? 1 : 0,
|
|
1466
1468
|
temperatureStep: temperatureStep,
|
|
1467
1469
|
useFahrenheit: this.accountInfo.useFahrenheit ? 1 : 0,
|
|
@@ -1753,49 +1755,49 @@ class DeviceAta extends EventEmitter {
|
|
|
1753
1755
|
case 7: //OPERATING MODE DRY CONTROL HIDE
|
|
1754
1756
|
button.state = power ? (hideDryModeControl === true) : false;
|
|
1755
1757
|
break;
|
|
1756
|
-
case 10: //VANE H
|
|
1758
|
+
case 10: //VANE H MODE AUTO
|
|
1757
1759
|
button.state = power ? (vaneHorizontalDirection === 0) : false;
|
|
1758
1760
|
break;
|
|
1759
|
-
case 11: //VANE H
|
|
1761
|
+
case 11: //VANE H MODE 1
|
|
1760
1762
|
button.state = power ? (vaneHorizontalDirection === 1) : false;
|
|
1761
1763
|
break;
|
|
1762
|
-
case 12: //VANE H
|
|
1764
|
+
case 12: //VANE H MODE 2
|
|
1763
1765
|
button.state = power ? (vaneHorizontalDirection === 2) : false;
|
|
1764
1766
|
break;
|
|
1765
|
-
case 13: //VANE H
|
|
1767
|
+
case 13: //VANE H MODE 3
|
|
1766
1768
|
button.state = power ? (vaneHorizontalDirection === 3) : false;
|
|
1767
1769
|
break;
|
|
1768
|
-
case 14: //VANE H
|
|
1770
|
+
case 14: //VANE H MODE 4
|
|
1769
1771
|
button.state = power ? (vaneHorizontalDirection === 4) : false;
|
|
1770
1772
|
break;
|
|
1771
|
-
case 15: //VANE H
|
|
1773
|
+
case 15: //VANE H MODE 5
|
|
1772
1774
|
button.state = power ? (vaneHorizontalDirection === 5) : false;
|
|
1773
1775
|
break;
|
|
1774
|
-
case 16: //VANE H
|
|
1776
|
+
case 16: //VANE H MODE SPLIT
|
|
1775
1777
|
button.state = power ? (vaneHorizontalDirection === 8) : false;
|
|
1776
1778
|
break;
|
|
1777
|
-
case 17: //VANE H
|
|
1779
|
+
case 17: //VANE H MODE SWING
|
|
1778
1780
|
button.state = power ? (vaneHorizontalDirection === 12) : false;
|
|
1779
1781
|
break;
|
|
1780
|
-
case 20: //VANE V
|
|
1782
|
+
case 20: //VANE V MODE AUTO
|
|
1781
1783
|
button.state = power ? (vaneVerticalDirection === 0) : false;
|
|
1782
1784
|
break;
|
|
1783
|
-
case 21: //VANE V
|
|
1785
|
+
case 21: //VANE V MODE 1
|
|
1784
1786
|
button.state = power ? (vaneVerticalDirection === 1) : false;
|
|
1785
1787
|
break;
|
|
1786
|
-
case 22: //VANE V
|
|
1788
|
+
case 22: //VANE V MODE 2
|
|
1787
1789
|
button.state = power ? (vaneVerticalDirection === 2) : false;
|
|
1788
1790
|
break;
|
|
1789
|
-
case 23: //VANE V
|
|
1791
|
+
case 23: //VANE V MODE 3
|
|
1790
1792
|
button.state = power ? (vaneVerticalDirection === 3) : false;
|
|
1791
1793
|
break;
|
|
1792
|
-
case 24: //VANE V
|
|
1794
|
+
case 24: //VANE V MODE 4
|
|
1793
1795
|
button.state = power ? (vaneVerticalDirection === 4) : false;
|
|
1794
1796
|
break;
|
|
1795
|
-
case 25: //VANE V
|
|
1797
|
+
case 25: //VANE V MODE 5
|
|
1796
1798
|
button.state = power ? (vaneVerticalDirection === 5) : false;
|
|
1797
1799
|
break;
|
|
1798
|
-
case 26: //VANE V
|
|
1800
|
+
case 26: //VANE V MODE SWING
|
|
1799
1801
|
button.state = power ? (vaneVerticalDirection === 7) : false;
|
|
1800
1802
|
break;
|
|
1801
1803
|
case 27: //VANE H/V CONTROLS HIDE
|
package/src/deviceatw.js
CHANGED
|
@@ -1567,7 +1567,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1567
1567
|
async start() {
|
|
1568
1568
|
try {
|
|
1569
1569
|
//melcloud device
|
|
1570
|
-
this.melCloudAtw = new MelCloudAtw(this.account, this.device, this.defaultTempsFile, this.accountFile, this.melcloud)
|
|
1570
|
+
this.melCloudAtw = new MelCloudAtw(this.account, this.device, this.defaultTempsFile, this.accountFile, this.melcloud, this.accountInfo)
|
|
1571
1571
|
.on('deviceInfo', (modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion, supportsHotWaterTank, supportsZone2) => {
|
|
1572
1572
|
if (this.logDeviceInfo && this.displayDeviceInfo) {
|
|
1573
1573
|
this.emit('devInfo', `---- ${this.deviceTypeString}: ${this.deviceName} ----`);
|
package/src/deviceerv.js
CHANGED
|
@@ -1121,7 +1121,7 @@ class DeviceErv extends EventEmitter {
|
|
|
1121
1121
|
async start() {
|
|
1122
1122
|
try {
|
|
1123
1123
|
//melcloud device
|
|
1124
|
-
this.melCloudErv = new MelCloudErv(this.account, this.device, this.defaultTempsFile, this.accountFile, this.melcloud)
|
|
1124
|
+
this.melCloudErv = new MelCloudErv(this.account, this.device, this.defaultTempsFile, this.accountFile, this.melcloud, this.accountInfo)
|
|
1125
1125
|
.on('deviceInfo', (modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
|
|
1126
1126
|
if (this.logDeviceInfo && this.displayDeviceInfo) {
|
|
1127
1127
|
this.emit('devInfo', `---- ${this.deviceTypeString}: ${this.deviceName} ----`);
|
package/src/melcloud.js
CHANGED
|
@@ -109,7 +109,6 @@ class MelCloud extends EventEmitter {
|
|
|
109
109
|
devicesList.State = true;
|
|
110
110
|
devicesList.Info = `Found ${devicesCount} devices`;
|
|
111
111
|
devicesList.Devices = devices;
|
|
112
|
-
devicesList.Headers = this.headers;
|
|
113
112
|
this.emit('devicesList', devicesList);
|
|
114
113
|
|
|
115
114
|
return devicesList;
|
|
@@ -122,7 +121,7 @@ class MelCloud extends EventEmitter {
|
|
|
122
121
|
if (this.logDebug) this.emit('debug', `Connecting to MELCloud`);
|
|
123
122
|
|
|
124
123
|
try {
|
|
125
|
-
const accountInfo = { State: false, Info: '', Account: null, UseFahrenheit: false }
|
|
124
|
+
const accountInfo = { State: false, Info: '', Account: null, UseFahrenheit: false, Headers: {} }
|
|
126
125
|
|
|
127
126
|
const payload = {
|
|
128
127
|
Email: this.user,
|
|
@@ -175,6 +174,7 @@ class MelCloud extends EventEmitter {
|
|
|
175
174
|
accountInfo.Info = 'Connect Success';
|
|
176
175
|
accountInfo.UseFahrenheit = loginData.UseFahrenheit;
|
|
177
176
|
accountInfo.Account = account;
|
|
177
|
+
accountInfo.Headers = headers;
|
|
178
178
|
await this.functions.saveData(this.accountFile, accountInfo);
|
|
179
179
|
|
|
180
180
|
return accountInfo
|
package/src/melcloudata.js
CHANGED
|
@@ -4,7 +4,7 @@ import Functions from './functions.js';
|
|
|
4
4
|
import { ApiUrls, ApiUrlsHome, AirConditioner } from './constants.js';
|
|
5
5
|
|
|
6
6
|
class MelCloudAta extends EventEmitter {
|
|
7
|
-
constructor(account, device, defaultTempsFile, accountFile, melcloud) {
|
|
7
|
+
constructor(account, device, defaultTempsFile, accountFile, melcloud, accountInfo) {
|
|
8
8
|
super();
|
|
9
9
|
this.accountType = account.type;
|
|
10
10
|
this.logSuccess = account.log?.success;
|
|
@@ -24,7 +24,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
24
24
|
|
|
25
25
|
//set default values
|
|
26
26
|
this.deviceData = {};
|
|
27
|
-
this.headers =
|
|
27
|
+
this.headers = accountInfo.Headers;
|
|
28
28
|
|
|
29
29
|
//handle melcloud events
|
|
30
30
|
let deviceData = null;
|
|
@@ -148,9 +148,6 @@ class MelCloudAta extends EventEmitter {
|
|
|
148
148
|
return acc;
|
|
149
149
|
}, { indoor: {}, outdoor: {} });
|
|
150
150
|
|
|
151
|
-
//display info if units are not configured in MELCloud service
|
|
152
|
-
if (unitsCount === 0 && this.logDebug) if (this.logDebug) this.emit('debug', `Units are not configured in MELCloud service`);
|
|
153
|
-
|
|
154
151
|
//filter info
|
|
155
152
|
const { Device: _ignored, ...info } = deviceData;
|
|
156
153
|
|
|
@@ -185,7 +182,6 @@ class MelCloudAta extends EventEmitter {
|
|
|
185
182
|
|
|
186
183
|
async checkState(devicesData) {
|
|
187
184
|
try {
|
|
188
|
-
this.headers = devicesData.Headers;
|
|
189
185
|
const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
190
186
|
deviceData.Scenes = devicesData.Scenes ?? [];
|
|
191
187
|
await this.updateState('request', deviceData);
|
|
@@ -238,7 +234,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
238
234
|
break;
|
|
239
235
|
}
|
|
240
236
|
|
|
241
|
-
if (this.logDebug) this.emit('debug', `Send
|
|
237
|
+
if (this.logDebug) this.emit('debug', `Send data: ${JSON.stringify(payload, null, 2)}`);
|
|
242
238
|
|
|
243
239
|
await axios(path, {
|
|
244
240
|
method: 'POST',
|
|
@@ -328,7 +324,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
328
324
|
//sens payload
|
|
329
325
|
headers['Content-Type'] = 'application/json; charset=utf-8';
|
|
330
326
|
headers.Origin = ApiUrlsHome.Origin;
|
|
331
|
-
if (this.logDebug) this.emit('debug', `Send
|
|
327
|
+
if (!this.logDebug) this.emit('debug', `Send data: ${JSON.stringify(payload, null, 2)}`);
|
|
332
328
|
|
|
333
329
|
await axios(path, {
|
|
334
330
|
method: method,
|
package/src/melcloudatw.js
CHANGED
|
@@ -4,7 +4,7 @@ import Functions from './functions.js';
|
|
|
4
4
|
import { ApiUrls, ApiUrlsHome, HeatPump } from './constants.js';
|
|
5
5
|
|
|
6
6
|
class MelCloudAtw extends EventEmitter {
|
|
7
|
-
constructor(account, device, defaultTempsFile, accountFile, melcloud) {
|
|
7
|
+
constructor(account, device, defaultTempsFile, accountFile, melcloud, accountInfo) {
|
|
8
8
|
super();
|
|
9
9
|
this.accountType = account.type;
|
|
10
10
|
this.logSuccess = account.log?.success;
|
|
@@ -24,7 +24,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
24
24
|
|
|
25
25
|
//set default values
|
|
26
26
|
this.deviceData = {};
|
|
27
|
-
this.headers =
|
|
27
|
+
this.headers = accountInfo.Headers;
|
|
28
28
|
|
|
29
29
|
//handle melcloud events
|
|
30
30
|
let deviceData = null;
|
|
@@ -135,9 +135,6 @@ class MelCloudAtw extends EventEmitter {
|
|
|
135
135
|
return acc;
|
|
136
136
|
}, { indoor: {}, outdoor: {} });
|
|
137
137
|
|
|
138
|
-
//display info if units are not configured in MELCloud service
|
|
139
|
-
if (unitsCount === 0 && this.logDebug) if (this.logDebug) this.emit('debug', `Units are not configured in MELCloud service`);
|
|
140
|
-
|
|
141
138
|
//filter info
|
|
142
139
|
const { Device: _ignored, ...info } = deviceData;
|
|
143
140
|
|
|
@@ -172,7 +169,6 @@ class MelCloudAtw extends EventEmitter {
|
|
|
172
169
|
|
|
173
170
|
async checkState(devicesData) {
|
|
174
171
|
try {
|
|
175
|
-
this.headers = devicesData.Headers;
|
|
176
172
|
const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
177
173
|
deviceData.Scenes = devicesData.Scenes ?? [];
|
|
178
174
|
await this.updateState('request', deviceData);
|
|
@@ -240,7 +236,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
240
236
|
break;
|
|
241
237
|
}
|
|
242
238
|
|
|
243
|
-
if (this.logDebug) this.emit('debug', `Send
|
|
239
|
+
if (this.logDebug) this.emit('debug', `Send data: ${JSON.stringify(payload, null, 2)}`);
|
|
244
240
|
|
|
245
241
|
await axios(path, {
|
|
246
242
|
method: 'POST',
|
|
@@ -300,7 +296,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
300
296
|
|
|
301
297
|
headers['Content-Type'] = 'application/json; charset=utf-8';
|
|
302
298
|
headers.Origin = ApiUrlsHome.Origin;
|
|
303
|
-
if (this.logDebug) this.emit('debug', `Send
|
|
299
|
+
if (this.logDebug) this.emit('debug', `Send data: ${JSON.stringify(payload, null, 2)}`);
|
|
304
300
|
|
|
305
301
|
await axios(path, {
|
|
306
302
|
method: method,
|
package/src/melclouderv.js
CHANGED
|
@@ -4,7 +4,7 @@ import Functions from './functions.js';
|
|
|
4
4
|
import { ApiUrls, ApiUrlsHome, Ventilation } from './constants.js';
|
|
5
5
|
|
|
6
6
|
class MelCloudErv extends EventEmitter {
|
|
7
|
-
constructor(account, device, defaultTempsFile, accountFile, melcloud) {
|
|
7
|
+
constructor(account, device, defaultTempsFile, accountFile, melcloud, accountInfo) {
|
|
8
8
|
super();
|
|
9
9
|
this.accountType = account.type;
|
|
10
10
|
this.logSuccess = account.log?.success;
|
|
@@ -24,7 +24,9 @@ class MelCloudErv extends EventEmitter {
|
|
|
24
24
|
|
|
25
25
|
//set default values
|
|
26
26
|
this.deviceData = {};
|
|
27
|
-
this.headers =
|
|
27
|
+
this.headers = accountInfo.Headers;
|
|
28
|
+
|
|
29
|
+
this.emit('debug', `Headers: ${JSON.stringify(melcloud.Headers, null, 2)}`);
|
|
28
30
|
|
|
29
31
|
//handle melcloud events
|
|
30
32
|
let deviceData = null;
|
|
@@ -134,9 +136,6 @@ class MelCloudErv extends EventEmitter {
|
|
|
134
136
|
return acc;
|
|
135
137
|
}, { indoor: {}, outdoor: {} });
|
|
136
138
|
|
|
137
|
-
//display info if units are not configured in MELCloud service
|
|
138
|
-
if (unitsCount === 0 && this.logDebug) if (this.logDebug) this.emit('debug', `Units are not configured in MELCloud service`);
|
|
139
|
-
|
|
140
139
|
//filter info
|
|
141
140
|
const { Device: _ignored, ...info } = deviceData;
|
|
142
141
|
|
|
@@ -171,7 +170,6 @@ class MelCloudErv extends EventEmitter {
|
|
|
171
170
|
|
|
172
171
|
async checkState(devicesData) {
|
|
173
172
|
try {
|
|
174
|
-
this.headers = devicesData.Headers;
|
|
175
173
|
const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
176
174
|
deviceData.Scenes = devicesData.Scenes ?? [];
|
|
177
175
|
await this.updateState('request', deviceData);
|
|
@@ -240,7 +238,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
240
238
|
break;
|
|
241
239
|
}
|
|
242
240
|
|
|
243
|
-
if (this.logDebug) this.emit('debug', `Send
|
|
241
|
+
if (this.logDebug) this.emit('debug', `Send data: ${JSON.stringify(payload, null, 2)}`);
|
|
244
242
|
|
|
245
243
|
await axios(path, {
|
|
246
244
|
method: 'POST',
|
|
@@ -304,7 +302,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
304
302
|
|
|
305
303
|
headers['Content-Type'] = 'application/json; charset=utf-8';
|
|
306
304
|
headers.Origin = ApiUrlsHome.Origin;
|
|
307
|
-
if (this.logDebug) this.emit('debug', `Send
|
|
305
|
+
if (this.logDebug) this.emit('debug', `Send data: ${JSON.stringify(payload, null, 2)}`);
|
|
308
306
|
|
|
309
307
|
await axios(path, {
|
|
310
308
|
method: method,
|
package/src/melcloudhome.js
CHANGED
|
@@ -256,7 +256,6 @@ class MelCloudHome extends EventEmitter {
|
|
|
256
256
|
devicesList.Info = `Found ${devicesCount} devices ${scenes.length > 0 ? `and ${scenes.length} scenes` : ''}`;
|
|
257
257
|
devicesList.Devices = devices;
|
|
258
258
|
devicesList.Scenes = scenes;
|
|
259
|
-
devicesList.Headers = this.headers;
|
|
260
259
|
this.emit('devicesList', devicesList);
|
|
261
260
|
|
|
262
261
|
return devicesList;
|
|
@@ -271,7 +270,7 @@ class MelCloudHome extends EventEmitter {
|
|
|
271
270
|
|
|
272
271
|
let browser;
|
|
273
272
|
try {
|
|
274
|
-
const accountInfo = { State: false, Info: '', Account: {}, UseFahrenheit: false };
|
|
273
|
+
const accountInfo = { State: false, Info: '', Account: {}, UseFahrenheit: false, Headers: {} };
|
|
275
274
|
let chromiumPath = await this.functions.ensureChromiumInstalled();
|
|
276
275
|
|
|
277
276
|
// === Fallback to Puppeteer's built-in Chromium ===
|
|
@@ -432,6 +431,7 @@ class MelCloudHome extends EventEmitter {
|
|
|
432
431
|
|
|
433
432
|
accountInfo.State = true;
|
|
434
433
|
accountInfo.Info = 'Connect Success';
|
|
434
|
+
accountInfo.Headers = headers;
|
|
435
435
|
await this.functions.saveData(this.accountFile, accountInfo);
|
|
436
436
|
|
|
437
437
|
return accountInfo;
|