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

+8 -4
View File
@@ -7,6 +7,7 @@ import { translate, type I18nKey } from "../i18n.ts";
import { openMoreInfo, stateText } from "../markers.ts";
import { tokens } from "../styles.ts";
import type { HassEntity, HomeAssistant } from "../types.ts";
import { coverWithTilt } from "../entities/covers.ts";
const COLORS: [number, number, number][] = [
[255, 181, 71],
@@ -45,6 +46,7 @@ export class NfQuickMenu extends LitElement {
presets: { attribute: false },
confirmSwitch: { type: Boolean },
myPosition: { attribute: false },
tiltEntity: { attribute: false },
low: { type: Boolean, reflect: true },
};
@@ -58,6 +60,7 @@ export class NfQuickMenu extends LitElement {
declare confirmSwitch: boolean;
/** Blinds: the favourite position (Somfy's "My", %), a button in the ring moves there; null = none. */
declare myPosition: number | null;
declare tiltEntity: string | null;
/** Tablet level: no blur behind the menu. */
declare low: boolean;
private t(key: I18nKey, vars?: Record<string, string | number>): string {
@@ -125,6 +128,7 @@ export class NfQuickMenu extends LitElement {
}
private renderCover(st: HassEntity) {
st = coverWithTilt(this.hass, st, this.tiltEntity);
const pos = typeof st.attributes.current_position === "number" ? (st.attributes.current_position as number) : null;
const moving = st.state === "opening" || st.state === "closing";
const setPos = coverPositionable(st);
@@ -138,9 +142,9 @@ export class NfQuickMenu extends LitElement {
...(setPos ? [75, 50].map((p) => slot(`${p}`, `${p} %`, () => this.ask() && this.call("cover", "set_cover_position", { position: p }), at(p))) : []),
slot("▼", this.t("cover_close"), () => this.ask() && this.call("cover", "close_cover"), at(0)),
...(setPos ? [25].map((p) => slot(`${p}`, `${p} %`, () => this.ask() && this.call("cover", "set_cover_position", { position: p }), at(p))) : []),
slot("■", this.t("cover_stop"), () => this.call("cover", "stop_cover"), moving),
...(Number(st.attributes.supported_features ?? 0) & 8 ? [slot("■", this.t("cover_stop"), () => this.call("cover", "stop_cover"), moving)] : []),
// the favourite position: a cover that sets positions goes there; a Somfy RTS motor without feedback goes to its own "My" on stop
...(this.myPosition != null
...(this.myPosition != null && (setPos || Number(st.attributes.supported_features ?? 0) & 8)
? [slot("My", this.t("cover_my_go", { p: this.myPosition }), () => this.ask() && (setPos ? this.call("cover", "set_cover_position", { position: this.myPosition }) : this.call("cover", "stop_cover")), at(this.myPosition))]
: []),
];
@@ -181,7 +185,7 @@ export class NfQuickMenu extends LitElement {
const tilt = typeof st.attributes.current_tilt_position === "number" ? (st.attributes.current_tilt_position as number) : null;
if (features & COVER_SET_TILT && tilt !== null)
return html`<label class="qm-tilt"
><span>${this.t("cover_tilt")} · ${tilt} %</span>
><span>${this.t("cover_tilt")} · ${Math.round(tilt)} %</span>
<input
class="qm-slider"
type="range"
@@ -189,7 +193,7 @@ export class NfQuickMenu extends LitElement {
max="100"
.value=${String(tilt)}
aria-label=${this.t("cover_tilt")}
@change=${(e: Event) => this.call("cover", "set_cover_tilt_position", { tilt_position: Number((e.target as HTMLInputElement).value) })}
@change=${(e: Event) => this.call("cover", "set_cover_tilt_position", { entity_id: this.tiltEntity || this.entity, tilt_position: Number((e.target as HTMLInputElement).value) })}
/></label>`;
if (features & (COVER_OPEN_TILT | COVER_CLOSE_TILT))
return html`<div class="qm-tilt-buttons">