Compare commits
No commits in common. "59e20641527ba033f11539416699b2ba1a8e0b29" and "271cacadf7e790f3953c76cf2e70fcc36e65938a" have entirely different histories.
59e2064152
...
271cacadf7
@ -57,7 +57,7 @@ E.g. `_(state.binary_sensor.motion.off)` will be replaced with `Clear` if your l
|
|||||||
|
|
||||||
To find the available keys, open your browsers console, type in the following and press Enter:
|
To find the available keys, open your browsers console, type in the following and press Enter:
|
||||||
```javascript
|
```javascript
|
||||||
document.querySelector("home-assistant").hass.resources
|
document.querySelector("home-assistant").hass.resouces
|
||||||
```
|
```
|
||||||
|
|
||||||
# FAQ
|
# FAQ
|
||||||
|
12
src/main.js
12
src/main.js
@ -27,18 +27,18 @@ class TemplateEntityRow extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setConfig(config) {
|
setConfig(config) {
|
||||||
this._config = {...config};
|
this._config = config;
|
||||||
this.state = {...this._config};
|
this.state = config;
|
||||||
|
|
||||||
for(const k of OPTIONS) {
|
for(const k of OPTIONS) {
|
||||||
if(this._config[k] && hasTemplate(this._config[k])) {
|
if(config[k] && hasTemplate(config[k])) {
|
||||||
subscribeRenderTemplate(null, (res) => {
|
subscribeRenderTemplate(null, (res) => {
|
||||||
this.state[k] = res;
|
this.state[k] = res;
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
}, {
|
}, {
|
||||||
template: this._config[k],
|
template: config[k],
|
||||||
variables: {config: this._config},
|
variables: {config},
|
||||||
entity_ids: this._config.entity_ids,
|
entity_ids: config.entity_ids,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
!function(t){var e={};function i(s){if(e[s])return e[s].exports;var n=e[s]={i:s,l:!1,exports:{}};return t[s].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=t,i.c=e,i.d=function(t,e,s){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(s,n,function(e){return t[e]}.bind(null,n));return s},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0)}([function(t,e,i){"use strict";i.r(e);const s=customElements.get("home-assistant-main")?Object.getPrototypeOf(customElements.get("home-assistant-main")):Object.getPrototypeOf(customElements.get("hui-view")),n=s.prototype.html;s.prototype.css;function o(){return document.querySelector("home-assistant")?document.querySelector("home-assistant").hass:document.querySelector("hc-main")?document.querySelector("hc-main").hass:void 0}let r=function(){if(window.fully&&"function"==typeof fully.getDeviceId)return fully.getDeviceId();if(!localStorage["lovelace-player-device-id"]){const t=()=>Math.floor(1e5*(1+Math.random())).toString(16).substring(1);localStorage["lovelace-player-device-id"]=`${t()}${t()}-${t()}${t()}`}return localStorage["lovelace-player-device-id"]}();function a(t,e,i){t||(t=o().connection);let s={user:o().user.name,browser:r,hash:location.hash.substr(1)||" ",...i.variables},n=i.template,a=i.entity_ids;return t.subscribeMessage(t=>{let i=t.result;i=i.replace(/_\([^)]*\)/g,t=>o().localize(t.substring(2,t.length-1))||t),e(i)},{type:"render_template",template:n,variables:s,entity_ids:a})}const c=["icon","active","name","secondary","state","condition","image","entity","color"];customElements.define("template-entity-row",class extends s{static get properties(){return{hass:{},state:{}}}setConfig(t){this._config={...t},this.state={...this._config};for(const t of c)this._config[t]&&(e=this._config[t],String(e).includes("{%")||String(e).includes("{{"))&&a(null,e=>{this.state[t]=e,this.requestUpdate()},{template:this._config[t],variables:{config:this._config},entity_ids:this._config.entity_ids});var e}render(){if(void 0!==this.state.condition&&"true"!==String(this.state.condition).toLowerCase())return n``;const t=this.hass.states[this.state.entity],e=t&&JSON.parse(JSON.stringify(t))||{entity_id:"light.",attributes:{icon:"no:icon"}},i=void 0!==this.state.icon?this.state.icon||"no:icon":void 0,s=this.state.image,o=void 0!==this.state.name?this.state.name:t?t.attributes.friendly_name||t.entity_id:void 0,r=this.state.secondary,a=void 0!==this.state.state?this.state.state:e?e.state:void 0,c=void 0!==this.state.active?"true"===String(this.state.active).toLowerCase():void 0;return void 0!==c&&(e.attributes.brightness=255,e.attributes.hs_color=void 0!==this.state.color?JSON.parse(this.state.color):[0,0]),n`
|
!function(t){var e={};function i(s){if(e[s])return e[s].exports;var n=e[s]={i:s,l:!1,exports:{}};return t[s].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=t,i.c=e,i.d=function(t,e,s){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(s,n,function(e){return t[e]}.bind(null,n));return s},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0)}([function(t,e,i){"use strict";i.r(e);const s=customElements.get("home-assistant-main")?Object.getPrototypeOf(customElements.get("home-assistant-main")):Object.getPrototypeOf(customElements.get("hui-view")),n=s.prototype.html;s.prototype.css;function o(){return document.querySelector("home-assistant")?document.querySelector("home-assistant").hass:document.querySelector("hc-main")?document.querySelector("hc-main").hass:void 0}let r=function(){if(window.fully&&"function"==typeof fully.getDeviceId)return fully.getDeviceId();if(!localStorage["lovelace-player-device-id"]){const t=()=>Math.floor(1e5*(1+Math.random())).toString(16).substring(1);localStorage["lovelace-player-device-id"]=`${t()}${t()}-${t()}${t()}`}return localStorage["lovelace-player-device-id"]}();function a(t,e,i){t||(t=o().connection);let s={user:o().user.name,browser:r,hash:location.hash.substr(1)||" ",...i.variables},n=i.template,a=i.entity_ids;return t.subscribeMessage(t=>{let i=t.result;i=i.replace(/_\([^)]*\)/g,t=>o().localize(t.substring(2,t.length-1))||t),e(i)},{type:"render_template",template:n,variables:s,entity_ids:a})}const c=["icon","active","name","secondary","state","condition","image","entity","color"];customElements.define("template-entity-row",class extends s{static get properties(){return{hass:{},state:{}}}setConfig(t){this._config=t,this.state=t;for(const i of c)t[i]&&(e=t[i],String(e).includes("{%")||String(e).includes("{{"))&&a(null,t=>{this.state[i]=t,this.requestUpdate()},{template:t[i],variables:{config:t},entity_ids:t.entity_ids});var e}render(){if(void 0!==this.state.condition&&"true"!==String(this.state.condition).toLowerCase())return n``;const t=this.hass.states[this.state.entity],e=t&&JSON.parse(JSON.stringify(t))||{entity_id:"light.",attributes:{icon:"no:icon"}},i=void 0!==this.state.icon?this.state.icon||"no:icon":void 0,s=this.state.image,o=void 0!==this.state.name?this.state.name:t?t.attributes.friendly_name||t.entity_id:void 0,r=this.state.secondary,a=void 0!==this.state.state?this.state.state:e?e.state:void 0,c=void 0!==this.state.active?"true"===String(this.state.active).toLowerCase():void 0;return void 0!==c&&(e.attributes.brightness=255,e.attributes.hs_color=void 0!==this.state.color?JSON.parse(this.state.color):[0,0]),n`
|
||||||
<div id="wrapper">
|
<div id="wrapper">
|
||||||
<state-badge
|
<state-badge
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user