feat: improve Symcon controls, device readings and designer help

This commit is contained in:
jhartworks committed 2026-11-10 09:19:13 +01:00
1 parent ff54f4461a
commit 00fca890de
50 files changed
+2447 -1840

No files matched your search

@@ -0,0 +1,27 @@
import assert from "node:assert/strict";
import { test } from "node:test";
import { entity, hassOf } from "./fixtures.ts";
import { deviceValueReadouts, deviceValuesText } from "./device-values.ts";
test("several temperatures and other device values keep independent symbols, labels and native readings", () => {
const h = hassOf([
entity("cover.temp", "open", { symcon_numeric_value: 22.7, unit_of_measurement: "°C", device_class: "temperature" }),
entity("sensor.out", "48.5", { unit_of_measurement: "°C", friendly_name: "Ausgang", device_class: "temperature" }),
entity("sensor.humidity", "55", { unit_of_measurement: "%", device_class: "humidity" }),
entity("sensor.status", "normal", {}),
]);
const links = [{ id: "a", entity: "cover.temp", icon: "❄", label: "Innen" }, { id: "b", entity: "sensor.out", icon: "🔥" }, { id: "c", entity: "sensor.humidity" }, { id: "d", entity: "sensor.status", icon: "✓" }];
const rows = deviceValueReadouts(h, links);
assert.deepEqual(rows.map((v) => v.icon), ["❄", "🔥", "💧", "✓"]);
assert.equal(rows[0].text, "22.7 °C", "an inferred actuator domain cannot replace the numeric reading with an on/off state");
assert.equal(rows[1].label, "Ausgang");
assert.equal(rows[3].text, "normal");
assert.match(deviceValuesText(h, links), /❄ Innen: 22.7 °C.*🔥 48.5 °C.*💧 55 %/);
assert.equal(deviceValueReadouts(h, [links[1]])[0].id, "b", "removing one link keeps the others intact");
});
test("unassigned values stay hidden and linked unavailable readings retain a dash", () => {
const h = hassOf([entity("sensor.offline", "unavailable"), entity("sensor.native", "on", { symcon_formatted: "Ein" })]);
const rows = deviceValueReadouts(h, [{ id: "empty", entity: null }, { id: "none", entity: "none" }, { id: "offline", entity: "sensor.offline" }, { id: "native", entity: "sensor.native" }]);
assert.deepEqual(rows.map((v) => v.text), ["–", "Ein"]);
});