diff --git a/src/panels/config/devices/device-detail/ha-device-automation-card.ts b/src/panels/config/devices/device-detail/ha-device-automation-card.ts
index 741c426f3d..47577805c3 100644
--- a/src/panels/config/devices/device-detail/ha-device-automation-card.ts
+++ b/src/panels/config/devices/device-detail/ha-device-automation-card.ts
@@ -1,6 +1,8 @@
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { property } from "lit/decorators";
+import { fireEvent } from "../../../../common/dom/fire_event";
import "../../../../components/ha-card";
+import "../../../../components/ha-chip";
import "../../../../components/ha-chip-set";
import { showAutomationEditor } from "../../../../data/automation";
import {
@@ -10,6 +12,12 @@ import {
import { showScriptEditor } from "../../../../data/script";
import { HomeAssistant } from "../../../../types";
+declare global {
+ interface HASSDomEvents {
+ "entry-selected": undefined;
+ }
+}
+
export abstract class HaDeviceAutomationCard<
T extends DeviceAutomation
> extends LitElement {
@@ -55,29 +63,34 @@ export abstract class HaDeviceAutomationCard<
return html`
${this.hass.localize(this.headerKey)}
-
- this._localizeDeviceAutomation(this.hass, automation)
+
+ ${this.automations.map(
+ (automation, idx) =>
+ html`
+
+ ${this._localizeDeviceAutomation(this.hass, automation)}
+
+ `
)}
- >
`;
}
private _handleAutomationClicked(ev: CustomEvent) {
- const automation = this.automations[ev.detail.index];
+ const automation = this.automations[(ev.currentTarget as any).index];
if (!automation) {
return;
}
if (this.script) {
showScriptEditor({ sequence: [automation as DeviceAction] });
+ fireEvent(this, "entry-selected");
return;
}
const data = {};
data[this.type] = [automation];
showAutomationEditor(data);
+ fireEvent(this, "entry-selected");
}
static get styles(): CSSResultGroup {
diff --git a/src/panels/config/devices/device-detail/ha-device-automation-dialog.ts b/src/panels/config/devices/device-detail/ha-device-automation-dialog.ts
index eb18201a25..b42d2f069b 100644
--- a/src/panels/config/devices/device-detail/ha-device-automation-dialog.ts
+++ b/src/panels/config/devices/device-detail/ha-device-automation-dialog.ts
@@ -91,7 +91,7 @@ export class DialogDeviceAutomation extends LitElement {
}.create`
)}
>
-
+
${this._triggers.length ||
this._conditions.length ||
this._actions.length