From 176d8567f4b7ca12eef9b2e38a04e103320c8adc Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 2 Oct 2022 17:39:15 +0200 Subject: [PATCH] Add condition description for trigger condition (#13941) --- gallery/src/pages/automation/describe-condition.ts | 1 + src/data/automation_i18n.ts | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/gallery/src/pages/automation/describe-condition.ts b/gallery/src/pages/automation/describe-condition.ts index 2f6cef5f47..3350dce74f 100644 --- a/gallery/src/pages/automation/describe-condition.ts +++ b/gallery/src/pages/automation/describe-condition.ts @@ -36,6 +36,7 @@ const conditions = [ { condition: "sun", after: "sunset" }, { condition: "sun", after: "sunrise", offset: "-01:00" }, { condition: "zone", entity_id: "device_tracker.person", zone: "zone.home" }, + { condition: "trigger", id: "motion" }, { condition: "time" }, { condition: "template" }, ]; diff --git a/src/data/automation_i18n.ts b/src/data/automation_i18n.ts index c84fc3b868..c4a49721fe 100644 --- a/src/data/automation_i18n.ts +++ b/src/data/automation_i18n.ts @@ -572,6 +572,13 @@ export const describeCondition = ( }`; } + if (condition.condition === "trigger") { + if (!condition.id) { + return "Trigger condition"; + } + return `When triggered by ${condition.id}`; + } + return `${ condition.condition ? condition.condition.replace(/_/g, " ") : "Unknown" } condition`;