mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 17:26:42 +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;
|
||||
case "!=":
|
||||
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": {
|
||||
return state.match(value);
|
||||
if (state !== null && typeof state === "object") {
|
||||
return RegExp(value).test(JSON.stringify(state));
|
||||
}
|
||||
return RegExp(value).test(state);
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user