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

+21 -2
View File
@@ -1,9 +1,28 @@
// Pack items with moving parts (curtains, roller screens, awnings, gates) and the cover entity they follow.
import type { Building } from "../model.ts";
import type { Building, Floor } from "../model.ts";
import { coverReach, hasMovingParts, packItem } from "../packs.ts";
import type { HomeAssistant } from "../types.ts";
import type { HassEntity, HomeAssistant } from "../types.ts";
import { isUnavailable } from "./kinds.ts";
import { openingEntities } from "./openings.ts";
/** The separately selected slat variable of either blind of an opening. */
export function coverTiltEntity(hass: HomeAssistant, floors: readonly Floor[], id: string): string | null {
for (const f of floors) for (const p of f.placements) if (p.entity_id === id && p.cover_tilt && p.cover_tilt !== "none") return p.cover_tilt;
for (const e of openingEntities(hass, floors).values()) {
if (e.cover === id && e.coverTilt) return e.coverTilt;
if (e.cover2 === id && e.cover2Tilt) return e.cover2Tilt;
}
return null;
}
export function coverWithTilt(hass: HomeAssistant, st: HassEntity, tilt: string | null | undefined): HassEntity {
if (!tilt) return st;
const a = hass.states[tilt]?.attributes;
const position = a?.current_tilt_position ?? a?.current_position;
if (typeof position !== "number") return st;
return { ...st, attributes: { ...st.attributes, current_tilt_position: position, supported_features: Number(st.attributes.supported_features ?? 0) | 128 } };
}
/** How far open a cover is in percent: its position, else 100 / 0 from open / closed (moving counts half). Null when unknown. */
export function coverPosition(hass: HomeAssistant, id: string | null | undefined): number | null {