homebridge-melcloud-control 3.1.4-beta.1 → 3.1.4-beta.10
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/homebridge-ui/public/index.html +1 -1
- package/index.js +11 -14
- package/package.json +2 -2
- package/src/deviceata.js +7 -6
- package/src/deviceatw.js +4 -3
- package/src/deviceerv.js +4 -3
- package/src/melcloud.js +10 -15
- package/src/melcloudata.js +8 -7
- package/src/melcloudatw.js +7 -6
- package/src/melclouderv.js +7 -6
|
@@ -173,7 +173,7 @@
|
|
|
173
173
|
|
|
174
174
|
//get devices from melcloud by type
|
|
175
175
|
for (const deviceInMelcloud of devicesInMelCloud) {
|
|
176
|
-
const deviceType =
|
|
176
|
+
const deviceType = devicesInMelCloud.Type;
|
|
177
177
|
const pusDeviceTypeAta = deviceType === 0 ? devicesByTypeInMelCloud.ata.push(deviceInMelcloud) : false;
|
|
178
178
|
const pusDeviceTypeAtw = deviceType === 1 ? devicesByTypeInMelCloud.atw.push(deviceInMelcloud) : false;
|
|
179
179
|
const pusDeviceTypeErv = deviceType === 3 ? devicesByTypeInMelCloud.erv.push(deviceInMelcloud) : false;
|
package/index.js
CHANGED
|
@@ -55,9 +55,9 @@ class MelCloudPlatform {
|
|
|
55
55
|
|
|
56
56
|
//define directory and file paths
|
|
57
57
|
const prefDir = path.join(api.user.storagePath(), 'melcloud');
|
|
58
|
-
const
|
|
58
|
+
const accountFile = `${prefDir}/${accountName}_Account`;
|
|
59
59
|
const buildingsFile = `${prefDir}/${accountName}_Buildings`;
|
|
60
|
-
const
|
|
60
|
+
const devicesFile = `${prefDir}/${accountName}_Devices`;
|
|
61
61
|
|
|
62
62
|
//create directory if it doesn't exist
|
|
63
63
|
try {
|
|
@@ -74,7 +74,7 @@ class MelCloudPlatform {
|
|
|
74
74
|
|
|
75
75
|
try {
|
|
76
76
|
//melcloud account
|
|
77
|
-
const melCloud = new MelCloud(user, passwd, language,
|
|
77
|
+
const melCloud = new MelCloud(user, passwd, language, accountFile, buildingsFile, devicesFile, enableDebugMode, false);
|
|
78
78
|
melCloud.on('success', (message) => {
|
|
79
79
|
log.success(`Account ${accountName}, ${message}`);
|
|
80
80
|
})
|
|
@@ -106,16 +106,15 @@ class MelCloudPlatform {
|
|
|
106
106
|
//Air Conditioner 0
|
|
107
107
|
for (const device of account.ataDevices) {
|
|
108
108
|
//chack device from config exist on melcloud
|
|
109
|
-
const
|
|
109
|
+
const deviceId = device.id;
|
|
110
|
+
const deviceExistInMelCloud = devices.some(dev => dev.DeviceID === deviceId);
|
|
110
111
|
if (!deviceExistInMelCloud || device.displayMode === 0) {
|
|
111
112
|
continue;
|
|
112
113
|
};
|
|
113
114
|
|
|
114
|
-
const deviceId = device.id.toString();
|
|
115
115
|
const deviceName = device.name;
|
|
116
116
|
const deviceTypeText = device.typeString;
|
|
117
|
-
const
|
|
118
|
-
const airConditioner = new DeviceAta(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, accountInfoFile, deviceInfoFile, deviceRefreshInterval)
|
|
117
|
+
const airConditioner = new DeviceAta(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, accountFile, devicesFile, deviceRefreshInterval)
|
|
119
118
|
airConditioner.on('publishAccessory', (accessory) => {
|
|
120
119
|
|
|
121
120
|
//publish device
|
|
@@ -145,16 +144,15 @@ class MelCloudPlatform {
|
|
|
145
144
|
//Heat Pump 1
|
|
146
145
|
for (const device of account.atwDevices) {
|
|
147
146
|
//chack device from config exist on melcloud
|
|
147
|
+
const deviceId = device.id;
|
|
148
148
|
const deviceExistInMelCloud = devices.some(dev => dev.DeviceID === device.id);
|
|
149
149
|
if (!deviceExistInMelCloud || device.displayMode === 0) {
|
|
150
150
|
continue;
|
|
151
151
|
};
|
|
152
152
|
|
|
153
|
-
const deviceId = device.id.toString();
|
|
154
153
|
const deviceName = device.name;
|
|
155
154
|
const deviceTypeText = device.typeString;
|
|
156
|
-
const
|
|
157
|
-
const heatPump = new DeviceAtw(api, account, melCloud, device, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, accountInfoFile, deviceInfoFile, deviceRefreshInterval)
|
|
155
|
+
const heatPump = new DeviceAtw(api, account, melCloud, device, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, accountFile, devicesFile, deviceRefreshInterval)
|
|
158
156
|
heatPump.on('publishAccessory', (accessory) => {
|
|
159
157
|
|
|
160
158
|
//publish device
|
|
@@ -184,16 +182,15 @@ class MelCloudPlatform {
|
|
|
184
182
|
//Energy Recovery Ventilation 3
|
|
185
183
|
for (const device of account.ervDevices) {
|
|
186
184
|
//chack device from config exist on melcloud
|
|
185
|
+
const deviceId = device.id;
|
|
187
186
|
const deviceExistInMelCloud = devices.some(dev => dev.DeviceID === device.id);
|
|
188
187
|
if (!deviceExistInMelCloud || device.displayMode === 0) {
|
|
189
188
|
continue;
|
|
190
189
|
};
|
|
191
190
|
|
|
192
|
-
const deviceId = device.id.toString();
|
|
193
191
|
const deviceName = device.name;
|
|
194
192
|
const deviceTypeText = device.typeString;
|
|
195
|
-
const
|
|
196
|
-
const energyRecoveryVentilation = new DeviceErv(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, accountInfoFile, deviceInfoFile, deviceRefreshInterval)
|
|
193
|
+
const energyRecoveryVentilation = new DeviceErv(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, accountFile, devicesFile, deviceRefreshInterval)
|
|
197
194
|
energyRecoveryVentilation.on('publishAccessory', (accessory) => {
|
|
198
195
|
|
|
199
196
|
//publish device
|
|
@@ -220,7 +217,7 @@ class MelCloudPlatform {
|
|
|
220
217
|
});
|
|
221
218
|
};
|
|
222
219
|
} catch (error) {
|
|
223
|
-
log.error(`Account: ${accountName},
|
|
220
|
+
log.error(`Account: ${accountName}, Did finish launching error: ${error.message ?? error}`);
|
|
224
221
|
}
|
|
225
222
|
};
|
|
226
223
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "3.1.4-beta.
|
|
4
|
+
"version": "3.1.4-beta.10",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"engines": {
|
|
31
31
|
"homebridge": "^1.6.0 || ^2.0.0-beta.0",
|
|
32
|
-
"node": "^18.20.4 || ^20.15.1
|
|
32
|
+
"node": "^18.20.4 || ^20.15.1 || ^22.7.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@homebridge/plugin-ui-utils": "^1.0.3",
|
package/src/deviceata.js
CHANGED
|
@@ -7,7 +7,7 @@ const CONSTANTS = require('./constants.json');
|
|
|
7
7
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
8
8
|
|
|
9
9
|
class DeviceAta extends EventEmitter {
|
|
10
|
-
constructor(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText,
|
|
10
|
+
constructor(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, accountFile, devicesFile, refreshInterval) {
|
|
11
11
|
super();
|
|
12
12
|
|
|
13
13
|
Accessory = api.platformAccessory;
|
|
@@ -94,8 +94,9 @@ class DeviceAta extends EventEmitter {
|
|
|
94
94
|
//melcloud device
|
|
95
95
|
this.melCloudAta = new MelCloudAta({
|
|
96
96
|
contextKey: contextKey,
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
accountFile: accountFile,
|
|
98
|
+
devicesFile: devicesFile,
|
|
99
|
+
deviceId: deviceId,
|
|
99
100
|
debugLog: account.enableDebugMode,
|
|
100
101
|
refreshInterval: refreshInterval
|
|
101
102
|
});
|
|
@@ -192,7 +193,6 @@ class DeviceAta extends EventEmitter {
|
|
|
192
193
|
.on('deviceState', async (deviceData, deviceState, useFahrenheit) => {
|
|
193
194
|
//device info
|
|
194
195
|
const displayMode = this.displayMode;
|
|
195
|
-
const inStandbyMode = deviceData.Device.InStandbyMode;
|
|
196
196
|
const hasAutomaticFanSpeed = deviceData.Device.HasAutomaticFanSpeed ?? false;
|
|
197
197
|
const airDirectionFunction = deviceData.Device.AirDirectionFunction ?? false;
|
|
198
198
|
const hasOutdoorTemperature = deviceData.Device.HasOutdoorTemperature ?? false;
|
|
@@ -213,6 +213,9 @@ class DeviceAta extends EventEmitter {
|
|
|
213
213
|
const presetsOnServer = deviceData.Presets ?? [];
|
|
214
214
|
|
|
215
215
|
//device state
|
|
216
|
+
const power = deviceState.Power;
|
|
217
|
+
const offline = deviceState.Offline;
|
|
218
|
+
const inStandbyMode = deviceState.InStandbyMode;
|
|
216
219
|
const roomTemperature = deviceState.RoomTemperature;
|
|
217
220
|
const setTemperature = deviceState.SetTemperature;
|
|
218
221
|
const setFanSpeed = deviceState.SetFanSpeed;
|
|
@@ -224,8 +227,6 @@ class DeviceAta extends EventEmitter {
|
|
|
224
227
|
const prohibitSetTemperature = deviceState.ProhibitSetTemperature;
|
|
225
228
|
const prohibitOperationMode = deviceState.ProhibitOperationMode;
|
|
226
229
|
const prohibitPower = deviceState.ProhibitPower;
|
|
227
|
-
const power = deviceState.Power;
|
|
228
|
-
const offline = deviceState.Offline;
|
|
229
230
|
|
|
230
231
|
//accessory
|
|
231
232
|
this.accessory.presetsOnServer = presetsOnServer;
|
package/src/deviceatw.js
CHANGED
|
@@ -7,7 +7,7 @@ const CONSTANTS = require('./constants.json');
|
|
|
7
7
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
8
8
|
|
|
9
9
|
class DeviceAtw extends EventEmitter {
|
|
10
|
-
constructor(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText,
|
|
10
|
+
constructor(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, accountFile, devicesFile, refreshInterval) {
|
|
11
11
|
super();
|
|
12
12
|
|
|
13
13
|
Accessory = api.platformAccessory;
|
|
@@ -90,8 +90,9 @@ class DeviceAtw extends EventEmitter {
|
|
|
90
90
|
//melcloud device
|
|
91
91
|
this.melCloudAtw = new MelCloudAtw({
|
|
92
92
|
contextKey: contextKey,
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
accountFile: accountFile,
|
|
94
|
+
devicesFile: devicesFile,
|
|
95
|
+
deviceId: deviceId,
|
|
95
96
|
debugLog: account.enableDebugMode,
|
|
96
97
|
refreshInterval: refreshInterval
|
|
97
98
|
});
|
package/src/deviceerv.js
CHANGED
|
@@ -7,7 +7,7 @@ const CONSTANTS = require('./constants.json');
|
|
|
7
7
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
8
8
|
|
|
9
9
|
class DeviceErv extends EventEmitter {
|
|
10
|
-
constructor(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText,
|
|
10
|
+
constructor(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, accountFile, devicesFile, refreshInterval) {
|
|
11
11
|
super();
|
|
12
12
|
|
|
13
13
|
Accessory = api.platformAccessory;
|
|
@@ -93,8 +93,9 @@ class DeviceErv extends EventEmitter {
|
|
|
93
93
|
//melcloud device
|
|
94
94
|
this.melCloudErv = new MelCloudErv({
|
|
95
95
|
contextKey: contextKey,
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
accountFile: accountFile,
|
|
97
|
+
devicesFile: devicesFile,
|
|
98
|
+
deviceId: deviceId,
|
|
98
99
|
debugLog: account.enableDebugMode,
|
|
99
100
|
refreshInterval: refreshInterval
|
|
100
101
|
});
|
package/src/melcloud.js
CHANGED
|
@@ -8,14 +8,15 @@ const ImpulseGenerator = require('./impulsegenerator.js');
|
|
|
8
8
|
const CONSTANTS = require('./constants.json');
|
|
9
9
|
|
|
10
10
|
class MelCloud extends EventEmitter {
|
|
11
|
-
constructor(user, passwd, language,
|
|
11
|
+
constructor(user, passwd, language, accountFile, buildingsFile, devicesFile, enableDebugMode, requestConfig) {
|
|
12
12
|
super();
|
|
13
|
-
this.
|
|
13
|
+
this.accountFile = accountFile;
|
|
14
14
|
this.buildingsFile = buildingsFile;
|
|
15
|
-
this.
|
|
15
|
+
this.devicesFile = devicesFile;
|
|
16
16
|
this.enableDebugMode = enableDebugMode;
|
|
17
17
|
this.requestConfig = requestConfig;
|
|
18
18
|
this.contextKey = '';
|
|
19
|
+
this.useFahrenheit = 0;
|
|
19
20
|
this.devicesId = [];
|
|
20
21
|
|
|
21
22
|
this.options = {
|
|
@@ -62,6 +63,7 @@ class MelCloud extends EventEmitter {
|
|
|
62
63
|
const account = accountData.data;
|
|
63
64
|
const accountInfo = account.LoginData;
|
|
64
65
|
const contextKey = accountInfo.ContextKey;
|
|
66
|
+
this.useFahrenheit = accountInfo.UseFahrenheit
|
|
65
67
|
this.contextKey = contextKey;
|
|
66
68
|
|
|
67
69
|
//remove sensitive data
|
|
@@ -82,7 +84,7 @@ class MelCloud extends EventEmitter {
|
|
|
82
84
|
};
|
|
83
85
|
|
|
84
86
|
//save melcloud info to the file
|
|
85
|
-
await this.saveData(this.
|
|
87
|
+
await this.saveData(this.accountFile, accountInfo);
|
|
86
88
|
|
|
87
89
|
//emit connect success
|
|
88
90
|
this.emit('success', `Connect to MELCloud Success.`)
|
|
@@ -144,6 +146,7 @@ class MelCloud extends EventEmitter {
|
|
|
144
146
|
];
|
|
145
147
|
|
|
146
148
|
//add all devices to the devices array
|
|
149
|
+
devices.useFahrenheit = this.useFahrenheit;
|
|
147
150
|
devices.push(...allDevices);
|
|
148
151
|
}
|
|
149
152
|
|
|
@@ -152,18 +155,10 @@ class MelCloud extends EventEmitter {
|
|
|
152
155
|
this.emit('warn', `No devices found.`);
|
|
153
156
|
return;
|
|
154
157
|
}
|
|
155
|
-
const debug3 = this.enableDebugMode ? this.emit('debug', `Found: ${devicesCount} devices.`) : false;
|
|
156
|
-
|
|
157
|
-
//get device info fom devices
|
|
158
|
-
for (const deviceInfo of devices) {
|
|
159
|
-
const deviceId = deviceInfo.DeviceID
|
|
160
|
-
const deviceName = deviceInfo.DeviceName;
|
|
161
158
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Device: ${deviceName} info saved.`) : false;
|
|
166
|
-
};
|
|
159
|
+
//save buildings to the file
|
|
160
|
+
await this.saveData(this.devicesFile, devices);
|
|
161
|
+
const debug3 = this.enableDebugMode ? this.emit('debug', `${devicesCount} devices saved.`) : false;
|
|
167
162
|
|
|
168
163
|
return devices;
|
|
169
164
|
} catch (error) {
|
package/src/melcloudata.js
CHANGED
|
@@ -11,8 +11,9 @@ class MelCloudAta extends EventEmitter {
|
|
|
11
11
|
constructor(config) {
|
|
12
12
|
super();
|
|
13
13
|
const contextKey = config.contextKey;
|
|
14
|
-
const
|
|
15
|
-
const
|
|
14
|
+
const accountFile = config.accountFile;
|
|
15
|
+
const devicesFile = config.devicesFile;
|
|
16
|
+
const deviceId = config.deviceId;
|
|
16
17
|
const debugLog = config.debugLog;
|
|
17
18
|
const refreshInterval = config.refreshInterval;
|
|
18
19
|
|
|
@@ -39,7 +40,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
39
40
|
impulseGenerator.on('checkDevice', async () => {
|
|
40
41
|
try {
|
|
41
42
|
//read account info from file
|
|
42
|
-
const accountInfo = await this.readData(
|
|
43
|
+
const accountInfo = await this.readData(accountFile);
|
|
43
44
|
|
|
44
45
|
//remove sensitive data
|
|
45
46
|
const debugData = {
|
|
@@ -56,8 +57,9 @@ class MelCloudAta extends EventEmitter {
|
|
|
56
57
|
this.useFahrenheit = useFahrenheit;
|
|
57
58
|
|
|
58
59
|
//read device info from file
|
|
59
|
-
const
|
|
60
|
-
const debug1 = debugLog ? this.emit('debug', `Device Info: ${JSON.stringify(
|
|
60
|
+
const devicesData = await this.readData(devicesFile);
|
|
61
|
+
const debug1 = debugLog ? this.emit('debug', `Device Info: ${JSON.stringify(devicesData, null, 2)}`) : false;
|
|
62
|
+
const deviceData = devicesData.find((device) => device.DeviceID === deviceId);
|
|
61
63
|
|
|
62
64
|
if (!deviceData) {
|
|
63
65
|
this.emit('warn', `Device data not found.`);
|
|
@@ -65,7 +67,6 @@ class MelCloudAta extends EventEmitter {
|
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
//device info
|
|
68
|
-
const deviceId = deviceData.DeviceID.toString();
|
|
69
70
|
const deviceName = deviceData.DeviceName;
|
|
70
71
|
const buildingId = deviceData.BuildingID;
|
|
71
72
|
const buildingName = deviceData.BuildingName;
|
|
@@ -413,7 +414,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
413
414
|
|
|
414
415
|
await this.axiosInstancePost(CONSTANTS.ApiUrls.SetAta, options);
|
|
415
416
|
this.emit('deviceState', this.deviceData, deviceState, this.useFahrenheit);
|
|
416
|
-
return true
|
|
417
|
+
return true;
|
|
417
418
|
} catch (error) {
|
|
418
419
|
throw new Error(error.message ?? error);
|
|
419
420
|
};
|
package/src/melcloudatw.js
CHANGED
|
@@ -11,8 +11,9 @@ class MelCloudAtw extends EventEmitter {
|
|
|
11
11
|
constructor(config) {
|
|
12
12
|
super();
|
|
13
13
|
const contextKey = config.contextKey;
|
|
14
|
-
const
|
|
15
|
-
const
|
|
14
|
+
const accountFile = config.accountFile;
|
|
15
|
+
const devicesFile = config.devicesFile;
|
|
16
|
+
const deviceId = config.deviceId;
|
|
16
17
|
const debugLog = config.debugLog;
|
|
17
18
|
const refreshInterval = config.refreshInterval;
|
|
18
19
|
|
|
@@ -39,7 +40,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
39
40
|
impulseGenerator.on('checkDevice', async () => {
|
|
40
41
|
try {
|
|
41
42
|
//read account info from file
|
|
42
|
-
const accountInfo = await this.readData(
|
|
43
|
+
const accountInfo = await this.readData(accountFile);
|
|
43
44
|
|
|
44
45
|
//remove sensitive data
|
|
45
46
|
const debugData = {
|
|
@@ -56,8 +57,9 @@ class MelCloudAtw extends EventEmitter {
|
|
|
56
57
|
this.useFahrenheit = useFahrenheit;
|
|
57
58
|
|
|
58
59
|
//read device info from file
|
|
59
|
-
const
|
|
60
|
-
const debug1 = debugLog ? this.emit('debug', `Device Info: ${JSON.stringify(
|
|
60
|
+
const devicesData = await this.readData(devicesFile);
|
|
61
|
+
const debug1 = debugLog ? this.emit('debug', `Device Info: ${JSON.stringify(devicesData, null, 2)}`) : false;
|
|
62
|
+
const deviceData = devicesData.find((device) => device.DeviceID === deviceId);
|
|
61
63
|
|
|
62
64
|
if (!deviceData) {
|
|
63
65
|
this.emit('warn', `Device data not found.`);
|
|
@@ -65,7 +67,6 @@ class MelCloudAtw extends EventEmitter {
|
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
//device info
|
|
68
|
-
const deviceId = deviceData.DeviceID.toString();
|
|
69
70
|
const deviceName = deviceData.DeviceName;
|
|
70
71
|
const buildingId = deviceData.BuildingID;
|
|
71
72
|
const buildingName = deviceData.BuildingName;
|
package/src/melclouderv.js
CHANGED
|
@@ -11,8 +11,9 @@ class MelCloudErv extends EventEmitter {
|
|
|
11
11
|
constructor(config) {
|
|
12
12
|
super();
|
|
13
13
|
const contextKey = config.contextKey;
|
|
14
|
-
const
|
|
15
|
-
const
|
|
14
|
+
const accountFile = config.accountFile;
|
|
15
|
+
const devicesFile = config.devicesFile;
|
|
16
|
+
const deviceId = config.deviceId;
|
|
16
17
|
const debugLog = config.debugLog;
|
|
17
18
|
const refreshInterval = config.refreshInterval;
|
|
18
19
|
|
|
@@ -39,7 +40,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
39
40
|
impulseGenerator.on('checkDevice', async () => {
|
|
40
41
|
try {
|
|
41
42
|
//read account info from file
|
|
42
|
-
const accountInfo = await this.readData(
|
|
43
|
+
const accountInfo = await this.readData(accountFile);
|
|
43
44
|
|
|
44
45
|
//remove sensitive data
|
|
45
46
|
const debugData = {
|
|
@@ -56,8 +57,9 @@ class MelCloudErv extends EventEmitter {
|
|
|
56
57
|
this.useFahrenheit = useFahrenheit;
|
|
57
58
|
|
|
58
59
|
//read device info from file
|
|
59
|
-
const
|
|
60
|
-
const debug1 = debugLog ? this.emit('debug', `Device Info: ${JSON.stringify(
|
|
60
|
+
const devicesData = await this.readData(devicesFile);
|
|
61
|
+
const debug1 = debugLog ? this.emit('debug', `Device Info: ${JSON.stringify(devicesData, null, 2)}`) : false;
|
|
62
|
+
const deviceData = devicesData.find((device) => device.DeviceID === deviceId);
|
|
61
63
|
|
|
62
64
|
if (!deviceData) {
|
|
63
65
|
this.emit('warn', `Device data not found.`);
|
|
@@ -65,7 +67,6 @@ class MelCloudErv extends EventEmitter {
|
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
//deviceData
|
|
68
|
-
const deviceId = deviceData.DeviceID.toString();
|
|
69
70
|
const deviceName = deviceData.DeviceName;
|
|
70
71
|
const buildingId = deviceData.BuildingID;
|
|
71
72
|
const buildingName = deviceData.BuildingName;
|