homebridge-midea-platform 1.2.6-beta.8 → 1.2.6-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.
@@ -199,6 +199,7 @@
199
199
  createForm(configSchema, configuration);
200
200
  homebridge.hideSpinner();
201
201
 
202
+ const main = document.getElementById('main');
202
203
  const loginSection = document.getElementById('login')
203
204
  const userPass = document.getElementById('userPass');
204
205
 
@@ -304,11 +305,13 @@
304
305
  <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
305
306
  </div>
306
307
  <div class="modal-body">
307
- <div class="mb-3">
308
- <button id="copyLuaBtn" class="btn btn-primary">Copy to Clipboard</button>
309
- <small class="text-muted ms-2">Save this as ${device.type.toString(16)}_${device.model}.lua</small>
308
+ <div class="mb-3 btn-toolbar">
309
+ <div class="btn-group me-2">
310
+ <button id="selectAllLuaBtn" class="btn btn-secondary">Select All</button>
311
+ </div>
312
+ <small class="text-warning ms-2 align-self-center">Save this as ${device.type.toString(16)}_${device.model}.lua</small>
310
313
  </div>
311
- <pre style="max-height: 500px; overflow-y: auto; white-space: pre-wrap; word-break: break-all;">${file_data_str}</pre>
314
+ <pre id="luaCodePre"><code style="color: var(--bs-body-color);">${file_data_str}</code></pre>
312
315
  </div>
313
316
  <div class="modal-footer">
314
317
  <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
@@ -317,25 +320,25 @@
317
320
  </div>
318
321
  `;
319
322
 
320
- document.body.appendChild(modal);
323
+ main.appendChild(modal);
321
324
 
322
325
  // Initialize the Bootstrap modal
323
326
  const bootstrapModal = new bootstrap.Modal(modal);
324
327
  bootstrapModal.show();
325
328
 
326
- // Add event listener for the copy button
327
- document.getElementById('copyLuaBtn').addEventListener('click', async () => {
328
- try {
329
- await navigator.clipboard.writeText(file_data_str);
330
- homebridge.toast.success('Lua code copied to clipboard!');
331
- } catch (e) {
332
- homebridge.toast.error('Failed to copy to clipboard. Please select and copy the code manually.');
333
- }
329
+ document.getElementById('selectAllLuaBtn').addEventListener('click', () => {
330
+ const codeElement = document.getElementById('luaCodePre');
331
+ const selection = window.getSelection();
332
+ const range = document.createRange();
333
+
334
+ range.selectNodeContents(codeElement);
335
+ selection.removeAllRanges();
336
+ selection.addRange(range);
334
337
  });
335
338
 
336
339
  // Clean up when modal is hidden
337
340
  modal.addEventListener('hidden.bs.modal', () => {
338
- document.body.removeChild(modal);
341
+ main.removeChild(modal);
339
342
  });
340
343
 
341
344
  homebridge.hideSpinner();
@@ -253,8 +253,10 @@ class UiServer extends HomebridgePluginUiServer {
253
253
  msg: 'Start device discovery',
254
254
  });
255
255
  // If IP addresses provided then probe them directly
256
- for (const ip of ipAddrs) {
257
- discover.discoverDeviceByIP(ip);
256
+ if (ipAddrs && ipAddrs.length > 0) {
257
+ for (const ip of ipAddrs) {
258
+ discover.discoverDeviceByIP(ip);
259
+ }
258
260
  }
259
261
  // And then send broadcast to network(s)
260
262
  discover.startDiscover();
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "displayName": "Homebridge Midea Platform",
3
3
  "name": "homebridge-midea-platform",
4
4
  "type": "module",
5
- "version": "1.2.6-beta.8",
5
+ "version": "1.2.6-beta.9",
6
6
  "description": "Homebridge plugin for Midea devices",
7
7
  "license": "Apache-2.0",
8
8
  "repository": {