diff --git a/src/data/automation.ts b/src/data/automation.ts
index 6359264eac..cdb751040a 100644
--- a/src/data/automation.ts
+++ b/src/data/automation.ts
@@ -173,6 +173,12 @@ export type Condition =
| DeviceCondition
| LogicalCondition;
+export const triggerAutomation = (hass: HomeAssistant, entityId: string) => {
+ hass.callService("automation", "trigger", {
+ entity_id: entityId,
+ });
+};
+
export const deleteAutomation = (hass: HomeAssistant, id: string) =>
hass.callApi("DELETE", `config/automation/config/${id}`);
diff --git a/src/dialogs/more-info/controls/more-info-automation.ts b/src/dialogs/more-info/controls/more-info-automation.ts
index 62dc5cd7c6..08b53b17cf 100644
--- a/src/dialogs/more-info/controls/more-info-automation.ts
+++ b/src/dialogs/more-info/controls/more-info-automation.ts
@@ -13,6 +13,7 @@ import "@material/mwc-button";
import "../../../components/ha-relative-time";
import { HomeAssistant } from "../../../types";
+import { triggerAutomation } from "../../../data/automation";
@customElement("more-info-automation")
class MoreInfoAutomation extends LitElement {
@@ -42,9 +43,7 @@ class MoreInfoAutomation extends LitElement {
}
private handleAction() {
- this.hass.callService("automation", "trigger", {
- entity_id: this.stateObj!.entity_id,
- });
+ triggerAutomation(this.hass, this.stateObj!.entity_id);
}
static get styles(): CSSResult {
diff --git a/src/panels/config/automation/ha-automation-editor.ts b/src/panels/config/automation/ha-automation-editor.ts
index 4b883b1282..221f5ec6ad 100644
--- a/src/panels/config/automation/ha-automation-editor.ts
+++ b/src/panels/config/automation/ha-automation-editor.ts
@@ -22,6 +22,7 @@ import {
deleteAutomation,
getAutomationEditorInitData,
Trigger,
+ triggerAutomation,
} from "../../../data/automation";
import { Action } from "../../../data/script";
import {
@@ -113,6 +114,28 @@ export class HaAutomationEditor extends LitElement {
@value-changed=${this._valueChanged}
>
+ ${this.creatingNew
+ ? ""
+ : html`
+
+
+
+ ${this.hass.localize(
+ "ui.panel.config.automation.editor.enable_disable"
+ )}
+
+
+ ${this.hass.localize(
+ "ui.card.automation.trigger"
+ )}
+
+
+ `}
@@ -319,6 +342,10 @@ export class HaAutomationEditor extends LitElement {
this._dirty = true;
}
+ private _excuteAutomation() {
+ triggerAutomation(this.hass, this.automation.entity_id);
+ }
+
private _backTapped(): void {
if (this._dirty) {
showConfirmationDialog(this, {
@@ -391,6 +418,9 @@ export class HaAutomationEditor extends LitElement {
span[slot="introduction"] a {
color: var(--primary-color);
}
+ ha-entity-toggle {
+ margin-right: 8px;
+ }
ha-fab {
position: fixed;
bottom: 16px;
diff --git a/src/resources/styles.ts b/src/resources/styles.ts
index 5a5c0cb837..38ab554d39 100644
--- a/src/resources/styles.ts
+++ b/src/resources/styles.ts
@@ -94,6 +94,47 @@ export const haStyle = css`
.card-actions .warning {
--mdc-theme-primary: var(--google-red-500);
}
+
+ .layout.horizontal,
+ .layout.vertical {
+ display: flex;
+ }
+ .layout.inline {
+ display: inline-flex;
+ }
+ .layout.horizontal {
+ flex-direction: row;
+ }
+ .layout.vertical {
+ flex-direction: column;
+ }
+ .layout.wrap {
+ flex-wrap: wrap;
+ }
+ .layout.no-wrap {
+ flex-wrap: nowrap;
+ }
+ .layout.center,
+ .layout.center-center {
+ align-items: center;
+ }
+ .layout.center-justified,
+ .layout.center-center {
+ justify-content: center;
+ }
+ .flex {
+ flex: 1;
+ flex-basis: 0.000000001px;
+ }
+ .flex-auto {
+ flex: 1 1 auto;
+ }
+ .flex-none {
+ flex: none;
+ }
+ .layout.justified {
+ justify-content: space-between;
+ }
`;
export const haStyleDialog = css`
diff --git a/src/translations/en.json b/src/translations/en.json
index 80916a9c1e..1efb96a42a 100755
--- a/src/translations/en.json
+++ b/src/translations/en.json
@@ -847,6 +847,7 @@
"delete_confirm": "Are you sure you want to delete this automation?"
},
"editor": {
+ "enable_disable": "Enable/Disable automation",
"introduction": "Use automations to bring your home alive.",
"default_name": "New Automation",
"load_error_not_editable": "Only automations in automations.yaml are editable.",