@homebridge-plugins/homebridge-ecovacs 8.1.4 → 8.2.0-beta.0
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/CHANGELOG.md +6 -0
- package/dist/homebridge-ui/public/index.html +295 -3
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@homebridge-plugins/homebridge-ecovacs` will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## v8.2.0 (Pending Release)
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- feat(ui): add, remove and hide devices from the config via the my devices tab
|
|
10
|
+
|
|
5
11
|
## v8.1.4 (2026-07-19)
|
|
6
12
|
|
|
7
13
|
### Changed
|
|
@@ -19,6 +19,22 @@
|
|
|
19
19
|
color: #eeeeee !important;
|
|
20
20
|
font-weight: 500 !important;
|
|
21
21
|
}
|
|
22
|
+
|
|
23
|
+
.list-group-item {
|
|
24
|
+
background-color: #333333;
|
|
25
|
+
border-color: #444444;
|
|
26
|
+
color: #eeeeee;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.text-muted {
|
|
30
|
+
color: #aaaaaa !important;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
.min-w-50 {
|
|
34
|
+
min-width: 50px;
|
|
35
|
+
}
|
|
36
|
+
.action-desc {
|
|
37
|
+
font-size: 0.85rem;
|
|
22
38
|
}
|
|
23
39
|
select {
|
|
24
40
|
background-image:
|
|
@@ -76,11 +92,46 @@
|
|
|
76
92
|
<!-- HAP device view (useMatter: false) -->
|
|
77
93
|
<div id="deviceInfo">
|
|
78
94
|
<form>
|
|
79
|
-
<div class="form-group">
|
|
95
|
+
<div class="form-group mb-0">
|
|
80
96
|
<select class="form-control" id="deviceSelect"></select>
|
|
81
97
|
</div>
|
|
82
98
|
</form>
|
|
83
|
-
<
|
|
99
|
+
<ul class="list-group mt-4 mb-4 mx-0" id="configActionList" style="display: none">
|
|
100
|
+
<li class="list-group-item">
|
|
101
|
+
<div class="d-flex justify-content-between align-items-center">
|
|
102
|
+
<div class="pr-2">
|
|
103
|
+
<div>Add All Devices</div>
|
|
104
|
+
<div class="text-muted action-desc">Add all devices to the config that are not already in the config.</div>
|
|
105
|
+
</div>
|
|
106
|
+
<button type="button" class="btn btn-primary m-0 ml-3 py-1 min-w-50" id="addAllBtn" aria-label="Add all devices to the config">
|
|
107
|
+
<i aria-hidden="true" class="fas fa-arrow-right"></i>
|
|
108
|
+
</button>
|
|
109
|
+
</div>
|
|
110
|
+
</li>
|
|
111
|
+
<li class="list-group-item">
|
|
112
|
+
<div class="d-flex justify-content-between align-items-center">
|
|
113
|
+
<div class="pr-2">
|
|
114
|
+
<div id="deviceConfigTitle">Add This Device</div>
|
|
115
|
+
<div class="text-muted action-desc" id="deviceConfigText">Add this device to the plugin config.</div>
|
|
116
|
+
</div>
|
|
117
|
+
<button type="button" class="btn btn-primary m-0 ml-3 py-1 min-w-50" id="deviceConfigBtn" aria-label="Add this device to the config">
|
|
118
|
+
<i aria-hidden="true" class="fas fa-arrow-right"></i>
|
|
119
|
+
</button>
|
|
120
|
+
</div>
|
|
121
|
+
</li>
|
|
122
|
+
<li class="list-group-item">
|
|
123
|
+
<div class="d-flex justify-content-between align-items-center">
|
|
124
|
+
<div class="pr-2">
|
|
125
|
+
<div id="hideDeviceTitle">Hide This Device</div>
|
|
126
|
+
<div class="text-muted action-desc" id="hideDeviceText">Hide this device from HomeKit. This adds the device to the config if needed.</div>
|
|
127
|
+
</div>
|
|
128
|
+
<button type="button" class="btn btn-primary m-0 ml-3 py-1 min-w-50" id="hideDeviceBtn" aria-label="Hide this device from HomeKit">
|
|
129
|
+
<i aria-hidden="true" class="fas fa-arrow-right"></i>
|
|
130
|
+
</button>
|
|
131
|
+
</div>
|
|
132
|
+
</li>
|
|
133
|
+
</ul>
|
|
134
|
+
<table class="table w-100 mt-0" id="deviceTable" style="display: none">
|
|
84
135
|
<thead>
|
|
85
136
|
<tr class="table-active">
|
|
86
137
|
<th scope="col" style="width: 40%">Device Name</th>
|
|
@@ -260,6 +311,238 @@
|
|
|
260
311
|
(async () => {
|
|
261
312
|
try {
|
|
262
313
|
const currentConfig = await homebridge.getPluginConfig();
|
|
314
|
+
|
|
315
|
+
// ===== Device picker (add/remove/hide config entries from the My Devices tab) =====
|
|
316
|
+
// The control state is always computed from a fresh getPluginConfig() call,
|
|
317
|
+
// so staged-but-unsaved edits made in the Settings tab are respected
|
|
318
|
+
let pickerAccessories = [];
|
|
319
|
+
let removeConfirmTimer;
|
|
320
|
+
|
|
321
|
+
// The action buttons always show the settings-page arrow; the row text
|
|
322
|
+
// (and the button's aria-label) says what the arrow will do
|
|
323
|
+
const actionArrow = '<i aria-hidden="true" class="fas fa-arrow-right"></i>';
|
|
324
|
+
|
|
325
|
+
// The platform matches device ids exactly (only whitespace is stripped),
|
|
326
|
+
// so the picker mirrors that rather than a looser comparison
|
|
327
|
+
const cleanId = (id) => (id || "").toString().replace(/\s+/g, "");
|
|
328
|
+
|
|
329
|
+
const getConfigBlocks = async () => {
|
|
330
|
+
const blocks = await homebridge.getPluginConfig();
|
|
331
|
+
if (!blocks.length) {
|
|
332
|
+
blocks.push({ name: "Deebot" });
|
|
333
|
+
}
|
|
334
|
+
return blocks;
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
const findInConfig = (config, deviceId) => {
|
|
338
|
+
const target = cleanId(deviceId);
|
|
339
|
+
if (!Array.isArray(config.devices)) {
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
const index = config.devices.findIndex(
|
|
343
|
+
(entry) => entry && cleanId(entry.deviceId) === target,
|
|
344
|
+
);
|
|
345
|
+
return index === -1 ? null : { index };
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
const selectedAccessory = () => {
|
|
349
|
+
const deviceId = document.getElementById("deviceSelect").value;
|
|
350
|
+
return pickerAccessories.find((x) => x.context.ecoDeviceId === deviceId);
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
const setHideControl = (hidden) => {
|
|
354
|
+
const btn = document.getElementById("hideDeviceBtn");
|
|
355
|
+
btn.dataset.hidden = hidden ? "yes" : "no";
|
|
356
|
+
btn.innerHTML = actionArrow;
|
|
357
|
+
btn.setAttribute(
|
|
358
|
+
"aria-label",
|
|
359
|
+
hidden ? "Show this device in HomeKit" : "Hide this device from HomeKit",
|
|
360
|
+
);
|
|
361
|
+
document.getElementById("hideDeviceTitle").innerHTML = hidden
|
|
362
|
+
? "Show This Device"
|
|
363
|
+
: "Hide This Device";
|
|
364
|
+
document.getElementById("hideDeviceText").innerHTML = hidden
|
|
365
|
+
? "Show this device in HomeKit again. The config entry is kept."
|
|
366
|
+
: "Hide this device from HomeKit. This adds the device to the config if needed.";
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
const setConfigButton = (inConfig) => {
|
|
370
|
+
const btn = document.getElementById("deviceConfigBtn");
|
|
371
|
+
clearTimeout(removeConfirmTimer);
|
|
372
|
+
delete btn.dataset.confirm;
|
|
373
|
+
btn.dataset.state = inConfig ? "remove" : "add";
|
|
374
|
+
btn.classList.remove("btn-danger");
|
|
375
|
+
btn.classList.add("btn-primary");
|
|
376
|
+
btn.innerHTML = actionArrow;
|
|
377
|
+
btn.setAttribute(
|
|
378
|
+
"aria-label",
|
|
379
|
+
inConfig ? "Remove this device from the config" : "Add this device to the config",
|
|
380
|
+
);
|
|
381
|
+
document.getElementById("deviceConfigTitle").innerHTML = inConfig
|
|
382
|
+
? "Remove This Device"
|
|
383
|
+
: "Add This Device";
|
|
384
|
+
document.getElementById("deviceConfigText").innerHTML = inConfig
|
|
385
|
+
? "Remove this device from the plugin config."
|
|
386
|
+
: "Add this device to the plugin config.";
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
const addDeviceToConfig = (config, acc) => {
|
|
390
|
+
if (!Array.isArray(config.devices)) {
|
|
391
|
+
config.devices = [];
|
|
392
|
+
}
|
|
393
|
+
// label is included so the entry is identifiable in the config editor
|
|
394
|
+
config.devices.push({
|
|
395
|
+
label: acc.displayName,
|
|
396
|
+
deviceId: acc.context.ecoDeviceId,
|
|
397
|
+
});
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
document.getElementById("deviceConfigBtn").addEventListener("click", async () => {
|
|
401
|
+
try {
|
|
402
|
+
const btn = document.getElementById("deviceConfigBtn");
|
|
403
|
+
const acc = selectedAccessory();
|
|
404
|
+
if (!acc) {
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
const blocks = await getConfigBlocks();
|
|
408
|
+
const config = blocks[0];
|
|
409
|
+
const found = findInConfig(config, acc.context.ecoDeviceId);
|
|
410
|
+
if (btn.dataset.state === "add") {
|
|
411
|
+
// The config may have changed since the button was drawn, so
|
|
412
|
+
// re-check and never add a duplicate - just correct the button
|
|
413
|
+
if (found) {
|
|
414
|
+
setConfigButton(true);
|
|
415
|
+
setHideControl(!!config.devices[found.index].ignoreDevice);
|
|
416
|
+
homebridge.toast.info(acc.displayName + " is already in the config.", "Not Added");
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
addDeviceToConfig(config, acc);
|
|
420
|
+
await homebridge.updatePluginConfig(blocks);
|
|
421
|
+
setConfigButton(true);
|
|
422
|
+
setHideControl(false);
|
|
423
|
+
homebridge.toast.success(acc.displayName + " added - press Save to apply.", "Added To Config");
|
|
424
|
+
} else {
|
|
425
|
+
if (!found) {
|
|
426
|
+
setConfigButton(false);
|
|
427
|
+
setHideControl(false);
|
|
428
|
+
homebridge.toast.info(acc.displayName + " is not in the config.", "Not Removed");
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
const entry = config.devices[found.index];
|
|
432
|
+
const extraKeys = Object.keys(entry).filter(
|
|
433
|
+
(k) => !["deviceId", "label"].includes(k),
|
|
434
|
+
);
|
|
435
|
+
if (extraKeys.length > 0 && btn.dataset.confirm !== "yes") {
|
|
436
|
+
// The entry has settings beyond id and label which would be
|
|
437
|
+
// lost, so ask for a second click within five seconds
|
|
438
|
+
btn.dataset.confirm = "yes";
|
|
439
|
+
btn.classList.remove("btn-primary");
|
|
440
|
+
btn.classList.add("btn-danger");
|
|
441
|
+
btn.innerHTML = actionArrow;
|
|
442
|
+
btn.setAttribute("aria-label", "Confirm removing this device from the config");
|
|
443
|
+
document.getElementById("deviceConfigText").innerHTML =
|
|
444
|
+
"This entry has extra settings which will be lost. Click again to remove it.";
|
|
445
|
+
removeConfirmTimer = setTimeout(() => setConfigButton(true), 5000);
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
config.devices.splice(found.index, 1);
|
|
449
|
+
if (config.devices.length === 0) {
|
|
450
|
+
delete config.devices;
|
|
451
|
+
}
|
|
452
|
+
await homebridge.updatePluginConfig(blocks);
|
|
453
|
+
setConfigButton(false);
|
|
454
|
+
setHideControl(false);
|
|
455
|
+
homebridge.toast.success(acc.displayName + " removed - press Save to apply.", "Removed From Config");
|
|
456
|
+
}
|
|
457
|
+
} catch (err) {
|
|
458
|
+
homebridge.toast.error(err.message, "Error");
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
document.getElementById("hideDeviceBtn").addEventListener("click", async () => {
|
|
463
|
+
try {
|
|
464
|
+
const acc = selectedAccessory();
|
|
465
|
+
if (!acc) {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
const blocks = await getConfigBlocks();
|
|
469
|
+
const config = blocks[0];
|
|
470
|
+
let found = findInConfig(config, acc.context.ecoDeviceId);
|
|
471
|
+
const currentlyHidden =
|
|
472
|
+
document.getElementById("hideDeviceBtn").dataset.hidden === "yes";
|
|
473
|
+
if (!currentlyHidden) {
|
|
474
|
+
// Hiding needs a config entry to carry the flag, so create one if
|
|
475
|
+
// the device is not in the config yet
|
|
476
|
+
if (!found) {
|
|
477
|
+
addDeviceToConfig(config, acc);
|
|
478
|
+
found = findInConfig(config, acc.context.ecoDeviceId);
|
|
479
|
+
}
|
|
480
|
+
config.devices[found.index].ignoreDevice = true;
|
|
481
|
+
await homebridge.updatePluginConfig(blocks);
|
|
482
|
+
setConfigButton(true);
|
|
483
|
+
setHideControl(true);
|
|
484
|
+
homebridge.toast.success(
|
|
485
|
+
acc.displayName + " will be hidden from HomeKit - press Save to apply.",
|
|
486
|
+
"Device Hidden",
|
|
487
|
+
);
|
|
488
|
+
} else {
|
|
489
|
+
if (found) {
|
|
490
|
+
// Drop the flag rather than storing ignoreDevice false, to keep
|
|
491
|
+
// the entry clean
|
|
492
|
+
delete config.devices[found.index].ignoreDevice;
|
|
493
|
+
await homebridge.updatePluginConfig(blocks);
|
|
494
|
+
}
|
|
495
|
+
setConfigButton(!!found);
|
|
496
|
+
setHideControl(false);
|
|
497
|
+
homebridge.toast.success(
|
|
498
|
+
acc.displayName + " will be shown in HomeKit - press Save to apply.",
|
|
499
|
+
"Device Unhidden",
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
} catch (err) {
|
|
503
|
+
homebridge.toast.error(err.message, "Error");
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
document.getElementById("addAllBtn").addEventListener("click", async () => {
|
|
508
|
+
try {
|
|
509
|
+
const blocks = await getConfigBlocks();
|
|
510
|
+
const config = blocks[0];
|
|
511
|
+
let added = 0;
|
|
512
|
+
let skipped = 0;
|
|
513
|
+
pickerAccessories.forEach((acc) => {
|
|
514
|
+
if (!acc.context?.ecoDeviceId) {
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
if (findInConfig(config, acc.context.ecoDeviceId)) {
|
|
518
|
+
skipped += 1;
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
addDeviceToConfig(config, acc);
|
|
522
|
+
added += 1;
|
|
523
|
+
});
|
|
524
|
+
if (added > 0) {
|
|
525
|
+
await homebridge.updatePluginConfig(blocks);
|
|
526
|
+
homebridge.toast.success(
|
|
527
|
+
added + " device(s) added, " + skipped + " already in the config - press Save to apply.",
|
|
528
|
+
"Added To Config",
|
|
529
|
+
);
|
|
530
|
+
} else {
|
|
531
|
+
homebridge.toast.info("All devices are already in the config.", "Nothing To Add");
|
|
532
|
+
}
|
|
533
|
+
const acc = selectedAccessory();
|
|
534
|
+
if (acc) {
|
|
535
|
+
const nowFound = findInConfig(config, acc.context.ecoDeviceId);
|
|
536
|
+
setConfigButton(!!nowFound);
|
|
537
|
+
if (nowFound) {
|
|
538
|
+
setHideControl(!!config.devices[nowFound.index].ignoreDevice);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
} catch (err) {
|
|
542
|
+
homebridge.toast.error(err.message, "Error");
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
// ===== End device picker =====
|
|
263
546
|
showIntro = () => {
|
|
264
547
|
homebridge.disableSaveButton?.();
|
|
265
548
|
const introContinue = document.getElementById("introContinue");
|
|
@@ -274,7 +557,9 @@
|
|
|
274
557
|
};
|
|
275
558
|
showDevices = async () => {
|
|
276
559
|
homebridge.showSpinner();
|
|
277
|
-
|
|
560
|
+
// The save button stays enabled here so entries staged by the picker
|
|
561
|
+
// buttons can be saved without switching back to the Settings tab
|
|
562
|
+
homebridge.enableSaveButton?.();
|
|
278
563
|
homebridge.hideSchemaForm();
|
|
279
564
|
document.getElementById("menuHome").classList.remove("btn-elegant");
|
|
280
565
|
document.getElementById("menuHome").classList.add("btn-primary");
|
|
@@ -382,6 +667,7 @@
|
|
|
382
667
|
: 0;
|
|
383
668
|
});
|
|
384
669
|
}
|
|
670
|
+
pickerAccessories = cachedAccessories;
|
|
385
671
|
const deviceSelect = document.getElementById("deviceSelect");
|
|
386
672
|
deviceSelect.innerHTML = "";
|
|
387
673
|
cachedAccessories.forEach((a) => {
|
|
@@ -421,6 +707,11 @@
|
|
|
421
707
|
: "";
|
|
422
708
|
document.getElementById("deviceTable").style.display =
|
|
423
709
|
"inline-table";
|
|
710
|
+
const configBlocks = await getConfigBlocks();
|
|
711
|
+
const configEntry = findInConfig(configBlocks[0], context.ecoDeviceId);
|
|
712
|
+
setConfigButton(!!configEntry);
|
|
713
|
+
setHideControl(!!(configEntry && configBlocks[0].devices[configEntry.index].ignoreDevice));
|
|
714
|
+
document.getElementById("configActionList").style.display = "block";
|
|
424
715
|
homebridge.hideSpinner();
|
|
425
716
|
};
|
|
426
717
|
deviceSelect.addEventListener("change", (event) =>
|
|
@@ -433,6 +724,7 @@
|
|
|
433
724
|
option.text = "No Devices";
|
|
434
725
|
deviceSelect.add(option);
|
|
435
726
|
deviceSelect.disabled = true;
|
|
727
|
+
document.getElementById("configActionList").style.display = "none";
|
|
436
728
|
}
|
|
437
729
|
}
|
|
438
730
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"displayName": "Homebridge Ecovacs",
|
|
4
4
|
"alias": "Deebot",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "8.
|
|
6
|
+
"version": "8.2.0-beta.0",
|
|
7
7
|
"description": "Homebridge plugin to integrate Ecovacs Deebot/Yeedi devices into HomeKit.",
|
|
8
8
|
"author": {
|
|
9
9
|
"name": "bwp91",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"keywords": [
|
|
40
40
|
"homebridge",
|
|
41
41
|
"homebridge-plugin",
|
|
42
|
+
"supports-matter",
|
|
42
43
|
"homebridge-deebot",
|
|
43
44
|
"homebridge-ecovacs",
|
|
44
45
|
"hoobs",
|