homebridge-melcloud-control 4.7.5-beta.1 → 4.7.5-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/package.json +1 -1
- package/src/melcloud.js +6 -1
- package/src/melcloudata.js +82 -82
- package/src/melcloudatw.js +67 -67
- package/src/melclouderv.js +72 -72
- package/src/melcloudhome.js +7 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.7.5-beta.
|
|
4
|
+
"version": "4.7.5-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/melcloud.js
CHANGED
|
@@ -111,7 +111,12 @@ class MelCloud extends EventEmitter {
|
|
|
111
111
|
await this.functions.saveData(this.buildingsFile, devicesList);
|
|
112
112
|
if (this.logDebug) this.emit('debug', `Buildings list saved`);
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
//emit device event
|
|
115
|
+
for (const deviceData of devicesList.Devices) {
|
|
116
|
+
const deviceId = deviceData.DeviceID;
|
|
117
|
+
deviceData.Scenes = devicesList.Devices.Scenes ?? [];
|
|
118
|
+
this.emit(deviceId, 'request', deviceData);
|
|
119
|
+
}
|
|
115
120
|
|
|
116
121
|
return devicesList;
|
|
117
122
|
} catch (error) {
|
package/src/melcloudata.js
CHANGED
|
@@ -30,97 +30,97 @@ class MelCloudAta extends EventEmitter {
|
|
|
30
30
|
let deviceData = null;
|
|
31
31
|
melcloud.on('client', (client) => {
|
|
32
32
|
this.client = client;
|
|
33
|
-
}).on(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
//update holiday mode
|
|
61
|
-
if (key === 'HolidayMode') {
|
|
62
|
-
deviceData.HolidayMode.Enabled = value;
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
33
|
+
}).on(this.deviceId, async (type, message) => {
|
|
34
|
+
switch (type) {
|
|
35
|
+
case 'ws':
|
|
36
|
+
try {
|
|
37
|
+
const messageType = message.messageType;
|
|
38
|
+
const messageData = message.Data;
|
|
39
|
+
const settings = this.functions.parseArrayNameValue(messageData.settings);
|
|
40
|
+
|
|
41
|
+
let updateState = false;
|
|
42
|
+
switch (messageType) {
|
|
43
|
+
case 'unitStateChanged':
|
|
44
|
+
|
|
45
|
+
//update values
|
|
46
|
+
for (const [key, value] of Object.entries(settings)) {
|
|
47
|
+
if (!this.functions.isValidValue(value)) continue;
|
|
48
|
+
|
|
49
|
+
//update holiday mode
|
|
50
|
+
if (key === 'HolidayMode') {
|
|
51
|
+
deviceData.HolidayMode.Enabled = value;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//update device settings
|
|
56
|
+
if (key in deviceData.Device) {
|
|
57
|
+
deviceData.Device[key] = value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
65
60
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
61
|
+
updateState = true;
|
|
62
|
+
break;
|
|
63
|
+
case 'ataUnitFrostProtectionTriggered':
|
|
64
|
+
deviceData.FrostProtection.Active = messageData.active;
|
|
71
65
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
deviceData.FrostProtection.Active = messageData.active;
|
|
66
|
+
//update device settings
|
|
67
|
+
for (const [key, value] of Object.entries(settings)) {
|
|
68
|
+
if (!this.functions.isValidValue(value) || key === 'SetTemperature') continue;
|
|
76
69
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
if (key in deviceData.Device) {
|
|
71
|
+
deviceData.Device[key] = value;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
80
74
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
updateState = true;
|
|
76
|
+
break;
|
|
77
|
+
case 'ataUnitOverheatProtectionTriggered':
|
|
78
|
+
deviceData.OverheatProtection.Active = messageData.active;
|
|
85
79
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
deviceData.OverheatProtection.Active = messageData.active;
|
|
80
|
+
//update device settings
|
|
81
|
+
for (const [key, value] of Object.entries(settings)) {
|
|
82
|
+
if (!this.functions.isValidValue(value) || key === 'SetTemperature') continue;
|
|
90
83
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
if (key in deviceData.Device) {
|
|
85
|
+
deviceData.Device[key] = value;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
94
88
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
89
|
+
updateState = true;
|
|
90
|
+
break;
|
|
91
|
+
case 'unitHolidayModeTriggered':
|
|
92
|
+
deviceData.Device.Power = settings.Power;
|
|
93
|
+
deviceData.HolidayMode.Enabled = settings.HolidayMode;
|
|
94
|
+
deviceData.HolidayMode.Active = messageData.active;
|
|
95
|
+
updateState = true;
|
|
96
|
+
break;
|
|
97
|
+
case 'unitWifiSignalChanged':
|
|
98
|
+
deviceData.Rssi = messageData.rssi;
|
|
99
|
+
updateState = true;
|
|
100
|
+
break;
|
|
101
|
+
case 'unitCommunicationRestored':
|
|
102
|
+
deviceData.Device.IsConnected = true;
|
|
103
|
+
break;
|
|
104
|
+
default:
|
|
105
|
+
if (this.logDebug) this.emit('debug', `Unit ${this.deviceId}, received unknown message type: ${messageType}`);
|
|
106
|
+
return;
|
|
98
107
|
}
|
|
99
108
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
deviceData.
|
|
110
|
-
updateState
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
default:
|
|
116
|
-
if (this.logDebug) this.emit('debug', `Unit ${unitId}, received unknown message type: ${parsedMessage}`);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
//update state
|
|
121
|
-
if (updateState) await this.updateState('ws', deviceData);
|
|
122
|
-
} catch (error) {
|
|
123
|
-
if (this.logError) this.emit('error', `Web socket process message error: ${error}`);
|
|
109
|
+
//update state
|
|
110
|
+
if (updateState) await this.updateState('ws', deviceData);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
if (this.logError) this.emit('error', `Web socket process message error: ${error}`);
|
|
113
|
+
}
|
|
114
|
+
break;
|
|
115
|
+
case 'request':
|
|
116
|
+
try {
|
|
117
|
+
//update state
|
|
118
|
+
if (this.logDebug) this.emit('debug', `Request update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
|
|
119
|
+
await this.updateState('request', deviceData);
|
|
120
|
+
} catch (error) {
|
|
121
|
+
if (this.logError) this.emit('error', `Request process message error: ${error}`);
|
|
122
|
+
}
|
|
123
|
+
break;
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
126
|
}
|
package/src/melcloudatw.js
CHANGED
|
@@ -29,82 +29,82 @@ class MelCloudAtw extends EventEmitter {
|
|
|
29
29
|
let deviceData = null;
|
|
30
30
|
melcloud.on('client', (client) => {
|
|
31
31
|
this.client = client;
|
|
32
|
-
}).on(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
}).on(this.deviceId, async (type, message) => {
|
|
33
|
+
switch (type) {
|
|
34
|
+
case 'ws':
|
|
35
|
+
try {
|
|
36
|
+
const messageType = message.messageType;
|
|
37
|
+
const messageData = message.Data;
|
|
38
|
+
const settings = this.functions.parseArrayNameValue(messageData.settings);
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} catch (error) {
|
|
42
|
-
if (this.logError) this.emit('error', `Request process message error: ${error}`);
|
|
43
|
-
}
|
|
44
|
-
}).on(this.deviceId, async (parsedMessage) => {
|
|
45
|
-
try {
|
|
46
|
-
if (!deviceData) return;
|
|
47
|
-
const messageData = parsedMessage[0]?.Data;
|
|
48
|
-
|
|
49
|
-
let updateState = false;
|
|
50
|
-
const messageType = parsedMessage[0].messageType;
|
|
51
|
-
const settings = this.functions.parseArrayNameValue(messageData.settings);
|
|
52
|
-
switch (messageType) {
|
|
53
|
-
case 'unitStateChanged':
|
|
40
|
+
let updateState = false;
|
|
41
|
+
switch (messageType) {
|
|
42
|
+
case 'unitStateChanged':
|
|
54
43
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
//update values
|
|
45
|
+
for (const [key, value] of Object.entries(settings)) {
|
|
46
|
+
if (!this.functions.isValidValue(value)) continue;
|
|
58
47
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
48
|
+
//update holiday mode
|
|
49
|
+
if (key === 'HolidayMode') {
|
|
50
|
+
deviceData.HolidayMode.Enabled = value;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
64
53
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
54
|
+
//update device settings
|
|
55
|
+
if (key in deviceData.Device) {
|
|
56
|
+
deviceData.Device[key] = value;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
70
59
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
60
|
+
updateState = true;
|
|
61
|
+
break;
|
|
62
|
+
case 'atwUnitFrostProtectionTriggered':
|
|
63
|
+
deviceData.FrostProtection.Active = messageData.active;
|
|
75
64
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
//update device settings
|
|
66
|
+
for (const [key, value] of Object.entries(settings)) {
|
|
67
|
+
if (!this.functions.isValidValue(value) || key === 'SetTemperature') continue;
|
|
79
68
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
69
|
+
if (key in deviceData.Device) {
|
|
70
|
+
deviceData.Device[key] = value;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
updateState = true;
|
|
74
|
+
break;
|
|
75
|
+
case 'unitHolidayModeTriggered':
|
|
76
|
+
deviceData.Device.Power = settings.Power;
|
|
77
|
+
deviceData.HolidayMode.Enabled = settings.HolidayMode;
|
|
78
|
+
deviceData.HolidayMode.Active = messageData.active;
|
|
79
|
+
updateState = true;
|
|
80
|
+
break;
|
|
81
|
+
case 'unitWifiSignalChanged':
|
|
82
|
+
deviceData.Rssi = messageData.rssi;
|
|
83
|
+
updateState = true;
|
|
84
|
+
break;
|
|
85
|
+
case 'unitCommunicationRestored':
|
|
86
|
+
deviceData.Device.IsConnected = true;
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
if (this.logDebug) this.emit('debug', `Unit ${this.deviceId}, received unknown message type: ${messageType}`);
|
|
90
|
+
return;
|
|
83
91
|
}
|
|
84
|
-
updateState = true;
|
|
85
|
-
break;
|
|
86
|
-
case 'unitHolidayModeTriggered':
|
|
87
|
-
deviceData.Device.Power = settings.Power;
|
|
88
|
-
deviceData.HolidayMode.Enabled = settings.HolidayMode;
|
|
89
|
-
deviceData.HolidayMode.Active = messageData.active;
|
|
90
|
-
updateState = true;
|
|
91
|
-
break;
|
|
92
|
-
case 'unitWifiSignalChanged':
|
|
93
|
-
deviceData.Rssi = messageData.rssi;
|
|
94
|
-
updateState = true;
|
|
95
|
-
break;
|
|
96
|
-
case 'unitCommunicationRestored':
|
|
97
|
-
deviceData.Device.IsConnected = true;
|
|
98
|
-
break;
|
|
99
|
-
default:
|
|
100
|
-
if (this.logDebug) this.emit('debug', `Unit ${unitId}, received unknown message type: ${parsedMessage}`);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
92
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
93
|
+
//update state
|
|
94
|
+
if (updateState) await this.updateState('ws', deviceData);
|
|
95
|
+
} catch (error) {
|
|
96
|
+
if (this.logError) this.emit('error', `Web socket process message error: ${error}`);
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
case 'request':
|
|
100
|
+
try {
|
|
101
|
+
//update state
|
|
102
|
+
if (this.logDebug) this.emit('debug', `Request update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
|
|
103
|
+
await this.updateState('request', deviceData);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
if (this.logError) this.emit('error', `Request process message error: ${error}`);
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
}
|
package/src/melclouderv.js
CHANGED
|
@@ -29,82 +29,82 @@ class MelCloudErv extends EventEmitter {
|
|
|
29
29
|
let deviceData = null;
|
|
30
30
|
melcloud.on('client', (client) => {
|
|
31
31
|
this.client = client;
|
|
32
|
-
}).on(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
//update holiday mode
|
|
60
|
-
if (key === 'HolidayMode') {
|
|
61
|
-
deviceData.HolidayMode.Enabled = value;
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
//update device settings
|
|
66
|
-
if (key in deviceData.Device) {
|
|
67
|
-
deviceData.Device[key] = value;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
32
|
+
}).on(this.deviceId, async (type, message) => {
|
|
33
|
+
switch (type) {
|
|
34
|
+
case 'ws':
|
|
35
|
+
try {
|
|
36
|
+
const messageType = message.messageType;
|
|
37
|
+
const messageData = message.Data;
|
|
38
|
+
const settings = this.functions.parseArrayNameValue(messageData.settings);
|
|
39
|
+
|
|
40
|
+
let updateState = false;
|
|
41
|
+
switch (messageType) {
|
|
42
|
+
case 'unitStateChanged':
|
|
43
|
+
|
|
44
|
+
//update values
|
|
45
|
+
for (const [key, value] of Object.entries(settings)) {
|
|
46
|
+
if (!this.functions.isValidValue(value)) continue;
|
|
47
|
+
|
|
48
|
+
//update holiday mode
|
|
49
|
+
if (key === 'HolidayMode') {
|
|
50
|
+
deviceData.HolidayMode.Enabled = value;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//update device settings
|
|
55
|
+
if (key in deviceData.Device) {
|
|
56
|
+
deviceData.Device[key] = value;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
70
59
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
60
|
+
updateState = true;
|
|
61
|
+
break;
|
|
62
|
+
case 'ervUnitFrostProtectionTriggered':
|
|
63
|
+
deviceData.FrostProtection.Active = messageData.active;
|
|
75
64
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
//update device settings
|
|
66
|
+
for (const [key, value] of Object.entries(settings)) {
|
|
67
|
+
if (!this.functions.isValidValue(value) || key === 'SetTemperature') continue;
|
|
79
68
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
69
|
+
if (key in deviceData.Device) {
|
|
70
|
+
deviceData.Device[key] = value;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
updateState = true;
|
|
74
|
+
break;
|
|
75
|
+
case 'unitHolidayModeTriggered':
|
|
76
|
+
deviceData.Device.Power = settings.Power;
|
|
77
|
+
deviceData.HolidayMode.Enabled = settings.HolidayMode;
|
|
78
|
+
deviceData.HolidayMode.Active = messageData.active;
|
|
79
|
+
updateState = true;
|
|
80
|
+
break;
|
|
81
|
+
case 'unitWifiSignalChanged':
|
|
82
|
+
deviceData.Rssi = messageData.rssi;
|
|
83
|
+
updateState = true;
|
|
84
|
+
break;
|
|
85
|
+
case 'unitCommunicationRestored':
|
|
86
|
+
deviceData.Device.IsConnected = true;
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
if (this.logDebug) this.emit('debug', `Unit ${this.deviceId}, received unknown message type: ${messageType}`);
|
|
90
|
+
return;
|
|
83
91
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (this.logDebug) this.emit('debug', `Unit ${unitId}, received unknown message type: ${parsedMessage}`);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
//update state
|
|
105
|
-
if (updateState) await this.updateState('ws', deviceData);
|
|
106
|
-
} catch (error) {
|
|
107
|
-
if (this.logError) this.emit('error', `Web socket process message error: ${error}`);
|
|
92
|
+
|
|
93
|
+
//update state
|
|
94
|
+
if (updateState) await this.updateState('ws', deviceData);
|
|
95
|
+
} catch (error) {
|
|
96
|
+
if (this.logError) this.emit('error', `Web socket process message error: ${error}`);
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
case 'request':
|
|
100
|
+
try {
|
|
101
|
+
//update state
|
|
102
|
+
if (this.logDebug) this.emit('debug', `Request update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
|
|
103
|
+
await this.updateState('request', deviceData);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
if (this.logError) this.emit('error', `Request process message error: ${error}`);
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
}
|
package/src/melcloudhome.js
CHANGED
|
@@ -209,7 +209,12 @@ class MelCloudHome extends EventEmitter {
|
|
|
209
209
|
await this.functions.saveData(this.buildingsFile, devicesList);
|
|
210
210
|
if (this.logDebug) this.emit('debug', `Buildings list saved`);
|
|
211
211
|
|
|
212
|
-
|
|
212
|
+
//emit device event
|
|
213
|
+
for (const deviceData of devicesList.Devices) {
|
|
214
|
+
deviceData.Scenes = devicesList.Devices.Scenes ?? [];
|
|
215
|
+
const deviceId = deviceData.DeviceID;
|
|
216
|
+
this.emit(deviceId, 'request', deviceData);
|
|
217
|
+
}
|
|
213
218
|
|
|
214
219
|
return devicesList;
|
|
215
220
|
} catch (error) {
|
|
@@ -334,7 +339,7 @@ class MelCloudHome extends EventEmitter {
|
|
|
334
339
|
const messageData = parsedMessage?.[0]?.Data;
|
|
335
340
|
if (!messageData || parsedMessage.message === 'Forbidden') return;
|
|
336
341
|
|
|
337
|
-
this.emit(messageData.id, parsedMessage);
|
|
342
|
+
this.emit(messageData.id, 'ws', parsedMessage[0]);
|
|
338
343
|
});
|
|
339
344
|
} catch (error) {
|
|
340
345
|
if (this.logError) this.emit('error', `Web socket connection failed: ${error}`);
|