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

+17 -5
View File
@@ -7,6 +7,7 @@ import { roomEntities } from "./registry.ts";
export interface OpeningEntities {
cover: string | null;
coverTilt?: string | null;
contact: string | null;
tilt: string | null;
/** Contact and tilt sensor of the second leaf of a double door or window. */
@@ -28,6 +29,7 @@ export interface OpeningEntities {
lock?: string | null;
/** A second blind of a wide window (its right half, seen from the room). */
cover2?: string | null;
cover2Tilt?: string | null;
}
const BLIND_CLASSES = new Set([undefined, "shutter", "blind", "awning", "shade", "curtain", "window"]);
@@ -91,6 +93,8 @@ export function openingEntities(hass: HomeAssistant, floors: readonly Floor[]):
angled: o.type === "door" && !!o.open_angle,
lock: o.type === "door" ? unlessNone(o.lock) : null,
cover2: o.type === "garage" ? null : unlessNone(o.cover2),
coverTilt: unlessNone(o.cover_tilt),
cover2Tilt: unlessNone(o.cover2_tilt),
});
}
}
@@ -146,8 +150,9 @@ function coverClosed(hass: HomeAssistant, id: string | null | undefined): number
}
/** 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): number | null {
const tilt = id ? hass.states[id]?.attributes.current_tilt_position : undefined;
function slatsOpen(hass: HomeAssistant, id: string | null | undefined, separate?: string | null): number | null {
const a = hass.states[separate || id || ""]?.attributes;
const tilt = a?.current_tilt_position ?? (separate ? a?.current_position : undefined);
return typeof tilt === "number" ? Math.min(100, Math.max(0, tilt)) / 100 : null;
}
@@ -185,6 +190,7 @@ export interface OpeningState {
cover2?: number | null;
/** Venetian blinds: how far the slats are open (0 shut, 1 level), from the cover's tilt position. */
slats?: number | null;
slats2?: number | null;
}
/**
@@ -196,12 +202,19 @@ export function openingState(hass: HomeAssistant, e: OpeningEntities, type: Open
const isKnown = (id: string | null | undefined) => !!id && !!hass.states[id] && !isUnavailable(hass.states[id]);
const positionOf = (id: string | null | undefined) => (id ? windowPosition(hass.states[id]) : null);
const cover = blindClosedFraction(hass, e);
const slats = slatsOpen(hass, e.cover, e.coverTilt);
const slats2 = slatsOpen(hass, e.cover2, e.cover2Tilt);
const blindState = {
...(e.cover2 ? { cover2: coverClosed(hass, e.cover2) } : {}),
...(slats !== null ? { slats } : {}),
...(slats2 !== null ? { slats2 } : {}),
};
if (type === "door") {
// a door with a roller shutter (front door, patio door): the blind comes down over it
const leaf = positionOf(e.contact);
const open = leaf === null ? (e.shut ? 0 : e.angled ? 1 : DOOR_DEFAULT_OPEN) : leaf === "closed" ? 0 : 1;
return { open, open2: positionOf(e.contact2) === "open" ? 1 : 0, tilt: 0, tilt2: 0, cover, sensed: leaf !== null || cover !== null, unlocked: isUnlocked(hass, e.lock), assumed: leaf === null };
return { open, open2: positionOf(e.contact2) === "open" ? 1 : 0, tilt: 0, tilt2: 0, cover, ...blindState, sensed: leaf !== null || cover !== null, unlocked: isUnlocked(hass, e.lock), assumed: leaf === null };
}
if (type === "garage") {
// a garage door without a cover shows its contact: open or closed; so does one whose cover cannot tell (a remote without
@@ -231,7 +244,6 @@ export function openingState(hass: HomeAssistant, e: OpeningEntities, type: Open
tilt2: secondTilted ? 1 : 0,
cover,
sensed: isKnown(e.contact) || isKnown(e.tilt) || Number.isFinite(rawAngle),
...(e.cover2 ? { cover2: coverClosed(hass, e.cover2) } : {}),
...(slatsOpen(hass, e.cover) !== null ? { slats: slatsOpen(hass, e.cover) } : {}),
...blindState,
};
}