fix: support Symcon numeric dimmers and independent blind slat controls
This commit is contained in:
1 parent
b934f78b9a
commit
24188f96f7
36 files changed
+1105
-683
No files matched your search
@@ -8,6 +8,7 @@ export interface EntityOption {
|
||||
label: string;
|
||||
/** A human-readable location, e.g. the path of an IP-Symcon variable in the object tree. */
|
||||
detail?: string;
|
||||
sourceEntity?: string;
|
||||
}
|
||||
|
||||
/** Entities that carry a number: sensors and the number helpers. */
|
||||
@@ -45,6 +46,7 @@ export function entityOptions(hass: HomeAssistant | undefined, accept: (id: stri
|
||||
// In Symcon this is the complete object-tree path. The browser only uses the synthetic id internally;
|
||||
// a person always picks a named variable from the tree path, never types an object id.
|
||||
if (path) option.detail = `Objektbaum: ${path}`;
|
||||
if (typeof state?.attributes.symcon_source_entity === "string") option.sourceEntity = state.attributes.symcon_source_entity;
|
||||
return option;
|
||||
})
|
||||
.sort((a, b) => a.label.localeCompare(b.label));
|
||||
|
||||
@@ -7,7 +7,8 @@ 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, glowField, iconField, markerField, pinShiftField, numberField, selectField, textField } from "../fields.ts";
|
||||
import { checkField, deviceIcon, entityField, glowField, iconField, markerField, pinShiftField, numberField, selectField, textField } from "../fields.ts";
|
||||
import { entityOptions } from "../entities.ts";
|
||||
import type { EditorHost } from "../host.ts";
|
||||
import { lightEffectFields } from "../light-effect-fields.ts";
|
||||
import { pluginDeviceSettings, pluginText, settingsWithDefaults } from "../../../plugins/registry.ts";
|
||||
@@ -96,6 +97,7 @@ export function renderDeviceForm(host: EditorHost, placed: Placement, actions: D
|
||||
${entityName(host.hass, placed.entity_id)}
|
||||
</p>
|
||||
<div class="nf-form">
|
||||
${kind === "cover" ? entityField(host, t("cover_tilt_entity"), placed.cover_tilt ?? null, undefined, entityOptions(host.hass, (id) => id.startsWith("cover.")), (v) => set({ cover_tilt: v && v !== "none" ? v : null })) : 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}
|
||||
|
||||
@@ -167,7 +167,9 @@ function blindFields(host: EditorHost, o: Opening, actions: OpeningActions, list
|
||||
const window = o.type === "window";
|
||||
const automatic = automaticLink(host, o, "cover");
|
||||
const hasBlind = o.cover !== "none" && (o.cover || automatic);
|
||||
return html`${entityField(host, t(window ? "cover_entity" : "door_cover"), o.cover, automatic, lists.covers, (v) => actions.update({ cover: v }))}
|
||||
const symcon = host.hass?.symconObjects !== undefined;
|
||||
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) }))}
|
||||
${o.position ? checkField(host, t("cover_position_invert"), !!o.position_inverted, (on) => actions.update({ position_inverted: on })) : nothing}
|
||||
@@ -177,6 +179,7 @@ function blindFields(host: EditorHost, o: Opening, actions: OpeningActions, list
|
||||
${entityField(host, t("cover2_entity"), o.cover2 ?? null, undefined, lists.covers, (v) => actions.update({ cover2: noneAsNull(v) }))}`
|
||||
: 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}
|
||||
${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}`;
|
||||
|
||||
Reference in new issue
Block a user