From 0edf41a634a09b49f2fb91e05da142101d31a655 Mon Sep 17 00:00:00 2001 From: dfcarvajal Date: Mon, 22 Jul 2019 18:44:22 +0000 Subject: [PATCH] Habilitar HACS --- configuration.yaml | 3 + .../fold-entity-row.js | 56 ++++++++ .../fold-entity-row.js.gz | Bin 0 -> 2415 bytes www/community/monster-card/monster-card.js | 122 ++++++++++++++++++ www/community/monster-card/monster-card.js.gz | Bin 0 -> 1310 bytes 5 files changed, 181 insertions(+) create mode 100644 www/community/lovelace-fold-entity-row/fold-entity-row.js create mode 100644 www/community/lovelace-fold-entity-row/fold-entity-row.js.gz create mode 100644 www/community/monster-card/monster-card.js create mode 100644 www/community/monster-card/monster-card.js.gz diff --git a/configuration.yaml b/configuration.yaml index f73524e..9d7c6c5 100644 --- a/configuration.yaml +++ b/configuration.yaml @@ -18,6 +18,9 @@ group: !include groups.yaml automation: !include_dir_merge_list automation script: !include scripts.yaml +hacs: + token: 5bb7e3904cd0c2928a78ac11c92ff6ac00c5d107 + plant: salon: sensors: diff --git a/www/community/lovelace-fold-entity-row/fold-entity-row.js b/www/community/lovelace-fold-entity-row/fold-entity-row.js new file mode 100644 index 0000000..447a16a --- /dev/null +++ b/www/community/lovelace-fold-entity-row/fold-entity-row.js @@ -0,0 +1,56 @@ +!function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(i,o,function(t){return e[t]}.bind(null,o));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);const i=Object.getPrototypeOf(customElements.get("home-assistant-main")),o=i.prototype.html,s=i.prototype.css;function r(e,t,n=null){if((e=new Event(e,{bubbles:!0,cancelable:!1,composed:!0})).detail=t||{},n)n.dispatchEvent(e);else{var i=document.querySelector("home-assistant");(i=(i=(i=(i=(i=(i=(i=(i=(i=(i=(i=i&&i.shadowRoot)&&i.querySelector("home-assistant-main"))&&i.shadowRoot)&&i.querySelector("app-drawer-layout partial-panel-resolver"))&&i.shadowRoot||i)&&i.querySelector("ha-panel-lovelace"))&&i.shadowRoot)&&i.querySelector("hui-root"))&&i.shadowRoot)&&i.querySelector("ha-app-layout #view"))&&i.firstElementChild)&&i.dispatchEvent(e)}}const a="custom:",c=["input_number","input_select","input_text","input_datetime","scene","weblink"];function l(e,t){const n=document.createElement("hui-error-card");return n.setConfig({type:"error",error:e,config:t}),n}function u(e,t){if(!t||"object"!=typeof t||!t.type)return l(`No ${e} type configured`,t);let n=t.type;if(n=n.startsWith(a)?n.substr(a.length):`hui-${n}-${e}`,customElements.get(n))return function(e,t){const n=document.createElement(e);try{n.setConfig(t)}catch(e){return l(e,t)}return n}(n,t);const i=l(`Custom element doesn't exist: ${n}.`,t);i.style.display="None";const o=setTimeout(()=>{i.style.display=""},2e3);return customElements.whenDefined(n).then(()=>{clearTimeout(o),r("ll-rebuild",{},i)}),i}class h extends i{static get properties(){return{hass:{},config:{}}}setConfig(e){var t;this._config=e,this.el?this.el.setConfig(e):this.el=this.create(e),this._hass&&(this.el.hass=this._hass),this.noHass&&(t=this,document.querySelector("home-assistant").provideHass(t))}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}`}}if(!customElements.get("card-maker")){class e extends h{create(e){return function(e){return u("card",e)}(e)}}customElements.define("card-maker",e)}if(!customElements.get("element-maker")){class e extends h{create(e){return function(e){return u("element",e)}(e)}}customElements.define("element-maker",e)}if(!customElements.get("entity-row-maker")){class e extends h{create(e){return function(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 n=e.type||"default";if(t.has(n)||n.startsWith(a))return u("row",e);const i=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"}[i]||"text"}),u("entity-row",e)}(e)}}customElements.define("entity-row-maker",e)}customElements.define("fold-entity-row",class extends i{static get properties(){return{hass:{},open:Boolean,items:{}}}setConfig(e){this._config=Object.assign({},{open:!1,padding:20,group_config:{}},e),this.open=this.open||this._config.open,this.items=this._config.items,this._config.entities&&(this.items=this._config.entities),"string"==typeof this._config.head&&this._config.head.startsWith("group.")&&(this.items=document.querySelector("home-assistant").hass.states[this._config.head].attributes.entity_id)}clickRow(e){const t=e.target.parentElement._config,n=t.entity||("string"==typeof t?t:null);e.stopPropagation(),this.hasMoreInfo(t)?function(e,t=!1){r("hass-more-info",{entityId:e},document.querySelector("home-assistant"));const n=document.querySelector("home-assistant")._moreInfoEl;n.large=t}(n):e.target.parentElement.hasAttribute("head")&&this.toggle(e)}toggle(e){e&&e.stopPropagation(),this.open=!this.open}hasMoreInfo(e){const t=e.entity||("string"==typeof e?e:null);return!(!t||c.includes(t.split(".",1)[0]))}firstUpdated(){const e=this.shadowRoot.querySelector("#head > entity-row-maker");e.updateComplete.then(()=>{const t=e.querySelector("hui-section-row");t&&t.updateComplete.then(()=>{t.shadowRoot.querySelector(".divider").style.marginRight="-56px"})})}render(){this._entities&&this._entities.forEach(e=>e.hass=this.hass);const e=e=>("string"==typeof e&&(e={entity:e}),Object.assign({},this._config.group_config,e));return o` + + +
+ ${this.items.map(t=>o` + + `)} +
+ `}static get styles(){return s` + #head { + display: flex; + cursor: pointer; + align-items: center; + } + #head entity-row-maker { + flex-grow: 1; + } + #head ha-icon { + width: 40px; + cursor: pointer + } + + #items { + padding: 0; + margin: 0; + overflow: hidden; + max-height: 0; + } + #items[open] { + overflow: visible; + max-height: none; + } + .state-card-dialog { + cursor: pointer; + } + `}})}]); \ No newline at end of file diff --git a/www/community/lovelace-fold-entity-row/fold-entity-row.js.gz b/www/community/lovelace-fold-entity-row/fold-entity-row.js.gz new file mode 100644 index 0000000000000000000000000000000000000000..ff0b80c68382298b14f029aae982012549898fd1 GIT binary patch literal 2415 zcmV-#36S<5iwFoi^E6!o|7LG&WG!WGbZK;XEpl&nE^2cCtypc3+qe<_e!oKI1+E21 zy4~EhDCB6jZ5p8YaF;`JML#SSyRtO4+0djaQR`jE`tLVGQg8M;yDb_7kx35ceV!R+ zwytHSxsnU;n}@XYbkelTZqt(s?l*kB&^P?nFG1I(^yqg4kA*6AwWKR5p{=ChF%LvM zyA0f6+_de|T>`q4r9v!JcQ;VM@LT%05XtOf*lT69OCXR@mT3GpPX<*39iUz^QuNb5 z96qi74VjK|SaS)#ma2eKKN+$HWW9qjT?vSh`37{%TfaqqWimFM)zaS1*(}jd1*o<6 z#of%th#z) zz6r|ZT+inVNXP&``14$M5rQS2{zRut8Br|hY=Zfm{zikO;S$A?Cr-JngjB;q)B#=PX+Vbb)vj31fjo?^el$-!5(@IW8$LEAYr?7{n#TK>N!~$x08A!kqrK zll5u6$m&X~-3I|Xkh-GN1>33}glSdrN~cnXyOc|YDWeiTR#WdpP))Y7sv5AMv^pgw zB`E(W^H0S~fIIoIS zXIsa~UxKKhvF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PA~@p~le)A1XFGP&Bs%Av57*$FZ>w---V#~FWhUwz%TpgW10250BkZ3A zK}^2ri#OohI_Kd-de!pvfs|?l7=&{ zP+a1KH5}j+zLBAwL_8eqMu+W0#IfchnItO2THVLq<@1+a%8l;qd9Jsy_tQmjUdx_U z$IGZWV$zL3-o?PfqT6JP#_+Wu^|n0EL5_(Z!!4NUc(~9`#NANJ-;RV1+#YzvR|1}A hCzXU_j?qbijQE}jQR|Wc0UF': (x, y) => x > y, + '<': (x, y) => x < y, + '<=': (x, y) => x <= y, + '>=': (x, y) => x >= y, + '=': (x, y) => x === y, + }; + let operator = '='; + let y = b; + let x = a; + if (!isNaN(a) && typeof (b) == 'string' + && b.split(" ").length > 1) { + [operator, y] = b.split(' ', 2); + x = parseFloat(a); + } + return _compare[operator](x, y); + } + const entities = new Map(); + filters.forEach((filter) => { + const filters = []; + if (filter.domain) { + filters.push(stateObj => stateObj.entity_id.split('.', 1)[0] === filter.domain); + } + if (filter.attributes) { + Object.keys(filter.attributes).forEach(key => { + filters.push(stateObj => _complexCompare(stateObj.attributes[key], filter.attributes[key])); + }); + } + if (filter.entity_id) { + filters.push(stateObj => _filterEntityId(stateObj, filter.entity_id)); + } + if (filter.name) { + filters.push(stateObj => _filterName(stateObj, filter.name)); + } + if (filter.state) { + filters.push(stateObj => _complexCompare(stateObj.state, filter.state)); + } + + const options = filter.options ? filter.options : {} + + Object.keys(hass.states).sort().forEach(key => { + if (filters.every(filterFunc => filterFunc(hass.states[key]))) { + entities.set(hass.states[key].entity_id, Object.assign({ "entity": hass.states[key].entity_id }, options)); + } + }); + }); + return Array.from(entities.values()); + } + + setConfig(config) { + if (!config.filter.include || !Array.isArray(config.filter.include)) { + throw new Error('Please define filters'); + } + + if (this.lastChild) this.removeChild(this.lastChild); + + const cardConfig = Object.assign({}, config); + if (!cardConfig.card) cardConfig.card = {}; + if (config.card.entities) delete config.card.entities; + if (!cardConfig.card.type) cardConfig.card.type = 'entities'; + + const element = document.createElement(`hui-${cardConfig.card.type}-card`); + this.appendChild(element); + + this._config = cardConfig; + } + + set hass(hass) { + const config = this._config; + let entities = this._getEntities(hass, config.filter.include); + if (config.filter.exclude) { + const excludeEntities = this._getEntities(hass, config.filter.exclude).map(entity => entity.entity); + entities = entities.filter(entity => !excludeEntities.includes(entity.entity)); + } + + + + if (entities.length === 0 && config.show_empty === false) { + this.style.display = 'none'; + } else { + if (config.when && (hass.states[config.when.entity].state == config.when.state) || !config.when) { + this.style.display = 'block'; + } else { + this.style.display = 'none'; + } + } + + if (!config.card.entities || config.card.entities.length !== entities.length || + !config.card.entities.every((value, index) => value.entity === entities[index].entity)) { + config.card.entities = entities; + this.lastChild.setConfig(config.card); + } + this.lastChild.hass = hass; + } + + getCardSize() { + return 'getCardSize' in this.lastChild ? this.lastChild.getCardSize() : 1; + } +} + +customElements.define('monster-card', MonsterCard); diff --git a/www/community/monster-card/monster-card.js.gz b/www/community/monster-card/monster-card.js.gz new file mode 100644 index 0000000000000000000000000000000000000000..7e3d017c117ce967925ca38b33f852e9adba0209 GIT binary patch literal 1310 zcmV+(1>yQ1iwFqH@-$rn|7~w>b97~LEn{JFWG-rR0KHh{St$Xd+04S6WH99{#qH?|epR?G){vQ+A(EM+?ySRW)X_`L^2yWoV z%gX?G2Gdqr6=I5;TLaAE9!zVGjr|j=m0YMp5e$QCV4EILtOrBbz!0{*ntRjY-ZZ&` zHha+E58M1nU>VE2B-`nf&rwA&^$99PaigTTxR38y9KySIAh!kP zM4YNXLm;RkvqeyuL=w|T6e*YN49>zR#cUy$6qH8&JUDa6^s&-!j|33(;D;*NplzX$ z3;dksu_P1Pm1XO}rKSQNo3Qw0V3LTo``J3YiwkC@Y$J^3c{z%yoR}f#&^8OfN)p7w z*bkJUN3(nt^UU|xK^JSWth$E6?P^3O5)nn>Dtx#c>!dc3+d=Sj*Db==PZ}_h(O2Ax z4#CP};``1XwY+^{I-1l2;f>vZY12b5%e!M9Rgrm9Ko3u?J-A~^RagBUeXVieqa0JC zPrO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