mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-09 09:27:46 +00:00
shorthand getValueFromEntityId
This commit is contained in:
parent
f2f9ddce33
commit
263efc35a7
@ -80,19 +80,16 @@ function getValueFromEntityId(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
value: string | string[]
|
value: string | string[]
|
||||||
): string | string[] {
|
): string | string[] {
|
||||||
let returned: string | string[];
|
|
||||||
if (
|
if (
|
||||||
typeof value === "string" &&
|
typeof value === "string" &&
|
||||||
isValidEntityId(value) &&
|
isValidEntityId(value) &&
|
||||||
hass.states[value]
|
hass.states[value]
|
||||||
) {
|
) {
|
||||||
returned = hass.states[value]?.state;
|
value = hass.states[value]?.state;
|
||||||
} else if (Array.isArray(value)) {
|
} else if (Array.isArray(value)) {
|
||||||
returned = value.map((v) => getValueFromEntityId(hass, v) as string);
|
value = value.map((v) => getValueFromEntityId(hass, v) as string);
|
||||||
} else {
|
|
||||||
returned = value;
|
|
||||||
}
|
}
|
||||||
return returned;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkLegacyFilterCondition(
|
function checkLegacyFilterCondition(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user