Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/panels/lovelace/common/evaluate-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down