homebridge-melcloud-control 4.7.5-beta.0 → 4.7.5-beta.2
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 +5 -1
- package/src/melcloudata.js +84 -82
- package/src/melcloudatw.js +69 -67
- package/src/melclouderv.js +74 -72
- package/src/melcloudhome.js +7 -3
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.2",
|
|
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,11 @@ 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
|
+
this.emit(deviceId, 'request', deviceData);
|
|
118
|
+
}
|
|
115
119
|
|
|
116
120
|
return devicesList;
|
|
117
121
|
} catch (error) {
|
package/src/melcloudata.js
CHANGED
|
@@ -30,97 +30,99 @@ 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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
+
deviceData.Scenes = message.Scenes ?? [];
|
|
118
|
+
|
|
119
|
+
//update state
|
|
120
|
+
if (this.logDebug) this.emit('debug', `Request update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
|
|
121
|
+
await this.updateState('request', deviceData);
|
|
122
|
+
} catch (error) {
|
|
123
|
+
if (this.logError) this.emit('error', `Request process message error: ${error}`);
|
|
124
|
+
}
|
|
125
|
+
break;
|
|
124
126
|
}
|
|
125
127
|
});
|
|
126
128
|
}
|
package/src/melcloudatw.js
CHANGED
|
@@ -29,82 +29,84 @@ 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
|
+
deviceData.Scenes = message.Scenes ?? [];
|
|
102
|
+
|
|
103
|
+
//update state
|
|
104
|
+
if (this.logDebug) this.emit('debug', `Request update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
|
|
105
|
+
await this.updateState('request', deviceData);
|
|
106
|
+
} catch (error) {
|
|
107
|
+
if (this.logError) this.emit('error', `Request process message error: ${error}`);
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
108
110
|
}
|
|
109
111
|
});
|
|
110
112
|
}
|
package/src/melclouderv.js
CHANGED
|
@@ -29,82 +29,84 @@ 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
|
-
deviceData.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
+
deviceData.Scenes = message.Scenes ?? [];
|
|
102
|
+
|
|
103
|
+
//update state
|
|
104
|
+
if (this.logDebug) this.emit('debug', `Request update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
|
|
105
|
+
await this.updateState('request', deviceData);
|
|
106
|
+
} catch (error) {
|
|
107
|
+
if (this.logError) this.emit('error', `Request process message error: ${error}`);
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
108
110
|
}
|
|
109
111
|
});
|
|
110
112
|
}
|
package/src/melcloudhome.js
CHANGED
|
@@ -209,7 +209,11 @@ 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
|
+
const deviceId = deviceData.DeviceID;
|
|
215
|
+
this.emit(deviceId, 'request', deviceData);
|
|
216
|
+
}
|
|
213
217
|
|
|
214
218
|
return devicesList;
|
|
215
219
|
} catch (error) {
|
|
@@ -330,11 +334,11 @@ class MelCloudHome extends EventEmitter {
|
|
|
330
334
|
})
|
|
331
335
|
.on('message', (message) => {
|
|
332
336
|
const parsedMessage = JSON.parse(message);
|
|
333
|
-
if (this.logDebug) this.emit('debug', `Web socket incoming message: ${JSON.stringify(parsedMessage, null, 2)}`);
|
|
337
|
+
if (!this.logDebug) this.emit('debug', `Web socket incoming message: ${JSON.stringify(parsedMessage, null, 2)}`);
|
|
334
338
|
const messageData = parsedMessage?.[0]?.Data;
|
|
335
339
|
if (!messageData || parsedMessage.message === 'Forbidden') return;
|
|
336
340
|
|
|
337
|
-
this.emit(messageData.id, parsedMessage);
|
|
341
|
+
this.emit(messageData.id, 'ws', parsedMessage[0]);
|
|
338
342
|
});
|
|
339
343
|
} catch (error) {
|
|
340
344
|
if (this.logError) this.emit('error', `Web socket connection failed: ${error}`);
|