diff --git a/package.json b/package.json index 4d8f433..ac78538 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "battery-state-card", - "version": "3.1.1", + "version": "3.1.2", "description": "Battery State card for Home Assistant", "main": "dist/battery-state-card.js", "author": "Max Chodorowski", diff --git a/src/filter.ts b/src/filter.ts index ae03c87..60747fd 100644 --- a/src/filter.ts +++ b/src/filter.ts @@ -1,4 +1,4 @@ -import { getRegexFromString, log, toNumber } from "./utils"; +import { getRegexFromString, isNumber, log, toNumber } from "./utils"; /** * Functions to check if filter condition is met @@ -7,7 +7,7 @@ const operatorHandlers: { [key in FilterOperator]: (val: string | number | undef "exists": val => val !== undefined, "not_exists": val => val === undefined, "contains": (val, searchString) => val !== undefined && val.toString().indexOf(searchString!.toString()) != -1, - "=": (val, expectedVal) => toNumber(val) == toNumber(expectedVal), + "=": (val, expectedVal) => isNumber(val) || isNumber(expectedVal) ? toNumber(val) == toNumber(expectedVal) : val == expectedVal, ">": (val, expectedVal) => toNumber(val) > toNumber(expectedVal), "<": (val, expectedVal) => toNumber(val) < toNumber(expectedVal), ">=": (val, expectedVal) => toNumber(val) >= toNumber(expectedVal), diff --git a/test/other/filter.test.ts b/test/other/filter.test.ts index c04f17c..e376e06 100644 --- a/test/other/filter.test.ts +++ b/test/other/filter.test.ts @@ -85,7 +85,9 @@ describe("Filter", () => { ["45", "matches", "55", false], [undefined, "matches", "55", false], ["45", "=", "45", true], - ["45", "=", "55", false], + ["45", "=", "45", true], + ["string test", "=", "string", false], + ["string test", "=", "string test", true], ["45", ">", "44", true], ["45", ">", "45", false], ["45", ">=", "45", true],