shorthand getValueFromEntityId

This commit is contained in:
Quentin POLLET 2024-01-24 16:08:29 +00:00
parent f2f9ddce33
commit 263efc35a7

View File

@ -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(