UI-002: align context and activation status
Some checks failed
quality / test (3.11) (pull_request) Has been cancelled
quality / test (3.13) (pull_request) Has been cancelled

This commit is contained in:
2026-06-14 15:28:52 +02:00
parent ede6b87dbd
commit 100f5af578
6 changed files with 42 additions and 5 deletions

View File

@@ -112,6 +112,7 @@ async function api(path, options = {}) {
}
function lifecycleLabel(record) {
if (record.behavior.status === "trained") return "Kontext erkannt";
const labels = {
trained: "lernt",
pending_history: "sammelt Historie",
@@ -124,6 +125,7 @@ function lifecycleLabel(record) {
}
function statusClass(record) {
if (record.behavior.status === "trained") return "ok";
if (record.lifecycle.status === "trained") return "ok";
if (["pending_history", "pending_assignment", "archived"].includes(record.lifecycle.status)) return "warn";
return "bad";
@@ -237,11 +239,18 @@ async function showActuator(actuatorId) {
.map(candidate => `<li><strong>${escapeHtml(candidate.friendly_name || candidate.entity_id)}</strong>: ${candidate.evidence.map(escapeHtml).join(", ") || "statistisch relevanter Kandidat"}</li>`)
.join("");
const prediction = record.behavior.prediction;
const requiredUserActions = 3;
const missingUserActions = Math.max(
0,
requiredUserActions - record.behavior.high_confidence_sample_count,
);
const activationButton = record.behavior.mode === "active"
? `<button class="danger" onclick="setActivation('${escapeHtml(record.actuator_entity_id)}', false)">Autonomes Schalten stoppen</button>`
: record.behavior.status === "trained"
: record.behavior.status === "trained" && missingUserActions === 0
? `<button onclick="setActivation('${escapeHtml(record.actuator_entity_id)}', true)">Lernen und Schalten freigeben</button>`
: "<p class='muted'>Freigabe wird möglich, sobald genügend Handlungen gelernt wurden.</p>";
: record.behavior.status === "trained"
? `<p class='muted'>Freigabe noch gesperrt: ${missingUserActions} eindeutig manuelle Bedienung${missingUserActions === 1 ? "" : "en"} fehlen. Bediene das Licht dafür direkt über Home Assistant.</p>`
: "<p class='muted'>Freigabe wird möglich, sobald genügend Handlungen gelernt wurden.</p>";
box.innerHTML = `
<div class="grid-two">
<div>