From beddbe114feee4a60f6b1241e87d22a3405a415d Mon Sep 17 00:00:00 2001 From: Simon Lamon <32477463+silamon@users.noreply.github.com> Date: Wed, 25 Oct 2023 19:15:46 +0000 Subject: [PATCH] Fix invalid trigger and conditions types --- src/data/automation_i18n.ts | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/data/automation_i18n.ts b/src/data/automation_i18n.ts index 1ff591e5e878..4037f67500d1 100644 --- a/src/data/automation_i18n.ts +++ b/src/data/automation_i18n.ts @@ -661,13 +661,15 @@ const tryDescribeTrigger = ( }`; } - if (typeof trigger.platform) { - return hass.localize( - `ui.panel.config.automation.editor.triggers.type.${trigger.platform}.label` - ); - } - return hass.localize( - `ui.panel.config.automation.editor.triggers.unknown_trigger` + const triggerType = trigger.platform + ? hass.localize( + `ui.panel.config.automation.editor.triggers.type.${trigger.platform}.label` + ) + : ""; + + return ( + triggerType || + hass.localize(`ui.panel.config.automation.editor.triggers.unknown_trigger`) ); }; @@ -1105,12 +1107,16 @@ const tryDescribeCondition = ( return `When triggered by ${condition.id}`; } - if (condition.condition) { - return hass.localize( - `ui.panel.config.automation.editor.conditions.type.${condition.condition}.label` - ); - } - return hass.localize( - `ui.panel.config.automation.editor.conditions.unknown_condition` + const conditionType = condition.condition + ? hass.localize( + `ui.panel.config.automation.editor.conditions.type.${condition.condition}.label` + ) + : ""; + + return ( + conditionType || + hass.localize( + `ui.panel.config.automation.editor.conditions.unknown_condition` + ) ); };