mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-09 01:17:48 +00:00
shorthand getValueFromEntityId
This commit is contained in:
parent
f2f9ddce33
commit
263efc35a7
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user