From 49f34cd1c9fef092c1b9f0c071da748ffaa8c74e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Thu, 30 Jan 2020 15:53:52 +0100 Subject: [PATCH] Fix home-assistant/home-assistant-polymer#4670 --- card-tools.js | 2 +- src/lovelace-element.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/card-tools.js b/card-tools.js index c3d1a8c..5262170 100644 --- a/card-tools.js +++ b/card-tools.js @@ -1 +1 @@ -!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=3)}([function(e,t,r){"use strict";function n(){return document.querySelector("hc-main")?document.querySelector("hc-main").hass:document.querySelector("home-assistant")?document.querySelector("home-assistant").hass:void 0}function o(e){return document.querySelector("hc-main")?document.querySelector("hc-main").provideHass(e):document.querySelector("home-assistant")?document.querySelector("home-assistant").provideHass(e):void 0}function s(){var e,t=document.querySelector("hc-main");return t?((e=t._lovelaceConfig).current_view=t._lovelacePath,e):(t=(t=(t=(t=(t=(t=(t=(t=(t=document.querySelector("home-assistant"))&&t.shadowRoot)&&t.querySelector("home-assistant-main"))&&t.shadowRoot)&&t.querySelector("app-drawer-layout partial-panel-resolver"))&&t.shadowRoot||t)&&t.querySelector("ha-panel-lovelace"))&&t.shadowRoot)&&t.querySelector("hui-root"))?((e=t.lovelace).current_view=t.___curView,e):null}function a(){var e=document.querySelector("hc-main");return e=e?(e=(e=(e=e&&e.shadowRoot)&&e.querySelector("hc-lovelace"))&&e.shadowRoot)&&e.querySelector("hui-view"):(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=document.querySelector("home-assistant"))&&e.shadowRoot)&&e.querySelector("home-assistant-main"))&&e.shadowRoot)&&e.querySelector("app-drawer-layout partial-panel-resolver"))&&e.shadowRoot||e)&&e.querySelector("ha-panel-lovelace"))&&e.shadowRoot)&&e.querySelector("hui-root"))&&e.shadowRoot)&&e.querySelector("ha-app-layout #view"))&&e.firstElementChild}r.d(t,"a",(function(){return n})),r.d(t,"d",(function(){return o})),r.d(t,"b",(function(){return s})),r.d(t,"c",(function(){return a}))},function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));let n=function(){if(window.fully&&"function"==typeof fully.getDeviceId)return fully.getDeviceId();if(!localStorage["lovelace-player-device-id"]){const e=()=>Math.floor(1e5*(1+Math.random())).toString(16).substring(1);localStorage["lovelace-player-device-id"]=`${e()}${e()}-${e()}${e()}`}return localStorage["lovelace-player-device-id"]}()},function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.d(__webpack_exports__,"a",(function(){return hasOldTemplate})),__webpack_require__.d(__webpack_exports__,"b",(function(){return parseOldTemplate}));var _hass_js__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),_deviceID_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1);function hasOldTemplate(e){return/\[\[\s+.*\s+\]\]/.test(e)}function parseTemplateString(str,specialData={}){if("string"!=typeof str)return text;const FUNCTION=/^[a-zA-Z0-9_]+\(.*\)$/,EXPR=/([^=<>!]+)\s*(==|!=|<|>|<=|>=)\s*([^=<>!]+)/,SPECIAL=/^\{.+\}$/,STRING=/^"[^"]*"|'[^']*'$/;"string"==typeof specialData&&(specialData={}),specialData=Object.assign({user:Object(_hass_js__WEBPACK_IMPORTED_MODULE_0__.a)().user.name,browser:_deviceID_js__WEBPACK_IMPORTED_MODULE_1__.a,hash:location.hash.substr(1)||" "},specialData);const _parse_function=e=>{let t=[e.substr(0,e.indexOf("(")).trim()];for(e=e.substr(e.indexOf("(")+1);e;){let r=0,n=0,o=!1;for(;e[r];){let t=e[r++];if(t===o&&r>1&&"\\"!==e[r-2]?o=!1:"\"'".includes(t)&&(o=t),!o){if("("===t)n+=1;else if(")"===t){n-=1;continue}if(!(n>0)&&",)".includes(t))break}}t.push(e.substr(0,r-1).trim()),e=e.substr(r)}return t},_parse_special=e=>(e=e.substr(1,e.length-2),specialData[e]||`{${e}}`),_parse_entity=e=>{let t;if((e=e.split("."))[0].match(SPECIAL))t=_parse_special(e.shift()),t=Object(_hass_js__WEBPACK_IMPORTED_MODULE_0__.a)().states[t]||t;else if(t=Object(_hass_js__WEBPACK_IMPORTED_MODULE_0__.a)().states[`${e.shift()}.${e.shift()}`],!e.length)return t.state;return e.forEach(e=>t=t[e]),t},_eval_expr=str=>{if(str=EXPR.exec(str),null===str)return!1;const lhs=parseTemplateString(str[1]),rhs=parseTemplateString(str[3]);var expr="";return expr=parseFloat(lhs)!=lhs?`"${lhs}" ${str[2]} "${rhs}"`:`${parseFloat(lhs)} ${str[2]} ${parseFloat(rhs)}`,eval(expr)},_eval_function=e=>{if("if"===e[0])return _eval_expr(e[1])?parseTemplateString(e[2]):parseTemplateString(e[3])};try{return str=str.trim(),str.match(STRING)?str.substr(1,str.length-2):str.match(SPECIAL)?_parse_special(str):str.match(FUNCTION)?_eval_function(_parse_function(str)):str.includes(".")?_parse_entity(str):str}catch(e){return`[[ Template matching failed: ${str} ]]`}}function parseOldTemplate(e,t={}){if("string"!=typeof e)return e;return e=e.replace(/\[\[\s(.*?)\s\]\]/g,(e,r,n,o)=>parseTemplateString(r,t))}},function(e,t,r){"use strict";r.r(t);const n=customElements.get("home-assistant-main")?Object.getPrototypeOf(customElements.get("home-assistant-main")):Object.getPrototypeOf(customElements.get("hui-view")),o=n.prototype.html,s=n.prototype.css;var a=r(0);function i(e,t,r=null){if((e=new Event(e,{bubbles:!0,cancelable:!1,composed:!0})).detail=t||{},r)r.dispatchEvent(e);else{var n=Object(a.c)();n&&n.dispatchEvent(e)}}const c="custom:";function l(e,t){const r=document.createElement("hui-error-card");return r.setConfig({type:"error",error:e,origConfig:t}),r}function u(e,t){if(!t||"object"!=typeof t||!t.type)return l(`No ${e} type configured`,t);let r=t.type;if(r=r.startsWith(c)?r.substr(c.length):`hui-${r}-${e}`,customElements.get(r))return function(e,t){const r=document.createElement(e);try{r.setConfig(t)}catch(e){return l(e,t)}return r}(r,t);const n=l(`Custom element doesn't exist: ${r}.`,t);n.style.display="None";const o=setTimeout(()=>{n.style.display=""},2e3);return customElements.whenDefined(r).then(()=>{clearTimeout(o),i("ll-rebuild",{},n)}),n}function d(e){return u("card",e)}function p(e){return u("element",e)}function f(e){const t=new Set(["call-service","divider","section","weblink"]);if(!e)return l("Invalid configuration given.",e);if("string"==typeof e&&(e={entity:e}),"object"!=typeof e||!e.entity&&!e.type)return l("Invalid configuration given.",e);const r=e.type||"default";if(t.has(r)||r.startsWith(c))return u("row",e);const n=e.entity.split(".",1)[0];return Object.assign(e,{type:{alert:"toggle",automation:"toggle",climate:"climate",cover:"cover",fan:"toggle",group:"group",input_boolean:"toggle",input_number:"input-number",input_select:"input-select",input_text:"input-text",light:"toggle",lock:"lock",media_player:"media-player",remote:"toggle",scene:"scene",script:"script",sensor:"sensor",timer:"timer",switch:"toggle",vacuum:"toggle",water_heater:"climate",input_datetime:"input-datetime"}[n]||"text"}),u("entity-row",e)}const m=2;class h extends n{static get version(){return m}static get properties(){return{noHass:{type:Boolean}}}setConfig(e){this._config=e,this.el?this.el.setConfig(e):(this.el=this.create(e),this._hass&&(this.el.hass=this._hass),this.noHass&&Object(a.d)(this))}set config(e){this.setConfig(e)}set hass(e){this._hass=e,this.el&&(this.el.hass=e)}createRenderRoot(){return this}render(){return o`${this.el}`}}const _=function(e,t){const r=Object.getOwnPropertyDescriptors(t.prototype);for(const[t,n]of Object.entries(r))"constructor"!==t&&Object.defineProperty(e.prototype,t,n);const n=Object.getOwnPropertyDescriptors(t);for(const[t,r]of Object.entries(n))"prototype"!==t&&Object.defineProperty(e,t,r);const o=Object.getPrototypeOf(t),s=Object.getOwnPropertyDescriptors(o.prototype);for(const[t,r]of Object.entries(s))"constructor"!==t&&Object.defineProperty(Object.getPrototypeOf(e).prototype,t,r);const a=Object.getOwnPropertyDescriptors(o);for(const[t,r]of Object.entries(a))"prototype"!==t&&Object.defineProperty(Object.getPrototypeOf(e),t,r)},g=customElements.get("card-maker");if(!g||!g.version||g.version{document.body.querySelector("long-press").bind(e)}),customElements.whenDefined("action-handler").then(()=>{document.body.querySelector("action-handler").bind(e,t)}),e}function O(e,t=!1){const r=document.querySelector("hc-main")||document.querySelector("home-assistant");i("hass-more-info",{entityId:e},r);const n=r._moreInfoEl;return n.large=t,n}function S(){const e=document.querySelector("hc-main")||document.querySelector("home-assistant"),t=e&&e._moreInfoEl;t&&t.close()}function E(e,t,r=!1,n=null,o=!1){const s=document.querySelector("hc-main")||document.querySelector("home-assistant");i("hass-more-info",{entityId:null},s);const a=s._moreInfoEl;a.close(),a.open();const c=document.createElement("div");c.innerHTML=`\n \n ${o?"":`\n \n \n
\n ${e}\n
\n
\n `}\n
\n \n \n
\n `;const l=c.querySelector(".scrollable");l.querySelector("card-maker").config=t,a.sizingTarget=l,a.large=r,a._page="none",a.shadowRoot.appendChild(c);let u={};if(n)for(var d in a.resetFit(),n)u[d]=a.style[d],a.style.setProperty(d,n[d]);return a._dialogOpenChanged=function(e){if(!e&&(this.stateObj&&this.fire("hass-more-info",{entityId:null}),this.shadowRoot==c.parentNode&&(this._page=null,this.shadowRoot.removeChild(c),n)))for(var t in a.resetFit(),u)u[t]?a.style.setProperty(t,u[t]):a.style.removeProperty(t)},a}function j(e,t,r){e||(e=Object(a.a)().connection);let n={user:Object(a.a)().user.name,browser:v.a,hash:location.hash.substr(1)||" ",...r.variables},o=r.template,s=r.entity_ids;return e.subscribeMessage(e=>{let r=e.result;r=r.replace(/_\([^)]*\)/g,e=>Object(a.a)().localize(e.substring(2,e.length-1))||e),t(r)},{type:"render_template",template:o,variables:n,entity_ids:s})}var D=r(2);const P=Object(a.a)().callWS({type:"config/area_registry/list"}),T=Object(a.a)().callWS({type:"config/device_registry/list"}),q=Object(a.a)().callWS({type:"config/entity_registry/list"});async function C(){return window.cardToolsData=window.cardToolsData||{areas:await P,devices:await T,entities:await q},window.cardToolsData}function I(e){const t=window.cardToolsData;for(const r of t.areas)if(r.name.toLowerCase()===e.toLowerCase())return r;return null}function R(e){const t=window.cardToolsData;let r=[];if(!e)return r;for(const n of t.devices)n.area_id===e.area_id&&r.push(n);return r}function x(e){const t=window.cardToolsData;for(const r of t.devices)if(r.name.toLowerCase()===e.toLowerCase())return r;return null}function $(e){const t=window.cardToolsData;let r=[];if(!e)return r;for(const n of t.entities)n.device_id===e.id&&r.push(n.entity_id);return r}C();class k{static checkVersion(e){}static args(){}static logger(){}static get localize(){return Object(a.a)().localize}static get deviceID(){return v.a}static get fireEvent(){return i}static get hass(){return Object(a.a)()}static get lovelace(){return Object(a.b)()}static get lovelace_view(){return a.c}static get provideHass(){return a.d}static get LitElement(){return n}static get LitHtml(){return o}static get LitCSS(){return s}static get longpress(){return w}static get createCard(){return d}static get createElement(){return p}static get createEntityRow(){return f}static get moreInfo(){return O}static get popUp(){return E}static get closePopUp(){return S}static get hasTemplate(){return e=>(function(e){return!!String(e).includes("{%")||(!!String(e).includes("{{")||void 0)})(e)||Object(D.a)(e)}static parseTemplate(e,t,r={}){return"string"==typeof e?Object(D.b)(e,t):async function(e,t,r={}){for(var n in e||(e=e()),r={},r=Object.assign({user:e.user.name,browser:v.a,hash:location.hash.substr(1)||" "},r)){var o=new RegExp(`\\{${n}\\}`,"g");t=t.replace(o,r[n])}return e.callApi("POST","template",{template:t})}(e,t,r)}static get subscribeRenderTemplate(){return j}static get getData(){return C}static get areaByName(){return I}static get areaDevices(){return R}static get deviceByName(){return x}static get deviceEntities(){return $}}customElements.get("card-tools")||(customElements.define("card-tools",k),window.cardTools=customElements.get("card-tools"),console.info(`%cCARD-TOOLS 2 IS INSTALLED\n %cDeviceID: ${customElements.get("card-tools").deviceID}`,"color: green; font-weight: bold",""))}]); \ No newline at end of file +!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=3)}([function(e,t,r){"use strict";function n(){return document.querySelector("hc-main")?document.querySelector("hc-main").hass:document.querySelector("home-assistant")?document.querySelector("home-assistant").hass:void 0}function o(e){return document.querySelector("hc-main")?document.querySelector("hc-main").provideHass(e):document.querySelector("home-assistant")?document.querySelector("home-assistant").provideHass(e):void 0}function s(){var e,t=document.querySelector("hc-main");return t?((e=t._lovelaceConfig).current_view=t._lovelacePath,e):(t=(t=(t=(t=(t=(t=(t=(t=(t=document.querySelector("home-assistant"))&&t.shadowRoot)&&t.querySelector("home-assistant-main"))&&t.shadowRoot)&&t.querySelector("app-drawer-layout partial-panel-resolver"))&&t.shadowRoot||t)&&t.querySelector("ha-panel-lovelace"))&&t.shadowRoot)&&t.querySelector("hui-root"))?((e=t.lovelace).current_view=t.___curView,e):null}function a(){var e=document.querySelector("hc-main");return e=e?(e=(e=(e=e&&e.shadowRoot)&&e.querySelector("hc-lovelace"))&&e.shadowRoot)&&e.querySelector("hui-view"):(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=document.querySelector("home-assistant"))&&e.shadowRoot)&&e.querySelector("home-assistant-main"))&&e.shadowRoot)&&e.querySelector("app-drawer-layout partial-panel-resolver"))&&e.shadowRoot||e)&&e.querySelector("ha-panel-lovelace"))&&e.shadowRoot)&&e.querySelector("hui-root"))&&e.shadowRoot)&&e.querySelector("ha-app-layout #view"))&&e.firstElementChild}r.d(t,"a",(function(){return n})),r.d(t,"d",(function(){return o})),r.d(t,"b",(function(){return s})),r.d(t,"c",(function(){return a}))},function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));let n=function(){if(window.fully&&"function"==typeof fully.getDeviceId)return fully.getDeviceId();if(!localStorage["lovelace-player-device-id"]){const e=()=>Math.floor(1e5*(1+Math.random())).toString(16).substring(1);localStorage["lovelace-player-device-id"]=`${e()}${e()}-${e()}${e()}`}return localStorage["lovelace-player-device-id"]}()},function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.d(__webpack_exports__,"a",(function(){return hasOldTemplate})),__webpack_require__.d(__webpack_exports__,"b",(function(){return parseOldTemplate}));var _hass_js__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),_deviceID_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1);function hasOldTemplate(e){return/\[\[\s+.*\s+\]\]/.test(e)}function parseTemplateString(str,specialData={}){if("string"!=typeof str)return text;const FUNCTION=/^[a-zA-Z0-9_]+\(.*\)$/,EXPR=/([^=<>!]+)\s*(==|!=|<|>|<=|>=)\s*([^=<>!]+)/,SPECIAL=/^\{.+\}$/,STRING=/^"[^"]*"|'[^']*'$/;"string"==typeof specialData&&(specialData={}),specialData=Object.assign({user:Object(_hass_js__WEBPACK_IMPORTED_MODULE_0__.a)().user.name,browser:_deviceID_js__WEBPACK_IMPORTED_MODULE_1__.a,hash:location.hash.substr(1)||" "},specialData);const _parse_function=e=>{let t=[e.substr(0,e.indexOf("(")).trim()];for(e=e.substr(e.indexOf("(")+1);e;){let r=0,n=0,o=!1;for(;e[r];){let t=e[r++];if(t===o&&r>1&&"\\"!==e[r-2]?o=!1:"\"'".includes(t)&&(o=t),!o){if("("===t)n+=1;else if(")"===t){n-=1;continue}if(!(n>0)&&",)".includes(t))break}}t.push(e.substr(0,r-1).trim()),e=e.substr(r)}return t},_parse_special=e=>(e=e.substr(1,e.length-2),specialData[e]||`{${e}}`),_parse_entity=e=>{let t;if((e=e.split("."))[0].match(SPECIAL))t=_parse_special(e.shift()),t=Object(_hass_js__WEBPACK_IMPORTED_MODULE_0__.a)().states[t]||t;else if(t=Object(_hass_js__WEBPACK_IMPORTED_MODULE_0__.a)().states[`${e.shift()}.${e.shift()}`],!e.length)return t.state;return e.forEach(e=>t=t[e]),t},_eval_expr=str=>{if(str=EXPR.exec(str),null===str)return!1;const lhs=parseTemplateString(str[1]),rhs=parseTemplateString(str[3]);var expr="";return expr=parseFloat(lhs)!=lhs?`"${lhs}" ${str[2]} "${rhs}"`:`${parseFloat(lhs)} ${str[2]} ${parseFloat(rhs)}`,eval(expr)},_eval_function=e=>{if("if"===e[0])return _eval_expr(e[1])?parseTemplateString(e[2]):parseTemplateString(e[3])};try{return str=str.trim(),str.match(STRING)?str.substr(1,str.length-2):str.match(SPECIAL)?_parse_special(str):str.match(FUNCTION)?_eval_function(_parse_function(str)):str.includes(".")?_parse_entity(str):str}catch(e){return`[[ Template matching failed: ${str} ]]`}}function parseOldTemplate(e,t={}){if("string"!=typeof e)return e;return e=e.replace(/\[\[\s(.*?)\s\]\]/g,(e,r,n,o)=>parseTemplateString(r,t))}},function(e,t,r){"use strict";r.r(t);const n=customElements.get("home-assistant-main")?Object.getPrototypeOf(customElements.get("home-assistant-main")):Object.getPrototypeOf(customElements.get("hui-view")),o=n.prototype.html,s=n.prototype.css;var a=r(0);function i(e,t,r=null){if((e=new Event(e,{bubbles:!0,cancelable:!1,composed:!0})).detail=t||{},r)r.dispatchEvent(e);else{var n=Object(a.c)();n&&n.dispatchEvent(e)}}const c="custom:";function l(e,t){const r=document.createElement("hui-error-card");return r.setConfig({type:"error",error:e,origConfig:t}),r}function u(e,t){if(!t||"object"!=typeof t||!t.type)return l(`No ${e} type configured`,t);let r=t.type;if(r=r.startsWith(c)?r.substr(c.length):`hui-${r}-${e}`,customElements.get(r))return function(e,t){const r=document.createElement(e);try{r.setConfig(t)}catch(e){return l(e,t)}return r}(r,t);const n=l(`Custom element doesn't exist: ${r}.`,t);n.style.display="None";const o=setTimeout(()=>{n.style.display=""},2e3);return customElements.whenDefined(r).then(()=>{clearTimeout(o),i("ll-rebuild",{},n)}),n}function d(e){return u("card",e)}function p(e){return u("element",e)}function f(e){const t=new Set(["call-service","divider","section","weblink"]);if(!e)return l("Invalid configuration given.",e);if("string"==typeof e&&(e={entity:e}),"object"!=typeof e||!e.entity&&!e.type)return l("Invalid configuration given.",e);const r=e.type||"default";return t.has(r)||r.startsWith(c)?u("row",e):u("entity-row",{type:{alert:"toggle",automation:"toggle",climate:"climate",cover:"cover",fan:"toggle",group:"group",input_boolean:"toggle",input_number:"input-number",input_select:"input-select",input_text:"input-text",light:"toggle",lock:"lock",media_player:"media-player",remote:"toggle",scene:"scene",script:"script",sensor:"sensor",timer:"timer",switch:"toggle",vacuum:"toggle",water_heater:"climate",input_datetime:"input-datetime"}[e.entity.split(".",1)[0]]||"text",...e})}const m=2;class h extends n{static get version(){return m}static get properties(){return{noHass:{type:Boolean}}}setConfig(e){this._config=e,this.el?this.el.setConfig(e):(this.el=this.create(e),this._hass&&(this.el.hass=this._hass),this.noHass&&Object(a.d)(this))}set config(e){this.setConfig(e)}set hass(e){this._hass=e,this.el&&(this.el.hass=e)}createRenderRoot(){return this}render(){return o`${this.el}`}}const _=function(e,t){const r=Object.getOwnPropertyDescriptors(t.prototype);for(const[t,n]of Object.entries(r))"constructor"!==t&&Object.defineProperty(e.prototype,t,n);const n=Object.getOwnPropertyDescriptors(t);for(const[t,r]of Object.entries(n))"prototype"!==t&&Object.defineProperty(e,t,r);const o=Object.getPrototypeOf(t),s=Object.getOwnPropertyDescriptors(o.prototype);for(const[t,r]of Object.entries(s))"constructor"!==t&&Object.defineProperty(Object.getPrototypeOf(e).prototype,t,r);const a=Object.getOwnPropertyDescriptors(o);for(const[t,r]of Object.entries(a))"prototype"!==t&&Object.defineProperty(Object.getPrototypeOf(e),t,r)},g=customElements.get("card-maker");if(!g||!g.version||g.version{document.body.querySelector("long-press").bind(e)}),customElements.whenDefined("action-handler").then(()=>{document.body.querySelector("action-handler").bind(e,t)}),e}function O(e,t=!1){const r=document.querySelector("hc-main")||document.querySelector("home-assistant");i("hass-more-info",{entityId:e},r);const n=r._moreInfoEl;return n.large=t,n}function S(){const e=document.querySelector("hc-main")||document.querySelector("home-assistant"),t=e&&e._moreInfoEl;t&&t.close()}function E(e,t,r=!1,n=null,o=!1){const s=document.querySelector("hc-main")||document.querySelector("home-assistant");i("hass-more-info",{entityId:null},s);const a=s._moreInfoEl;a.close(),a.open();const c=document.createElement("div");c.innerHTML=`\n \n ${o?"":`\n \n \n
\n ${e}\n
\n
\n `}\n
\n \n \n
\n `;const l=c.querySelector(".scrollable");l.querySelector("card-maker").config=t,a.sizingTarget=l,a.large=r,a._page="none",a.shadowRoot.appendChild(c);let u={};if(n)for(var d in a.resetFit(),n)u[d]=a.style[d],a.style.setProperty(d,n[d]);return a._dialogOpenChanged=function(e){if(!e&&(this.stateObj&&this.fire("hass-more-info",{entityId:null}),this.shadowRoot==c.parentNode&&(this._page=null,this.shadowRoot.removeChild(c),n)))for(var t in a.resetFit(),u)u[t]?a.style.setProperty(t,u[t]):a.style.removeProperty(t)},a}function j(e,t,r){e||(e=Object(a.a)().connection);let n={user:Object(a.a)().user.name,browser:v.a,hash:location.hash.substr(1)||" ",...r.variables},o=r.template,s=r.entity_ids;return e.subscribeMessage(e=>{let r=e.result;r=r.replace(/_\([^)]*\)/g,e=>Object(a.a)().localize(e.substring(2,e.length-1))||e),t(r)},{type:"render_template",template:o,variables:n,entity_ids:s})}var D=r(2);const P=Object(a.a)().callWS({type:"config/area_registry/list"}),T=Object(a.a)().callWS({type:"config/device_registry/list"}),q=Object(a.a)().callWS({type:"config/entity_registry/list"});async function C(){return window.cardToolsData=window.cardToolsData||{areas:await P,devices:await T,entities:await q},window.cardToolsData}function I(e){const t=window.cardToolsData;for(const r of t.areas)if(r.name.toLowerCase()===e.toLowerCase())return r;return null}function R(e){const t=window.cardToolsData;let r=[];if(!e)return r;for(const n of t.devices)n.area_id===e.area_id&&r.push(n);return r}function x(e){const t=window.cardToolsData;for(const r of t.devices)if(r.name.toLowerCase()===e.toLowerCase())return r;return null}function $(e){const t=window.cardToolsData;let r=[];if(!e)return r;for(const n of t.entities)n.device_id===e.id&&r.push(n.entity_id);return r}C();class k{static checkVersion(e){}static args(){}static logger(){}static get localize(){return Object(a.a)().localize}static get deviceID(){return v.a}static get fireEvent(){return i}static get hass(){return Object(a.a)()}static get lovelace(){return Object(a.b)()}static get lovelace_view(){return a.c}static get provideHass(){return a.d}static get LitElement(){return n}static get LitHtml(){return o}static get LitCSS(){return s}static get longpress(){return w}static get createCard(){return d}static get createElement(){return p}static get createEntityRow(){return f}static get moreInfo(){return O}static get popUp(){return E}static get closePopUp(){return S}static get hasTemplate(){return e=>(function(e){return!!String(e).includes("{%")||(!!String(e).includes("{{")||void 0)})(e)||Object(D.a)(e)}static parseTemplate(e,t,r={}){return"string"==typeof e?Object(D.b)(e,t):async function(e,t,r={}){for(var n in e||(e=e()),r={},r=Object.assign({user:e.user.name,browser:v.a,hash:location.hash.substr(1)||" "},r)){var o=new RegExp(`\\{${n}\\}`,"g");t=t.replace(o,r[n])}return e.callApi("POST","template",{template:t})}(e,t,r)}static get subscribeRenderTemplate(){return j}static get getData(){return C}static get areaByName(){return I}static get areaDevices(){return R}static get deviceByName(){return x}static get deviceEntities(){return $}}customElements.get("card-tools")||(customElements.define("card-tools",k),window.cardTools=customElements.get("card-tools"),console.info(`%cCARD-TOOLS 2 IS INSTALLED\n %cDeviceID: ${customElements.get("card-tools").deviceID}`,"color: green; font-weight: bold",""))}]); \ No newline at end of file diff --git a/src/lovelace-element.js b/src/lovelace-element.js index 82e775e..17fe272 100644 --- a/src/lovelace-element.js +++ b/src/lovelace-element.js @@ -108,7 +108,8 @@ export function createEntityRow(config) { return createLovelaceElement('row', config); const domain = config.entity.split(".", 1)[0]; - Object.assign(config, {type: DEFAULT_ROWS[domain] || "text"}); - - return createLovelaceElement('entity-row', config); + return createLovelaceElement('entity-row', { + type: DEFAULT_ROWS[domain] || "text", + ...config, + }); }