Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -643,11 +643,10 @@ Milestone 01.2 will deliver:

### 5. Home Automation Integration

**Status:** 🟡 In progress — both slices implemented and unit-tested
(read-only slice also manually verified in Console); real-hardware
qualification of either slice blocked on an external dependency (see
below); Console UI for the second (allowlisted-action) slice's control
toggle/picker not yet built
**Status:** 🟡 In progress — both slices implemented, unit-tested, and
manually verified in Console (including the second slice's control
toggle/picker); real-hardware qualification of either slice blocked on
an external dependency (see below)

**Depends on:** Qualified capability executor (satisfied — see Milestone 4's
real-hardware qualification of the confirmation/policy/audit machinery via
Expand Down Expand Up @@ -715,11 +714,22 @@ never contacts Home Assistant), and success verified against the real
service-call response rather than trusting a 200 status alone. Extending
the config endpoint's required fields would have silently broken
Console's already-shipped read-only "Save connection" button — fixed by
having it load, retain, and resend the two new control fields unchanged
even though this pass builds no UI to edit them yet. Console's own
settings UI for the control toggle/picker remains unbuilt, and
real-hardware qualification depends on the same unresolved external
dependency (no Home Assistant instance yet) named above.
having it load, retain, and resend the two new control fields even
before any UI existed to edit them.

**Console-wired**: an "Allow control" toggle independent of the
existing "Allow Home Assistant" toggle, and a per-entity "Control"
checkbox next to each allowlisted entity's existing "Read" checkbox —
offered only for `light`/`switch`-domain entities, disabled until Read
is checked for that entity, and cascaded off if Read is later
unchecked (client-side mirror of the same subset invariant
`write_config()` enforces server-side). Manually verified end-to-end in
a browser against a stub backend: sign in, save a connection, enable
both toggles, load entities, confirm Control is offered only for
light/switch domains, check Read+Control on two entities, save, reload,
and confirm both the toggle and per-entity grants persisted. Real-hardware
qualification depends on the same unresolved external dependency (no
Home Assistant instance yet) named above.

### 6. Full Base-OS Updates

Expand Down Expand Up @@ -821,10 +831,10 @@ This milestone closes the remaining “flash once” gap.
Accepted); a real signed-release qualification (artifact/import systemd
paths, the real hardened sandbox) remains
- 🟡 Home Assistant capability integration — read-only entity/history
mapping (RFC-0018) implemented and Console-wired; allowlisted-action
mapping (RFC-0019, `light`/`switch` only) implemented, Console UI for
it still unbuilt; real-hardware qualification of either blocked on no
Home Assistant instance existing on the household network yet
mapping (RFC-0018) and allowlisted-action mapping (RFC-0019,
`light`/`switch` only) both implemented and Console-wired; real-hardware
qualification of either blocked on no Home Assistant instance existing
on the household network yet
- ✅ A/B full base-OS updates (RFC-0016): every Acceptance Criteria item
hardware-qualified, including a second base-OS update with no
reflash, the Console panel against a live transaction, and a genuine
Expand Down
111 changes: 91 additions & 20 deletions image-builder/sovereign/appliance/console/assets/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ function showSignedIn() {
chatWebSearchToggle.disabled = false;
loadWebSearchPolicy();
haPolicyRow.hidden = false;
haControlPolicyRow.hidden = false;
haEntitiesHint.hidden = false;
setHaFieldsEnabled(true);
loadHomeAssistantConfig();
}
Expand All @@ -214,6 +216,8 @@ function showSignedOut() {
chatWebSearchToggle.checked = false;
setChatPolicyMessage("");
haPolicyRow.hidden = true;
haControlPolicyRow.hidden = true;
haEntitiesHint.hidden = true;
setHaFieldsEnabled(false);
resetHomeAssistantSettingsUI();
}
Expand Down Expand Up @@ -706,6 +710,9 @@ chatWebSearchToggle.addEventListener("change", async () => {
// /home-assistant endpoints.
const haPolicyRow = document.querySelector("#ha-policy-row");
const haEnabledToggle = document.querySelector("#ha-enabled-toggle");
const haControlPolicyRow = document.querySelector("#ha-control-policy-row");
const haControlEnabledToggle = document.querySelector("#ha-control-enabled-toggle");
const haEntitiesHint = document.querySelector("#ha-entities-hint");
const haBaseUrlScheme = document.querySelector("#ha-base-url-scheme");
const haBaseUrlHost = document.querySelector("#ha-base-url-host");
const haAccessTokenInput = document.querySelector("#ha-access-token");
Expand All @@ -719,22 +726,28 @@ const haSaveAllowlistButton = document.querySelector("#ha-save-allowlist");
const haStatusPill = document.querySelector("#ha-status-pill");
const haStatusDetail = document.querySelector("#ha-status-detail");
const haEntityCount = document.querySelector("#ha-entity-count");
const HA_ENTITIES_PLACEHOLDER = "Sign in, save a connection, then load entities to choose which ones the assistant may read.";
const HA_ENTITIES_PLACEHOLDER = "Sign in, save a connection, then load entities to choose which ones the assistant may read and control.";

// RFC-0019: the same light/switch restriction the backend enforces
// (write_config(), _control_policy_check, and the implementation itself
// all independently check this) -- mirrored here only to decide whether
// to offer a Control checkbox at all. This is a UI convenience, not a
// security boundary: the real enforcement is server-side, so offering
// (or not) a checkbox here changes nothing about what a bypassed request
// could do.
const HA_CONTROLLABLE_DOMAINS = new Set(["light", "switch"]);

// The live-editable allowlist, loaded from the real config and mutated by
// the entity checklist below -- resent in full on every save, since
// POST /home-assistant always replaces the whole allowlisted_entities
// list (there is no partial-update endpoint).
let haAllowlist = [];

// RFC-0019: control_enabled/controllable_entities -- loaded and resent
// unchanged on every save the same way haAllowlist is, even though this
// pass builds no UI to edit them yet (that's Console's own follow-up
// per RFC-0019's Non-Goals). Without this, "Save connection" would
// silently wipe out control settings a household configured through
// some other path (a future settings page, or a direct API call),
// since POST /home-assistant always replaces the whole config object.
let haControlEnabled = false;
// RFC-0019: the live-editable controllable-entities list, same pattern
// as haAllowlist above. control_enabled itself is read directly from
// haControlEnabledToggle.checked at save time, the same way enabled
// already reads from haEnabledToggle.checked -- no separate variable
// needed for a single checkbox's own state.
let haControllableEntities = [];

function setHaSettingsMessage(text, isError) {
Expand All @@ -749,6 +762,7 @@ function setHaEntitiesMessage(text, isError) {

function setHaFieldsEnabled(enabled) {
haEnabledToggle.disabled = !enabled;
haControlEnabledToggle.disabled = !enabled;
haBaseUrlScheme.disabled = !enabled;
haBaseUrlHost.disabled = !enabled;
haAccessTokenInput.disabled = !enabled;
Expand Down Expand Up @@ -806,12 +820,12 @@ function applyHaBaseUrl(baseUrl) {

function resetHomeAssistantSettingsUI() {
haEnabledToggle.checked = false;
haControlEnabledToggle.checked = false;
haBaseUrlScheme.value = "http";
haBaseUrlHost.value = "";
haAccessTokenInput.value = "";
renderHaTokenStatus(false);
haAllowlist = [];
haControlEnabled = false;
haControllableEntities = [];
haEntitiesList.replaceChildren();
const placeholder = document.createElement("p");
Expand Down Expand Up @@ -846,7 +860,7 @@ async function loadHomeAssistantConfig() {
haAccessTokenInput.value = "";
renderHaTokenStatus(Boolean(data.has_access_token));
haAllowlist = Array.isArray(data.allowlisted_entities) ? data.allowlisted_entities.slice() : [];
haControlEnabled = Boolean(data.control_enabled);
haControlEnabledToggle.checked = Boolean(data.control_enabled);
haControllableEntities = Array.isArray(data.controllable_entities) ? data.controllable_entities.slice() : [];
renderHaStatus(data);
} catch (error) {
Expand All @@ -859,7 +873,7 @@ async function saveHomeAssistantConfig(reportTo) {
enabled: haEnabledToggle.checked,
base_url: buildHaBaseUrl(),
allowlisted_entities: haAllowlist,
control_enabled: haControlEnabled,
control_enabled: haControlEnabledToggle.checked,
controllable_entities: haControllableEntities,
};
// Omitted entirely (not even an empty string) means "leave the stored
Expand All @@ -884,7 +898,7 @@ async function saveHomeAssistantConfig(reportTo) {
haAccessTokenInput.value = "";
renderHaTokenStatus(Boolean(data.has_access_token));
haAllowlist = Array.isArray(data.allowlisted_entities) ? data.allowlisted_entities.slice() : [];
haControlEnabled = Boolean(data.control_enabled);
haControlEnabledToggle.checked = Boolean(data.control_enabled);
haControllableEntities = Array.isArray(data.controllable_entities) ? data.controllable_entities.slice() : [];
renderHaStatus(data);
reportTo("Saved.");
Expand Down Expand Up @@ -922,8 +936,9 @@ function renderHaEntities(entities) {
return;
}
const allowedSet = new Set(haAllowlist);
const controllableSet = new Set(haControllableEntities);
entities.forEach((entity) => {
const row = document.createElement("label");
const row = document.createElement("div");
row.className = "check-row";
const info = document.createElement("div");
const name = document.createElement("div");
Expand All @@ -933,18 +948,74 @@ function renderHaEntities(entities) {
detail.className = "detail";
detail.textContent = `${entity.entity_id} · ${entity.state || "unknown"}`;
info.append(name, detail);
const checkbox = document.createElement("input");
checkbox.type = "checkbox";
checkbox.checked = allowedSet.has(entity.entity_id);
checkbox.addEventListener("change", () => {
if (checkbox.checked) {

const toggles = document.createElement("div");
toggles.style.display = "flex";
toggles.style.gap = "16px";
toggles.style.alignItems = "center";

const readLabel = document.createElement("label");
readLabel.style.display = "inline-flex";
readLabel.style.gap = "4px";
readLabel.style.alignItems = "center";
const readCheckbox = document.createElement("input");
readCheckbox.type = "checkbox";
readCheckbox.checked = allowedSet.has(entity.entity_id);
const readText = document.createElement("span");
readText.className = "detail";
readText.textContent = "Read";
readLabel.append(readCheckbox, readText);
toggles.append(readLabel);

// RFC-0019: control is only ever offered for light/switch entities,
// and only once Read is checked -- you cannot control something you
// haven't also chosen to let the assistant see (the same subset
// invariant write_config() enforces server-side).
const controllable = HA_CONTROLLABLE_DOMAINS.has(entity.domain);
let controlCheckbox = null;
if (controllable) {
const controlLabel = document.createElement("label");
controlLabel.style.display = "inline-flex";
controlLabel.style.gap = "4px";
controlLabel.style.alignItems = "center";
controlCheckbox = document.createElement("input");
controlCheckbox.type = "checkbox";
controlCheckbox.checked = controllableSet.has(entity.entity_id) && readCheckbox.checked;
controlCheckbox.disabled = !readCheckbox.checked;
const controlText = document.createElement("span");
controlText.className = "detail";
controlText.textContent = "Control";
controlLabel.append(controlCheckbox, controlText);
toggles.append(controlLabel);

controlCheckbox.addEventListener("change", () => {
if (controlCheckbox.checked) {
if (!haControllableEntities.includes(entity.entity_id)) haControllableEntities.push(entity.entity_id);
} else {
haControllableEntities = haControllableEntities.filter((id) => id !== entity.entity_id);
}
});
}

readCheckbox.addEventListener("change", () => {
if (readCheckbox.checked) {
if (!haAllowlist.includes(entity.entity_id)) haAllowlist.push(entity.entity_id);
} else {
haAllowlist = haAllowlist.filter((id) => id !== entity.entity_id);
// Unchecking Read must also drop Control -- the backend rejects
// a controllable entity that isn't also allowlisted, so the UI
// enforces the same subset invariant rather than letting a save
// fail with an error the household didn't expect.
if (controlCheckbox) {
controlCheckbox.checked = false;
haControllableEntities = haControllableEntities.filter((id) => id !== entity.entity_id);
}
}
if (controlCheckbox) controlCheckbox.disabled = !readCheckbox.checked;
haEntityCount.textContent = String(haAllowlist.length);
});
row.append(info, checkbox);

row.append(info, toggles);
haEntitiesList.append(row);
});
haSaveAllowlistButton.hidden = false;
Expand Down
20 changes: 14 additions & 6 deletions image-builder/sovereign/appliance/console/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ <h1 id="chat-title" class="visually-hidden" style="position:absolute; left:-9999
<section id="page-home" class="console-page" hidden aria-labelledby="home-title">
<div class="preview-banner">
<strong>Preview</strong>
<span>Home Assistant <em>control</em> (turning things on or off) is part of a later milestone and isn't available on this device yet — the recent-operations and capability-scope sections below show that planned design. Reading allowlisted entities and their history is real today; connect it below.</span>
<span>Turning allowlisted lights and switches on or off is real today, below. Broader control (locks, climate, covers, cameras) and the automations/operations ledger are part of a later milestone and aren't available on this device yet — the recent-operations and capability-scope sections below show that planned design.</span>
</div>
<div class="hero">
<div>
<p class="eyebrow">Read-only integration</p>
<p class="eyebrow">Read and light/switch control</p>
<h1 id="home-title">Home Assistant</h1>
<p class="lede">What the assistant may read in your home, and the history it can answer questions about.</p>
<p class="lede">What the assistant may read in your home, the history it can answer questions about, and the lights and switches it may turn on or off.</p>
</div>
<div class="status-panel">
<span id="ha-status-pill" class="pill neutral">Not connected</span>
Expand All @@ -232,6 +232,13 @@ <h2 id="ha-settings-title">Connection</h2>
</label>
<span class="policy-detail">Reads only the entities you allow below. Leaves your device only when you approve a specific request.</span>
</div>
<div id="ha-control-policy-row" class="policy-row" hidden>
<label class="switch">
<input type="checkbox" id="ha-control-enabled-toggle" disabled>
<span>Allow control</span>
</label>
<span class="policy-detail">Turns allowlisted lights and switches on or off, only with your approval each time. Independent of the read setting above.</span>
</div>
<div class="field grow">
<label for="ha-base-url-host">Base URL</label>
<div style="display:flex; gap:8px;">
Expand All @@ -258,12 +265,13 @@ <h2 id="ha-settings-title">Connection</h2>
<div class="panel-heading">
<div>
<p class="eyebrow">Allowlist</p>
<h2 id="ha-entities-title">Entities the assistant may read</h2>
<h2 id="ha-entities-title">Entities the assistant may read and control</h2>
</div>
<button id="ha-save-allowlist" type="button" class="btn primary sm" hidden>Save allowlist</button>
<button id="ha-save-allowlist" type="button" class="btn primary sm" hidden>Save entity settings</button>
</div>
<p class="policy-detail" id="ha-entities-hint" hidden>Control is only offered for lights and switches, and only once Read is checked for that entity.</p>
<div id="ha-entities-list" aria-live="polite">
<p class="placeholder">Sign in, save a connection, then load entities to choose which ones the assistant may read.</p>
<p class="placeholder">Sign in, save a connection, then load entities to choose which ones the assistant may read and control.</p>
</div>
<p id="ha-entities-message" role="status" aria-live="polite"></p>
</div>
Expand Down
Loading
Loading