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

+18
View File
@@ -0,0 +1,18 @@
import assert from "node:assert/strict";
import { test } from "node:test";
import { symconControl, symconPercent } from "./symcon-controls.ts";
import { entity } from "./entities/fixtures.ts";
test("integer dimmers, normalized floats and separate blind variables preserve their native ranges", () => {
const integer = entity("cover.6", "open", { symcon_id: 6, symcon_numeric_value: 128, symcon_min: 0, symcon_max: 255 });
const light = symconControl(integer, "light")!;
assert.equal(light.entity_id, "light.6");
assert.equal(light.attributes.brightness, 128);
assert.deepEqual(light.attributes.supported_color_modes, ["brightness"]);
assert.equal(light.attributes.symcon_source_entity, "cover.6");
const fraction = entity("sensor.7", "0.4", { symcon_id: 7, symcon_numeric_value: 0.4, symcon_min: 0, symcon_max: 1 });
assert.equal(symconControl(fraction, "light")!.attributes.brightness, 102);
assert.equal(symconControl(fraction, "cover")!.attributes.current_position, 40);
assert.equal(symconPercent(entity("sensor.low", "10", { symcon_numeric_value: 10, symcon_min: 10, symcon_max: 110 })), 0);
assert.equal(symconControl(entity("switch.8", "on", { symcon_id: 8, symcon_variable_type: 0 }), "light"), null, "a boolean switch cannot pretend to dim");
});