homebridge-melcloud-control 4.0.0-beta.355 → 4.0.0-beta.357
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/melcloudhometoken.js +8 -4
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.357",
|
|
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/melcloudhometoken.js
CHANGED
|
@@ -112,8 +112,12 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
112
112
|
async loginToMelCloudHome(url) {
|
|
113
113
|
try {
|
|
114
114
|
|
|
115
|
+
const jar = new CookieJar();
|
|
116
|
+
const client = wrapper(axios.create({ jar, withCredentials: true }));
|
|
117
|
+
client.defaults.headers['User-Agent'] = MOBILE_USER_AGENT;
|
|
118
|
+
|
|
115
119
|
// --- Krok 1: GET strony logowania ---
|
|
116
|
-
const getResp = await
|
|
120
|
+
const getResp = await client.get(url, {
|
|
117
121
|
headers: { 'User-Agent': MOBILE_USER_AGENT }
|
|
118
122
|
});
|
|
119
123
|
|
|
@@ -128,7 +132,7 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
128
132
|
password: this.passwd
|
|
129
133
|
}).toString();
|
|
130
134
|
|
|
131
|
-
const postResp = await
|
|
135
|
+
const postResp = await client.post(url, formData, {
|
|
132
136
|
headers: {
|
|
133
137
|
'User-Agent': MOBILE_USER_AGENT,
|
|
134
138
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
@@ -142,7 +146,7 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
142
146
|
if (postResp.status === 400) throw new Error('Login failed');
|
|
143
147
|
|
|
144
148
|
// --- Krok 3: GET dashboard po zalogowaniu ---
|
|
145
|
-
const dashboardResp = await
|
|
149
|
+
const dashboardResp = await client.get('https://melcloudhome.com/dashboard', {
|
|
146
150
|
headers: { 'User-Agent': MOBILE_USER_AGENT }
|
|
147
151
|
});
|
|
148
152
|
|
|
@@ -151,7 +155,7 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
151
155
|
// Możemy zwrócić jako string do użycia w nagłówku:
|
|
152
156
|
const cookieHeader = dashboardCookies.map(c => `${c.key}=${c.value}`).join('; ');
|
|
153
157
|
|
|
154
|
-
this.emit('
|
|
158
|
+
this.emit('warn', `Cookies ${cookieHeader}`);
|
|
155
159
|
|
|
156
160
|
return dashboardCookies.map(c => `${c.key}=${c.value}`);
|
|
157
161
|
|