diff --git a/package.json b/package.json index 0428ad4..7216b8a 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "@babel/core": "^7.10.3", "@babel/register": "^7.10.3", "@rollup/plugin-commonjs": "^13.0.0", - "@ava/babel-preset-stage-4": "^4.0.0", "ava": "^3.9.0", "husky": "^4.2.5", "prettier": "^1.18.2", diff --git a/src/filterEntity.js b/src/filterEntity.js index 48a0eba..448bf77 100644 --- a/src/filterEntity.js +++ b/src/filterEntity.js @@ -38,6 +38,9 @@ function compareValue(expect, real) { // And the entire HASS state tree // this function will determine if the passed entity passes filtering rules or not function filterEntity(config, allStates) { + if (!allStates.hasOwnProperty(config.entity)) { + return false; + } if (config.when) { const { state: expect, entity = config.entity, attributes } = typeof config.when === "string" ? { state: config.when } : config.when; diff --git a/src/index.js b/src/index.js index de320f0..c28a088 100644 --- a/src/index.js +++ b/src/index.js @@ -97,7 +97,7 @@ class BannerCard extends LitElement { this._hass = hass; // Parse new state values for _entities_ - this.entityValues = this.entities + this.entityValues = (this.entities || []) .filter(conf => filterEntity(conf, hass.states)) .map(conf => this.parseEntity(conf)); }