v1.8.9: Z2M Geräte-Dropdown für Überschuss-Steuerung

- MQTT Subscribe auf zigbee2mqtt/bridge/devices beim Connect
- Neuer Endpoint GET /api/z2m-devices liefert Friendly Names + Beschreibung
- Eingabefeld für Z2M Name als Datalist-Combo (tippen oder aus Liste wählen)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
retr0
2026-05-04 10:57:52 +02:00
parent 83035fed0e
commit 10e21f031a
3 changed files with 59 additions and 2 deletions
+14 -2
View File
@@ -335,6 +335,7 @@
</div>
</div>
<datalist id="z2m-device-list"></datalist>
<div class="toast" id="toast"></div>
<script>
@@ -992,7 +993,7 @@ function renderSurplusDeviceRow(dev) {
return `<div class="surplus-device-row" data-id="${esc(id)}">
<div style="display:flex;gap:8px;flex-wrap:wrap;align-items:center">
<input type="text" placeholder="Name" style="flex:1;min-width:110px" value="${esc(dev.name||'')}" data-field="name">
<input type="text" placeholder="Z2M Friendly Name" style="flex:1;min-width:140px" value="${esc(dev.z2m_name||'')}" data-field="z2m_name">
<input type="text" placeholder="Z2M Friendly Name" list="z2m-device-list" style="flex:1;min-width:140px" value="${esc(dev.z2m_name||'')}" data-field="z2m_name">
<input type="number" placeholder="Ab (W)" title="Schwellwert" style="width:76px" value="${dev.threshold_w||500}" min="0" step="50" data-field="threshold_w">
<input type="number" placeholder="Hysterese (W)" title="Hysterese" style="width:90px" value="${dev.hysteresis_w||150}" min="0" step="50" data-field="hysteresis_w">
<label style="cursor:pointer;display:flex;align-items:center;gap:4px;font-size:12px;white-space:nowrap">
@@ -1003,8 +1004,19 @@ function renderSurplusDeviceRow(dev) {
</div>`;
}
async function loadZ2mDevices() {
const devices = await fetchJSON(api("api/z2m-devices")).catch(() => []);
const dl = document.getElementById("z2m-device-list");
dl.innerHTML = devices.map(d =>
`<option value="${esc(d.friendly_name)}">${esc(d.friendly_name)}${d.description ? ' — ' + esc(d.description) : ''}</option>`
).join('');
}
async function loadSurplusDevices() {
const d = await fetchJSON(api("api/surplus-devices")).catch(() => ({}));
const [d] = await Promise.all([
fetchJSON(api("api/surplus-devices")).catch(() => ({})),
loadZ2mDevices(),
]);
surplusDevices = d.devices || [];
document.getElementById("cfg-z2m-base").value = d.z2m_base || "zigbee2mqtt";
const list = document.getElementById("surplus-device-list");