fix: restrict blind direction reversal to 3D appearance
This commit is contained in:
1 parent
b9a095bc6e
commit
7a9b2c0a38
19 files changed
+721
-629
No files matched your search
@@ -7,7 +7,7 @@ import { iconPath } from "../../../icons.ts";
|
||||
import { ceilingAt, FURNITURE_TYPES, isLamp, type LampMount, type Placement } from "../../../model.ts";
|
||||
import { packItemLabel, packLabel } from "../../../furniture-names.ts";
|
||||
import { isClimateFurniture, isElectric, isPackType, packType, type FurniturePack } from "../../../packs.ts";
|
||||
import { checkField, deviceIcon, entityField, glowField, iconField, markerField, pinShiftField, numberField, selectField, textField } from "../fields.ts";
|
||||
import { checkField, deviceIcon, entityField, glowField, hint, iconField, markerField, pinShiftField, numberField, selectField, textField } from "../fields.ts";
|
||||
import { entityOptions } from "../entities.ts";
|
||||
import { isPositionVariable } from "../../../entities/position-value.ts";
|
||||
import { renderDeviceValues } from "../device-values.ts";
|
||||
@@ -104,7 +104,8 @@ export function renderDeviceForm(host: EditorHost, placed: Placement, actions: D
|
||||
${checkField(host, t("cover_direction_invert"), !!placed.cover_inverted, (on) => set({ cover_inverted: on || undefined }))}
|
||||
${checkField(host, t("cover_tilt_direction_invert"), !!placed.cover_tilt_inverted, (on) => set({ cover_tilt_inverted: on || undefined }))}
|
||||
${entityField(host, t("cover_position_entity"), placed.position ?? null, undefined, entityOptions(host.hass, (id) => isPositionVariable(host.hass, id)), (v) => set({ position: v && v !== "none" ? v : null }))}
|
||||
${placed.position ? checkField(host, t("cover_position_invert"), !!placed.position_inverted, (on) => set({ position_inverted: on || undefined })) : nothing}` : nothing}
|
||||
${placed.position ? checkField(host, t("cover_position_invert"), !!placed.position_inverted, (on) => set({ position_inverted: on || undefined })) : nothing}
|
||||
${hint(t("cover_direction_hint"), "nf-wide")}` : nothing}
|
||||
${light ? html`${selectField(host, t("lamp_mount"), mount, lampMounts, mountChange, { wide: true })}${glowField(host, placed.glow_scale, (v) => set({ glow_scale: v }))}` : nothing}
|
||||
${light ? lightEffectFields(host, placed, host.hass?.states[placed.entity_id]?.attributes.effect_list, set) : nothing}
|
||||
${placed.entity_id.startsWith("media_player.") ? glowField(host, placed.sound_rings, (v) => set({ sound_rings: v }), { label: "sound_rings", hint: "sound_rings_hint", lowest: 0 }) : nothing}
|
||||
|
||||
@@ -185,6 +185,7 @@ function blindFields(host: EditorHost, o: Opening, actions: OpeningActions, list
|
||||
${o.cover2 && o.cover2 !== "none" ? entityField(host, t("cover2_tilt_entity"), o.cover2_tilt ?? null, undefined, lists.covers, (v) => actions.update({ cover2_tilt: noneAsNull(v) })) : nothing}
|
||||
${o.cover2 && o.cover2 !== "none" ? html`${checkField(host, t("cover2_direction_invert"), !!o.cover2_inverted, (on) => actions.update({ cover2_inverted: on || undefined }))}${checkField(host, t("cover2_tilt_direction_invert"), !!o.cover2_tilt_inverted, (on) => actions.update({ cover2_tilt_inverted: on || undefined }))}` : nothing}
|
||||
${numberField(host, t("cover_my"), o.my_position ?? 0, (v) => actions.update({ my_position: v > 0 ? Math.min(100, Math.round(v)) : null }), 5, 0)}
|
||||
${hint(t("cover_direction_hint"), "nf-wide")}
|
||||
${hint(t("blind_hint"), "nf-wide")}`
|
||||
: nothing}`;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { box, entity, floorWith, hassOf, opening } from "./fixtures.ts";
|
||||
import { openingEntities, openingState } from "./openings.ts";
|
||||
import { isPositionVariable, positionPercent } from "./position-value.ts";
|
||||
import { withCoverControls } from "./cover-controls.ts";
|
||||
import { stateText } from "../markers.ts";
|
||||
|
||||
test("Symcon position feedback accepts numeric actuator domains and respects native integer/float ranges", () => {
|
||||
const h = hassOf([
|
||||
@@ -20,39 +21,92 @@ test("Symcon position feedback accepts numeric actuator domains and respects nat
|
||||
assert.equal(positionPercent(h, "cover.one"), 1, "integer 1 is one percent, not a normalized float at full travel");
|
||||
});
|
||||
|
||||
test("blind and slat inversions act independently on feedback, 3D, sliders, buttons and grouped commands", async () => {
|
||||
test("blind and slat inversions affect only 3D, retaining readings and slider, button and grouped command values", async () => {
|
||||
for (const inverted of [false, true]) for (const tiltInverted of [false, true]) {
|
||||
const calls: unknown[] = [];
|
||||
const raw = hassOf([entity("cover.height", "open", { current_position: 5 }), entity("cover.slats", "open", { current_position: 30, symcon_id: 9 }), entity("cover.feedback", "open", { symcon_numeric_value: 40, symcon_min: 0, symcon_max: 100 }), entity("cover.normal", "open", { current_position: 90 })], {}, { callService: async (domain: string, service: string, data: unknown) => { calls.push([domain, service, data]); } });
|
||||
const floor = floorWith([box("r", 0, 0, 4, 4)], { openings: [opening("w", "r", "window", { cover: "cover.height", cover_tilt: "cover.slats", position: "cover.feedback", cover_inverted: inverted, cover_tilt_inverted: tiltInverted })] });
|
||||
const view = withCoverControls(raw, [floor]);
|
||||
assert.equal(view.states["cover.height"].attributes.current_position, inverted ? 60 : 40);
|
||||
assert.equal(view.states["cover.height"].attributes.current_tilt_position, tiltInverted ? 70 : 30);
|
||||
assert.equal(view.states["cover.height"].attributes.current_position, 40);
|
||||
assert.equal(view.states["cover.height"].attributes.current_tilt_position, 30);
|
||||
assert.equal(stateText(view, view.states["cover.height"]), "40 %");
|
||||
const links = openingEntities(raw, [floor]).get("w")!;
|
||||
const fromRaw = openingState(raw, links), fromView = openingState(view, links);
|
||||
assert.ok(Math.abs(fromView.cover! - (inverted ? 0.4 : 0.6)) < 1e-9);
|
||||
assert.equal(fromView.slats, tiltInverted ? 0.7 : 0.3);
|
||||
assert.equal(fromRaw.cover, fromView.cover, "3D feedback cannot be inverted twice");
|
||||
assert.equal(fromRaw.slats, fromView.slats);
|
||||
await view.callService("cover", "set_cover_position", { entity_id: "cover.height", position: 75 });
|
||||
await view.callService("cover", "set_cover_tilt_position", { entity_id: "cover.height", tilt_position: 20 });
|
||||
await view.callService("cover", "open_cover", { entity_id: ["cover.height", "cover.normal"] });
|
||||
assert.deepEqual(calls, [
|
||||
["cover", "set_cover_position", { entity_id: "cover.height", position: inverted ? 25 : 75 }],
|
||||
["cover", "set_cover_tilt_position", { entity_id: "cover.slats", tilt_position: tiltInverted ? 80 : 20 }],
|
||||
["cover", inverted ? "close_cover" : "open_cover", { entity_id: "cover.height" }],
|
||||
["cover", "set_cover_position", { entity_id: "cover.height", position: 75 }],
|
||||
["cover", "set_cover_tilt_position", { entity_id: "cover.slats", tilt_position: 20 }],
|
||||
["cover", "open_cover", { entity_id: "cover.height" }],
|
||||
["cover", "open_cover", { entity_id: "cover.normal" }],
|
||||
]);
|
||||
assert.equal(raw.states["cover.height"].attributes.current_position, 5, "the native state remains unchanged");
|
||||
}
|
||||
});
|
||||
|
||||
test("standalone covers, feedback-only inversion, facade reuse and changed settings remain consistent", async () => {
|
||||
test("standalone feedback inversion is visual only, including facade reuse and changed settings", async () => {
|
||||
const raw = hassOf([entity("cover.height", "closed", { current_position: 0, current_tilt_position: 20 }), entity("sensor.feedback", "25", { unit_of_measurement: "%" })]);
|
||||
const floor = floorWith([], { placements: [{ entity_id: "cover.height", x: 1, z: 1, y: null, position: "sensor.feedback", position_inverted: true, cover_tilt_inverted: true }] });
|
||||
const floors = [floor];
|
||||
const first = withCoverControls(raw, floors);
|
||||
assert.equal(first.states["cover.height"].attributes.current_position, 75);
|
||||
assert.equal(first.states["cover.height"].attributes.current_tilt_position, 80);
|
||||
assert.equal(first.states["cover.height"].attributes.current_position, 25);
|
||||
assert.equal(first.states["cover.height"].attributes.current_tilt_position, 20);
|
||||
assert.equal(withCoverControls(first, floors), first, "nested views cannot invert an already adapted facade again");
|
||||
const next = withCoverControls(first, [{ ...floor, placements: [{ ...floor.placements[0], cover_inverted: true }] }]);
|
||||
assert.equal(next.states["cover.height"].attributes.current_position, 25);
|
||||
});
|
||||
|
||||
test("zero and full travel stay unchanged in values and commands, while each blind half reverses only its geometry", async () => {
|
||||
for (const value of [0, 100]) for (const inverted of [false, true]) for (const tiltInverted of [false, true]) {
|
||||
const calls: unknown[] = [];
|
||||
const raw = hassOf([
|
||||
entity("cover.main", value ? "open" : "closed", { current_position: value, current_tilt_position: value, symcon_id: 1 }),
|
||||
entity("cover.second", value ? "open" : "closed", { current_position: value, current_tilt_position: value, symcon_id: 2 }),
|
||||
], {}, { callService: async (domain: string, service: string, data: unknown) => { calls.push([domain, service, data]); } });
|
||||
const floors = [floorWith([box("r", 0, 0, 4, 4)], { openings: [opening("w", "r", "window", { cover: "cover.main", cover2: "cover.second", cover_inverted: inverted, cover_tilt_inverted: tiltInverted, cover2_inverted: inverted, cover2_tilt_inverted: tiltInverted })] })];
|
||||
const controls = withCoverControls(raw, floors);
|
||||
const visual = openingState(controls, openingEntities(controls, floors).get("w")!);
|
||||
const fraction = value / 100;
|
||||
assert.equal(visual.cover, inverted ? fraction : 1 - fraction);
|
||||
assert.equal(visual.cover2, visual.cover);
|
||||
assert.equal(visual.slats, tiltInverted ? 1 - fraction : fraction);
|
||||
assert.equal(visual.slats2, visual.slats);
|
||||
assert.equal(stateText(controls, controls.states["cover.main"]), `${value} %`);
|
||||
for (const id of ["cover.main", "cover.second"]) {
|
||||
assert.equal(controls.states[id].attributes.current_tilt_position, value);
|
||||
await controls.callService("cover", "set_cover_position", { entity_id: id, position: value });
|
||||
await controls.callService("cover", "set_cover_tilt_position", { entity_id: id, tilt_position: value });
|
||||
await controls.callService("cover", "close_cover", { entity_id: id });
|
||||
await controls.callService("cover", "open_cover_tilt", { entity_id: id });
|
||||
await controls.callService("cover", "stop_cover", { entity_id: id });
|
||||
}
|
||||
assert.deepEqual(calls, ["cover.main", "cover.second"].flatMap((id) => [
|
||||
["cover", "set_cover_position", { entity_id: id, position: value }],
|
||||
["cover", "set_cover_tilt_position", { entity_id: id, tilt_position: value }],
|
||||
["cover", "close_cover", { entity_id: id }],
|
||||
["cover", "open_cover_tilt", { entity_id: id }],
|
||||
["cover", "stop_cover", { entity_id: id }],
|
||||
]));
|
||||
}
|
||||
});
|
||||
|
||||
test("a reversed feedback sensor changes only 3D, not the value shown on the cover", () => {
|
||||
const raw = hassOf([entity("cover.main", "closed", { current_position: 0 }), entity("sensor.feedback", "0", { unit_of_measurement: "%" })]);
|
||||
const floors = [floorWith([box("r", 0, 0, 4, 4)], { openings: [opening("w", "r", "window", { cover: "cover.main", position: "sensor.feedback", position_inverted: true })] })];
|
||||
const controls = withCoverControls(raw, floors);
|
||||
assert.equal(controls.states["cover.main"].attributes.current_position, 0);
|
||||
assert.equal(stateText(controls, controls.states["cover.main"]), "0 %");
|
||||
assert.equal(openingState(controls, openingEntities(controls, floors).get("w")!).cover, 0);
|
||||
});
|
||||
|
||||
test("unavailable slat feedback does not substitute the blind height in 3D", () => {
|
||||
const raw = hassOf([entity("cover.main", "open", { current_position: 40 }), entity("cover.slats", "unavailable")]);
|
||||
const floors = [floorWith([box("r", 0, 0, 4, 4)], { openings: [opening("w", "r", "window", { cover: "cover.main", cover_tilt: "cover.slats", cover_tilt_inverted: true })] })];
|
||||
const controls = withCoverControls(raw, floors);
|
||||
assert.equal(openingState(controls, openingEntities(controls, floors).get("w")!).slats, undefined);
|
||||
});
|
||||
@@ -1,20 +1,16 @@
|
||||
// Present a plan's cover wiring as one consistent logical direction to every view and command.
|
||||
// Combine live cover feedback and separate slat controls without changing values or command direction.
|
||||
import type { Floor } from "../model.ts";
|
||||
import type { HassEntity, HomeAssistant } from "../types.ts";
|
||||
import { openingEntities } from "./openings.ts";
|
||||
import { positionPercent } from "./position-value.ts";
|
||||
|
||||
interface Binding {
|
||||
inverted?: boolean;
|
||||
tiltInverted?: boolean;
|
||||
tilt?: string | null;
|
||||
position?: string | null;
|
||||
positionInverted?: boolean;
|
||||
}
|
||||
|
||||
const cache = new WeakMap<HomeAssistant, WeakMap<readonly Floor[], HomeAssistant>>();
|
||||
const sources = new WeakMap<HomeAssistant, HomeAssistant>();
|
||||
const swapped: Record<string, string> = { open_cover: "close_cover", close_cover: "open_cover", open_cover_tilt: "close_cover_tilt", close_cover_tilt: "open_cover_tilt" };
|
||||
|
||||
export function withCoverControls(hass: HomeAssistant, floors: readonly Floor[]): HomeAssistant {
|
||||
const raw = sources.get(hass) ?? hass;
|
||||
@@ -24,11 +20,11 @@ export function withCoverControls(hass: HomeAssistant, floors: readonly Floor[])
|
||||
if (existing) return existing;
|
||||
const bindings = new Map<string, Binding>();
|
||||
for (const f of floors) for (const p of f.placements) if (p.entity_id.startsWith("cover.")) {
|
||||
bindings.set(p.entity_id, { inverted: p.cover_inverted, tiltInverted: p.cover_tilt_inverted, tilt: p.cover_tilt === "none" ? null : p.cover_tilt, position: p.position, positionInverted: p.position_inverted });
|
||||
bindings.set(p.entity_id, { tilt: p.cover_tilt === "none" ? null : p.cover_tilt, position: p.position });
|
||||
}
|
||||
for (const e of openingEntities(raw, floors).values()) {
|
||||
if (e.cover && !bindings.has(e.cover)) bindings.set(e.cover, { inverted: e.coverInverted, tiltInverted: e.coverTiltInverted, tilt: e.coverTilt, position: e.position, positionInverted: e.positionInverted });
|
||||
if (e.cover2 && !bindings.has(e.cover2)) bindings.set(e.cover2, { inverted: e.cover2Inverted, tiltInverted: e.cover2TiltInverted, tilt: e.cover2Tilt });
|
||||
if (e.cover && !bindings.has(e.cover)) bindings.set(e.cover, { tilt: e.coverTilt, position: e.position });
|
||||
if (e.cover2 && !bindings.has(e.cover2)) bindings.set(e.cover2, { tilt: e.cover2Tilt });
|
||||
}
|
||||
const states = { ...raw.states };
|
||||
for (const [id, b] of bindings) {
|
||||
@@ -36,18 +32,15 @@ export function withCoverControls(hass: HomeAssistant, floors: readonly Floor[])
|
||||
if (!st) continue;
|
||||
const a: Record<string, unknown> = { ...st.attributes, nf_cover_control: true };
|
||||
let position = positionPercent(raw, b.position);
|
||||
if (position !== null && b.positionInverted) position = 100 - position;
|
||||
if (position === null) position = typeof st.attributes.current_position === "number" ? st.attributes.current_position : null;
|
||||
if (position !== null) a.current_position = b.inverted ? 100 - position : position;
|
||||
if (position !== null) a.current_position = position;
|
||||
const tiltState = b.tilt ? raw.states[b.tilt] : st;
|
||||
let tilt = typeof tiltState?.attributes.current_tilt_position === "number" ? tiltState.attributes.current_tilt_position : b.tilt ? positionPercent(raw, b.tilt) : null;
|
||||
const tilt = typeof tiltState?.attributes.current_tilt_position === "number" ? tiltState.attributes.current_tilt_position : b.tilt ? positionPercent(raw, b.tilt) : null;
|
||||
if (tilt !== null) {
|
||||
if (b.tiltInverted) tilt = 100 - tilt;
|
||||
a.current_tilt_position = tilt;
|
||||
a.supported_features = Number(a.supported_features ?? 0) | 128;
|
||||
}
|
||||
let state = st.state;
|
||||
if (b.inverted) state = ({ open: "closed", closed: "open", opening: "closing", closing: "opening" } as Record<string, string>)[state] ?? state;
|
||||
if (typeof a.current_position === "number" && state !== "unavailable" && state !== "unknown" && state !== "opening" && state !== "closing") state = a.current_position > 0 ? "open" : "closed";
|
||||
states[id] = { ...st, state, attributes: a } satisfies HassEntity;
|
||||
}
|
||||
@@ -62,11 +55,6 @@ export function withCoverControls(hass: HomeAssistant, floors: readonly Floor[])
|
||||
if (command === "toggle" || command === "toggle_cover") command = states[String(id)]?.state === "closed" ? "open_cover" : "close_cover";
|
||||
const tilt = command.includes("tilt");
|
||||
if (tilt && b.tilt) payload.entity_id = b.tilt;
|
||||
if (tilt ? b.tiltInverted : b.inverted) {
|
||||
command = swapped[command] ?? command;
|
||||
const key = tilt ? "tilt_position" : "position";
|
||||
if (typeof payload[key] === "number") payload[key] = 100 - payload[key];
|
||||
}
|
||||
// A separate HA position-only cover controls its slats through its position service.
|
||||
const target = b.tilt ? raw.states[b.tilt] : undefined;
|
||||
if (tilt && b.tilt && !target?.attributes.symcon_id && typeof target?.attributes.current_tilt_position !== "number") {
|
||||
|
||||
@@ -150,24 +150,23 @@ function coverClosed(hass: HomeAssistant, id: string | null | undefined, inverte
|
||||
const cover = id ? hass.states[id] : undefined;
|
||||
if (!cover || isUnavailable(cover)) return id ? 0 : null;
|
||||
const percent = cover.attributes.current_position;
|
||||
if (typeof percent === "number") { const closed = 1 - Math.min(100, Math.max(0, percent)) / 100; return inverted && !cover.attributes.nf_cover_control ? 1 - closed : closed; }
|
||||
if (cover.state === "closed") return inverted && !cover.attributes.nf_cover_control ? 0 : 1;
|
||||
if (cover.state === "open") return inverted && !cover.attributes.nf_cover_control ? 1 : 0;
|
||||
if (typeof percent === "number") { const closed = 1 - Math.min(100, Math.max(0, percent)) / 100; return inverted ? 1 - closed : closed; }
|
||||
if (cover.state === "closed") return inverted ? 0 : 1;
|
||||
if (cover.state === "open") return inverted ? 1 : 0;
|
||||
return cover.state === "opening" || cover.state === "closing" ? 0.5 : 0;
|
||||
}
|
||||
|
||||
/** How far the slats of a venetian blind are open (0 shut, 1 level), from its tilt position; null when it reports none. */
|
||||
function slatsOpen(hass: HomeAssistant, id: string | null | undefined, separate?: string | null, inverted = false): number | null {
|
||||
const main = hass.states[id || ""];
|
||||
if (main?.attributes.nf_cover_control) return typeof main.attributes.current_tilt_position === "number" ? main.attributes.current_tilt_position / 100 : null;
|
||||
const a = hass.states[separate || id || ""]?.attributes;
|
||||
const tilt = a?.current_tilt_position ?? (separate ? a?.current_position : undefined);
|
||||
const combined = !!main?.attributes.nf_cover_control;
|
||||
const a = combined ? main!.attributes : hass.states[separate || id || ""]?.attributes;
|
||||
const tilt = a?.current_tilt_position ?? (!combined && separate ? a?.current_position : undefined);
|
||||
const value = typeof tilt === "number" ? Math.min(100, Math.max(0, tilt)) : separate ? positionPercent(hass, separate) : null;
|
||||
return value === null ? null : (inverted ? 100 - value : value) / 100;
|
||||
}
|
||||
|
||||
function blindClosedFraction(hass: HomeAssistant, e: OpeningEntities): number | null {
|
||||
if (hass.states[e.cover || ""]?.attributes.nf_cover_control) return coverClosed(hass, e.cover);
|
||||
const reported = reportedPosition(hass, e.position);
|
||||
if (reported !== null) { const closed = e.positionInverted ? reported : 1 - reported; return e.coverInverted ? 1 - closed : closed; }
|
||||
const cover = e.cover ? hass.states[e.cover] : undefined;
|
||||
|
||||
+12
-10
@@ -37,10 +37,11 @@ const DE = {
|
||||
device_value_label: "Bezeichnung (optional)",
|
||||
device_values_hint: "Über + weitere Datenpunkte auswählen, zum Beispiel mehrere Temperaturen oder andere Messwerte. Als Symbol eignen sich Emojis oder kurze Zeichen wie 🌡, 💧, ☁ oder ⚡. Die Werte erscheinen am Gerät und im Raumfenster.",
|
||||
cover_tilt_entity: "Lamellenposition",
|
||||
cover_direction_invert: "Wirksinn Behang umkehren",
|
||||
cover_tilt_direction_invert: "Wirksinn Lamellen umkehren",
|
||||
cover2_direction_invert: "Wirksinn zweiter Behang umkehren",
|
||||
cover2_tilt_direction_invert: "Wirksinn Lamellen des zweiten Behangs umkehren",
|
||||
cover_direction_invert: "Behang in 3D umkehren",
|
||||
cover_tilt_direction_invert: "Lamellen in 3D umkehren",
|
||||
cover2_direction_invert: "Zweiten Behang in 3D umkehren",
|
||||
cover2_tilt_direction_invert: "Lamellen des zweiten Behangs in 3D umkehren",
|
||||
cover_direction_hint: "Die Umkehrung betrifft nur die 3D-Darstellung. Zahlenwerte, Regler und Steuerbefehle bleiben unverändert: Ein empfangener Wert von 0 wird weiterhin als 0 angezeigt und ein eingestellter Wert von 0 als 0 gesendet.",
|
||||
cover2_tilt_entity: "Lamellenposition (zweiter Behang)",
|
||||
symcon_variables_loading: "Variablen werden geladen …",
|
||||
symcon_variables_loaded: "Variablen und Objektbaum wurden neu geladen.",
|
||||
@@ -1287,7 +1288,7 @@ const DE = {
|
||||
cover_entity: "Rollladen",
|
||||
door_cover: "Antrieb (Tür oder Tor mit Motor)",
|
||||
cover_position_entity: "Positions-Sensor (live)",
|
||||
cover_position_invert: "Sensor zählt umgekehrt (0 = offen)",
|
||||
cover_position_invert: "Positionssensor in 3D umkehren (0 = offen)",
|
||||
contact_entity: "Kontakt",
|
||||
sensor_kind: "Sensor-Art",
|
||||
sensor_kind_contact: "Fensterkontakt (offen/zu)",
|
||||
@@ -2078,10 +2079,11 @@ const EN: Record<Key, string> = {
|
||||
device_value_label: "Label (optional)",
|
||||
device_values_hint: "Use + to select additional data points, such as several temperatures or other readings. Symbols can be emoji or short characters such as 🌡, 💧, ☁ or ⚡. Values appear on the device and in the room panel.",
|
||||
cover_tilt_entity: "Slat position",
|
||||
cover_direction_invert: "Reverse blind direction",
|
||||
cover_tilt_direction_invert: "Reverse slat direction",
|
||||
cover2_direction_invert: "Reverse second blind direction",
|
||||
cover2_tilt_direction_invert: "Reverse second blind slat direction",
|
||||
cover_direction_invert: "Reverse blind in 3D",
|
||||
cover_tilt_direction_invert: "Reverse slats in 3D",
|
||||
cover2_direction_invert: "Reverse second blind in 3D",
|
||||
cover2_tilt_direction_invert: "Reverse second blind slats in 3D",
|
||||
cover_direction_hint: "Reversal affects only the 3D appearance. Numeric values, sliders and control commands stay unchanged: a received value of 0 is still displayed as 0, and a chosen value of 0 is sent as 0.",
|
||||
cover2_tilt_entity: "Slat position (second blind)",
|
||||
symcon_variables_loading: "Loading variables …",
|
||||
symcon_variables_loaded: "Variables and object tree reloaded.",
|
||||
@@ -3328,7 +3330,7 @@ const EN: Record<Key, string> = {
|
||||
cover_entity: "Blind",
|
||||
door_cover: "Drive (motorised door or gate)",
|
||||
cover_position_entity: "Position sensor (live)",
|
||||
cover_position_invert: "Sensor counts the other way round (0 = open)",
|
||||
cover_position_invert: "Reverse position sensor in 3D (0 = open)",
|
||||
contact_entity: "Contact",
|
||||
sensor_kind: "Sensor type",
|
||||
sensor_kind_contact: "Window contact (open/closed)",
|
||||
|
||||
@@ -90,6 +90,18 @@ test("toggling uses the service of the entity's own domain", async () => {
|
||||
assert.deepEqual(hass.calls[0], ["switch", "toggle", { entity_id: "switch.pump" }]);
|
||||
});
|
||||
|
||||
test("a placed blind reverses its 3D marker without changing its zero reading", () => {
|
||||
const building = emptyBuilding();
|
||||
const floor = newFloor("g", "Ground", 0);
|
||||
floor.placements = [{ entity_id: "cover.a", x: 1, z: 1, y: null, cover_inverted: true }];
|
||||
building.floors = [floor];
|
||||
const hass = hassOf([state("cover.a", "closed", { current_position: 0 })]);
|
||||
const [marker] = buildMarkers(hass, building);
|
||||
assert.equal(marker.text, "0 %");
|
||||
assert.equal(marker.active, true);
|
||||
assert.equal(hass.states["cover.a"].attributes.current_position, 0);
|
||||
});
|
||||
|
||||
test("a wall button (event entity) shows when it was last pressed, and a dash before its first press", () => {
|
||||
const hass = hassOf([]);
|
||||
const now = new Date(2026, 10, 1, 18, 0);
|
||||
|
||||
@@ -137,7 +137,7 @@ function markerFor(hass: HomeAssistant, floor: Floor, placed: Placement): Device
|
||||
ownName: placed.name || undefined,
|
||||
showName: !!placed.show_name,
|
||||
text: [stateText(hass, st), deviceValuesText(hass, placed.values)].filter(Boolean).join(" · "),
|
||||
active: isActive(st),
|
||||
active: kind === "cover" && (!!placed.cover_inverted !== (!!placed.position && !!placed.position_inverted)) && !isUnavailable(st) ? !isActive(st) : isActive(st),
|
||||
unavailable: isUnavailable(st),
|
||||
glow: kind === "light" ? scaleGlow(lightGlow(st), placed.glow_scale) : null,
|
||||
effect: kind === "light" ? lightAnimation(placed, st) : undefined,
|
||||
|
||||
@@ -171,6 +171,7 @@ export interface Opening {
|
||||
cover: EntityRef;
|
||||
/** Separate numeric control for the venetian blind's slat position. */
|
||||
cover_tilt?: EntityRef;
|
||||
/** Reverse only the 3D appearance; displayed positions and control commands keep their original direction. */
|
||||
cover_inverted?: boolean;
|
||||
cover_tilt_inverted?: boolean;
|
||||
/** Windows and doors: a second blind for the right half (seen from the room) of a wide window. */
|
||||
@@ -358,6 +359,7 @@ export interface Placement extends LightEffectConfig {
|
||||
/** A placed blind's separate slat position control. */
|
||||
cover_tilt?: EntityRef;
|
||||
values?: DeviceValueLink[];
|
||||
/** Visual direction only; values and commands are unchanged. */
|
||||
cover_inverted?: boolean;
|
||||
cover_tilt_inverted?: boolean;
|
||||
position?: EntityRef;
|
||||
|
||||
@@ -179,9 +179,9 @@ try {
|
||||
await window.chooseControl(field("Lamellenposition"), 102, "Lamellen Position");
|
||||
await window.chooseControl(field("Positions-Sensor (live)"), 103, "Positionsrückmeldung");
|
||||
const check = (text) => [...e.shadowRoot.querySelectorAll("label.nf-check")].find((el) => el.textContent.includes(text)).querySelector("input").click();
|
||||
check("Wirksinn Behang umkehren");
|
||||
check("Behang in 3D umkehren");
|
||||
await e.updateComplete;
|
||||
check("Wirksinn Lamellen umkehren");
|
||||
check("Lamellen in 3D umkehren");
|
||||
await e.updateComplete;
|
||||
await p.updateComplete;
|
||||
await e.updateComplete;
|
||||
@@ -204,8 +204,8 @@ try {
|
||||
const o = f.openings.find((o) => o.id === window.controlWindow);
|
||||
return [f.furniture.find((m) => m.id === window.controlLamp).entity, o.cover, o.cover_tilt, o.position, o.cover_inverted, o.cover_tilt_inverted];
|
||||
}), ["light.42", "cover.101", "cover.102", "cover.103", true, true], "native feedback selection and independent direction switches persist");
|
||||
assert.equal(await page.evaluate(() => window.controlHass.states["cover.101"].attributes.current_position), 80, "display follows inverted 0-255 feedback rather than the command value");
|
||||
assert.equal(await page.evaluate(() => window.controlHass.states["cover.101"].attributes.current_tilt_position), 100 - 128 / 255 * 100);
|
||||
assert.equal(await page.evaluate(() => window.controlHass.states["cover.101"].attributes.current_position), 20, "display follows the unchanged 0-255 feedback despite reversed 3D direction");
|
||||
assert.equal(await page.evaluate(() => window.controlHass.states["cover.101"].attributes.current_tilt_position), 128 / 255 * 100);
|
||||
await page.evaluate(async () => {
|
||||
window.logicalControlCalls = [];
|
||||
const send = window.controlHass.callService;
|
||||
@@ -230,10 +230,30 @@ try {
|
||||
await page.waitForFunction(() => window.actuatorCalls.length === 4);
|
||||
assert.deepEqual(await page.evaluate(() => window.actuatorCalls.map((c) => [c.domain, c.service, c.data])), [
|
||||
["light", "turn_on", { entity_id: "light.42", brightness_pct: 25 }],
|
||||
["cover", "set_cover_position", { entity_id: "cover.101", position: 40 }],
|
||||
["cover", "set_cover_tilt_position", { entity_id: "cover.102", tilt_position: 70 }],
|
||||
["cover", "set_cover_position", { entity_id: "cover.101", position: 60 }],
|
||||
["cover", "set_cover_tilt_position", { entity_id: "cover.102", tilt_position: 30 }],
|
||||
["cover", "set_cover_tilt_position", { entity_id: "cover.102", tilt_position: 70 }],
|
||||
], JSON.stringify(await page.evaluate(() => window.logicalControlCalls)));
|
||||
await page.evaluate(async () => {
|
||||
const raw = window.nfPanel.hass;
|
||||
const states = { ...raw.states };
|
||||
for (const id of ["cover.101", "cover.102", "cover.103"]) states[id] = { ...states[id], state: "closed", attributes: { ...states[id].attributes, symcon_numeric_value: 0, current_position: 0, current_tilt_position: 0 } };
|
||||
const zero = window.SymconAdapter.withCoverControls({ ...raw, states }, window.ed._doc.floors);
|
||||
const panel = document.querySelector("#controls-room"), quick = document.querySelector("#controls-quick");
|
||||
panel.hass = quick.hass = zero;
|
||||
await panel.updateComplete;
|
||||
await quick.updateComplete;
|
||||
const row = [...panel.shadowRoot.querySelectorAll(".nf-rp-row")].find((r) => r.textContent.includes("Behang Position"));
|
||||
const sliders = [...row.querySelectorAll('input[type="range"]')];
|
||||
if (!sliders.every((input) => input.value === "0")) throw new Error("Reversed 3D settings changed a zero slider value");
|
||||
if (quick.shadowRoot.querySelector(".qm-blind b").textContent !== "0 %") throw new Error("Quick menu changed the zero reading");
|
||||
for (const input of sliders) input.dispatchEvent(new Event("change", { bubbles: true }));
|
||||
});
|
||||
await page.waitForFunction(() => window.actuatorCalls.length === 6);
|
||||
assert.deepEqual(await page.evaluate(() => window.actuatorCalls.slice(4).map((c) => [c.service, c.data])), [
|
||||
["set_cover_position", { entity_id: "cover.101", position: 0 }],
|
||||
["set_cover_tilt_position", { entity_id: "cover.102", tilt_position: 0 }],
|
||||
], "zero must be sent unchanged for both blind and slats");
|
||||
assert.equal(await page.evaluate(() => window.actuatorCalls.some((c) => c.data.entity_id === "cover.103")), false, "feedback is never written");
|
||||
await page.evaluate(async () => {
|
||||
const e = window.ed;
|
||||
@@ -245,9 +265,9 @@ try {
|
||||
const positionField = [...e.shadowRoot.querySelectorAll("label.nf-field")].find((el) => el.textContent.trim().startsWith("Positions-Sensor (live)"));
|
||||
await window.chooseControl(positionField.querySelector("nf-entity-picker"), 103, "Positionsrückmeldung");
|
||||
const check = (text) => [...e.shadowRoot.querySelectorAll("label.nf-check")].find((el) => el.textContent.includes(text)).querySelector("input").click();
|
||||
check("Wirksinn Behang umkehren");
|
||||
check("Behang in 3D umkehren");
|
||||
await e.updateComplete;
|
||||
check("Wirksinn Lamellen umkehren");
|
||||
check("Lamellen in 3D umkehren");
|
||||
await e.updateComplete;
|
||||
});
|
||||
assert.equal(await page.evaluate(() => window.ed._doc.floors[0].placements.find((p) => p.entity_id === "cover.101").cover_tilt), "cover.102", "standalone blinds also expose the actual native slat picker");
|
||||
|
||||
Reference in new issue
Block a user