homebridge-melcloud-control 4.1.2-beta.40 → 4.1.2-beta.42

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.
@@ -273,41 +273,23 @@
273
273
 
274
274
  const deviceInConfig = devicesInConfig.find(dev => String(dev.id) === device.DeviceID);
275
275
  if (deviceInConfig) {
276
- if (account.type === 'melcloud') {
277
- const presets = device.Presets || [];
278
- presets.forEach((preset, index) => {
279
- const presetObj = {
280
- id: preset.ID,
281
- displayType: 0,
282
- name: preset.NumberDescription || `Preset ${index}`,
283
- namePrefix: false
284
- };
285
-
286
- const presetsInConfig = deviceInConfig.presets || [];
287
- if (!presetsInConfig.some(pres => String(pres.id) === preset.ID)) {
288
- presetsInConfig.push(presetObj);
289
- newPresets.push(presetObj);
290
- }
291
- });
292
- }
293
-
294
- if (account.type === 'melcloudhome') {
295
- const schedules = device.Schedule || [];
296
- schedules.forEach((schedule, index) => {
297
- const scheduleObj = {
298
- id: schedule.Id,
299
- displayType: 0,
300
- name: `Schedule ${index}`,
301
- namePrefix: false
302
- };
303
-
304
- const schedulesInConfig = deviceInConfig.schedules || [];
305
- if (!schedulesInConfig.some(sched => String(sched.id) === schedule.Id)) {
306
- schedulesInConfig.push(scheduleObj);
307
- newPresets.push(scheduleObj);
308
- }
309
- });
310
- }
276
+ const idKey = account.type === 'melcloud' ? 'ID' : 'Id';
277
+ const typeKey = account.type === 'melcloud' ? 'Presets' : 'Schedules';
278
+ const presets = device[typeKey] || [];
279
+ presets.forEach((preset, index) => {
280
+ const presetObj = {
281
+ id: preset[idKey],
282
+ displayType: 0,
283
+ name: preset.NumberDescription || `Schedule ${index}`,
284
+ namePrefix: false
285
+ };
286
+
287
+ const presetsInConfig = deviceInConfig.presets || [];
288
+ if (!presetsInConfig.some(pres => String(pres.id) === preset[idKey])) {
289
+ presetsInConfig.push(presetObj);
290
+ newPresets.push(presetObj);
291
+ }
292
+ });
311
293
  }
312
294
  });
313
295
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.1.2-beta.40",
4
+ "version": "4.1.2-beta.42",
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/functions.js CHANGED
@@ -116,7 +116,6 @@ class Functions extends EventEmitter {
116
116
  // === Linux (x64, Docker, QNAP etc.) ===
117
117
  if (osName === 'Linux') {
118
118
  try {
119
- // --- Try detect common Chromium binaries ---
120
119
  const { stdout: checkOut } = await execPromise('which chromium || which chromium-browser || true');
121
120
  chromiumPath = checkOut.trim();
122
121
  if (chromiumPath) {
@@ -148,6 +147,24 @@ class Functions extends EventEmitter {
148
147
  } catch (error) {
149
148
  if (this.logDebug) this.emit('debug', `Entware installation failed: ${error.message}`);
150
149
  }
150
+
151
+ // === 🔧 Additional dependency install for QNAP/Entware ===
152
+ try {
153
+ if (this.logDebug) this.emit('debug', 'Installing missing libraries required for Chromium (libnspr4, nss, X11, etc.)...');
154
+ await execPromise('/opt/bin/opkg install nspr nss libx11 libxcomposite libxdamage libxrandr libatk libatk-bridge libcups libdrm libgbm libasound');
155
+ if (this.logDebug) this.emit('debug', 'Chromium dependencies installed successfully.');
156
+ } catch (depErr) {
157
+ if (this.logError) this.emit('error', `Failed to install Chromium dependencies: ${depErr.message}`);
158
+ }
159
+
160
+ // Try again to locate Chromium
161
+ try {
162
+ const { stdout: checkOut } = await execPromise('which chromium || which chromium-browser || true');
163
+ chromiumPath = checkOut.trim() || '/opt/bin/chromium';
164
+ if (chromiumPath) {
165
+ return chromiumPath;
166
+ }
167
+ } catch { }
151
168
  }
152
169
 
153
170
  // --- Try install (Docker-optimized first) ---
@@ -182,10 +199,10 @@ class Functions extends EventEmitter {
182
199
  return null;
183
200
  }
184
201
  }
202
+
185
203
  return null;
186
204
  }
187
205
 
188
- // Unknown OS
189
206
  if (this.logDebug) this.emit('debug', `Unsupported OS: ${osName}.`);
190
207
  return null;
191
208
  } catch (error) {
@@ -195,5 +212,6 @@ class Functions extends EventEmitter {
195
212
  }
196
213
 
197
214
 
215
+
198
216
  }
199
217
  export default Functions