homebridge-melcloud-control 4.2.3-beta.2 → 4.2.3-beta.4
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 -8
- package/src/melcloudata.js +2 -4
- package/src/melcloudatw.js +46 -58
- package/src/melclouderv.js +33 -45
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.2.3-beta.
|
|
4
|
+
"version": "4.2.3-beta.4",
|
|
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
|
@@ -68,16 +68,15 @@ class MelCloud extends EventEmitter {
|
|
|
68
68
|
'X-MitsContextKey': this.contextKey,
|
|
69
69
|
'Content-Type': 'application/json'
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
|
|
72
|
+
if (this.logDebug) this.emit('debug', `Scanning for devices...`);
|
|
73
|
+
const listDevicesData = await axios(ApiUrls.ListDevices, {
|
|
72
74
|
method: 'GET',
|
|
73
75
|
baseURL: ApiUrls.BaseURL,
|
|
74
76
|
timeout: 15000,
|
|
75
77
|
headers: headers
|
|
76
78
|
});
|
|
77
79
|
|
|
78
|
-
if (this.logDebug) this.emit('debug', `Scanning for devices...`);
|
|
79
|
-
const listDevicesData = await axiosInstance(ApiUrls.ListDevices);
|
|
80
|
-
|
|
81
80
|
if (!listDevicesData || !listDevicesData.data) {
|
|
82
81
|
devicesList.Info = 'Invalid or empty response from MELCloud API'
|
|
83
82
|
return devicesList;
|
|
@@ -207,15 +206,14 @@ class MelCloud extends EventEmitter {
|
|
|
207
206
|
'Sec-Fetch-Site': 'same-origin',
|
|
208
207
|
'X-CSRF': '1'
|
|
209
208
|
};
|
|
210
|
-
|
|
209
|
+
|
|
210
|
+
if (this.logDebug) this.emit('debug', `Scanning for devices`);
|
|
211
|
+
const listDevicesData = await axios(ApiUrlsHome.GetUserContext, {
|
|
211
212
|
method: 'GET',
|
|
212
213
|
baseURL: ApiUrlsHome.BaseURL,
|
|
213
214
|
timeout: 25000,
|
|
214
215
|
headers: headers
|
|
215
216
|
});
|
|
216
|
-
|
|
217
|
-
if (this.logDebug) this.emit('debug', `Scanning for devices`);
|
|
218
|
-
const listDevicesData = await axiosInstance(ApiUrlsHome.GetUserContext);
|
|
219
217
|
const buildingsList = listDevicesData.data.buildings;
|
|
220
218
|
if (this.logDebug) this.emit('debug', `Buildings: ${JSON.stringify(buildingsList, null, 2)}`);
|
|
221
219
|
|
package/src/melcloudata.js
CHANGED
|
@@ -167,17 +167,15 @@ class MelCloudAta extends EventEmitter {
|
|
|
167
167
|
HideDryModeControl: deviceData.HideDryModeControl,
|
|
168
168
|
HasPendingCommand: true
|
|
169
169
|
};
|
|
170
|
-
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|
|
171
170
|
|
|
172
|
-
|
|
171
|
+
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|
|
172
|
+
await axios(ApiUrls.SetAta, {
|
|
173
173
|
method: 'POST',
|
|
174
174
|
baseURL: ApiUrls.BaseURL,
|
|
175
175
|
timeout: 10000,
|
|
176
176
|
headers: deviceData.Headers,
|
|
177
177
|
data: payload
|
|
178
178
|
});
|
|
179
|
-
|
|
180
|
-
await axiosInstancePost(ApiUrls.SetAta);
|
|
181
179
|
this.updateData(deviceData);
|
|
182
180
|
return true;
|
|
183
181
|
case "melcloudhome":
|
package/src/melcloudatw.js
CHANGED
|
@@ -148,93 +148,81 @@ class MelCloudAtw extends EventEmitter {
|
|
|
148
148
|
let path = '';
|
|
149
149
|
switch (accountType) {
|
|
150
150
|
case "melcloud":
|
|
151
|
-
|
|
151
|
+
deviceData.Device.EffectiveFlags = effectiveFlags;
|
|
152
|
+
payload = {
|
|
153
|
+
DeviceID: deviceData.Device.DeviceID,
|
|
154
|
+
EffectiveFlags: deviceData.Device.EffectiveFlags,
|
|
155
|
+
Power: deviceData.Device.Power,
|
|
156
|
+
SetTemperatureZone1: deviceData.Device.SetTemperatureZone1,
|
|
157
|
+
SetTemperatureZone2: deviceData.Device.SetTemperatureZone2,
|
|
158
|
+
OperationMode: deviceData.Device.OperationMode,
|
|
159
|
+
OperationModeZone1: deviceData.Device.OperationModeZone1,
|
|
160
|
+
OperationModeZone2: deviceData.Device.OperationModeZone2,
|
|
161
|
+
SetHeatFlowTemperatureZone1: deviceData.Device.SetHeatFlowTemperatureZone1,
|
|
162
|
+
SetHeatFlowTemperatureZone2: deviceData.Device.SetHeatFlowTemperatureZone2,
|
|
163
|
+
SetCoolFlowTemperatureZone1: deviceData.Device.SetCoolFlowTemperatureZone1,
|
|
164
|
+
SetCoolFlowTemperatureZone2: deviceData.Device.SetCoolFlowTemperatureZone2,
|
|
165
|
+
SetTankWaterTemperature: deviceData.Device.SetTankWaterTemperature,
|
|
166
|
+
ForcedHotWaterMode: deviceData.Device.ForcedHotWaterMode,
|
|
167
|
+
EcoHotWater: deviceData.Device.EcoHotWater,
|
|
168
|
+
HolidayMode: deviceData.Device.HolidayMode,
|
|
169
|
+
ProhibitZone1: deviceData.Device.ProhibitHeatingZone1,
|
|
170
|
+
ProhibitZone2: deviceData.Device.ProhibitHeatingZone2,
|
|
171
|
+
ProhibitHotWater: deviceData.Device.ProhibitHotWater,
|
|
172
|
+
HasPendingCommand: true
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|
|
176
|
+
await axios(ApiUrls.SetAtw, {
|
|
152
177
|
method: 'POST',
|
|
153
178
|
baseURL: ApiUrls.BaseURL,
|
|
154
179
|
timeout: 10000,
|
|
155
180
|
headers: deviceData.Headers,
|
|
156
|
-
|
|
181
|
+
data: payload
|
|
157
182
|
});
|
|
158
|
-
|
|
159
|
-
deviceData.Device.EffectiveFlags = effectiveFlags;
|
|
160
|
-
payload = {
|
|
161
|
-
data: {
|
|
162
|
-
DeviceID: deviceData.Device.DeviceID,
|
|
163
|
-
EffectiveFlags: deviceData.Device.EffectiveFlags,
|
|
164
|
-
Power: deviceData.Device.Power,
|
|
165
|
-
SetTemperatureZone1: deviceData.Device.SetTemperatureZone1,
|
|
166
|
-
SetTemperatureZone2: deviceData.Device.SetTemperatureZone2,
|
|
167
|
-
OperationMode: deviceData.Device.OperationMode,
|
|
168
|
-
OperationModeZone1: deviceData.Device.OperationModeZone1,
|
|
169
|
-
OperationModeZone2: deviceData.Device.OperationModeZone2,
|
|
170
|
-
SetHeatFlowTemperatureZone1: deviceData.Device.SetHeatFlowTemperatureZone1,
|
|
171
|
-
SetHeatFlowTemperatureZone2: deviceData.Device.SetHeatFlowTemperatureZone2,
|
|
172
|
-
SetCoolFlowTemperatureZone1: deviceData.Device.SetCoolFlowTemperatureZone1,
|
|
173
|
-
SetCoolFlowTemperatureZone2: deviceData.Device.SetCoolFlowTemperatureZone2,
|
|
174
|
-
SetTankWaterTemperature: deviceData.Device.SetTankWaterTemperature,
|
|
175
|
-
ForcedHotWaterMode: deviceData.Device.ForcedHotWaterMode,
|
|
176
|
-
EcoHotWater: deviceData.Device.EcoHotWater,
|
|
177
|
-
HolidayMode: deviceData.Device.HolidayMode,
|
|
178
|
-
ProhibitZone1: deviceData.Device.ProhibitHeatingZone1,
|
|
179
|
-
ProhibitZone2: deviceData.Device.ProhibitHeatingZone2,
|
|
180
|
-
ProhibitHotWater: deviceData.Device.ProhibitHotWater,
|
|
181
|
-
HasPendingCommand: true
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
await axiosInstancePost(ApiUrls.SetAtw, payload);
|
|
186
183
|
this.updateData(deviceData);
|
|
187
184
|
return true;
|
|
188
185
|
case "melcloudhome":
|
|
189
186
|
switch (effectiveFlags) {
|
|
190
187
|
case 'holidaymode':
|
|
191
|
-
payload = {
|
|
192
|
-
data: { enabled: deviceData.HolidayMode.Enabled, startDate: deviceData.HolidayMode.StartDate, endDate: deviceData.HolidayMode.EndDate, units: { "ATW": [deviceData.DeviceID] } }
|
|
193
|
-
};
|
|
188
|
+
payload = { enabled: deviceData.HolidayMode.Enabled, startDate: deviceData.HolidayMode.StartDate, endDate: deviceData.HolidayMode.EndDate, units: { "ATW": [deviceData.DeviceID] } };
|
|
194
189
|
method = 'POST';
|
|
195
190
|
path = ApiUrlsHome.PostHolidayMode;
|
|
196
191
|
break;
|
|
197
192
|
case 'schedule':
|
|
198
|
-
payload = {
|
|
199
|
-
data: {
|
|
200
|
-
enabled: deviceData.ScheduleEnabled
|
|
201
|
-
}
|
|
202
|
-
};
|
|
193
|
+
payload = { enabled: deviceData.ScheduleEnabled };
|
|
203
194
|
method = 'PUT';
|
|
204
195
|
path = ApiUrlsHome.PutScheduleEnable.replace('deviceid', deviceData.DeviceID);
|
|
205
196
|
break;
|
|
206
197
|
default:
|
|
207
198
|
payload = {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
EcoHotWater: deviceData.Device.EcoHotWater,
|
|
222
|
-
}
|
|
199
|
+
Power: deviceData.Device.Power,
|
|
200
|
+
SetTemperatureZone1: deviceData.Device.SetTemperatureZone1,
|
|
201
|
+
SetTemperatureZone2: deviceData.Device.SetTemperatureZone2,
|
|
202
|
+
OperationMode: HeatPump.OperationModeMapEnumToString[deviceData.Device.OperationMode],
|
|
203
|
+
OperationModeZone1: HeatPump.OperationModeMapEnumToString[deviceData.Device.OperationModeZone1],
|
|
204
|
+
OperationModeZone2: HeatPump.OperationModeMapEnumToString[deviceData.Device.OperationModeZone2],
|
|
205
|
+
SetHeatFlowTemperatureZone1: deviceData.Device.SetHeatFlowTemperatureZone1,
|
|
206
|
+
SetHeatFlowTemperatureZone2: deviceData.Device.SetHeatFlowTemperatureZone2,
|
|
207
|
+
SetCoolFlowTemperatureZone1: deviceData.Device.SetCoolFlowTemperatureZone1,
|
|
208
|
+
SetCoolFlowTemperatureZone2: deviceData.Device.SetCoolFlowTemperatureZone2,
|
|
209
|
+
SetTankWaterTemperature: deviceData.Device.SetTankWaterTemperature,
|
|
210
|
+
ForcedHotWaterMode: deviceData.Device.ForcedHotWaterMode,
|
|
211
|
+
EcoHotWater: deviceData.Device.EcoHotWater,
|
|
223
212
|
};
|
|
224
213
|
method = 'PUT';
|
|
225
214
|
path = ApiUrlsHome.SetAtw.replace('deviceid', deviceData.DeviceID);
|
|
226
215
|
break
|
|
227
216
|
}
|
|
228
217
|
|
|
229
|
-
|
|
218
|
+
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|
|
219
|
+
await axios(path, {
|
|
230
220
|
method: method,
|
|
231
221
|
baseURL: ApiUrlsHome.BaseURL,
|
|
232
222
|
timeout: 10000,
|
|
233
|
-
headers: deviceData.Headers
|
|
223
|
+
headers: deviceData.Headers,
|
|
224
|
+
data: payload
|
|
234
225
|
});
|
|
235
|
-
|
|
236
|
-
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload.data, null, 2)}`);
|
|
237
|
-
await axiosInstancePut(path, payload);
|
|
238
226
|
this.updateData(deviceData);
|
|
239
227
|
return true;
|
|
240
228
|
default:
|
package/src/melclouderv.js
CHANGED
|
@@ -137,14 +137,6 @@ class MelCloudErv extends EventEmitter {
|
|
|
137
137
|
let path = '';
|
|
138
138
|
switch (accountType) {
|
|
139
139
|
case "melcloud":
|
|
140
|
-
const axiosInstancePost = axios.create({
|
|
141
|
-
method: 'POST',
|
|
142
|
-
baseURL: ApiUrls.BaseURL,
|
|
143
|
-
timeout: 10000,
|
|
144
|
-
headers: deviceData.Headers,
|
|
145
|
-
withCredentials: true
|
|
146
|
-
});
|
|
147
|
-
|
|
148
140
|
//set target temp based on display mode and ventilation mode
|
|
149
141
|
switch (displayType) {
|
|
150
142
|
case 1: //Heather/Cooler
|
|
@@ -168,25 +160,30 @@ class MelCloudErv extends EventEmitter {
|
|
|
168
160
|
//device state
|
|
169
161
|
deviceData.Device.EffectiveFlags = effectiveFlags;
|
|
170
162
|
payload = {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
HasPendingCommand: true
|
|
186
|
-
}
|
|
163
|
+
DeviceID: deviceData.Device.DeviceID,
|
|
164
|
+
EffectiveFlags: deviceData.Device.EffectiveFlags,
|
|
165
|
+
Power: deviceData.Device.Power,
|
|
166
|
+
SetTemperature: deviceData.Device.SetTemperature,
|
|
167
|
+
SetFanSpeed: deviceData.Device.SetFanSpeed,
|
|
168
|
+
OperationMode: deviceData.Device.OperationMode,
|
|
169
|
+
VentilationMode: deviceData.Device.VentilationMode,
|
|
170
|
+
DefaultCoolingSetTemperature: deviceData.Device.DefaultCoolingSetTemperature,
|
|
171
|
+
DefaultHeatingSetTemperature: deviceData.Device.DefaultHeatingSetTemperature,
|
|
172
|
+
HideRoomTemperature: deviceData.Device.HideRoomTemperature,
|
|
173
|
+
HideSupplyTemperature: deviceData.Device.HideSupplyTemperature,
|
|
174
|
+
HideOutdoorTemperature: deviceData.Device.HideOutdoorTemperature,
|
|
175
|
+
NightPurgeMode: deviceData.Device.NightPurgeMode,
|
|
176
|
+
HasPendingCommand: true
|
|
187
177
|
}
|
|
188
178
|
|
|
189
|
-
|
|
179
|
+
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|
|
180
|
+
await axios(ApiUrls.SetErv, {
|
|
181
|
+
method: 'POST',
|
|
182
|
+
baseURL: ApiUrls.BaseURL,
|
|
183
|
+
timeout: 10000,
|
|
184
|
+
headers: deviceData.Headers,
|
|
185
|
+
data: payload
|
|
186
|
+
});
|
|
190
187
|
this.updateData(deviceData);
|
|
191
188
|
return true;
|
|
192
189
|
case "melcloudhome":
|
|
@@ -204,45 +201,36 @@ class MelCloudErv extends EventEmitter {
|
|
|
204
201
|
|
|
205
202
|
switch (effectiveFlags) {
|
|
206
203
|
case 'holidaymode':
|
|
207
|
-
payload = {
|
|
208
|
-
data: { enabled: deviceData.HolidayMode.Enabled, startDate: deviceData.HolidayMode.StartDate, endDate: deviceData.HolidayMode.EndDate, units: { "ERV": [deviceData.DeviceID] } }
|
|
209
|
-
};
|
|
204
|
+
payload = { enabled: deviceData.HolidayMode.Enabled, startDate: deviceData.HolidayMode.StartDate, endDate: deviceData.HolidayMode.EndDate, units: { "ERV": [deviceData.DeviceID] } };
|
|
210
205
|
method = 'POST';
|
|
211
206
|
path = ApiUrlsHome.PostHolidayMode;
|
|
212
207
|
break;
|
|
213
208
|
case 'schedule':
|
|
214
|
-
payload = {
|
|
215
|
-
data: {
|
|
216
|
-
enabled: deviceData.ScheduleEnabled
|
|
217
|
-
}
|
|
218
|
-
};
|
|
209
|
+
payload = { enabled: deviceData.ScheduleEnabled };
|
|
219
210
|
method = 'PUT';
|
|
220
211
|
path = ApiUrlsHome.PutScheduleEnable.replace('deviceid', deviceData.DeviceID);
|
|
221
212
|
break;
|
|
222
213
|
default:
|
|
223
214
|
payload = {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
VentilationMode: Ventilation.VentilationModeMapEnumToString[deviceData.Device.VentilationMode],
|
|
230
|
-
}
|
|
215
|
+
Power: deviceData.Device.Power,
|
|
216
|
+
SetTemperature: deviceData.Device.SetTemperature,
|
|
217
|
+
SetFanSpeed: String(deviceData.Device.SetFanSpeed),
|
|
218
|
+
OperationMode: Ventilation.OperationModeMapEnumToString[deviceData.Device.OperationMode],
|
|
219
|
+
VentilationMode: Ventilation.VentilationModeMapEnumToString[deviceData.Device.VentilationMode],
|
|
231
220
|
};
|
|
232
221
|
method = 'PUT';
|
|
233
222
|
path = ApiUrlsHome.SetErv.replace('deviceid', deviceData.DeviceID);
|
|
234
223
|
break
|
|
235
224
|
}
|
|
236
225
|
|
|
237
|
-
|
|
226
|
+
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|
|
227
|
+
await axios(path, {
|
|
238
228
|
method: method,
|
|
239
229
|
baseURL: ApiUrlsHome.BaseURL,
|
|
240
230
|
timeout: 10000,
|
|
241
|
-
headers: deviceData.Headers
|
|
231
|
+
headers: deviceData.Headers,
|
|
232
|
+
data: payload
|
|
242
233
|
});
|
|
243
|
-
|
|
244
|
-
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload.data, null, 2)}`);
|
|
245
|
-
await axiosInstancePut(path, payload);
|
|
246
234
|
this.updateData(deviceData);
|
|
247
235
|
return true;
|
|
248
236
|
default:
|