Skip to content
Merged
Changes from 2 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
19 changes: 19 additions & 0 deletions src/panels/lovelace/common/evaluate-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,26 @@ export const evaluateFilter = (stateObj: HassEntity, filter: any): boolean => {
return state > value;
case "!=":
return state !== value;
case "in":
if (Array.isArray(state) || typeof state === typeof "string") {
return state.includes(value);
}
return false;
case "not in":
if (Array.isArray(state) || typeof state === typeof "string") {
return !state.includes(value);
}
return false;
case "regex": {
if (
typeof state !== typeof "string" &&
typeof state !== typeof 1 &&
typeof state !== typeof true &&
state !== null &&
typeof state !== typeof undefined
Comment thread
jayknott marked this conversation as resolved.
Outdated
) {
return (JSON.stringify(state) as any).match(value);
}
return state.match(value);
Comment thread
jayknott marked this conversation as resolved.
Outdated
}
default:
Expand Down