homebridge-melcloud-control 4.0.0-beta.192 → 4.0.0-beta.194
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 +4 -4
- package/package.json +1 -1
- package/src/deviceata.js +3 -2
- package/src/deviceatw.js +3 -2
- package/src/deviceerv.js +3 -2
- package/src/functions.js +7 -3
- package/src/melcloudata.js +19 -10
- package/src/melcloudatw.js +3 -3
- package/src/melclouderv.js +3 -3
package/index.js
CHANGED
|
@@ -80,7 +80,6 @@ class MelCloudPlatform {
|
|
|
80
80
|
const buildingsFile = `${prefDir}/${accountName}_Buildings`;
|
|
81
81
|
const devicesFile = `${prefDir}/${accountName}_Devices`;
|
|
82
82
|
|
|
83
|
-
|
|
84
83
|
//set account refresh interval
|
|
85
84
|
const refreshInterval = (account.refreshInterval ?? 120) * 1000
|
|
86
85
|
|
|
@@ -142,19 +141,20 @@ class MelCloudPlatform {
|
|
|
142
141
|
const deviceType = device.type;
|
|
143
142
|
const deviceTypeText = device.typeString;
|
|
144
143
|
const deviceRefreshInterval = (device.refreshInterval ?? 5) * 1000;
|
|
144
|
+
const defaultTempsFile = `${prefDir}/${accountName}_${device.id}_Temps`;
|
|
145
145
|
|
|
146
146
|
let configuredDevice;
|
|
147
147
|
switch (deviceType) {
|
|
148
148
|
case 0: //ATA
|
|
149
|
-
configuredDevice = new DeviceAta(api, account, device, devicesFile, useFahrenheit, restFul, mqtt);
|
|
149
|
+
configuredDevice = new DeviceAta(api, account, device, devicesFile, defaultTempsFile, useFahrenheit, restFul, mqtt);
|
|
150
150
|
break;
|
|
151
151
|
case 1: //ATW
|
|
152
|
-
configuredDevice = new DeviceAtw(api, account, device, contextKey, devicesFile, useFahrenheit, restFul, mqtt);
|
|
152
|
+
configuredDevice = new DeviceAtw(api, account, device, contextKey, devicesFile, defaultTempsFile, useFahrenheit, restFul, mqtt);
|
|
153
153
|
break;
|
|
154
154
|
case 2:
|
|
155
155
|
break;
|
|
156
156
|
case 3: //ERV
|
|
157
|
-
configuredDevice = new DeviceErv(api, account, device, contextKey, devicesFile, useFahrenheit, restFul, mqtt);
|
|
157
|
+
configuredDevice = new DeviceErv(api, account, device, contextKey, devicesFile, defaultTempsFile, useFahrenheit, restFul, mqtt);
|
|
158
158
|
break;
|
|
159
159
|
default:
|
|
160
160
|
if (logLevel.warn) log.warn(`${accountName}, ${deviceTypeText}, ${deviceName}, unknown device: ${deviceType}.`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.194",
|
|
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, ApiUrlsHome } from './constant
|
|
|
6
6
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
7
7
|
|
|
8
8
|
class DeviceAta extends EventEmitter {
|
|
9
|
-
constructor(api, account, device, devicesFile, useFahrenheit, restFul, mqtt) {
|
|
9
|
+
constructor(api, account, device, devicesFile, defaultTempsFile, useFahrenheit, restFul, mqtt) {
|
|
10
10
|
super();
|
|
11
11
|
|
|
12
12
|
Accessory = api.platformAccessory;
|
|
@@ -36,6 +36,7 @@ class DeviceAta extends EventEmitter {
|
|
|
36
36
|
this.deviceName = device.name;
|
|
37
37
|
this.deviceTypeText = device.typeString;
|
|
38
38
|
this.devicesFile = devicesFile;
|
|
39
|
+
this.defaultTempsFile = defaultTempsFile;
|
|
39
40
|
this.displayDeviceInfo = true;
|
|
40
41
|
|
|
41
42
|
//external integrations
|
|
@@ -922,7 +923,7 @@ class DeviceAta extends EventEmitter {
|
|
|
922
923
|
async start() {
|
|
923
924
|
try {
|
|
924
925
|
//melcloud device
|
|
925
|
-
this.melCloudAta = new MelCloudAta(this.account, this.device, this.devicesFile)
|
|
926
|
+
this.melCloudAta = new MelCloudAta(this.account, this.device, this.devicesFile, this.defaultTempsFile)
|
|
926
927
|
.on('deviceInfo', (manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
|
|
927
928
|
if (this.logDeviceInfo && this.displayDeviceInfo) {
|
|
928
929
|
this.emit('devInfo', `---- ${this.deviceTypeText}: ${this.deviceName} ----`);
|
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, contextKey, devicesFile, useFahrenheit, restFul, mqtt) {
|
|
9
|
+
constructor(api, account, device, contextKey, devicesFile, defaultTempsFile, useFahrenheit, restFul, mqtt) {
|
|
10
10
|
super();
|
|
11
11
|
|
|
12
12
|
Accessory = api.platformAccessory;
|
|
@@ -41,6 +41,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
41
41
|
this.deviceName = device.name;
|
|
42
42
|
this.deviceTypeText = device.typeString;
|
|
43
43
|
this.devicesFile = devicesFile;
|
|
44
|
+
this.defaultTempsFile = defaultTempsFile;
|
|
44
45
|
this.displayDeviceInfo = true;
|
|
45
46
|
|
|
46
47
|
//external integrations
|
|
@@ -1285,7 +1286,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1285
1286
|
async start() {
|
|
1286
1287
|
try {
|
|
1287
1288
|
//melcloud device
|
|
1288
|
-
this.melCloudAtw = new MelCloudAtw(this.device, this.contextKey, this.devicesFile)
|
|
1289
|
+
this.melCloudAtw = new MelCloudAtw(this.device, this.contextKey, this.devicesFile, this.defaultTempsFile)
|
|
1289
1290
|
.on('deviceInfo', (manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion, hasHotWaterTank, hasZone2) => {
|
|
1290
1291
|
if (this.logDeviceInfo && this.displayDeviceInfo) {
|
|
1291
1292
|
this.emit('devInfo', `---- ${this.deviceTypeText}: ${this.deviceName} ----`);
|
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, contextKey, devicesFile, useFahrenheit, restFul, mqtt) {
|
|
9
|
+
constructor(api, account, device, contextKey, devicesFile, defaultTempsFile, useFahrenheit, restFul, mqtt) {
|
|
10
10
|
super();
|
|
11
11
|
|
|
12
12
|
Accessory = api.platformAccessory;
|
|
@@ -34,6 +34,7 @@ class DeviceErv extends EventEmitter {
|
|
|
34
34
|
this.deviceName = device.name;
|
|
35
35
|
this.deviceTypeText = device.typeString;
|
|
36
36
|
this.devicesFile = devicesFile;
|
|
37
|
+
this.defaultTempsFile = defaultTempsFile;
|
|
37
38
|
this.displayDeviceInfo = true;
|
|
38
39
|
|
|
39
40
|
//external integrations
|
|
@@ -840,7 +841,7 @@ class DeviceErv extends EventEmitter {
|
|
|
840
841
|
async start() {
|
|
841
842
|
try {
|
|
842
843
|
//melcloud device
|
|
843
|
-
this.melCloudErv = new MelCloudErv(this.device, this.contextKey, this.devicesFile)
|
|
844
|
+
this.melCloudErv = new MelCloudErv(this.device, this.contextKey, this.devicesFile, this.defaultTempsFile)
|
|
844
845
|
.on('deviceInfo', (manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
|
|
845
846
|
if (this.logDeviceInfo && this.displayDeviceInfo) {
|
|
846
847
|
this.emit('devInfo', `---- ${this.deviceTypeText}: ${this.deviceName} ----`);
|
package/src/functions.js
CHANGED
|
@@ -14,11 +14,15 @@ class Functions {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
async readData(path) {
|
|
17
|
+
async readData(path, parseJson = false) {
|
|
18
18
|
try {
|
|
19
|
-
const data = await fsPromises.readFile(path);
|
|
20
|
-
return data;
|
|
19
|
+
const data = await fsPromises.readFile(path, 'utf8');
|
|
20
|
+
return parseJson ? JSON.parse(data) : data;
|
|
21
21
|
} catch (error) {
|
|
22
|
+
if (error.code === 'ENOENT') {
|
|
23
|
+
// File does not exist
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
22
26
|
throw new Error(`Read data error: ${error}`);
|
|
23
27
|
}
|
|
24
28
|
}
|
package/src/melcloudata.js
CHANGED
|
@@ -5,16 +5,15 @@ 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) {
|
|
8
|
+
constructor(account, device, devicesFile, defaultTempsFile) {
|
|
9
9
|
super();
|
|
10
10
|
this.accountType = account.displayType
|
|
11
11
|
this.deviceId = device.id;
|
|
12
12
|
this.logWarn = device.log?.warn;
|
|
13
13
|
this.logDebug = device.log?.debug;
|
|
14
14
|
this.devicesFile = devicesFile;
|
|
15
|
+
this.defaultTempsFile = defaultTempsFile;
|
|
15
16
|
this.functions = new Functions();
|
|
16
|
-
this.defaultHeatingSetTemperature = 20;
|
|
17
|
-
this.defaultCoolingSetTemperature = 23;
|
|
18
17
|
|
|
19
18
|
//set default values
|
|
20
19
|
this.deviceState = {};
|
|
@@ -47,9 +46,11 @@ class MelCloudAta extends EventEmitter {
|
|
|
47
46
|
|
|
48
47
|
async checkState() {
|
|
49
48
|
try {
|
|
49
|
+
//read default temps
|
|
50
|
+
const temps = await this.functions.readData(this.defaultTempsFile, true);
|
|
51
|
+
|
|
50
52
|
//read device info from file
|
|
51
|
-
const
|
|
52
|
-
const devicesData = JSON.parse(data);
|
|
53
|
+
const devicesData = await this.functions.readData(this.devicesFile, true);
|
|
53
54
|
|
|
54
55
|
if (!Array.isArray(devicesData)) {
|
|
55
56
|
if (this.logWarn) this.emit('warn', `Device data not found`);
|
|
@@ -63,8 +64,8 @@ class MelCloudAta extends EventEmitter {
|
|
|
63
64
|
deviceData.Device.SetFanSpeed = AirConditioner.FanSpeedMapStringToEnum[deviceData.Device.SetFanSpeed] ?? deviceData.Device.SetFanSpeed;
|
|
64
65
|
deviceData.Device.VaneVerticalDirection = AirConditioner.VaneVerticalDirectionMapStringToEnum[deviceData.Device.VaneVerticalDirection] ?? deviceData.Device.VaneVerticalDirection;
|
|
65
66
|
deviceData.Device.VaneHorizontalDirection = AirConditioner.VaneHorizontalDirectionMapStringToEnum[deviceData.Device.VaneHorizontalDirection] ?? deviceData.Device.VaneHorizontalDirection;
|
|
66
|
-
deviceData.Device.DefaultHeatingSetTemperature =
|
|
67
|
-
deviceData.Device.DefaultCoolingSetTemperature =
|
|
67
|
+
deviceData.Device.DefaultHeatingSetTemperature = temps?.defaultHeatingSetTemperature ?? 20;
|
|
68
|
+
deviceData.Device.DefaultCoolingSetTemperature = temps?.defaultCoolingSetTemperature ?? 24;
|
|
68
69
|
deviceData.Device.FirmwareAppVersion = '4.0.0';
|
|
69
70
|
}
|
|
70
71
|
if (this.logDebug) this.emit('debug', `Device Data: ${JSON.stringify(deviceData, null, 2)}`);
|
|
@@ -238,7 +239,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
238
239
|
HasPendingCommand: true
|
|
239
240
|
}
|
|
240
241
|
};
|
|
241
|
-
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(
|
|
242
|
+
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload.data, null, 2)}`);
|
|
242
243
|
|
|
243
244
|
await axiosInstancePost(ApiUrls.SetAta, payload);
|
|
244
245
|
this.emit('deviceState', deviceData);
|
|
@@ -282,13 +283,21 @@ class MelCloudAta extends EventEmitter {
|
|
|
282
283
|
break;
|
|
283
284
|
case 8: //AUTO
|
|
284
285
|
deviceData.Device.SetTemperature = (deviceData.Device.DefaultCoolingSetTemperature + deviceData.Device.DefaultHeatingSetTemperature) / 2;
|
|
285
|
-
this.defaultCoolingSetTemperature = deviceData.Device.DefaultCoolingSetTemperature;
|
|
286
|
-
this.defaultHeatingSetTemperature = deviceData.Device.DefaultHeatingSetTemperature;
|
|
287
286
|
break;
|
|
288
287
|
default:
|
|
289
288
|
if (this.logWarn) this.emit('warn', `Unknown operation mode: ${deviceData.Device.OperationMode}`);
|
|
290
289
|
return;
|
|
291
290
|
};
|
|
291
|
+
|
|
292
|
+
if (this.deviceState.DefaultCoolingSetTemperature !== deviceData.Device.DefaultCoolingSetTemperature || this.deviceState.DefaultHeatingSetTemperature !== deviceData.Device.DefaultHeatingSetTemperature) {
|
|
293
|
+
const temps = {
|
|
294
|
+
defaultCoolingSetTemperature: deviceData.Device.DefaultCoolingSetTemperature,
|
|
295
|
+
defaultHeatingSetTemperature: deviceData.Device.DefaultHeatingSetTemperature
|
|
296
|
+
};
|
|
297
|
+
await this.functions.saveData(this.defaultTempsFile, temps);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
break
|
|
292
301
|
case 2: //Thermostat
|
|
293
302
|
deviceData.Device.SetTemperature = deviceData.Device.SetTemperature;
|
|
294
303
|
break;
|
package/src/melcloudatw.js
CHANGED
|
@@ -6,12 +6,13 @@ import Functions from './functions.js';
|
|
|
6
6
|
import { ApiUrls } from './constants.js';
|
|
7
7
|
|
|
8
8
|
class MelCloudAtw extends EventEmitter {
|
|
9
|
-
constructor(device, contextKey, devicesFile) {
|
|
9
|
+
constructor(device, contextKey, devicesFile, defaultTempsFile) {
|
|
10
10
|
super();
|
|
11
11
|
this.deviceId = device.id;
|
|
12
12
|
this.logWarn = device.log?.warn;
|
|
13
13
|
this.logDebug = device.log?.debug;
|
|
14
14
|
this.devicesFile = devicesFile;
|
|
15
|
+
this.defaultTempsFile = defaultTempsFile;
|
|
15
16
|
this.functions = new Functions();
|
|
16
17
|
|
|
17
18
|
//set default values
|
|
@@ -61,8 +62,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
61
62
|
async checkState() {
|
|
62
63
|
try {
|
|
63
64
|
//read device info from file
|
|
64
|
-
const
|
|
65
|
-
const devicesData = JSON.parse(data);
|
|
65
|
+
const devicesData = await this.functions.readData(this.devicesFile, true);
|
|
66
66
|
|
|
67
67
|
if (!Array.isArray(devicesData)) {
|
|
68
68
|
if (this.logWarn) this.emit('warn', `Device data not found`);
|
package/src/melclouderv.js
CHANGED
|
@@ -6,12 +6,13 @@ import Functions from './functions.js';
|
|
|
6
6
|
import { ApiUrls } from './constants.js';
|
|
7
7
|
|
|
8
8
|
class MelCloudErv extends EventEmitter {
|
|
9
|
-
constructor(device, contextKey, devicesFile) {
|
|
9
|
+
constructor(device, contextKey, devicesFile, defaultTempsFile) {
|
|
10
10
|
super();
|
|
11
11
|
this.deviceId = device.id;
|
|
12
12
|
this.logWarn = device.log?.warn;
|
|
13
13
|
this.logDebug = device.log?.debug;
|
|
14
14
|
this.devicesFile = devicesFile;
|
|
15
|
+
this.defaultTempsFile = defaultTempsFile;
|
|
15
16
|
this.functions = new Functions();
|
|
16
17
|
|
|
17
18
|
//set default values
|
|
@@ -61,8 +62,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
61
62
|
async checkState() {
|
|
62
63
|
try {
|
|
63
64
|
//read device info from file
|
|
64
|
-
const
|
|
65
|
-
const devicesData = JSON.parse(data);
|
|
65
|
+
const devicesData = await this.functions.readData(this.devicesFile, true);
|
|
66
66
|
|
|
67
67
|
if (!Array.isArray(devicesData)) {
|
|
68
68
|
if (this.logWarn) this.emit('warn', `Device data not found`);
|