diff --git a/src/data/automation_i18n.ts b/src/data/automation_i18n.ts index 908c37954cbf..f6bc8b208fba 100644 --- a/src/data/automation_i18n.ts +++ b/src/data/automation_i18n.ts @@ -68,9 +68,18 @@ export const describeTrigger = ( hass: HomeAssistant, entityRegistry: EntityRegistryEntry[], ignoreAlias = false -) => { +): string => { try { - return tryDescribeTrigger(trigger, hass, entityRegistry, ignoreAlias); + const description = tryDescribeTrigger( + trigger, + hass, + entityRegistry, + ignoreAlias + ); + if (typeof description !== "string") { + throw new Error(String(description)); + } + return description; } catch (error: any) { // eslint-disable-next-line no-console console.error(error); @@ -700,9 +709,18 @@ export const describeCondition = ( hass: HomeAssistant, entityRegistry: EntityRegistryEntry[], ignoreAlias = false -) => { +): string => { try { - return tryDescribeCondition(condition, hass, entityRegistry, ignoreAlias); + const description = tryDescribeCondition( + condition, + hass, + entityRegistry, + ignoreAlias + ); + if (typeof description !== "string") { + throw new Error(String(description)); + } + return description; } catch (error: any) { // eslint-disable-next-line no-console console.error(error); diff --git a/src/data/script_i18n.ts b/src/data/script_i18n.ts index 64852bc6e779..b623aba7dba5 100644 --- a/src/data/script_i18n.ts +++ b/src/data/script_i18n.ts @@ -50,7 +50,7 @@ export const describeAction = ( ignoreAlias = false ): string => { try { - return tryDescribeAction( + const description = tryDescribeAction( hass, entityRegistry, labelRegistry, @@ -59,6 +59,10 @@ export const describeAction = ( actionType, ignoreAlias ); + if (typeof description !== "string") { + throw new Error(String(description)); + } + return description; } catch (error: any) { // eslint-disable-next-line no-console console.error(error);