1
mirror of https://github.com/home-assistant/frontend synced 2024-09-28 00:43:28 +02:00

Handle unavailable entity in conditional-card (#2996)

* Handle unavailable entity in conditional-card

* cleanup
This commit is contained in:
Ian Richardson 2019-03-23 13:09:30 -05:00 committed by Paulus Schoutsen
parent 8aa501b7bd
commit e2a9cf0d3c

View File

@ -11,13 +11,11 @@ export function checkConditionsMet(
hass: HomeAssistant
): boolean {
return conditions.every((c) => {
if (!(c.entity in hass.states)) {
return false;
}
if (c.state) {
return hass.states[c.entity].state === c.state;
}
return hass!.states[c.entity].state !== c.state_not;
const state = hass.states[c.entity]
? hass!.states[c.entity].state
: "unavailable";
return c.state ? state === c.state : state !== c.state_not;
});
}