From eee0c2e53ff2653d0139e2bef1fc8911e9428aab Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Fri, 20 Sep 2019 17:19:38 +0200 Subject: [PATCH] Add support for automation description (#3723) * Add support for automation annotation * Update label and add placeholder * Rename annotation to description * Adress review comments, fix lint errors --- src/components/ha-textarea.js | 7 ++++++- src/data/automation.ts | 1 + .../config/automation/ha-automation-editor.ts | 1 + src/panels/config/js/automation.tsx | 14 +++++++++++++- src/translations/en.json | 6 +++++- 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/components/ha-textarea.js b/src/components/ha-textarea.js index ef941a39ce..70de137543 100644 --- a/src/components/ha-textarea.js +++ b/src/components/ha-textarea.js @@ -21,7 +21,11 @@ class HaTextarea extends PolymerElement { display: block; } - + `; } @@ -29,6 +33,7 @@ class HaTextarea extends PolymerElement { return { name: String, label: String, + placeholder: String, value: { type: String, notify: true, diff --git a/src/data/automation.ts b/src/data/automation.ts index ad968cc1df..241edf3008 100644 --- a/src/data/automation.ts +++ b/src/data/automation.ts @@ -13,6 +13,7 @@ export interface AutomationEntity extends HassEntityBase { export interface AutomationConfig { alias: string; + description: string; trigger: any[]; condition?: any[]; action: any[]; diff --git a/src/panels/config/automation/ha-automation-editor.ts b/src/panels/config/automation/ha-automation-editor.ts index 92e34d43cb..547f0219b7 100644 --- a/src/panels/config/automation/ha-automation-editor.ts +++ b/src/panels/config/automation/ha-automation-editor.ts @@ -183,6 +183,7 @@ class HaAutomationEditor extends LitElement { alias: this.hass.localize( "ui.panel.config.automation.editor.default_name" ), + description: "", trigger: [{ platform: "state" }], condition: [], action: [{ service: "" }], diff --git a/src/panels/config/js/automation.tsx b/src/panels/config/js/automation.tsx index bb3ff51ee8..e94284cbf2 100644 --- a/src/panels/config/js/automation.tsx +++ b/src/panels/config/js/automation.tsx @@ -3,6 +3,7 @@ import { h, Component } from "preact"; import "@polymer/paper-input/paper-input"; import "../ha-config-section"; import "../../../components/ha-card"; +import "../../../components/ha-textarea"; import Trigger from "./trigger/index"; import Condition from "./condition/index"; @@ -38,7 +39,7 @@ export default class Automation extends Component { } public render({ automation, isWide, hass, localize }) { - const { alias, trigger, condition, action } = automation; + const { alias, description, trigger, condition, action } = automation; return (
@@ -55,6 +56,17 @@ export default class Automation extends Component { value={alias} onvalue-changed={this.onChange} /> +
diff --git a/src/translations/en.json b/src/translations/en.json index 9ef2dd6626..b1c4c24edd 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -699,13 +699,17 @@ "add_automation": "Add automation" }, "editor": { - "introduction": "Use automations to bring your home alive", + "introduction": "Use automations to bring your home alive.", "default_name": "New Automation", "load_error_not_editable": "Only automations in automations.yaml are editable.", "load_error_unknown": "Error loading automation ({err_no}).", "save": "Save", "unsaved_confirm": "You have unsaved changes. Are you sure you want to leave?", "alias": "Name", + "description": { + "label": "Description", + "placeholder": "Optional description" + }, "triggers": { "header": "Triggers", "introduction": "Triggers are what starts the processing of an automation rule. It is possible to specify multiple triggers for the same rule. Once a trigger starts, Home Assistant will validate the conditions, if any, and call the action.",