diff --git a/src/components/ha-selector/ha-selector-object.ts b/src/components/ha-selector/ha-selector-object.ts index 38d58217b2..7ea17e840e 100644 --- a/src/components/ha-selector/ha-selector-object.ts +++ b/src/components/ha-selector/ha-selector-object.ts @@ -52,9 +52,10 @@ export class HaObjectSelector extends LitElement { const translationKey = this.selector.object?.translation_key; if (this.localizeValue && translationKey) { - const label = this.localizeValue( - `${translationKey}.fields.${schema.name}` - ); + const label = + this.localizeValue(`${translationKey}.fields.${schema.name}.name`) || + // Fallback for backward compatibility + this.localizeValue(`${translationKey}.fields.${schema.name}`); if (label) { return label; } @@ -62,6 +63,20 @@ export class HaObjectSelector extends LitElement { return this.selector.object?.fields?.[schema.name]?.label || schema.name; }; + private _computeHelper = (schema: HaFormSchema): string => { + const translationKey = this.selector.object?.translation_key; + + if (this.localizeValue && translationKey) { + const helper = this.localizeValue( + `${translationKey}.fields.${schema.name}.description` + ); + if (helper) { + return helper; + } + } + return this.selector.object?.fields?.[schema.name]?.description || ""; + }; + private _renderItem(item: any, index: number) { const labelField = this.selector.object!.label_field || @@ -214,6 +229,7 @@ export class HaObjectSelector extends LitElement { schema: this._schema(this.selector), data: {}, computeLabel: this._computeLabel, + computeHelper: this._computeHelper, submitText: this.hass.localize("ui.common.add"), }); diff --git a/src/data/selector.ts b/src/data/selector.ts index ae84dbcd28..73555ccfff 100644 --- a/src/data/selector.ts +++ b/src/data/selector.ts @@ -352,6 +352,7 @@ export interface NumberSelector { interface ObjectSelectorField { selector: Selector; label?: string; + description?: string; required?: boolean; }