homebridge-melcloud-control 4.0.0-beta.59 → 4.0.0-beta.60

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.
@@ -104,8 +104,7 @@
104
104
  return;
105
105
  }
106
106
 
107
- this.deviceIndex = 0;
108
-
107
+ this.accountIndex = 0;
109
108
  const accountsCount = pluginConfig[0].accounts.length;
110
109
  for (let i = 0; i < accountsCount; i++) {
111
110
  const button = document.createElement("button");
@@ -129,7 +128,7 @@
129
128
  document.getElementById('language').value = acc.language || '0';
130
129
  document.getElementById('displayType').value = acc.displayType || 'disabled';
131
130
  document.getElementById('logIn').disabled = !(acc.name && acc.user && acc.passwd && acc.language && acc.displayType);
132
- this.deviceIndex = i;
131
+ this.accountIndex = i;
133
132
  });
134
133
 
135
134
  if (i === accountsCount - 1) document.getElementById(`button0`).click();
@@ -138,7 +137,7 @@
138
137
  document.getElementById('melCloudAccount').style.display = 'block';
139
138
 
140
139
  document.getElementById('configForm').addEventListener('input', async () => {
141
- const acc = pluginConfig[0].accounts[this.deviceIndex];
140
+ const acc = pluginConfig[0].accounts[this.accountIndex];
142
141
  acc.name = document.querySelector('#name').value;
143
142
  acc.user = document.querySelector('#user').value;
144
143
  acc.passwd = document.querySelector('#passwd').value;
@@ -201,7 +200,7 @@
201
200
  updateInfo('info', 'Connecting...', 'yellow');
202
201
 
203
202
  try {
204
- const acc = pluginConfig[0].accounts[this.deviceIndex];
203
+ const acc = pluginConfig[0].accounts[this.accountIndex];
205
204
  const payload = { accountName: acc.name, user: acc.user, passwd: acc.passwd, language: acc.language, displayType: acc.displayType };
206
205
  const devicesInMelCloud = await homebridge.request('/connect', payload);
207
206
 
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.59",
4
+ "version": "4.0.0-beta.60",
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
@@ -206,10 +206,9 @@ class MelCloud extends EventEmitter {
206
206
 
207
207
  // Funkcja tworząca finalny obiekt Device
208
208
  const createDevice = (device, type) => {
209
- // Upewniamy się, że Settings jest tablicą
209
+ // Settings już kapitalizowane w nazwach
210
210
  const settingsArray = device.Settings || [];
211
211
 
212
- // Zamiana settings na obiekt z poprawnymi typami
213
212
  const settingsObject = Object.fromEntries(
214
213
  settingsArray.map(({ name, value }) => {
215
214
  let parsedValue = value;
@@ -222,7 +221,7 @@ class MelCloud extends EventEmitter {
222
221
  })
223
222
  );
224
223
 
225
- // Scal Capabilities + Settings + DeviceType w Device, kapitalizując Capabilities
224
+ // Scal Capabilities + Settings + DeviceType w Device
226
225
  const deviceObject = {
227
226
  ...capitalizeKeys(device.Capabilities || {}),
228
227
  ...settingsObject,
@@ -234,6 +233,7 @@ class MelCloud extends EventEmitter {
234
233
 
235
234
  return {
236
235
  ...rest,
236
+ Type: type, // <-- Type na głównym poziomie według źródła
237
237
  DeviceID: Id,
238
238
  DeviceName: GivenDisplayName,
239
239
  Device: deviceObject
@@ -254,6 +254,13 @@ class MelCloud extends EventEmitter {
254
254
  }
255
255
 
256
256
 
257
+ // Jeśli nie ma urządzeń
258
+ if (devices.length === 0) {
259
+ if (this.logWarn) this.emit('warn', `No devices found`);
260
+ return null;
261
+ }
262
+
263
+
257
264
  await this.functions.saveData(this.devicesFile, devices);
258
265
  if (this.logDebug) this.emit('debug', `${devices.length} devices saved`);
259
266