homebridge-melcloud-control 4.2.5-beta.9 → 4.2.5
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/CHANGELOG.md +12 -0
- package/README.md +19 -18
- package/config.schema.json +11 -11
- package/index.js +6 -15
- package/package.json +2 -2
- package/src/constants.js +1 -0
- package/src/deviceata.js +33 -30
- package/src/deviceatw.js +31 -28
- package/src/deviceerv.js +31 -28
- package/src/melcloud.js +3 -14
- package/src/melcloudata.js +70 -52
- package/src/melcloudatw.js +65 -45
- package/src/melclouderv.js +77 -57
- package/src/melcloudhome.js +16 -34
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.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.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
|
};
|
|
@@ -1137,7 +1138,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1137
1138
|
.onSet(async (state) => {
|
|
1138
1139
|
try {
|
|
1139
1140
|
deviceData.HolidayMode.Enabled = state;
|
|
1140
|
-
if (this.logInfo) this.emit('info', `Holiday mode: ${state ? '
|
|
1141
|
+
if (this.logInfo) this.emit('info', `Holiday mode: ${state ? 'Enabled' : 'Disabled'}`);
|
|
1141
1142
|
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, 'holidaymode');
|
|
1142
1143
|
} catch (error) {
|
|
1143
1144
|
if (this.logWarn) this.emit('warn', `Set holiday mode error: ${error}`);
|
|
@@ -1177,16 +1178,17 @@ class DeviceAtw extends EventEmitter {
|
|
|
1177
1178
|
this.presets.forEach((preset, i) => {
|
|
1178
1179
|
const presetData = presetsOnServer.find(p => p.ID === preset.id);
|
|
1179
1180
|
|
|
1180
|
-
//get
|
|
1181
|
+
//get name
|
|
1181
1182
|
const name = preset.name;
|
|
1182
1183
|
|
|
1183
|
-
//get
|
|
1184
|
+
//get name prefix
|
|
1184
1185
|
const namePrefix = preset.namePrefix;
|
|
1185
1186
|
|
|
1186
1187
|
const serviceName1 = namePrefix ? `${accessoryName} ${name}` : name;
|
|
1187
1188
|
const serviceType = preset.serviceType;
|
|
1188
1189
|
const characteristicType = preset.characteristicType;
|
|
1189
1190
|
|
|
1191
|
+
//control
|
|
1190
1192
|
if (preset.displayType > 3) {
|
|
1191
1193
|
if (this.logDebug) this.emit('debug', `Prepare preset control ${name} service`);
|
|
1192
1194
|
const presetControlService = new Service.Switch(serviceName1, `presetControlService${deviceId} ${i}`);
|
|
@@ -1219,7 +1221,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1219
1221
|
break;
|
|
1220
1222
|
};
|
|
1221
1223
|
|
|
1222
|
-
if (this.logInfo) this.emit('info', `Preset ${name}: ${state ? 'Set
|
|
1224
|
+
if (this.logInfo) this.emit('info', `Preset ${name}: ${state ? 'Set' : 'Unset'}`);
|
|
1223
1225
|
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.Presets);
|
|
1224
1226
|
} catch (error) {
|
|
1225
1227
|
if (this.logWarn) this.emit('warn', `Set preset error: ${error}`);
|
|
@@ -1249,13 +1251,14 @@ class DeviceAtw extends EventEmitter {
|
|
|
1249
1251
|
if (this.logDebug) this.emit('debug', `Prepare schedules services`);
|
|
1250
1252
|
this.scheduleSensorServices = [];
|
|
1251
1253
|
this.schedules.forEach((schedule, i) => {
|
|
1252
|
-
|
|
1254
|
+
const scheduleData = schedulesOnServer.find(s => s.Id === schedule.id);
|
|
1255
|
+
|
|
1256
|
+
//get name
|
|
1253
1257
|
const name = schedule.name;
|
|
1254
1258
|
|
|
1255
|
-
//get
|
|
1259
|
+
//get name prefix
|
|
1256
1260
|
const namePrefix = schedule.namePrefix;
|
|
1257
1261
|
|
|
1258
|
-
//control sensor
|
|
1259
1262
|
const serviceName1 = namePrefix ? `${accessoryName} ${name}` : name;
|
|
1260
1263
|
const serviceName2 = namePrefix ? `${accessoryName} Schedules` : 'Schedules';
|
|
1261
1264
|
const serviceType = schedule.serviceType;
|
|
@@ -1276,8 +1279,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
1276
1279
|
.onSet(async (state) => {
|
|
1277
1280
|
try {
|
|
1278
1281
|
deviceData.ScheduleEnabled = state;
|
|
1279
|
-
if (this.logInfo) this.emit('info', `Schedules: ${state ? '
|
|
1280
|
-
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, 'schedule');
|
|
1282
|
+
if (this.logInfo) this.emit('info', `Schedules: ${state ? 'Enabled' : 'Disabled'}`);
|
|
1283
|
+
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, 'schedule', scheduleData);
|
|
1281
1284
|
} catch (error) {
|
|
1282
1285
|
if (this.logWarn) this.emit('warn', `Set schedules error: ${error}`);
|
|
1283
1286
|
};
|
|
@@ -1321,10 +1324,10 @@ class DeviceAtw extends EventEmitter {
|
|
|
1321
1324
|
this.scenes.forEach((scene, i) => {
|
|
1322
1325
|
const sceneData = scenesOnServer.find(s => s.Id === scene.id);
|
|
1323
1326
|
|
|
1324
|
-
//get
|
|
1327
|
+
//get name
|
|
1325
1328
|
const name = scene.name;
|
|
1326
1329
|
|
|
1327
|
-
//get
|
|
1330
|
+
//get name prefix
|
|
1328
1331
|
const namePrefix = scene.namePrefix;
|
|
1329
1332
|
|
|
1330
1333
|
const serviceName1 = namePrefix ? `${accessoryName} ${name}` : name;
|
|
@@ -1345,7 +1348,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1345
1348
|
.onSet(async (state) => {
|
|
1346
1349
|
try {
|
|
1347
1350
|
sceneData.Enabled = state;
|
|
1348
|
-
if (this.logInfo) this.emit('info', `Scene ${name}: ${state ? '
|
|
1351
|
+
if (this.logInfo) this.emit('info', `Scene ${name}: ${state ? 'Set' : 'Unset'}`);
|
|
1349
1352
|
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, 'scene', sceneData);
|
|
1350
1353
|
} catch (error) {
|
|
1351
1354
|
if (this.logWarn) this.emit('warn', `Set scene error: ${error}`);
|
|
@@ -1375,13 +1378,13 @@ class DeviceAtw extends EventEmitter {
|
|
|
1375
1378
|
this.buttonControlServices = [];
|
|
1376
1379
|
this.buttonControlSensorServices = [];
|
|
1377
1380
|
this.buttons.lengthforEach((button, i) => {
|
|
1378
|
-
//get
|
|
1381
|
+
//get mode
|
|
1379
1382
|
const mode = button.mode;
|
|
1380
1383
|
|
|
1381
|
-
//get
|
|
1384
|
+
//get name
|
|
1382
1385
|
const name = button.name;
|
|
1383
1386
|
|
|
1384
|
-
//get
|
|
1387
|
+
//get name prefix
|
|
1385
1388
|
const namePrefix = button.namePrefix;
|
|
1386
1389
|
|
|
1387
1390
|
const serviceName1 = namePrefix ? `${accessoryName} ${name}` : name;
|
|
@@ -1536,7 +1539,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1536
1539
|
break;
|
|
1537
1540
|
};
|
|
1538
1541
|
|
|
1539
|
-
if (this.logInfo) this.emit('info',
|
|
1542
|
+
if (this.logInfo) this.emit('info', `Button ${name}: ${state ? `Enabled` : `Disabled`}`);
|
|
1540
1543
|
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, flag);
|
|
1541
1544
|
} catch (error) {
|
|
1542
1545
|
if (this.logWarn) this.emit('warn', `Set button error: ${error}`);
|
|
@@ -1572,7 +1575,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1572
1575
|
async start() {
|
|
1573
1576
|
try {
|
|
1574
1577
|
//melcloud device
|
|
1575
|
-
this.melCloudAtw = new MelCloudAtw(this.account, this.device, this.devicesFile, this.defaultTempsFile)
|
|
1578
|
+
this.melCloudAtw = new MelCloudAtw(this.account, this.device, this.devicesFile, this.defaultTempsFile, this.accountFile)
|
|
1576
1579
|
.on('deviceInfo', (modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion, supportsHotWaterTank, supportsZone2) => {
|
|
1577
1580
|
if (this.logDeviceInfo && this.displayDeviceInfo) {
|
|
1578
1581
|
this.emit('devInfo', `---- ${this.deviceTypeText}: ${this.deviceName} ----`);
|
|
@@ -1720,8 +1723,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
1720
1723
|
caseHotWaterSensor: caseHotWaterSensor,
|
|
1721
1724
|
caseZone2Sensor: caseZone2Sensor,
|
|
1722
1725
|
sensorsCount: zonesSensorsCount,
|
|
1723
|
-
useFahrenheit: this.useFahrenheit,
|
|
1724
|
-
temperatureUnit: TemperatureDisplayUnits[this.useFahrenheit],
|
|
1726
|
+
useFahrenheit: this.accountInfo.useFahrenheit ? 1 : 0,
|
|
1727
|
+
temperatureUnit: TemperatureDisplayUnits[this.accountInfo.useFahrenheit ? 1 : 0],
|
|
1725
1728
|
isConnected: isConnected,
|
|
1726
1729
|
isInError: isInError,
|
|
1727
1730
|
scheduleEnabled: scheduleEnabled,
|
|
@@ -2150,7 +2153,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
2150
2153
|
this.schedules.forEach((schedule, i) => {
|
|
2151
2154
|
const scheduleData = schedulesOnServer.find(s => s.Id === schedule.id);
|
|
2152
2155
|
const characteristicType = schedule.characteristicType;
|
|
2153
|
-
schedule.state = scheduleEnabled ? scheduleData.Enabled ?? false : false;
|
|
2156
|
+
schedule.state = scheduleEnabled ? (scheduleData.Enabled ?? false) : false;
|
|
2154
2157
|
|
|
2155
2158
|
//control
|
|
2156
2159
|
if (i === 0) {
|
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.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.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
|
};
|
|
@@ -741,7 +742,7 @@ class DeviceErv extends EventEmitter {
|
|
|
741
742
|
.onSet(async (state) => {
|
|
742
743
|
try {
|
|
743
744
|
deviceData.HolidayMode.Enabled = state;
|
|
744
|
-
if (this.logInfo) this.emit('info', `Holiday mode: ${state ? '
|
|
745
|
+
if (this.logInfo) this.emit('info', `Holiday mode: ${state ? 'Enabled' : 'Disabled'}`);
|
|
745
746
|
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, 'holidaymode');
|
|
746
747
|
} catch (error) {
|
|
747
748
|
if (this.logWarn) this.emit('warn', `Set holiday mode error: ${error}`);
|
|
@@ -781,16 +782,17 @@ class DeviceErv extends EventEmitter {
|
|
|
781
782
|
this.presets.forEach((preset, i) => {
|
|
782
783
|
const presetData = presetsOnServer.find(p => p.ID === preset.id);
|
|
783
784
|
|
|
784
|
-
//get
|
|
785
|
+
//get name
|
|
785
786
|
const name = preset.name;
|
|
786
787
|
|
|
787
|
-
//get
|
|
788
|
+
//get name prefix
|
|
788
789
|
const namePrefix = preset.namePrefix;
|
|
789
790
|
|
|
790
791
|
const serviceName1 = namePrefix ? `${accessoryName} ${name}` : name;
|
|
791
792
|
const serviceType = preset.serviceType;
|
|
792
793
|
const characteristicType = preset.characteristicType;
|
|
793
794
|
|
|
795
|
+
//control
|
|
794
796
|
if (preset.displayType > 3) {
|
|
795
797
|
if (this.logDebug) this.emit('debug', `Prepare preset control ${name} service`);
|
|
796
798
|
const presetControlService = new Service.Switch(serviceName1, `presetControlService${deviceId} ${i}`);
|
|
@@ -823,7 +825,7 @@ class DeviceErv extends EventEmitter {
|
|
|
823
825
|
break;
|
|
824
826
|
};
|
|
825
827
|
|
|
826
|
-
if (this.logInfo) this.emit('info', `Preset ${name}: ${state ? 'Set
|
|
828
|
+
if (this.logInfo) this.emit('info', `Preset ${name}: ${state ? 'Set' : 'Unset'}`);
|
|
827
829
|
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.Presets);
|
|
828
830
|
} catch (error) {
|
|
829
831
|
if (this.logWarn) this.emit('warn', `Set preset error: ${error}`);
|
|
@@ -853,13 +855,14 @@ class DeviceErv extends EventEmitter {
|
|
|
853
855
|
if (this.logDebug) this.emit('debug', `Prepare schedules services`);
|
|
854
856
|
this.scheduleSensorServices = [];
|
|
855
857
|
this.schedules.forEach((schedule, i) => {
|
|
856
|
-
|
|
858
|
+
const scheduleData = schedulesOnServer.find(s => s.Id === schedule.id);
|
|
859
|
+
|
|
860
|
+
//get name
|
|
857
861
|
const name = schedule.name;
|
|
858
862
|
|
|
859
|
-
//get
|
|
863
|
+
//get name prefix
|
|
860
864
|
const namePrefix = schedule.namePrefix;
|
|
861
865
|
|
|
862
|
-
//control sensor
|
|
863
866
|
const serviceName1 = namePrefix ? `${accessoryName} ${name}` : name;
|
|
864
867
|
const serviceName2 = namePrefix ? `${accessoryName} Schedules` : 'Schedules';
|
|
865
868
|
const serviceType = schedule.serviceType;
|
|
@@ -880,8 +883,8 @@ class DeviceErv extends EventEmitter {
|
|
|
880
883
|
.onSet(async (state) => {
|
|
881
884
|
try {
|
|
882
885
|
deviceData.ScheduleEnabled = state;
|
|
883
|
-
if (this.logInfo) this.emit('info', `Schedules: ${state ? '
|
|
884
|
-
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, 'schedule');
|
|
886
|
+
if (this.logInfo) this.emit('info', `Schedules: ${state ? 'Enabled' : 'Disabled'}`);
|
|
887
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, 'schedule', scheduleData);
|
|
885
888
|
} catch (error) {
|
|
886
889
|
if (this.logWarn) this.emit('warn', `Set schedule serror: ${error}`);
|
|
887
890
|
};
|
|
@@ -925,10 +928,10 @@ class DeviceErv extends EventEmitter {
|
|
|
925
928
|
this.scenes.forEach((scene, i) => {
|
|
926
929
|
const sceneData = scenesOnServer.find(s => s.Id === scene.id);
|
|
927
930
|
|
|
928
|
-
//get
|
|
931
|
+
//get name
|
|
929
932
|
const name = scene.name;
|
|
930
933
|
|
|
931
|
-
//get
|
|
934
|
+
//get name prefix
|
|
932
935
|
const namePrefix = scene.namePrefix;
|
|
933
936
|
|
|
934
937
|
const serviceName1 = namePrefix ? `${accessoryName} ${name}` : name;
|
|
@@ -949,7 +952,7 @@ class DeviceErv extends EventEmitter {
|
|
|
949
952
|
.onSet(async (state) => {
|
|
950
953
|
try {
|
|
951
954
|
sceneData.Enabled = state;
|
|
952
|
-
if (this.logInfo) this.emit('info', `Scene ${name}: ${state ? '
|
|
955
|
+
if (this.logInfo) this.emit('info', `Scene ${name}: ${state ? 'Set' : 'Unset'}`);
|
|
953
956
|
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, 'scene', sceneData);
|
|
954
957
|
} catch (error) {
|
|
955
958
|
if (this.logWarn) this.emit('warn', `Set scene error: ${error}`);
|
|
@@ -979,13 +982,13 @@ class DeviceErv extends EventEmitter {
|
|
|
979
982
|
this.buttonControlServices = [];
|
|
980
983
|
this.buttonControlSensorServices = [];
|
|
981
984
|
this.buttons.forEach((button, i) => {
|
|
982
|
-
//get
|
|
985
|
+
//get mode
|
|
983
986
|
const mode = button.mode;
|
|
984
987
|
|
|
985
|
-
//get
|
|
988
|
+
//get name
|
|
986
989
|
const name = button.name;
|
|
987
990
|
|
|
988
|
-
//get
|
|
991
|
+
//get name prefix
|
|
989
992
|
const namePrefix = button.namePrefix;
|
|
990
993
|
|
|
991
994
|
const serviceName1 = namePrefix ? `${accessoryName} ${name}` : name;
|
|
@@ -1082,7 +1085,7 @@ class DeviceErv extends EventEmitter {
|
|
|
1082
1085
|
break;
|
|
1083
1086
|
};
|
|
1084
1087
|
|
|
1085
|
-
if (this.logInfo) this.emit('info',
|
|
1088
|
+
if (this.logInfo) this.emit('info', `Button ${name}: ${state ? `Enabled` : `Disabled`}`);
|
|
1086
1089
|
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, flag);
|
|
1087
1090
|
} catch (error) {
|
|
1088
1091
|
if (this.logWarn) this.emit('warn', `Set button error: ${error}`);
|
|
@@ -1117,7 +1120,7 @@ class DeviceErv extends EventEmitter {
|
|
|
1117
1120
|
async start() {
|
|
1118
1121
|
try {
|
|
1119
1122
|
//melcloud device
|
|
1120
|
-
this.melCloudErv = new MelCloudErv(this.account, this.device, this.devicesFile, this.defaultTempsFile)
|
|
1123
|
+
this.melCloudErv = new MelCloudErv(this.account, this.device, this.devicesFile, this.defaultTempsFile, this.accountFile)
|
|
1121
1124
|
.on('deviceInfo', (modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
|
|
1122
1125
|
if (this.logDeviceInfo && this.displayDeviceInfo) {
|
|
1123
1126
|
this.emit('devInfo', `---- ${this.deviceTypeText}: ${this.deviceName} ----`);
|
|
@@ -1251,8 +1254,8 @@ class DeviceErv extends EventEmitter {
|
|
|
1251
1254
|
temperatureIncrement: maxTempHeat,
|
|
1252
1255
|
minTempCoolDry: minTempCoolDry,
|
|
1253
1256
|
maxTempCoolDry: maxTempCoolDry,
|
|
1254
|
-
useFahrenheit: this.useFahrenheit,
|
|
1255
|
-
temperatureUnit: TemperatureDisplayUnits[this.useFahrenheit],
|
|
1257
|
+
useFahrenheit: this.accountInfo.useFahrenheit ? 1 : 0,
|
|
1258
|
+
temperatureUnit: TemperatureDisplayUnits[this.accountInfo.useFahrenheit ? 1 : 0],
|
|
1256
1259
|
isConnected: isConnected,
|
|
1257
1260
|
isInError: isInError,
|
|
1258
1261
|
scheduleEnabled: scheduleEnabled,
|
|
@@ -1435,7 +1438,7 @@ class DeviceErv extends EventEmitter {
|
|
|
1435
1438
|
this.schedules.forEach((schedule, i) => {
|
|
1436
1439
|
const scheduleData = schedulesOnServer.find(s => s.Id === schedule.id);
|
|
1437
1440
|
const characteristicType = schedule.characteristicType;
|
|
1438
|
-
schedule.state = scheduleEnabled ? scheduleData.Enabled ?? false : false;
|
|
1441
|
+
schedule.state = scheduleEnabled ? (scheduleData.Enabled ?? false) : false;
|
|
1439
1442
|
|
|
1440
1443
|
//control
|
|
1441
1444
|
if (i === 0) {
|
package/src/melcloud.js
CHANGED
|
@@ -52,7 +52,6 @@ class MelCloud extends EventEmitter {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
// MELCloud
|
|
56
55
|
async checkDevicesList() {
|
|
57
56
|
try {
|
|
58
57
|
const devicesList = { State: false, Info: null, Devices: [], Scenes: [] }
|
|
@@ -126,7 +125,7 @@ class MelCloud extends EventEmitter {
|
|
|
126
125
|
if (this.logDebug) this.emit('debug', `Connecting to MELCloud`);
|
|
127
126
|
|
|
128
127
|
try {
|
|
129
|
-
const accountInfo = { State: false, Info: '',
|
|
128
|
+
const accountInfo = { State: false, Info: '', Account: null, UseFahrenheit: false }
|
|
130
129
|
|
|
131
130
|
const payload = {
|
|
132
131
|
Email: this.user,
|
|
@@ -176,7 +175,8 @@ class MelCloud extends EventEmitter {
|
|
|
176
175
|
|
|
177
176
|
accountInfo.State = true;
|
|
178
177
|
accountInfo.Info = 'Connect to MELCloud Success';
|
|
179
|
-
accountInfo.
|
|
178
|
+
accountInfo.UseFahrenheit = loginData.UseFahrenheit;
|
|
179
|
+
accountInfo.Account = account;
|
|
180
180
|
await this.functions.saveData(this.accountFile, accountInfo);
|
|
181
181
|
|
|
182
182
|
return accountInfo
|
|
@@ -184,17 +184,6 @@ class MelCloud extends EventEmitter {
|
|
|
184
184
|
throw new Error(`Connect error: ${error.message}`);
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
|
|
188
|
-
async send(accountInfo) {
|
|
189
|
-
try {
|
|
190
|
-
const payload = { data: accountInfo.LoginData };
|
|
191
|
-
await this.axiosInstance(ApiUrls.UpdateApplicationOptions, { method: 'POST', data: payload });
|
|
192
|
-
await this.functions.saveData(this.accountFile, accountInfo);
|
|
193
|
-
return true;
|
|
194
|
-
} catch (error) {
|
|
195
|
-
throw new Error(`Send data error: ${error.message}`);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
187
|
}
|
|
199
188
|
|
|
200
189
|
export default MelCloud;
|