Enable use with entity-filter

This commit is contained in:
Thomas Lovén 2019-01-15 22:09:13 +01:00
parent 9f30bdce1b
commit 3ae2c4e8dc

View File

@ -68,6 +68,7 @@ class FoldEntityRow extends LitElement {
conf = (typeof conf === "string") ? {entity: conf} : conf; conf = (typeof conf === "string") ? {entity: conf} : conf;
conf = Object.assign(conf, options); conf = Object.assign(conf, options);
const element = window.cardTools.createEntityRow(conf); const element = window.cardTools.createEntityRow(conf);
element.hass = this._hass;
const DOMAINS_HIDE_MORE_INFO = [ const DOMAINS_HIDE_MORE_INFO = [
"input_number", "input_number",
@ -104,19 +105,25 @@ class FoldEntityRow extends LitElement {
} }
setConfig(config) { setConfig(config) {
if(!window.cardTools) throw new Error(`Can't find card-tools. See https://github.com/thomasloven/lovelace-card-tools`); if(!this._config) {
window.cardTools.checkVersion(0.1); if(!window.cardTools) throw new Error(`Can't find card-tools. See https://github.com/thomasloven/lovelace-card-tools`);
this._config = config; window.cardTools.checkVersion(0.1);
this._closed = !config.open; this._config = config;
this._closed = !config.open;
this._head = this._renderHead(config.head); this._head = this._renderHead(config.head);
}
const head = (typeof config.head === "string") ? config.head : config.head.entity; const head = (typeof config.head === "string") ? config.head : config.head.entity;
let items = config.items let items = config.items
if (config.entities)
items = config.entities;
if (head && head.split('.')[0] === "group") if (head && head.split('.')[0] === "group")
items = window.cardTools.hass().states[head].attributes.entity_id; items = window.cardTools.hass().states[head].attributes.entity_id;
this._entities = items.map((e) => this._renderItem(e, config.group_config)); if(items)
this._entities = items.map((e) => this._renderItem(e, config.group_config));
this.requestUpdate();
} }
set hass(hass) { set hass(hass) {