From 263efc35a70ab6fc720e20b74820b875d8799858 Mon Sep 17 00:00:00 2001 From: Quentin POLLET Date: Wed, 24 Jan 2024 16:08:29 +0000 Subject: [PATCH] shorthand getValueFromEntityId --- src/panels/lovelace/common/validate-condition.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/panels/lovelace/common/validate-condition.ts b/src/panels/lovelace/common/validate-condition.ts index eab274a522..33df9219e2 100644 --- a/src/panels/lovelace/common/validate-condition.ts +++ b/src/panels/lovelace/common/validate-condition.ts @@ -80,19 +80,16 @@ function getValueFromEntityId( hass: HomeAssistant, value: string | string[] ): string | string[] { - let returned: string | string[]; if ( typeof value === "string" && isValidEntityId(value) && hass.states[value] ) { - returned = hass.states[value]?.state; + value = hass.states[value]?.state; } else if (Array.isArray(value)) { - returned = value.map((v) => getValueFromEntityId(hass, v) as string); - } else { - returned = value; + value = value.map((v) => getValueFromEntityId(hass, v) as string); } - return returned; + return value; } function checkLegacyFilterCondition(