feat: improve Symcon controls, device readings and designer help

This commit is contained in:
jhartworks committed 2026-11-10 09:19:13 +01:00
1 parent ff54f4461a
commit 00fca890de
50 files changed
+2447 -1840

No files matched your search

@@ -6,6 +6,7 @@ import { entityName, openingEntities, windowPosition } from "../../../devices.ts
import type { I18nKey } from "../../../i18n.ts";
import { DOOR_STYLES, OPENING_PRESETS, openingPreset, openingStyle, WINDOW_OPENINGS, WINDOW_STYLES, type Opening, type OpeningPreset, type OpeningStyle } from "../../../model.ts";
import { entityOptions, isNumeric } from "../entities.ts";
import { isPositionVariable } from "../../../entities/position-value.ts";
import { checkField, entityField, hint, numberField, selectField } from "../fields.ts";
import type { EditorHost } from "../host.ts";
@@ -41,7 +42,7 @@ function choices(host: EditorHost) {
return {
covers: entityOptions(hass, (id) => id.startsWith("cover.")),
// numbers that can report where a blind is
positions: entityOptions(hass, (id) => /^(sensor|number|input_number)\./.test(id) && Number.isFinite(Number(stateOf(id)?.state))),
positions: entityOptions(hass, (id) => isPositionVariable(hass, id)),
// plain contacts, and handle sensors with three states (open, tilted, closed)
contacts: entityOptions(hass, (id) => isContact(id) || (isNumeric(id) && windowPosition(stateOf(id)) !== null)),
plainContacts: entityOptions(hass, isContact),
@@ -171,7 +172,9 @@ function blindFields(host: EditorHost, o: Opening, actions: OpeningActions, list
return html`${entityField(host, t(symcon ? "symcon_cover_position" : window ? "cover_entity" : "door_cover"), o.cover, automatic, lists.covers, (v) => actions.update({ cover: v }))}
${symcon || (hasBlind && o.blind === "venetian") ? entityField(host, t("cover_tilt_entity"), o.cover_tilt ?? null, undefined, lists.covers, (v) => actions.update({ cover_tilt: noneAsNull(v) })) : nothing}
${hasBlind
? html`${entityField(host, t("cover_position_entity"), o.position ?? null, undefined, lists.positions, (v) => actions.update({ position: noneAsNull(v) }))}
? html`${checkField(host, t("cover_direction_invert"), !!o.cover_inverted, (on) => actions.update({ cover_inverted: on || undefined }))}
${o.cover_tilt || o.blind === "venetian" ? checkField(host, t("cover_tilt_direction_invert"), !!o.cover_tilt_inverted, (on) => actions.update({ cover_tilt_inverted: on || undefined })) : nothing}
${entityField(host, t("cover_position_entity"), o.position ?? null, undefined, lists.positions, (v) => actions.update({ position: noneAsNull(v) }))}
${o.position ? checkField(host, t("cover_position_invert"), !!o.position_inverted, (on) => actions.update({ position_inverted: on })) : nothing}
${checkField(host, t("device_confirm"), !!o.confirm, (on) => actions.update({ confirm: on }), { title: t("cover_confirm_hint") })}
${window
@@ -180,6 +183,7 @@ function blindFields(host: EditorHost, o: Opening, actions: OpeningActions, list
: nothing}
${!window && o.type !== "garage" ? entityField(host, t("cover2_entity"), o.cover2 ?? null, undefined, lists.covers, (v) => actions.update({ cover2: noneAsNull(v) })) : nothing}
${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("blind_hint"), "nf-wide")}`
: nothing}`;