homebridge-melcloud-control 4.4.1-beta.7 → 4.4.1-beta.9
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/constants.js +62 -50
- package/src/deviceata.js +2 -2
- package/src/deviceatw.js +2 -2
- package/src/deviceerv.js +2 -2
- package/src/melcloud.js +4 -4
- package/src/melcloudata.js +9 -9
- package/src/melcloudatw.js +8 -8
- package/src/melclouderv.js +7 -7
- package/src/melcloudhome.js +10 -10
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.4.1-beta.
|
|
4
|
+
"version": "4.4.1-beta.9",
|
|
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/constants.js
CHANGED
|
@@ -2,60 +2,67 @@ export const PlatformName = "melcloudcontrol";
|
|
|
2
2
|
export const PluginName = "homebridge-melcloud-control";
|
|
3
3
|
|
|
4
4
|
export const ApiUrls = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
SetAtw: "/Device/SetAtw",
|
|
14
|
-
SetErv: "/Device/SetErv",
|
|
15
|
-
GetRefreshUnit: "/Device/RequestRefresh?id=deviceid",
|
|
16
|
-
UpdateApplicationOptions: "/User/UpdateApplicationOptions",
|
|
17
|
-
HolidayModeUpdate: "/HolidayMode/Update",
|
|
18
|
-
EnergyCostReport: "/EnergyCost/Report",
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const ApiUrlsHome = {
|
|
22
|
-
BaseURL: "https://melcloudhome.com",
|
|
23
|
-
GetConfiguration: "https://melcloudhome.com/api/configuration",
|
|
24
|
-
GetUserContext: "/api/user/context",
|
|
25
|
-
GetUserScenes: "/api/user/scenes",
|
|
26
|
-
PostSchedule: "/api/cloudschedule/deviceid", // POST {"days":[2],"time":"17:59:00","enabled":true,"id":"53c5e804-0663-47d0-85c2-2d8ccd2573de","power":false,"operationMode":null,"setPoint":null,"vaneVerticalDirection":null,"vaneHorizontalDirection":null,"setFanSpeed":null}
|
|
27
|
-
PostProtectionFrost: "/api/protection/frost", // POST {"enabled":true,"min":13,"max":16,"units":{"ATA":["ef333525-2699-4290-af5a-2922566676da"]}}
|
|
28
|
-
PostProtectionOverheat: "/api/protection/overheat", // POST {"enabled":true,"min":32,"max":35,"units":{"ATA":["ef333525-2699-4290-af5a-2922566676da"]}}
|
|
29
|
-
PostHolidayMode: " /api/holidaymode", // POST {"enabled":true,"startDate":"2025-11-11T17:42:24.913","endDate":"2026-06-01T09:18:00","units":{"ATA":["ef333525-2699-4290-af5a-2922566676da"]}}
|
|
30
|
-
PutAta: "/api/ataunit/deviceid",
|
|
31
|
-
PutAtw: "/api/atwunit/deviceid",
|
|
32
|
-
PutErv: "/api/ervunit/deviceid",
|
|
33
|
-
PutScheduleEnabled: "/api/cloudschedule/deviceid/enabled", // PUT {"enabled":true}
|
|
34
|
-
PutScene: {
|
|
35
|
-
Enable: "/api/scene/sceneid/enable",
|
|
36
|
-
Disable: "/api/scene/sceneid/disable",
|
|
5
|
+
Base: "https://app.melcloud.com/Mitsubishi.Wifi.Client",
|
|
6
|
+
Get: {
|
|
7
|
+
UserDetails: "/User/GetUserDetails",
|
|
8
|
+
ListDevices: "/User/ListDevices",
|
|
9
|
+
ListDeviceUnits: "/Device/ListDeviceUnits",
|
|
10
|
+
RefreshUnit: "/Device/RequestRefresh?id=deviceid",
|
|
11
|
+
DeviceState: "/Device/Get?id=DID&buildingID=BID",
|
|
12
|
+
TileState: "/Tile/Get2?id=DID&buildingID=BID",
|
|
37
13
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
14
|
+
Post: {
|
|
15
|
+
ClientLogin: "/Login/ClientLogin",
|
|
16
|
+
Ata: "/Device/SetAta",
|
|
17
|
+
Atw: "/Device/SetAtw",
|
|
18
|
+
Erv: "/Device/SetErv",
|
|
19
|
+
UpdateApplicationOptions: "/User/UpdateApplicationOptions",
|
|
20
|
+
HolidayModeUpdate: "/HolidayMode/Update",
|
|
21
|
+
EnergyCostReport: "/EnergyCost/Report",
|
|
46
22
|
},
|
|
47
|
-
|
|
48
|
-
|
|
23
|
+
Home: {
|
|
24
|
+
Base: "https://melcloudhome.com",
|
|
25
|
+
WebSocket: "wss://ws.melcloudhome.com/?hash=",
|
|
26
|
+
Get: {
|
|
27
|
+
Configuration: "/api/configuration",
|
|
28
|
+
UserContext: "/api/user/context",
|
|
29
|
+
UserScenes: "/api/user/scenes",
|
|
30
|
+
},
|
|
31
|
+
Post: {
|
|
32
|
+
Schedule: "/api/cloudschedule/deviceid", // POST {"days":[2],"time":"17:59:00","enabled":true,"id":"53c5e804-0663-47d0-85c2-2d8ccd2573de","power":false,"operationMode":null,"setPoint":null,"vaneVerticalDirection":null,"vaneHorizontalDirection":null,"setFanSpeed":null}
|
|
33
|
+
ProtectionFrost: "/api/protection/frost", // POST {"enabled":true,"min":13,"max":16,"units":{"ATA":["ef333525-2699-4290-af5a-2922566676da"]}}
|
|
34
|
+
ProtectionOverheat: "/api/protection/overheat", // POST {"enabled":true,"min":32,"max":35,"units":{"ATA":["ef333525-2699-4290-af5a-2922566676da"]}}
|
|
35
|
+
HolidayMode: "/api/holidaymode", // POST {"enabled":true,"startDate":"2025-11-11T17:42:24.913","endDate":"2026-06-01T09:18:00","units":{"ATA":["ef333525-2699-4290-af5a-2922566676da"]}}
|
|
36
|
+
Scene: "/api/scene", // POST {"id": "8e484d50-528b-434a-9acb-7d7c81f06a12", "userId": "2db32d6f-c19c-4b1f-a0dd-1915420a5152","name": "Poza domem","enabled": false,"icon": "AwayIcon","ataSceneSettings": [{"unitId": "054dd950-f6e0-4195-bea7-59d8ea0668c2","ataSettings": { "power": false, "operationMode": "heat","setFanSpeed": "auto","vaneHorizontalDirection": "auto", "vaneVerticalDirection": "auto", "setTemperature": 21,"temperatureIncrementOverride": null,"inStandbyMode": null},"previousSettings": null}],"atwSceneSettings": []}
|
|
37
|
+
},
|
|
38
|
+
Put: {
|
|
39
|
+
Ata: "/api/ataunit/deviceid",
|
|
40
|
+
Atw: "/api/atwunit/deviceid",
|
|
41
|
+
Erv: "/api/ervunit/deviceid",
|
|
42
|
+
ScheduleEnableDisable: "/api/cloudschedule/deviceid/enabled", // PUT {"enabled":true}
|
|
43
|
+
SceneEnableDisable: "/api/scene/sceneid/enabledisable",
|
|
44
|
+
},
|
|
45
|
+
Delete: {
|
|
46
|
+
Schedule: "/api/cloudschedule/deviceid/scheduleid",
|
|
47
|
+
Scene: "/api/scene/sceneid"
|
|
48
|
+
},
|
|
49
|
+
Referers: {
|
|
50
|
+
GetPutScenes: "https://melcloudhome.com/scenes",
|
|
51
|
+
PostHolidayMode: "https://melcloudhome.com/ata/deviceid/holidaymode",
|
|
52
|
+
PostProtectionFrost: "https://melcloudhome.com/ata/deviceid/frostprotection",
|
|
53
|
+
PostProtectionOverheat: "https://melcloudhome.com/ata/deviceid/overheatprotection",
|
|
54
|
+
PutDeviceSettings: "https://melcloudhome.com/dashboard",
|
|
55
|
+
PutScheduleEnabled: "https://melcloudhome.com/ata/deviceid/schedule",
|
|
56
|
+
}
|
|
57
|
+
}
|
|
49
58
|
};
|
|
50
59
|
|
|
51
|
-
export const DeviceType =
|
|
52
|
-
"Air Conditioner",
|
|
53
|
-
"Heat Pump",
|
|
54
|
-
"Unknown",
|
|
55
|
-
"Energy Recovery Ventilation"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
export const TemperatureDisplayUnits = ["°C", "°F"];
|
|
60
|
+
export const DeviceType = {
|
|
61
|
+
0: "Air Conditioner",
|
|
62
|
+
1: "Heat Pump",
|
|
63
|
+
2: "Unknown",
|
|
64
|
+
3: "Energy Recovery Ventilation"
|
|
65
|
+
};
|
|
59
66
|
|
|
60
67
|
export const AirConditioner = {
|
|
61
68
|
SystemMapEnumToString: { 0: "Air Conditioner Off", 1: "Air Conditioner On", 2: "Air Conditioner Offline" },
|
|
@@ -183,6 +190,11 @@ export const Ventilation = {
|
|
|
183
190
|
}
|
|
184
191
|
};
|
|
185
192
|
|
|
193
|
+
export const TemperatureDisplayUnits = {
|
|
194
|
+
0: "°C",
|
|
195
|
+
1: "°F"
|
|
196
|
+
};
|
|
197
|
+
|
|
186
198
|
export const AccessLevel = {
|
|
187
199
|
Quest: 3,
|
|
188
200
|
Owner: 4
|
package/src/deviceata.js
CHANGED
|
@@ -518,8 +518,8 @@ class DeviceAta extends EventEmitter {
|
|
|
518
518
|
|
|
519
519
|
try {
|
|
520
520
|
this.accessory.useFahrenheit = value ? true : false;
|
|
521
|
-
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
522
521
|
this.accountInfo.UseFahrenheit = value ? true : false;
|
|
522
|
+
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
523
523
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'account', this.accountInfo);
|
|
524
524
|
} catch (error) {
|
|
525
525
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
@@ -611,8 +611,8 @@ class DeviceAta extends EventEmitter {
|
|
|
611
611
|
|
|
612
612
|
try {
|
|
613
613
|
this.accessory.useFahrenheit = value ? true : false;
|
|
614
|
-
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
615
614
|
this.accountInfo.UseFahrenheit = value ? true : false;
|
|
615
|
+
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
616
616
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'account', this.accountInfo);
|
|
617
617
|
} catch (error) {
|
|
618
618
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
package/src/deviceatw.js
CHANGED
|
@@ -641,8 +641,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
641
641
|
|
|
642
642
|
try {
|
|
643
643
|
this.accessory.useFahrenheit = value ? true : false;
|
|
644
|
-
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
645
644
|
this.accountInfo.UseFahrenheit = value ? true : false;
|
|
645
|
+
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
646
646
|
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, 'account', this.accountInfo);
|
|
647
647
|
} catch (error) {
|
|
648
648
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
@@ -822,8 +822,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
822
822
|
|
|
823
823
|
try {
|
|
824
824
|
this.accessory.useFahrenheit = value ? true : false;
|
|
825
|
-
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
826
825
|
this.accountInfo.UseFahrenheit = value ? true : false;
|
|
826
|
+
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
827
827
|
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, 'account', this.accountInfo);
|
|
828
828
|
} catch (error) {
|
|
829
829
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
package/src/deviceerv.js
CHANGED
|
@@ -450,8 +450,8 @@ class DeviceErv extends EventEmitter {
|
|
|
450
450
|
|
|
451
451
|
try {
|
|
452
452
|
this.accessory.useFahrenheit = value ? true : false;
|
|
453
|
-
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
454
453
|
this.accountInfo.UseFahrenheit = value ? true : false;
|
|
454
|
+
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
455
455
|
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, 'account', this.accountInfo);
|
|
456
456
|
} catch (error) {
|
|
457
457
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
@@ -544,8 +544,8 @@ class DeviceErv extends EventEmitter {
|
|
|
544
544
|
|
|
545
545
|
try {
|
|
546
546
|
this.accessory.useFahrenheit = value ? true : false;
|
|
547
|
-
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
548
547
|
this.accountInfo.UseFahrenheit = value ? true : false;
|
|
548
|
+
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
549
549
|
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, 'account', this.accountInfo);
|
|
550
550
|
} catch (error) {
|
|
551
551
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
package/src/melcloud.js
CHANGED
|
@@ -56,7 +56,7 @@ class MelCloud extends EventEmitter {
|
|
|
56
56
|
try {
|
|
57
57
|
const devicesList = { State: false, Info: null, Devices: [], Scenes: [] }
|
|
58
58
|
if (this.logDebug) this.emit('debug', `Scanning for devices...`);
|
|
59
|
-
const listDevicesData = await this.client(ApiUrls.ListDevices, { method: 'GET', });
|
|
59
|
+
const listDevicesData = await this.client(ApiUrls.Get.ListDevices, { method: 'GET', });
|
|
60
60
|
|
|
61
61
|
if (!listDevicesData || !listDevicesData.data) {
|
|
62
62
|
devicesList.Info = 'Invalid or empty response from MELCloud API'
|
|
@@ -132,9 +132,9 @@ class MelCloud extends EventEmitter {
|
|
|
132
132
|
CaptchaResponse: '',
|
|
133
133
|
Persist: true
|
|
134
134
|
};
|
|
135
|
-
const accountData = await axios(ApiUrls.ClientLogin, {
|
|
135
|
+
const accountData = await axios(ApiUrls.Post.ClientLogin, {
|
|
136
136
|
method: 'POST',
|
|
137
|
-
baseURL: ApiUrls.
|
|
137
|
+
baseURL: ApiUrls.Base,
|
|
138
138
|
timeout: 15000,
|
|
139
139
|
data: payload
|
|
140
140
|
});
|
|
@@ -164,7 +164,7 @@ class MelCloud extends EventEmitter {
|
|
|
164
164
|
};
|
|
165
165
|
|
|
166
166
|
this.client = axios.create({
|
|
167
|
-
baseURL: ApiUrls.
|
|
167
|
+
baseURL: ApiUrls.Base,
|
|
168
168
|
timeout: 30000,
|
|
169
169
|
headers: headers
|
|
170
170
|
});
|
package/src/melcloudata.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import EventEmitter from 'events';
|
|
2
2
|
import Functions from './functions.js';
|
|
3
|
-
import { ApiUrls,
|
|
3
|
+
import { ApiUrls, AirConditioner } from './constants.js';
|
|
4
4
|
|
|
5
5
|
class MelCloudAta extends EventEmitter {
|
|
6
6
|
constructor(account, device, defaultTempsFile, accountFile, melcloud) {
|
|
@@ -204,7 +204,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
204
204
|
case 'account':
|
|
205
205
|
flagData.Account.LoginData.UseFahrenheit = flagData.UseFahrenheit;
|
|
206
206
|
payload = { data: flagData.LoginData };
|
|
207
|
-
path = ApiUrls.UpdateApplicationOptions;
|
|
207
|
+
path = ApiUrls.Post.UpdateApplicationOptions;
|
|
208
208
|
await this.functions.saveData(this.accountFile, flagData);
|
|
209
209
|
break;
|
|
210
210
|
default:
|
|
@@ -230,7 +230,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
230
230
|
HideDryModeControl: deviceData.HideDryModeControl,
|
|
231
231
|
HasPendingCommand: true
|
|
232
232
|
};
|
|
233
|
-
path = ApiUrls.
|
|
233
|
+
path = ApiUrls.Post.Ata;
|
|
234
234
|
update = true;
|
|
235
235
|
break;
|
|
236
236
|
}
|
|
@@ -254,7 +254,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
254
254
|
units: { ATA: [deviceData.DeviceID] }
|
|
255
255
|
};
|
|
256
256
|
method = 'POST';
|
|
257
|
-
path =
|
|
257
|
+
path = ApiUrls.Home.Post.ProtectionFrost;
|
|
258
258
|
update = true;
|
|
259
259
|
break;
|
|
260
260
|
case 'overheatprotection':
|
|
@@ -265,7 +265,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
265
265
|
units: { ATA: [deviceData.DeviceID] }
|
|
266
266
|
};
|
|
267
267
|
method = 'POST';
|
|
268
|
-
path =
|
|
268
|
+
path = ApiUrls.Home.Post.ProtectionOverheat;
|
|
269
269
|
update = true;
|
|
270
270
|
break;
|
|
271
271
|
case 'holidaymode':
|
|
@@ -276,17 +276,17 @@ class MelCloudAta extends EventEmitter {
|
|
|
276
276
|
units: { ATA: [deviceData.DeviceID] }
|
|
277
277
|
};
|
|
278
278
|
method = 'POST';
|
|
279
|
-
path =
|
|
279
|
+
path = ApiUrls.Home.Post.HolidayMode;
|
|
280
280
|
break;
|
|
281
281
|
case 'schedule':
|
|
282
282
|
payload = { enabled: deviceData.ScheduleEnabled };
|
|
283
283
|
method = 'PUT';
|
|
284
|
-
path =
|
|
284
|
+
path = ApiUrls.Home.Put.ScheduleEnableDisable.Home.replace('deviceid', deviceData.DeviceID);
|
|
285
285
|
update = true;
|
|
286
286
|
break;
|
|
287
287
|
case 'scene':
|
|
288
288
|
method = 'PUT';
|
|
289
|
-
path =
|
|
289
|
+
path = `${ApiUrls.Home.Put.SceneEnableDisable.replace('sceneid', flagData.Id)}${flagData.Enabled ? 'enable' : 'disable'}`;
|
|
290
290
|
break;
|
|
291
291
|
default:
|
|
292
292
|
if (displayType === 1 && deviceData.Device.OperationMode === 8) {
|
|
@@ -312,7 +312,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
312
312
|
inStandbyMode: null
|
|
313
313
|
};
|
|
314
314
|
method = 'PUT';
|
|
315
|
-
path =
|
|
315
|
+
path = ApiUrls.Home.Put.Ata.replace('deviceid', deviceData.DeviceID);
|
|
316
316
|
break;
|
|
317
317
|
}
|
|
318
318
|
|
package/src/melcloudatw.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import EventEmitter from 'events';
|
|
2
2
|
import Functions from './functions.js';
|
|
3
|
-
import { ApiUrls,
|
|
3
|
+
import { ApiUrls, HeatPump } from './constants.js';
|
|
4
4
|
|
|
5
5
|
class MelCloudAtw extends EventEmitter {
|
|
6
6
|
constructor(account, device, defaultTempsFile, accountFile, melcloud) {
|
|
@@ -204,7 +204,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
204
204
|
case 'account':
|
|
205
205
|
flagData.Account.LoginData.UseFahrenheit = flagData.UseFahrenheit;
|
|
206
206
|
payload = { data: flagData.LoginData };
|
|
207
|
-
path = ApiUrls.UpdateApplicationOptions;
|
|
207
|
+
path = ApiUrls.Post.UpdateApplicationOptions;
|
|
208
208
|
await this.functions.saveData(this.accountFile, flagData);
|
|
209
209
|
break;
|
|
210
210
|
default:
|
|
@@ -231,7 +231,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
231
231
|
ProhibitHotWater: deviceData.Device.ProhibitHotWater,
|
|
232
232
|
HasPendingCommand: true
|
|
233
233
|
}
|
|
234
|
-
path = ApiUrls.
|
|
234
|
+
path = ApiUrls.Post.Atw;
|
|
235
235
|
update = true;
|
|
236
236
|
break;
|
|
237
237
|
}
|
|
@@ -255,7 +255,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
255
255
|
units: { ATA: [deviceData.DeviceID] }
|
|
256
256
|
};
|
|
257
257
|
method = 'POST';
|
|
258
|
-
path =
|
|
258
|
+
path = ApiUrls.Home.Post.ProtectionFrost;
|
|
259
259
|
update = true;
|
|
260
260
|
break;
|
|
261
261
|
case 'holidaymode':
|
|
@@ -266,17 +266,17 @@ class MelCloudAtw extends EventEmitter {
|
|
|
266
266
|
units: { ATW: [deviceData.DeviceID] }
|
|
267
267
|
};
|
|
268
268
|
method = 'POST';
|
|
269
|
-
path =
|
|
269
|
+
path = ApiUrls.Home.Post.HolidayMode;
|
|
270
270
|
break;
|
|
271
271
|
case 'schedule':
|
|
272
272
|
payload = { enabled: deviceData.ScheduleEnabled };
|
|
273
273
|
method = 'PUT';
|
|
274
|
-
path =
|
|
274
|
+
path = ApiUrls.Home.Put.ScheduleEnableDisable.Home.replace('deviceid', deviceData.DeviceID);
|
|
275
275
|
update = true;
|
|
276
276
|
break;
|
|
277
277
|
case 'scene':
|
|
278
278
|
method = 'PUT';
|
|
279
|
-
path =
|
|
279
|
+
path = `${ApiUrls.Home.Put.SceneEnableDisable.replace('sceneid', flagData.Id)}${flagData.Enabled ? 'enable' : 'disable'}`;
|
|
280
280
|
break;
|
|
281
281
|
default:
|
|
282
282
|
payload = {
|
|
@@ -295,7 +295,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
295
295
|
ecoHotWater: deviceData.Device.EcoHotWater,
|
|
296
296
|
};
|
|
297
297
|
method = 'PUT';
|
|
298
|
-
path =
|
|
298
|
+
path = ApiUrls.Home.Put.Atw.replace('deviceid', deviceData.DeviceID);
|
|
299
299
|
break
|
|
300
300
|
}
|
|
301
301
|
|
package/src/melclouderv.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import EventEmitter from 'events';
|
|
2
2
|
import Functions from './functions.js';
|
|
3
|
-
import { ApiUrls,
|
|
3
|
+
import { ApiUrls, Ventilation } from './constants.js';
|
|
4
4
|
|
|
5
5
|
class MelCloudErv extends EventEmitter {
|
|
6
6
|
constructor(account, device, defaultTempsFile, accountFile, melcloud) {
|
|
@@ -189,7 +189,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
189
189
|
case 'account':
|
|
190
190
|
flagData.Account.LoginData.UseFahrenheit = flagData.UseFahrenheit;
|
|
191
191
|
payload = { data: flagData.LoginData };
|
|
192
|
-
path = ApiUrls.UpdateApplicationOptions;
|
|
192
|
+
path = ApiUrls.Post.UpdateApplicationOptions;
|
|
193
193
|
await this.functions.saveData(this.accountFile, flagData);
|
|
194
194
|
break;
|
|
195
195
|
default:
|
|
@@ -231,7 +231,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
231
231
|
NightPurgeMode: deviceData.Device.NightPurgeMode,
|
|
232
232
|
HasPendingCommand: true
|
|
233
233
|
}
|
|
234
|
-
path = ApiUrls.
|
|
234
|
+
path = ApiUrls.Post.Erv;
|
|
235
235
|
update = true;
|
|
236
236
|
break;
|
|
237
237
|
}
|
|
@@ -255,17 +255,17 @@ class MelCloudErv extends EventEmitter {
|
|
|
255
255
|
units: { ERV: [deviceData.DeviceID] }
|
|
256
256
|
};
|
|
257
257
|
method = 'POST';
|
|
258
|
-
path =
|
|
258
|
+
path = ApiUrls.Home.Post.HolidayMode;
|
|
259
259
|
break;
|
|
260
260
|
case 'schedule':
|
|
261
261
|
payload = { enabled: deviceData.ScheduleEnabled };
|
|
262
262
|
method = 'PUT';
|
|
263
|
-
path =
|
|
263
|
+
path = ApiUrls.Home.Put.ScheduleEnableDisable.Home.replace('deviceid', deviceData.DeviceID);
|
|
264
264
|
update = true;
|
|
265
265
|
break;
|
|
266
266
|
case 'scene':
|
|
267
267
|
method = 'PUT';
|
|
268
|
-
path =
|
|
268
|
+
path = `${ApiUrls.Home.Put.SceneEnableDisable.replace('sceneid', flagData.Id)}${flagData.Enabled ? 'enable' : 'disable'}`;
|
|
269
269
|
break;
|
|
270
270
|
default:
|
|
271
271
|
if (displayType === 1 && deviceData.Device.VentilationMode === 2) {
|
|
@@ -288,7 +288,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
288
288
|
ventilationMode: Ventilation.VentilationModeMapEnumToString[deviceData.Device.VentilationMode],
|
|
289
289
|
};
|
|
290
290
|
method = 'PUT';
|
|
291
|
-
path =
|
|
291
|
+
path = ApiUrls.Home.Put.Erv.replace('deviceid', deviceData.DeviceID);
|
|
292
292
|
break
|
|
293
293
|
}
|
|
294
294
|
|
package/src/melcloudhome.js
CHANGED
|
@@ -6,7 +6,7 @@ import EventEmitter from 'events';
|
|
|
6
6
|
import puppeteer from 'puppeteer';
|
|
7
7
|
import ImpulseGenerator from './impulsegenerator.js';
|
|
8
8
|
import Functions from './functions.js';
|
|
9
|
-
import {
|
|
9
|
+
import { ApiUrls, LanguageLocaleMap } from './constants.js';
|
|
10
10
|
const execPromise = promisify(exec);
|
|
11
11
|
|
|
12
12
|
class MelCloudHome extends EventEmitter {
|
|
@@ -77,7 +77,7 @@ class MelCloudHome extends EventEmitter {
|
|
|
77
77
|
async checkScenesList() {
|
|
78
78
|
try {
|
|
79
79
|
if (this.logDebug) this.emit('debug', `Scanning for scenes`);
|
|
80
|
-
const listScenesData = await this.client(
|
|
80
|
+
const listScenesData = await this.client(ApiUrls.Home.Get.UserScenes, { method: 'GET', });
|
|
81
81
|
|
|
82
82
|
const scenesList = listScenesData.data;
|
|
83
83
|
if (this.logDebug) this.emit('debug', `Scenes: ${JSON.stringify(scenesList, null, 2)}`);
|
|
@@ -109,7 +109,7 @@ class MelCloudHome extends EventEmitter {
|
|
|
109
109
|
try {
|
|
110
110
|
const devicesList = { State: false, Info: null, Devices: [], Scenes: [] }
|
|
111
111
|
if (this.logDebug) this.emit('debug', `Scanning for devices`);
|
|
112
|
-
const listDevicesData = await this.client(
|
|
112
|
+
const listDevicesData = await this.client(ApiUrls.Home.Get.UserContext, { method: 'GET' });
|
|
113
113
|
|
|
114
114
|
const userContext = listDevicesData.data;
|
|
115
115
|
const buildings = userContext.buildings ?? [];
|
|
@@ -280,7 +280,7 @@ class MelCloudHome extends EventEmitter {
|
|
|
280
280
|
await client.send('Network.enable')
|
|
281
281
|
client.on('Network.webSocketCreated', ({ url }) => {
|
|
282
282
|
try {
|
|
283
|
-
if (url.startsWith(`${
|
|
283
|
+
if (url.startsWith(`${ApiUrls.Home.WebSocket}`)) {
|
|
284
284
|
const params = new URL(url).searchParams;
|
|
285
285
|
const hash = params.get('hash');
|
|
286
286
|
if (this.logDebug) this.emit('debug', `Web socket hash detected: ${hash}`);
|
|
@@ -291,11 +291,11 @@ class MelCloudHome extends EventEmitter {
|
|
|
291
291
|
|
|
292
292
|
try {
|
|
293
293
|
const headers = {
|
|
294
|
-
'Origin':
|
|
294
|
+
'Origin': ApiUrls.Home.Base,
|
|
295
295
|
'Pragma': 'no-cache',
|
|
296
296
|
'Cache-Control': 'no-cache'
|
|
297
297
|
};
|
|
298
|
-
const webSocket = new WebSocket(`${
|
|
298
|
+
const webSocket = new WebSocket(`${ApiUrls.Home.WebSocket}${hash}`, { headers: headers })
|
|
299
299
|
.on('error', (error) => {
|
|
300
300
|
if (this.logError) this.emit('error', `Web socket error: ${error}`);
|
|
301
301
|
try {
|
|
@@ -341,9 +341,9 @@ class MelCloudHome extends EventEmitter {
|
|
|
341
341
|
});
|
|
342
342
|
|
|
343
343
|
try {
|
|
344
|
-
await page.goto(
|
|
344
|
+
await page.goto(ApiUrls.Home.Base, { waitUntil: ['domcontentloaded', 'networkidle2'], timeout: GLOBAL_TIMEOUT });
|
|
345
345
|
} catch (error) {
|
|
346
|
-
accountInfo.Info = `Navigation to ${
|
|
346
|
+
accountInfo.Info = `Navigation to ${ApiUrls.Home.Base} failed: ${error.message}`;
|
|
347
347
|
return accountInfo;
|
|
348
348
|
}
|
|
349
349
|
|
|
@@ -405,7 +405,7 @@ class MelCloudHome extends EventEmitter {
|
|
|
405
405
|
'Accept-Language': LanguageLocaleMap[this.language],
|
|
406
406
|
'Cookie': cookies,
|
|
407
407
|
'Priority': 'u=3, i',
|
|
408
|
-
'Referer':
|
|
408
|
+
'Referer': ApiUrls.Home.Dashboard,
|
|
409
409
|
'Sec-Fetch-Dest': 'empty',
|
|
410
410
|
'Sec-Fetch-Mode': 'cors',
|
|
411
411
|
'Sec-Fetch-Site': 'same-origin',
|
|
@@ -414,7 +414,7 @@ class MelCloudHome extends EventEmitter {
|
|
|
414
414
|
};
|
|
415
415
|
|
|
416
416
|
this.client = axios.create({
|
|
417
|
-
baseURL:
|
|
417
|
+
baseURL: ApiUrls.Home.Base,
|
|
418
418
|
timeout: 30000,
|
|
419
419
|
headers: headers
|
|
420
420
|
})
|