feat: add home-assistant renderer
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
export function renderHomeAssistant(state) {
|
||||
const d = state.home_assistant || {};
|
||||
const online = d.status === "online";
|
||||
|
||||
// pill
|
||||
const pill = document.getElementById("ha-pill");
|
||||
if (pill) {
|
||||
pill.textContent = online ? "ONLINE" : "OFFLINE";
|
||||
pill.className = "status-pill " + (online ? "pill-online" : "pill-offline");
|
||||
}
|
||||
|
||||
// stat blocks
|
||||
const set = (id, val) => { const el = document.getElementById(id); if (el) el.textContent = val; };
|
||||
|
||||
set("ha-lights", online ? `${d.lights_on ?? 0}/${d.lights_total ?? 0}` : "—");
|
||||
set("ha-climate", online ? (d.climate_active ?? 0) : "—");
|
||||
set("ha-doors", online ? (d.doors_open ?? 0) : "—");
|
||||
set("ha-alerts", online ? (d.alerts ?? 0) : "—");
|
||||
|
||||
// version subtitle
|
||||
const ver = document.getElementById("ha-version");
|
||||
if (ver) ver.textContent = d.version ? `v${d.version}` : "";
|
||||
|
||||
// alerts highlight
|
||||
const alertsEl = document.getElementById("ha-alerts");
|
||||
if (alertsEl) {
|
||||
alertsEl.style.color = d.alerts > 0 ? "var(--clr-warn)" : "";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user