fix: support Symcon numeric dimmers and independent blind slat controls

This commit is contained in:
jhartworks committed 2026-11-09 15:24:59 +01:00
1 parent b934f78b9a
commit 24188f96f7
36 files changed
+1105 -683

No files matched your search

+20
View File
@@ -1,6 +1,8 @@
import assert from "node:assert/strict";
import { test, type TestContext } from "node:test";
import { SymconBridge } from "./symcon-bridge.ts";
import { entityOptions } from "./components/editor/entities.ts";
import { areaEntities } from "./entities/registry.ts";
function mockWindow(context: TestContext): void {
const previous = Object.getOwnPropertyDescriptor(globalThis, "window");
@@ -11,6 +13,24 @@ function mockWindow(context: TestContext): void {
});
}
test("numeric control roles stay selectable in the real tree without duplicating automatic device lists", async (context) => {
mockWindow(context);
context.mock.method(globalThis, "fetch", async () => new Response(JSON.stringify({ state_revision: 1, building_revision: 1, areas: [{ area_id: "room", name: "Raum" }],
variables: [{ entity_id: "sensor.6", name: "Dimmerwert", path: "Haus / KNX / Dimmerwert", state: "128", area_id: "room",
attributes: { symcon_id: 6, symcon_variable_type: 1, symcon_numeric_value: 128, symcon_min: 0, symcon_max: 255 } }],
objects: [{ object_id: 6, parent_id: 0, entity_id: "sensor.6", name: "Dimmerwert", object_type: 2 }] })));
const bridge = new SymconBridge();
try {
const hass = await bridge.start();
assert.equal(hass.states["light.6"].attributes.brightness, 128);
assert.equal(hass.states["cover.6"].attributes.current_position, 128 / 255 * 100);
assert.equal(entityOptions(hass, (id) => id.startsWith("light."))[0].sourceEntity, "sensor.6");
assert.ok(!areaEntities(hass, "room").includes("light.6"));
assert.ok(!areaEntities(hass, "room").includes("cover.6"));
assert.equal(hass.symconObjects?.length, 1, "no artificial duplicate nodes in the native object tree");
} finally { bridge.stop(); }
});
test("manual reload waits for polling, replaces removed variables and reloads the whole tree", async (context) => {
mockWindow(context);
const variable = (id: number) => ({ entity_id: `sensor.${id}`, name: "KNX Wert", path: "Haus / KNX / Wert", state: "21.75", attributes: { unit_of_measurement: "°C" } });