import {LitElement, html, css } from "card-tools/src/lit-element"; import {subscribeRenderTemplate} from "card-tools/src/templates"; class TemplateEntityRow extends LitElement { static get properties() { return { hass: {}, _config: {}, state: {}, }; } setConfig(config) { this._config = config; this.state = { icon: "", active: "", name: "", secondary: "", state: "", ...config, }; for(const k of ["icon", "active", "name", "secondary", "state", "condition"]) { if(config[k] && (String(config[k]).includes("{%") || String(config[k]).includes("{{")) ) { subscribeRenderTemplate(null, (res) => { this.state[k] = res; this.requestUpdate(); }, { template: config[k], entity_ids: config.entity_ids, }); } } } render() { if (this._config.condition && String(this.state.condition).toLowerCase() !== "true") return html``; const active = String(this.state.active).toLowerCase(); return html`