homebridge-melcloud-control 4.0.0-beta.34 → 4.0.0-beta.36

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.
@@ -76,6 +76,15 @@
76
76
  </select>
77
77
  </div>
78
78
 
79
+ <div class="mb-2">
80
+ <label for="accountType" class="form-label">Account Type</label>
81
+ <select id="accountType" name="accountType" class="form-control">
82
+ <option value="0">None/Disabled</option>
83
+ <option value="1">MELCloud</option>
84
+ <option value="2">MELCloud Home</option>
85
+ </select>
86
+ </div>
87
+
79
88
  <div class="text-center">
80
89
  <button id="logIn" type="button" class="btn btn-secondary">Connect to MELCloud</button>
81
90
  <button id="configButton" type="button" class="btn btn-secondary"><i class="fas fa-gear"></i></button>
@@ -119,7 +128,8 @@
119
128
  document.getElementById('user').value = acc.user || '';
120
129
  document.getElementById('passwd').value = acc.passwd || '';
121
130
  document.getElementById('language').value = acc.language || '';
122
- document.getElementById('logIn').disabled = !(acc.name && acc.user && acc.passwd && acc.language);
131
+ document.getElementById('accountType').value = acc.displaytype || '';
132
+ document.getElementById('logIn').disabled = !(acc.name && acc.user && acc.passwd && acc.language && acc.displaytype);
123
133
  this.deviceIndex = i;
124
134
  });
125
135
 
@@ -134,8 +144,9 @@
134
144
  acc.user = document.querySelector('#user').value;
135
145
  acc.passwd = document.querySelector('#passwd').value;
136
146
  acc.language = document.querySelector('#language').value;
147
+ acc.displaytype = document.querySelector('#accountType').value;
137
148
 
138
- document.getElementById('logIn').disabled = !(acc.name && acc.user && acc.passwd && acc.language);
149
+ document.getElementById('logIn').disabled = !(acc.name && acc.user && acc.passwd && acc.languaged && acc.displaytype);
139
150
 
140
151
  await homebridge.updatePluginConfig(pluginConfig);
141
152
  await homebridge.savePluginConfig(pluginConfig);
@@ -192,7 +203,7 @@
192
203
 
193
204
  try {
194
205
  const acc = pluginConfig[0].accounts[this.deviceIndex];
195
- const payload = { accountName: acc.name, user: acc.user, passwd: acc.passwd, language: acc.language };
206
+ const payload = { accountName: acc.name, user: acc.user, passwd: acc.passwd, language: acc.language, accountType: acc.displaytype };
196
207
  const devicesInMelCloud = await homebridge.request('/connect', payload);
197
208
 
198
209
  // Initialize devices arrays
@@ -17,10 +17,11 @@ class PluginUiServer extends HomebridgePluginUiServer {
17
17
  const user = payload.user;
18
18
  const passwd = payload.passwd;
19
19
  const language = payload.language;
20
+ const accountType = payload.accountType;
20
21
  const accountFile = `${this.homebridgeStoragePath}/melcloud/${accountName}_Account`;
21
22
  const buildingsFile = `${this.homebridgeStoragePath}/melcloud/${accountName}_Buildings`;
22
23
  const devicesFile = `${this.homebridgeStoragePath}/melcloud/${accountName}_Devices`;
23
- const melCloud = new MelCloud(user, passwd, language, accountFile, buildingsFile, devicesFile, false, true);
24
+ const melCloud = new MelCloud(accountType, user, passwd, language, accountFile, buildingsFile, devicesFile, false, true);
24
25
 
25
26
  try {
26
27
  const response = await melCloud.connect();
package/index.js CHANGED
@@ -107,10 +107,10 @@ class MelCloudPlatform {
107
107
  }
108
108
 
109
109
  const accountInfo = response.accountInfo ?? false;
110
- const contextKey = displayType === 1 ? response.contextKey : response;
110
+ const contextKey = response.contextKey;
111
111
  const useFahrenheit = response.useFahrenheit ?? false;
112
112
 
113
- if (contextKey === false) {
113
+ if (!contextKey) {
114
114
  return;
115
115
  }
116
116
 
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.34",
4
+ "version": "4.0.0-beta.36",
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
@@ -163,8 +163,6 @@ class MelCloud extends EventEmitter {
163
163
  }
164
164
 
165
165
  async checkMelcloudHomeDevicesList(cookies) {
166
- if (this.logDebug) this.emit('debug', `Connecting to MELCloud Home`);
167
-
168
166
  try {
169
167
  const c1 = cookies.c1.trim();
170
168
  const c2 = cookies.c2.trim();
@@ -177,7 +175,7 @@ class MelCloud extends EventEmitter {
177
175
 
178
176
  const axiosInstance = axios.create({
179
177
  baseURL: ApiUrlsHome.BaseURL,
180
- timeout: 10000,
178
+ timeout: 20000,
181
179
  httpsAgent: new Agent({
182
180
  keepAlive: false,
183
181
  rejectUnauthorized: false
@@ -276,12 +274,15 @@ class MelCloud extends EventEmitter {
276
274
  if (this.logWarn) this.emit('warn', `Cookies C1/C2 missing`);
277
275
  return null;
278
276
  }
279
- const cookies = { c1, c2 };
280
- this.contextKey = cookies;
277
+
278
+ const accountInfo = {};
279
+ const contextKey = { c1, c2 };
280
+ const useFahrenheit = false;
281
+ this.contextKey = contextKey;
281
282
 
282
283
  this.emit('success', `Connect to MELCloud Home Success`);
283
284
 
284
- return cookies;
285
+ return { accountInfo, contextKey, useFahrenheit };
285
286
  } catch (error) {
286
287
  throw new Error(`Connect to MELCloud Home error: ${error.message}`);
287
288
  } finally {