mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 10:16:46 +00:00
Added options to Lovelace evaluate filter (#5694)
This commit is contained in:
parent
db07eeb916
commit
c631554eb0
@ -20,8 +20,21 @@ export const evaluateFilter = (stateObj: HassEntity, filter: any): boolean => {
|
|||||||
return state > value;
|
return state > value;
|
||||||
case "!=":
|
case "!=":
|
||||||
return state !== value;
|
return state !== value;
|
||||||
|
case "in":
|
||||||
|
if (Array.isArray(state) || typeof state === "string") {
|
||||||
|
return state.includes(value);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case "not in":
|
||||||
|
if (Array.isArray(state) || typeof state === "string") {
|
||||||
|
return !state.includes(value);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
case "regex": {
|
case "regex": {
|
||||||
return state.match(value);
|
if (state !== null && typeof state === "object") {
|
||||||
|
return RegExp(value).test(JSON.stringify(state));
|
||||||
|
}
|
||||||
|
return RegExp(value).test(state);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user