homebridge-melcloud-control 3.1.4-beta.2 → 3.1.4-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/index.js +5 -8
- package/package.json +1 -1
- package/src/deviceata.js +6 -5
- package/src/deviceatw.js +3 -2
- package/src/deviceerv.js +3 -2
- package/src/melcloud.js +5 -12
- package/src/melcloudata.js +6 -5
- package/src/melcloudatw.js +6 -5
- package/src/melclouderv.js +6 -5
package/index.js
CHANGED
|
@@ -57,7 +57,7 @@ class MelCloudPlatform {
|
|
|
57
57
|
const prefDir = path.join(api.user.storagePath(), 'melcloud');
|
|
58
58
|
const accountInfoFile = `${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, accountInfoFile, buildingsFile,
|
|
77
|
+
const melCloud = new MelCloud(user, passwd, language, accountInfoFile, buildingsFile, devicesFile, enableDebugMode, false);
|
|
78
78
|
melCloud.on('success', (message) => {
|
|
79
79
|
log.success(`Account ${accountName}, ${message}`);
|
|
80
80
|
})
|
|
@@ -114,8 +114,7 @@ class MelCloudPlatform {
|
|
|
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, accountInfoFile, devicesFile, deviceRefreshInterval)
|
|
119
118
|
airConditioner.on('publishAccessory', (accessory) => {
|
|
120
119
|
|
|
121
120
|
//publish device
|
|
@@ -153,8 +152,7 @@ class MelCloudPlatform {
|
|
|
153
152
|
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, accountInfoFile, devicesFile, deviceRefreshInterval)
|
|
158
156
|
heatPump.on('publishAccessory', (accessory) => {
|
|
159
157
|
|
|
160
158
|
//publish device
|
|
@@ -192,8 +190,7 @@ class MelCloudPlatform {
|
|
|
192
190
|
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, accountInfoFile, devicesFile, deviceRefreshInterval)
|
|
197
194
|
energyRecoveryVentilation.on('publishAccessory', (accessory) => {
|
|
198
195
|
|
|
199
196
|
//publish device
|
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.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
|
@@ -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, accountInfoFile,
|
|
10
|
+
constructor(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, accountInfoFile, devicesFile, refreshInterval) {
|
|
11
11
|
super();
|
|
12
12
|
|
|
13
13
|
Accessory = api.platformAccessory;
|
|
@@ -95,7 +95,8 @@ class DeviceAta extends EventEmitter {
|
|
|
95
95
|
this.melCloudAta = new MelCloudAta({
|
|
96
96
|
contextKey: contextKey,
|
|
97
97
|
accountInfoFile: accountInfoFile,
|
|
98
|
-
|
|
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, accountInfoFile,
|
|
10
|
+
constructor(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, accountInfoFile, devicesFile, refreshInterval) {
|
|
11
11
|
super();
|
|
12
12
|
|
|
13
13
|
Accessory = api.platformAccessory;
|
|
@@ -91,7 +91,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
91
91
|
this.melCloudAtw = new MelCloudAtw({
|
|
92
92
|
contextKey: contextKey,
|
|
93
93
|
accountInfoFile: accountInfoFile,
|
|
94
|
-
|
|
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, accountInfoFile,
|
|
10
|
+
constructor(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, accountInfoFile, devicesFile, refreshInterval) {
|
|
11
11
|
super();
|
|
12
12
|
|
|
13
13
|
Accessory = api.platformAccessory;
|
|
@@ -94,7 +94,8 @@ class DeviceErv extends EventEmitter {
|
|
|
94
94
|
this.melCloudErv = new MelCloudErv({
|
|
95
95
|
contextKey: contextKey,
|
|
96
96
|
accountInfoFile: accountInfoFile,
|
|
97
|
-
|
|
97
|
+
devicesFile: devicesFile,
|
|
98
|
+
deviceId: deviceId,
|
|
98
99
|
debugLog: account.enableDebugMode,
|
|
99
100
|
refreshInterval: refreshInterval
|
|
100
101
|
});
|
package/src/melcloud.js
CHANGED
|
@@ -8,11 +8,11 @@ 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, accountInfoFile, buildingsFile,
|
|
11
|
+
constructor(user, passwd, language, accountInfoFile, buildingsFile, devicesFile, enableDebugMode, requestConfig) {
|
|
12
12
|
super();
|
|
13
13
|
this.accountInfoFile = accountInfoFile;
|
|
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 = '';
|
|
@@ -154,16 +154,9 @@ class MelCloud extends EventEmitter {
|
|
|
154
154
|
}
|
|
155
155
|
const debug3 = this.enableDebugMode ? this.emit('debug', `Found: ${devicesCount} devices.`) : false;
|
|
156
156
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const deviceName = deviceInfo.DeviceName;
|
|
161
|
-
|
|
162
|
-
//save every device info to the file
|
|
163
|
-
const deviceFile = `${this.deviceFile}${deviceId}`;
|
|
164
|
-
await this.saveData(deviceFile, deviceInfo);
|
|
165
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Device: ${deviceName} info saved.`) : false;
|
|
166
|
-
};
|
|
157
|
+
//save buildings to the file
|
|
158
|
+
await this.saveData(this.devicesFile, devices);
|
|
159
|
+
const debug4 = this.enableDebugMode ? this.emit('debug', `Devices list saved.`) : false;
|
|
167
160
|
|
|
168
161
|
return devices;
|
|
169
162
|
} catch (error) {
|
package/src/melcloudata.js
CHANGED
|
@@ -12,7 +12,8 @@ class MelCloudAta extends EventEmitter {
|
|
|
12
12
|
super();
|
|
13
13
|
const contextKey = config.contextKey;
|
|
14
14
|
const accountInfoFile = config.accountInfoFile;
|
|
15
|
-
const
|
|
15
|
+
const devicesFile = config.devicesFile;
|
|
16
|
+
const deviceId = config.deviceId;
|
|
16
17
|
const debugLog = config.debugLog;
|
|
17
18
|
const refreshInterval = config.refreshInterval;
|
|
18
19
|
|
|
@@ -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 devicesData = await this.readData(devicesFile);
|
|
60
61
|
const debug1 = debugLog ? this.emit('debug', `Device Info: ${JSON.stringify(deviceData, 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;
|
|
@@ -323,7 +324,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
323
324
|
|
|
324
325
|
//device state
|
|
325
326
|
const deviceState = {
|
|
326
|
-
DeviceId: deviceId,
|
|
327
|
+
DeviceId: deviceId.toString(),
|
|
327
328
|
EffectiveFlags: effectiveFlags,
|
|
328
329
|
RoomTemperature: roomTemperature,
|
|
329
330
|
SetTemperature: setTemperature,
|
|
@@ -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
|
@@ -12,7 +12,8 @@ class MelCloudAtw extends EventEmitter {
|
|
|
12
12
|
super();
|
|
13
13
|
const contextKey = config.contextKey;
|
|
14
14
|
const accountInfoFile = config.accountInfoFile;
|
|
15
|
-
const
|
|
15
|
+
const devicesFile = config.devicesFile;
|
|
16
|
+
const deviceId = config.deviceId;
|
|
16
17
|
const debugLog = config.debugLog;
|
|
17
18
|
const refreshInterval = config.refreshInterval;
|
|
18
19
|
|
|
@@ -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;
|
|
@@ -385,7 +386,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
385
386
|
|
|
386
387
|
//device state
|
|
387
388
|
const deviceState = {
|
|
388
|
-
DeviceId: deviceId,
|
|
389
|
+
DeviceId: deviceId.toString(),
|
|
389
390
|
EffectiveFlags: effectiveFlags,
|
|
390
391
|
SetTemperatureZone1: setTemperatureZone1,
|
|
391
392
|
SetTemperatureZone2: setTemperatureZone2,
|
package/src/melclouderv.js
CHANGED
|
@@ -12,7 +12,8 @@ class MelCloudErv extends EventEmitter {
|
|
|
12
12
|
super();
|
|
13
13
|
const contextKey = config.contextKey;
|
|
14
14
|
const accountInfoFile = config.accountInfoFile;
|
|
15
|
-
const
|
|
15
|
+
const devicesFile = config.devicesFile;
|
|
16
|
+
const deviceId = config.deviceId;
|
|
16
17
|
const debugLog = config.debugLog;
|
|
17
18
|
const refreshInterval = config.refreshInterval;
|
|
18
19
|
|
|
@@ -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;
|
|
@@ -312,7 +313,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
312
313
|
|
|
313
314
|
//device state
|
|
314
315
|
const deviceState = {
|
|
315
|
-
DeviceId: deviceId,
|
|
316
|
+
DeviceId: deviceId.toString(),
|
|
316
317
|
EffectiveFlags: effectiveFlags,
|
|
317
318
|
RoomTemperature: roomTemperature,
|
|
318
319
|
SupplyTemperature: supplyTemperature,
|