Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class HaTriggerCondition extends LitElement {

@property({ attribute: false }) public condition!: TriggerCondition;

@state() private _triggers?: Trigger | Trigger[];
@state() private _triggers: Trigger[] = [];

private _unsub?: UnsubscribeFunc;

Expand All @@ -44,7 +44,8 @@ export class HaTriggerCondition extends LitElement {

protected render() {
const { id } = this.condition;
if (!this._triggers) {

if (!this._triggers.length) {
return this.hass.localize(
"ui.panel.config.automation.editor.conditions.type.trigger.no_triggers"
);
Expand All @@ -56,20 +57,19 @@ export class HaTriggerCondition extends LitElement {
.value=${id}
@selected=${this._triggerPicked}
>
${ensureArray(this._triggers).map((trigger) =>
trigger.id
? html`
<mwc-list-item .value=${trigger.id}>
${trigger.id}
</mwc-list-item>
`
: ""
${this._triggers.map(
(trigger) =>
html`
<mwc-list-item .value=${trigger.id}> ${trigger.id} </mwc-list-item>
`
)}
</mwc-select>`;
}

private _automationUpdated(config?: AutomationConfig) {
this._triggers = config?.trigger;
this._triggers = config?.trigger
? ensureArray(config.trigger).filter((t) => t.id)
: [];
}

private _triggerPicked(ev) {
Expand Down
6 changes: 3 additions & 3 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1799,9 +1799,9 @@
}
},
"trigger": {
"label": "Trigger",
"no_triggers": "No triggers available",
"id": "Trigger ID"
"label": "Triggered by",
"no_triggers": "No triggers have an ID set. You can set an ID using the trigger menu button.",
"id": "Trigger"
},
"zone": {
"label": "[%key:ui::panel::config::automation::editor::triggers::type::zone::label%]",
Expand Down