homebridge-melcloud-control 4.2.5-beta.25 → 4.2.5-beta.27
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/index.js +6 -15
- package/package.json +1 -1
- package/src/deviceata.js +12 -11
- package/src/deviceatw.js +12 -11
- package/src/deviceerv.js +12 -11
- package/src/melcloud.js +0 -11
- package/src/melcloudata.js +34 -25
- package/src/melcloudatw.js +37 -26
- package/src/melclouderv.js +49 -39
- package/src/melcloudhome.js +0 -10
package/index.js
CHANGED
|
@@ -106,7 +106,6 @@ class MelCloudPlatform {
|
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
108
|
if (logLevel.success) log.success(accountInfo.Info);
|
|
109
|
-
const useFahrenheit = accountInfo.UseFahrenheit;
|
|
110
109
|
|
|
111
110
|
//check devices list
|
|
112
111
|
let devicesList;
|
|
@@ -166,30 +165,22 @@ class MelCloudPlatform {
|
|
|
166
165
|
let configuredDevice;
|
|
167
166
|
switch (deviceType) {
|
|
168
167
|
case 0: //ATA
|
|
169
|
-
configuredDevice = new DeviceAta(api, account, device, devicesFile, defaultTempsFile,
|
|
168
|
+
configuredDevice = new DeviceAta(api, account, device, devicesFile, defaultTempsFile, accountInfo, accountFile);
|
|
170
169
|
break;
|
|
171
170
|
case 1: //ATW
|
|
172
|
-
configuredDevice = new DeviceAtw(api, account, device, devicesFile, defaultTempsFile,
|
|
171
|
+
configuredDevice = new DeviceAtw(api, account, device, devicesFile, defaultTempsFile, accountInfo, accountFile);
|
|
173
172
|
break;
|
|
174
173
|
case 2:
|
|
175
174
|
break;
|
|
176
175
|
case 3: //ERV
|
|
177
|
-
configuredDevice = new DeviceErv(api, account, device, devicesFile, defaultTempsFile,
|
|
176
|
+
configuredDevice = new DeviceErv(api, account, device, devicesFile, defaultTempsFile, accountInfo, accountFile);
|
|
178
177
|
break;
|
|
179
178
|
default:
|
|
180
179
|
if (logLevel.warn) log.warn(`${accountName}, ${deviceTypeText}, ${deviceName}, unknown device: ${deviceType}.`);
|
|
181
180
|
return;
|
|
182
181
|
}
|
|
183
182
|
|
|
184
|
-
configuredDevice.on('
|
|
185
|
-
try {
|
|
186
|
-
const accountDate = account.type === 'melcloud' ? accountInfo.LoginData[key] = value : accountInfo[key];
|
|
187
|
-
await melCloud.send(accountDate);
|
|
188
|
-
} catch (error) {
|
|
189
|
-
if (logLevel.error) log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error.message ?? error}.`);
|
|
190
|
-
}
|
|
191
|
-
})
|
|
192
|
-
.on('devInfo', (info) => logLevel.devInfo && log.info(info))
|
|
183
|
+
configuredDevice.on('devInfo', (info) => logLevel.devInfo && log.info(info))
|
|
193
184
|
.on('success', (msg) => logLevel.success && log.success(`${accountName}, ${deviceTypeText}, ${deviceName}, ${msg}`))
|
|
194
185
|
.on('info', (msg) => logLevel.info && log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, ${msg}`))
|
|
195
186
|
.on('debug', (msg) => logLevel.debug && log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, debug: ${msg}`))
|
|
@@ -202,9 +193,9 @@ class MelCloudPlatform {
|
|
|
202
193
|
if (logLevel.success) log.success(`${accountName}, ${deviceTypeText}, ${deviceName}, Published as external accessory.`);
|
|
203
194
|
|
|
204
195
|
//start impulse generators\
|
|
205
|
-
const timmers = accountType === 'melcloudhome' ? [{ name: 'connect', sampling: 3000000 }, { name: 'checkDevicesList', sampling: deviceRefreshInterval }] : [{ name: 'checkDevicesList', sampling: refreshInterval }];
|
|
206
|
-
await melCloud.impulseGenerator.state(true, timmers, false);
|
|
207
196
|
await configuredDevice.startStopImpulseGenerator(true, [{ name: 'checkState', sampling: deviceRefreshInterval }]);
|
|
197
|
+
const timmers = accountType === 'melcloudhome' ? [{ name: 'connect', sampling: 3000000 }, { name: 'checkDevicesList', sampling: 3000 }] : [{ name: 'checkDevicesList', sampling: refreshInterval }];
|
|
198
|
+
await melCloud.impulseGenerator.state(true, timmers, false);
|
|
208
199
|
|
|
209
200
|
//stop impulse generator
|
|
210
201
|
await impulseGenerator.state(false);
|
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.5-beta.
|
|
4
|
+
"version": "4.2.5-beta.27",
|
|
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
|
@@ -6,7 +6,7 @@ import { TemperatureDisplayUnits, AirConditioner } from './constants.js';
|
|
|
6
6
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
7
7
|
|
|
8
8
|
class DeviceAta extends EventEmitter {
|
|
9
|
-
constructor(api, account, device, devicesFile, defaultTempsFile,
|
|
9
|
+
constructor(api, account, device, devicesFile, defaultTempsFile, accountInfo, accountFile) {
|
|
10
10
|
super();
|
|
11
11
|
|
|
12
12
|
Accessory = api.platformAccessory;
|
|
@@ -49,6 +49,8 @@ class DeviceAta extends EventEmitter {
|
|
|
49
49
|
//files
|
|
50
50
|
this.devicesFile = devicesFile;
|
|
51
51
|
this.defaultTempsFile = defaultTempsFile;
|
|
52
|
+
this.accountInfo = accountInfo;
|
|
53
|
+
this.accountFile = accountFile;
|
|
52
54
|
this.displayDeviceInfo = true;
|
|
53
55
|
|
|
54
56
|
//external integrations
|
|
@@ -99,7 +101,6 @@ class DeviceAta extends EventEmitter {
|
|
|
99
101
|
|
|
100
102
|
//accessory
|
|
101
103
|
this.accessory = {};
|
|
102
|
-
this.useFahrenheit = useFahrenheit ? 1 : 0;
|
|
103
104
|
};
|
|
104
105
|
|
|
105
106
|
async externalIntegrations() {
|
|
@@ -524,10 +525,10 @@ class DeviceAta extends EventEmitter {
|
|
|
524
525
|
if (this.account.type === 'melcloudhome') return;
|
|
525
526
|
|
|
526
527
|
try {
|
|
527
|
-
|
|
528
|
-
this.accessory.useFahrenheit = value;
|
|
528
|
+
this.accessory.useFahrenheit = value ? true : false;
|
|
529
529
|
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
530
|
-
this.
|
|
530
|
+
this.accountInfo.LoginData.UseFahrenheit = value ? true : false;
|
|
531
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'account', this.accountInfo);
|
|
531
532
|
} catch (error) {
|
|
532
533
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
533
534
|
};
|
|
@@ -619,10 +620,10 @@ class DeviceAta extends EventEmitter {
|
|
|
619
620
|
if (this.account.type === 'melcloudhome') return;
|
|
620
621
|
|
|
621
622
|
try {
|
|
622
|
-
|
|
623
|
-
this.accessory.useFahrenheit = value;
|
|
623
|
+
this.accessory.useFahrenheit = value ? true : false;
|
|
624
624
|
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
625
|
-
this.
|
|
625
|
+
this.accountInfo.LoginData.UseFahrenheit = value ? true : false;
|
|
626
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'account', this.accountInfo);
|
|
626
627
|
} catch (error) {
|
|
627
628
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
628
629
|
};
|
|
@@ -1322,7 +1323,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1322
1323
|
async start() {
|
|
1323
1324
|
try {
|
|
1324
1325
|
//melcloud device
|
|
1325
|
-
this.melCloudAta = new MelCloudAta(this.account, this.device, this.devicesFile, this.defaultTempsFile)
|
|
1326
|
+
this.melCloudAta = new MelCloudAta(this.account, this.device, this.devicesFile, this.defaultTempsFile, this.accountFile)
|
|
1326
1327
|
.on('deviceInfo', (modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
|
|
1327
1328
|
if (this.logDeviceInfo && this.displayDeviceInfo) {
|
|
1328
1329
|
this.emit('devInfo', `---- ${this.deviceTypeText}: ${this.deviceName} ----`);
|
|
@@ -1462,8 +1463,8 @@ class DeviceAta extends EventEmitter {
|
|
|
1462
1463
|
currentSwingMode: supportsSwingFunction && vaneHorizontalDirection === 12 && vaneVerticalDirection === 7 ? 1 : 0,
|
|
1463
1464
|
lockPhysicalControl: prohibitSetTemperature && prohibitOperationMode && prohibitPower ? 1 : 0,
|
|
1464
1465
|
temperatureStep: temperatureStep,
|
|
1465
|
-
useFahrenheit: this.useFahrenheit,
|
|
1466
|
-
temperatureUnit: TemperatureDisplayUnits[this.useFahrenheit],
|
|
1466
|
+
useFahrenheit: this.accountInfo.useFahrenheit ? 1 : 0,
|
|
1467
|
+
temperatureUnit: TemperatureDisplayUnits[this.accountInfo.useFahrenheit ? 1 : 0],
|
|
1467
1468
|
isConnected: isConnected,
|
|
1468
1469
|
isInError: isInError,
|
|
1469
1470
|
frostProtectionEnabled: frostProtectionEnabled,
|
package/src/deviceatw.js
CHANGED
|
@@ -6,7 +6,7 @@ import { TemperatureDisplayUnits, HeatPump } from './constants.js';
|
|
|
6
6
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
7
7
|
|
|
8
8
|
class DeviceAtw extends EventEmitter {
|
|
9
|
-
constructor(api, account, device, devicesFile, defaultTempsFile,
|
|
9
|
+
constructor(api, account, device, devicesFile, defaultTempsFile, accountInfo, accountFile) {
|
|
10
10
|
super();
|
|
11
11
|
|
|
12
12
|
Accessory = api.platformAccessory;
|
|
@@ -50,6 +50,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
50
50
|
this.deviceTypeText = device.typeString;
|
|
51
51
|
this.devicesFile = devicesFile;
|
|
52
52
|
this.defaultTempsFile = defaultTempsFile;
|
|
53
|
+
this.accountInfo = accountInfo;
|
|
54
|
+
this.accountFile = accountFile;
|
|
53
55
|
this.displayDeviceInfo = true;
|
|
54
56
|
|
|
55
57
|
//external integrations
|
|
@@ -100,7 +102,6 @@ class DeviceAtw extends EventEmitter {
|
|
|
100
102
|
|
|
101
103
|
//accessory
|
|
102
104
|
this.accessory = {};
|
|
103
|
-
this.useFahrenheit = useFahrenheit ? 1 : 0;
|
|
104
105
|
};
|
|
105
106
|
|
|
106
107
|
async externalIntegrations() {
|
|
@@ -649,10 +650,10 @@ class DeviceAtw extends EventEmitter {
|
|
|
649
650
|
if (this.account.type === 'melcloudhome') return;
|
|
650
651
|
|
|
651
652
|
try {
|
|
652
|
-
|
|
653
|
-
this.accessory.useFahrenheit = value;
|
|
653
|
+
this.accessory.useFahrenheit = value ? true : false;
|
|
654
654
|
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
655
|
-
this.
|
|
655
|
+
this.accountInfo.LoginData.UseFahrenheit = value ? true : false;
|
|
656
|
+
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, 'account', this.accountInfo);
|
|
656
657
|
} catch (error) {
|
|
657
658
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
658
659
|
};
|
|
@@ -835,10 +836,10 @@ class DeviceAtw extends EventEmitter {
|
|
|
835
836
|
if (this.account.type === 'melcloudhome') return;
|
|
836
837
|
|
|
837
838
|
try {
|
|
838
|
-
|
|
839
|
-
this.accessory.useFahrenheit = value;
|
|
839
|
+
this.accessory.useFahrenheit = value ? true : false;
|
|
840
840
|
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
841
|
-
this.
|
|
841
|
+
this.accountInfo.LoginData.UseFahrenheit = value ? true : false;
|
|
842
|
+
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, 'account', this.accountInfo);
|
|
842
843
|
} catch (error) {
|
|
843
844
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
844
845
|
};
|
|
@@ -1572,7 +1573,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1572
1573
|
async start() {
|
|
1573
1574
|
try {
|
|
1574
1575
|
//melcloud device
|
|
1575
|
-
this.melCloudAtw = new MelCloudAtw(this.account, this.device, this.devicesFile, this.defaultTempsFile)
|
|
1576
|
+
this.melCloudAtw = new MelCloudAtw(this.account, this.device, this.devicesFile, this.defaultTempsFile, this.accountFile)
|
|
1576
1577
|
.on('deviceInfo', (modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion, supportsHotWaterTank, supportsZone2) => {
|
|
1577
1578
|
if (this.logDeviceInfo && this.displayDeviceInfo) {
|
|
1578
1579
|
this.emit('devInfo', `---- ${this.deviceTypeText}: ${this.deviceName} ----`);
|
|
@@ -1720,8 +1721,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
1720
1721
|
caseHotWaterSensor: caseHotWaterSensor,
|
|
1721
1722
|
caseZone2Sensor: caseZone2Sensor,
|
|
1722
1723
|
sensorsCount: zonesSensorsCount,
|
|
1723
|
-
useFahrenheit: this.useFahrenheit,
|
|
1724
|
-
temperatureUnit: TemperatureDisplayUnits[this.useFahrenheit],
|
|
1724
|
+
useFahrenheit: this.accountInfo.useFahrenheit ? 1 : 0,
|
|
1725
|
+
temperatureUnit: TemperatureDisplayUnits[this.accountInfo.useFahrenheit ? 1 : 0],
|
|
1725
1726
|
isConnected: isConnected,
|
|
1726
1727
|
isInError: isInError,
|
|
1727
1728
|
scheduleEnabled: scheduleEnabled,
|
package/src/deviceerv.js
CHANGED
|
@@ -6,7 +6,7 @@ import { TemperatureDisplayUnits, Ventilation } from './constants.js';
|
|
|
6
6
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
7
7
|
|
|
8
8
|
class DeviceErv extends EventEmitter {
|
|
9
|
-
constructor(api, account, device, devicesFile, defaultTempsFile,
|
|
9
|
+
constructor(api, account, device, devicesFile, defaultTempsFile, accountInfo, accountFile) {
|
|
10
10
|
super();
|
|
11
11
|
|
|
12
12
|
Accessory = api.platformAccessory;
|
|
@@ -43,6 +43,8 @@ class DeviceErv extends EventEmitter {
|
|
|
43
43
|
this.deviceTypeText = device.typeString;
|
|
44
44
|
this.devicesFile = devicesFile;
|
|
45
45
|
this.defaultTempsFile = defaultTempsFile;
|
|
46
|
+
this.accountInfo = accountInfo;
|
|
47
|
+
this.accountFile = accountFile;
|
|
46
48
|
this.displayDeviceInfo = true;
|
|
47
49
|
|
|
48
50
|
//external integrations
|
|
@@ -93,7 +95,6 @@ class DeviceErv extends EventEmitter {
|
|
|
93
95
|
|
|
94
96
|
//accessory
|
|
95
97
|
this.accessory = {};
|
|
96
|
-
this.useFahrenheit = useFahrenheit ? 1 : 0;
|
|
97
98
|
};
|
|
98
99
|
|
|
99
100
|
async externalIntegrations() {
|
|
@@ -455,10 +456,10 @@ class DeviceErv extends EventEmitter {
|
|
|
455
456
|
if (this.account.type === 'melcloudhome') return;
|
|
456
457
|
|
|
457
458
|
try {
|
|
458
|
-
|
|
459
|
-
this.accessory.useFahrenheit = value;
|
|
459
|
+
this.accessory.useFahrenheit = value ? true : false;
|
|
460
460
|
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
461
|
-
this.
|
|
461
|
+
this.accountInfo.LoginData.UseFahrenheit = value ? true : false;
|
|
462
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, 'account', this.accountInfo);
|
|
462
463
|
} catch (error) {
|
|
463
464
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
464
465
|
};
|
|
@@ -548,10 +549,10 @@ class DeviceErv extends EventEmitter {
|
|
|
548
549
|
if (this.account.type === 'melcloudhome') return;
|
|
549
550
|
|
|
550
551
|
try {
|
|
551
|
-
|
|
552
|
-
this.accessory.useFahrenheit = value;
|
|
552
|
+
this.accessory.useFahrenheit = value ? true : false;
|
|
553
553
|
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
554
|
-
this.
|
|
554
|
+
this.accountInfo.LoginData.UseFahrenheit = value ? true : false;
|
|
555
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, 'account', this.accountInfo);
|
|
555
556
|
} catch (error) {
|
|
556
557
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
557
558
|
};
|
|
@@ -1117,7 +1118,7 @@ class DeviceErv extends EventEmitter {
|
|
|
1117
1118
|
async start() {
|
|
1118
1119
|
try {
|
|
1119
1120
|
//melcloud device
|
|
1120
|
-
this.melCloudErv = new MelCloudErv(this.account, this.device, this.devicesFile, this.defaultTempsFile)
|
|
1121
|
+
this.melCloudErv = new MelCloudErv(this.account, this.device, this.devicesFile, this.defaultTempsFile, this.accountFile)
|
|
1121
1122
|
.on('deviceInfo', (modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
|
|
1122
1123
|
if (this.logDeviceInfo && this.displayDeviceInfo) {
|
|
1123
1124
|
this.emit('devInfo', `---- ${this.deviceTypeText}: ${this.deviceName} ----`);
|
|
@@ -1251,8 +1252,8 @@ class DeviceErv extends EventEmitter {
|
|
|
1251
1252
|
temperatureIncrement: maxTempHeat,
|
|
1252
1253
|
minTempCoolDry: minTempCoolDry,
|
|
1253
1254
|
maxTempCoolDry: maxTempCoolDry,
|
|
1254
|
-
useFahrenheit: this.useFahrenheit,
|
|
1255
|
-
temperatureUnit: TemperatureDisplayUnits[this.useFahrenheit],
|
|
1255
|
+
useFahrenheit: this.accountInfo.useFahrenheit ? 1 : 0,
|
|
1256
|
+
temperatureUnit: TemperatureDisplayUnits[this.accountInfo.useFahrenheit ? 1 : 0],
|
|
1256
1257
|
isConnected: isConnected,
|
|
1257
1258
|
isInError: isInError,
|
|
1258
1259
|
scheduleEnabled: scheduleEnabled,
|
package/src/melcloud.js
CHANGED
|
@@ -183,17 +183,6 @@ class MelCloud extends EventEmitter {
|
|
|
183
183
|
throw new Error(`Connect error: ${error.message}`);
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
|
-
|
|
187
|
-
async send(accountInfo) {
|
|
188
|
-
try {
|
|
189
|
-
const payload = { data: accountInfo.LoginData };
|
|
190
|
-
await this.axiosInstance(ApiUrls.UpdateApplicationOptions, { method: 'POST', data: payload });
|
|
191
|
-
await this.functions.saveData(this.accountFile, accountInfo);
|
|
192
|
-
return true;
|
|
193
|
-
} catch (error) {
|
|
194
|
-
throw new Error(`Send data error: ${error.message}`);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
186
|
}
|
|
198
187
|
|
|
199
188
|
export default MelCloud;
|
package/src/melcloudata.js
CHANGED
|
@@ -5,7 +5,7 @@ import Functions from './functions.js';
|
|
|
5
5
|
import { ApiUrls, ApiUrlsHome, AirConditioner } from './constants.js';
|
|
6
6
|
|
|
7
7
|
class MelCloudAta extends EventEmitter {
|
|
8
|
-
constructor(account, device, devicesFile, defaultTempsFile) {
|
|
8
|
+
constructor(account, device, devicesFile, defaultTempsFile, accountFile) {
|
|
9
9
|
super();
|
|
10
10
|
this.accountType = account.type;
|
|
11
11
|
this.logWarn = account.log?.warn;
|
|
@@ -16,6 +16,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
16
16
|
this.deviceId = device.id;
|
|
17
17
|
this.devicesFile = devicesFile;
|
|
18
18
|
this.defaultTempsFile = defaultTempsFile;
|
|
19
|
+
this.accountFile = accountFile;
|
|
19
20
|
this.functions = new Functions(this.logWarn, this.logError, this.logDebug)
|
|
20
21
|
.on('warn', warn => this.emit('warn', warn))
|
|
21
22
|
.on('error', error => this.emit('error', error))
|
|
@@ -136,33 +137,42 @@ class MelCloudAta extends EventEmitter {
|
|
|
136
137
|
let path = '';
|
|
137
138
|
switch (accountType) {
|
|
138
139
|
case "melcloud":
|
|
139
|
-
|
|
140
140
|
if (displayType === 1 && deviceData.Device.OperationMode === 8) {
|
|
141
141
|
deviceData.Device.SetTemperature = (deviceData.Device.DefaultCoolingSetTemperature + deviceData.Device.DefaultHeatingSetTemperature) / 2;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
144
|
+
switch (flag) {
|
|
145
|
+
case 'account':
|
|
146
|
+
payload = { data: flagData.LoginData };
|
|
147
|
+
path = ApiUrls.UpdateApplicationOptions;
|
|
148
|
+
await this.functions.saveData(this.accountFile, flagData);
|
|
149
|
+
break;
|
|
150
|
+
default:
|
|
151
|
+
deviceData.Device.EffectiveFlags = flag;
|
|
152
|
+
payload = {
|
|
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
|
|
169
|
+
};
|
|
170
|
+
path = ApiUrls.SetAta;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
163
173
|
|
|
164
174
|
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|
|
165
|
-
await axios(
|
|
175
|
+
await axios(path, {
|
|
166
176
|
method: 'POST',
|
|
167
177
|
baseURL: ApiUrls.BaseURL,
|
|
168
178
|
timeout: 30000,
|
|
@@ -258,24 +268,23 @@ class MelCloudAta extends EventEmitter {
|
|
|
258
268
|
data: payload
|
|
259
269
|
});
|
|
260
270
|
|
|
261
|
-
this.lock = true;
|
|
262
271
|
this.updateData(deviceData);
|
|
263
272
|
return true;
|
|
264
273
|
default:
|
|
265
274
|
return;
|
|
266
275
|
}
|
|
267
276
|
} catch (error) {
|
|
268
|
-
this.lock = false;
|
|
269
277
|
if (error.response?.status === 500) return true; // Return 500 for schedule hovewer working correct
|
|
270
278
|
throw new Error(`Send data error: ${error.message}`);
|
|
271
279
|
}
|
|
272
280
|
}
|
|
273
281
|
|
|
274
282
|
updateData(deviceData) {
|
|
283
|
+
this.locks = true;
|
|
275
284
|
this.emit('deviceState', deviceData);
|
|
276
285
|
|
|
277
286
|
setTimeout(() => {
|
|
278
|
-
this.
|
|
287
|
+
this.locks = false
|
|
279
288
|
}, 5000);
|
|
280
289
|
}
|
|
281
290
|
};
|
package/src/melcloudatw.js
CHANGED
|
@@ -5,7 +5,7 @@ import Functions from './functions.js';
|
|
|
5
5
|
import { ApiUrls, ApiUrlsHome, HeatPump } from './constants.js';
|
|
6
6
|
|
|
7
7
|
class MelCloudAtw extends EventEmitter {
|
|
8
|
-
constructor(account, device, devicesFile, defaultTempsFile) {
|
|
8
|
+
constructor(account, device, devicesFile, defaultTempsFile, accountFile) {
|
|
9
9
|
super();
|
|
10
10
|
this.accountType = account.type;
|
|
11
11
|
this.logWarn = account.log?.warn;
|
|
@@ -16,6 +16,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
16
16
|
this.deviceId = device.id;
|
|
17
17
|
this.devicesFile = devicesFile;
|
|
18
18
|
this.defaultTempsFile = defaultTempsFile;
|
|
19
|
+
this.accountFile = accountFile;
|
|
19
20
|
this.functions = new Functions(this.logWarn, this.logError, this.logDebug)
|
|
20
21
|
.on('warn', warn => this.emit('warn', warn))
|
|
21
22
|
.on('error', error => this.emit('error', error))
|
|
@@ -143,32 +144,42 @@ class MelCloudAtw extends EventEmitter {
|
|
|
143
144
|
let path = '';
|
|
144
145
|
switch (accountType) {
|
|
145
146
|
case "melcloud":
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
147
|
+
switch (flag) {
|
|
148
|
+
case 'account':
|
|
149
|
+
payload = { data: flagData.LoginData };
|
|
150
|
+
path = ApiUrls.UpdateApplicationOptions;
|
|
151
|
+
await this.functions.saveData(this.accountFile, flagData);
|
|
152
|
+
break;
|
|
153
|
+
default:
|
|
154
|
+
deviceData.Device.EffectiveFlags = flag;
|
|
155
|
+
payload = {
|
|
156
|
+
DeviceID: deviceData.Device.DeviceID,
|
|
157
|
+
EffectiveFlags: deviceData.Device.EffectiveFlags,
|
|
158
|
+
Power: deviceData.Device.Power,
|
|
159
|
+
SetTemperatureZone1: deviceData.Device.SetTemperatureZone1,
|
|
160
|
+
SetTemperatureZone2: deviceData.Device.SetTemperatureZone2,
|
|
161
|
+
OperationMode: deviceData.Device.OperationMode,
|
|
162
|
+
OperationModeZone1: deviceData.Device.OperationModeZone1,
|
|
163
|
+
OperationModeZone2: deviceData.Device.OperationModeZone2,
|
|
164
|
+
SetHeatFlowTemperatureZone1: deviceData.Device.SetHeatFlowTemperatureZone1,
|
|
165
|
+
SetHeatFlowTemperatureZone2: deviceData.Device.SetHeatFlowTemperatureZone2,
|
|
166
|
+
SetCoolFlowTemperatureZone1: deviceData.Device.SetCoolFlowTemperatureZone1,
|
|
167
|
+
SetCoolFlowTemperatureZone2: deviceData.Device.SetCoolFlowTemperatureZone2,
|
|
168
|
+
SetTankWaterTemperature: deviceData.Device.SetTankWaterTemperature,
|
|
169
|
+
ForcedHotWaterMode: deviceData.Device.ForcedHotWaterMode,
|
|
170
|
+
EcoHotWater: deviceData.Device.EcoHotWater,
|
|
171
|
+
HolidayMode: deviceData.Device.HolidayMode,
|
|
172
|
+
ProhibitZone1: deviceData.Device.ProhibitHeatingZone1,
|
|
173
|
+
ProhibitZone2: deviceData.Device.ProhibitHeatingZone2,
|
|
174
|
+
ProhibitHotWater: deviceData.Device.ProhibitHotWater,
|
|
175
|
+
HasPendingCommand: true
|
|
176
|
+
}
|
|
177
|
+
path = ApiUrls.SetAtw;
|
|
178
|
+
break;
|
|
168
179
|
}
|
|
169
180
|
|
|
170
181
|
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|
|
171
|
-
await axios(
|
|
182
|
+
await axios(path, {
|
|
172
183
|
method: 'POST',
|
|
173
184
|
baseURL: ApiUrls.BaseURL,
|
|
174
185
|
timeout: 30000,
|
|
@@ -246,11 +257,11 @@ class MelCloudAtw extends EventEmitter {
|
|
|
246
257
|
}
|
|
247
258
|
|
|
248
259
|
updateData(deviceData) {
|
|
249
|
-
this.
|
|
260
|
+
this.locks = true;
|
|
250
261
|
this.emit('deviceState', deviceData);
|
|
251
262
|
|
|
252
263
|
setTimeout(() => {
|
|
253
|
-
this.
|
|
264
|
+
this.locks = false
|
|
254
265
|
}, 5000);
|
|
255
266
|
}
|
|
256
267
|
};
|
package/src/melclouderv.js
CHANGED
|
@@ -5,7 +5,7 @@ import Functions from './functions.js';
|
|
|
5
5
|
import { ApiUrls, ApiUrlsHome, Ventilation } from './constants.js';
|
|
6
6
|
|
|
7
7
|
class MelCloudErv extends EventEmitter {
|
|
8
|
-
constructor(account, device, devicesFile, defaultTempsFile) {
|
|
8
|
+
constructor(account, device, devicesFile, defaultTempsFile, accountFile) {
|
|
9
9
|
super();
|
|
10
10
|
this.accountType = account.type;
|
|
11
11
|
this.logWarn = account.log?.warn;
|
|
@@ -16,6 +16,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
16
16
|
this.deviceId = device.id;
|
|
17
17
|
this.devicesFile = devicesFile;
|
|
18
18
|
this.defaultTempsFile = defaultTempsFile;
|
|
19
|
+
this.accountFile = accountFile;
|
|
19
20
|
this.functions = new Functions(this.logWarn, this.logError, this.logDebug)
|
|
20
21
|
.on('warn', warn => this.emit('warn', warn))
|
|
21
22
|
.on('error', error => this.emit('error', error))
|
|
@@ -131,47 +132,56 @@ class MelCloudErv extends EventEmitter {
|
|
|
131
132
|
let path = '';
|
|
132
133
|
switch (accountType) {
|
|
133
134
|
case "melcloud":
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
135
|
+
switch (flag) {
|
|
136
|
+
case 'account':
|
|
137
|
+
payload = { data: flagData.LoginData };
|
|
138
|
+
path = ApiUrls.UpdateApplicationOptions;
|
|
139
|
+
await this.functions.saveData(this.accountFile, flagData);
|
|
140
|
+
break;
|
|
141
|
+
default:
|
|
142
|
+
//set target temp based on display mode and ventilation mode
|
|
143
|
+
switch (displayType) {
|
|
144
|
+
case 1: //Heather/Cooler
|
|
145
|
+
switch (deviceData.Device.VentilationMode) {
|
|
146
|
+
case 0: //LOSNAY
|
|
147
|
+
deviceData.Device.SetTemperature = deviceData.Device.DefaultHeatingSetTemperature;
|
|
148
|
+
break;
|
|
149
|
+
case 1: //BYPASS
|
|
150
|
+
deviceData.Device.SetTemperature = deviceData.Device.DefaultCoolingSetTemperature;
|
|
151
|
+
break;
|
|
152
|
+
case 2: //AUTO
|
|
153
|
+
const setTemperature = (deviceData.Device.DefaultCoolingSetTemperature + deviceData.Device.DefaultHeatingSetTemperature) / 2;
|
|
154
|
+
deviceData.Device.SetTemperature = setTemperature;
|
|
155
|
+
break;
|
|
156
|
+
};
|
|
157
|
+
case 2: //Thermostat
|
|
158
|
+
deviceData.Device.SetTemperature = deviceData.Device.SetTemperature;
|
|
147
159
|
break;
|
|
148
160
|
};
|
|
149
|
-
case 2: //Thermostat
|
|
150
|
-
deviceData.Device.SetTemperature = deviceData.Device.SetTemperature;
|
|
151
|
-
break;
|
|
152
|
-
};
|
|
153
161
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
162
|
+
//device state
|
|
163
|
+
deviceData.Device.EffectiveFlags = flag;
|
|
164
|
+
payload = {
|
|
165
|
+
DeviceID: deviceData.Device.DeviceID,
|
|
166
|
+
EffectiveFlags: deviceData.Device.EffectiveFlags,
|
|
167
|
+
Power: deviceData.Device.Power,
|
|
168
|
+
SetTemperature: deviceData.Device.SetTemperature,
|
|
169
|
+
SetFanSpeed: deviceData.Device.SetFanSpeed,
|
|
170
|
+
OperationMode: deviceData.Device.OperationMode,
|
|
171
|
+
VentilationMode: deviceData.Device.VentilationMode,
|
|
172
|
+
DefaultCoolingSetTemperature: deviceData.Device.DefaultCoolingSetTemperature,
|
|
173
|
+
DefaultHeatingSetTemperature: deviceData.Device.DefaultHeatingSetTemperature,
|
|
174
|
+
HideRoomTemperature: deviceData.Device.HideRoomTemperature,
|
|
175
|
+
HideSupplyTemperature: deviceData.Device.HideSupplyTemperature,
|
|
176
|
+
HideOutdoorTemperature: deviceData.Device.HideOutdoorTemperature,
|
|
177
|
+
NightPurgeMode: deviceData.Device.NightPurgeMode,
|
|
178
|
+
HasPendingCommand: true
|
|
179
|
+
}
|
|
180
|
+
path = ApiUrls.SetErv;
|
|
181
|
+
break;
|
|
171
182
|
}
|
|
172
|
-
|
|
173
183
|
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|
|
174
|
-
await axios(
|
|
184
|
+
await axios(path, {
|
|
175
185
|
method: 'POST',
|
|
176
186
|
baseURL: ApiUrls.BaseURL,
|
|
177
187
|
timeout: 30000,
|
|
@@ -253,11 +263,11 @@ class MelCloudErv extends EventEmitter {
|
|
|
253
263
|
}
|
|
254
264
|
|
|
255
265
|
updateData(deviceData) {
|
|
256
|
-
this.
|
|
266
|
+
this.locks = true;
|
|
257
267
|
this.emit('deviceState', deviceData);
|
|
258
268
|
|
|
259
269
|
setTimeout(() => {
|
|
260
|
-
this.
|
|
270
|
+
this.locks = false
|
|
261
271
|
}, 5000);
|
|
262
272
|
}
|
|
263
273
|
};
|
package/src/melcloudhome.js
CHANGED
|
@@ -365,16 +365,6 @@ class MelCloud extends EventEmitter {
|
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
|
-
|
|
369
|
-
async send(accountInfo) {
|
|
370
|
-
try {
|
|
371
|
-
//await this.axiosInstance(ApiUrlsHome.UpdateApplicationOptions, { method: 'POST' });
|
|
372
|
-
//await this.functions.saveData(this.accountFile, accountInfo);
|
|
373
|
-
return true;
|
|
374
|
-
} catch (error) {
|
|
375
|
-
throw new Error(`Send data error: ${error.message}`);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
368
|
}
|
|
379
369
|
|
|
380
370
|
export default MelCloud;
|