iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
2 lines • 9.97 kB
JavaScript
export const __webpack_ids__=["52876"];export const __webpack_modules__={31146:function(e,t,i){i.d(t,{i:()=>s});const n=(0,i(93826).P)((e=>{history.replaceState({scrollPosition:e},"")}),300),s=e=>t=>({kind:"method",placement:"prototype",key:t.key,descriptor:{set(e){n(e),this[`__${String(t.key)}`]=e},get(){return this[`__${String(t.key)}`]||history.state?.scrollPosition},enumerable:!0,configurable:!0},finisher(i){const n=i.prototype.connectedCallback;i.prototype.connectedCallback=function(){n.call(this);const i=this[t.key];i&&this.updateComplete.then((()=>{const t=this.renderRoot.querySelector(e);t&&setTimeout((()=>{t.scrollTop=i}),0)}))}}})},12753:function(e,t,i){i.d(t,{N:()=>s});const n=[" ",": "," - "],s=(e,t)=>{const i=e.toLowerCase(),s=t.toLowerCase();for(const t of n){const n=`${s}${t}`;if(i.startsWith(n)){const t=e.substring(n.length);if(t.length)return o(t.substr(0,t.indexOf(" ")))?t:t[0].toUpperCase()+t.slice(1)}}},o=e=>e.toLowerCase()!==e},20526:function(e,t,i){i.d(t,{oU:()=>m,lY:()=>f,VG:()=>_,AP:()=>g});i(92745),i(84283),i(9359),i(56475),i(1331),i(31526),i(70104),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814);var n=i(73358),s=i(73850),o=i(59847),a=i(47194);var r=i(12753),c=i(1416),l=i(82100),d=i(57816),h=i(4242),u=i(96530);const y=new Set(["automation","configurator","device_tracker","event","geo_location","notify","persistent_notification","script","sun","tag","todo","zone",...n.a5]),p=new Set(["backup","mobile_app"]),f=(e,t)=>({type:"grid",cards:e.map((e=>({type:"tile",entity:e,show_entity_picture:["camera","image","person"].includes((0,s.M)(e))||void 0}))),...t}),_=(e,t,i,o=!0)=>{const l=[],d=[],h=i.title?i.title.toLowerCase():void 0,u=[];for(const i of t){const t=e[i],n=(0,s.M)(i);if("alarm_control_panel"===n){const e={type:"alarm-panel",entity:i};l.push(e)}else if("camera"===n){const e={type:"picture-entity",entity:i};l.push(e)}else if("image"===n){const e={type:"picture",image_entity:i};l.push(e)}else if("climate"===n){const t={type:"thermostat",entity:i,features:(e[i]?.attributes?.hvac_modes?.length??0)>1?[{type:"climate-hvac-modes",hvac_modes:e[i]?.attributes?.hvac_modes}]:void 0};l.push(t)}else if("humidifier"===n){const e={type:"humidifier",entity:i,features:[{type:"humidifier-toggle"}]};l.push(e)}else if("media_player"===n){const e={type:"media-control",entity:i};l.push(e)}else if("plant"===n){const e={type:"plant-status",entity:i};l.push(e)}else if("weather"===n){const e={type:"weather-forecast",entity:i,show_forecast:!1};l.push(e)}else if(!o||"scene"!==n&&"script"!==n){let e;const n=h&&t&&(e=(0,r.N)((0,a.C)(t),h))?{entity:i,name:e}:i;d.push(n)}else{const e={entity:i,show_icon:!0,show_name:!0};let n;h&&t&&(n=(0,r.N)((0,a.C)(t),h))&&(e.name=n),u.push(e)}}if(d.sort(((t,i)=>{const o="string"==typeof t?t:t.entity,r="string"==typeof i?i:i.entity,l=n.zF.includes((0,s.M)(o))?"sensor":"control";return l!==(n.zF.includes((0,s.M)(r))?"sensor":"control")?"sensor"===l?1:-1:(0,c.$K)("string"==typeof t?e[t]?(0,a.C)(e[t]):"":t.name||"","string"==typeof i?e[i]?(0,a.C)(e[i]):"":i.name||"")})),0===d.length&&u.length>0)return _(e,t,i,!1);if(d.length>0||u.length>0){const e={type:"entities",entities:d,...i};u.length>0&&(e.footer={type:"buttons",entities:u}),l.unshift(e)}return l.length<2?l:[{type:"grid",square:!1,columns:1,cards:l}]},m=(e,t)=>{const i=[];for(const e of t){const t={type:"entity",entity:e};i.push(t)}return i},g=(e,t,i,n,r,f,m,g,b)=>{const v=((e,t)=>{const i={},n=new Set(Object.values(t).filter((e=>e.entity_category||e.platform&&p.has(e.platform)||e.hidden)).map((e=>e.entity_id)));for(const t of Object.keys(e)){const s=e[t];y.has((0,o.N)(s))||n.has(s.entity_id)||(i[t]=e[t])}return i})(n,i),k={};for(const e of Object.keys(v)){const t=v[e];t.attributes.order&&(k[e]=t.attributes.order)}const C=((e,t,i,n)=>{const s={...n},o={},a={};for(const n of Object.values(i)){const i=n.area_id||n.device_id&&t[n.device_id]?.area_id;i&&i in e&&n.entity_id in s?(i in o||(o[i]=[]),o[i].push(s[n.entity_id]),delete s[n.entity_id]):n.device_id&&n.device_id in t&&n.entity_id in s&&(n.device_id in a||(a[n.device_id]=[]),a[n.device_id].push(s[n.entity_id]),delete s[n.entity_id])}for(const[e,t]of Object.entries(a))1===t.length&&(s[t[0].entity_id]=t[0],delete a[e]);return{areasWithEntities:o,devicesWithEntities:a,otherEntities:s}})(e,t,i,v);if(m?.hidden)for(const e of m.hidden)delete C.areasWithEntities[e];g&&(C.devicesWithEntities={},C.otherEntities={});const w=(e=>{const t=[],i={};return Object.keys(e).forEach((n=>{const o=e[n];"group"===(0,s.M)(n)?t.push(o):i[n]=o})),t.forEach((e=>e.attributes.entity_id.forEach((e=>{delete i[e]})))),{groups:t,ungrouped:i}})(C.otherEntities);w.groups.sort(((e,t)=>k[e.entity_id]-k[t.entity_id]));const $=[];for(const e of w.groups)$.push(..._(n,e.attributes.entity_id,{title:(0,a.C)(e),show_header_toggle:"hidden"!==e.attributes.control}));const E=((e,t,i,n,s)=>{const r={};for(const e of Object.keys(s)){const t=s[e],i=(0,o.N)(t);i in r||(r[i]=[]),r[i].push(t.entity_id)}const l=[];if("person"in r){const e=[];if(1===r.person.length)l.push({type:"entities",entities:r.person});else{let t,i="";for(const n of r.person){const o=s[n];let a=o.attributes.entity_picture;if(!a){if(void 0===t){const e=getComputedStyle(document.body);t=encodeURIComponent(e.getPropertyValue("--light-primary-color").trim()),i=encodeURIComponent((e.getPropertyValue("--text-light-primary-color")||e.getPropertyValue("--primary-text-color")).trim())}a=`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 50 50' width='50' height='50' style='background-color:${t}'%3E%3Cg%3E%3Ctext font-family='roboto' x='50%25' y='50%25' text-anchor='middle' stroke='${i}' font-size='1.3em' dy='.3em'%3E${(0,h.fm)(o.attributes.friendly_name||"")}%3C/text%3E%3C/g%3E%3C/svg%3E`}e.push({type:"picture-entity",entity:n,aspect_ratio:"1",show_name:!1,image:a})}l.push({type:"grid",square:!0,columns:3,cards:e})}delete r.person}const y=[];for(const e of u.y)e in r&&(y.push(...r[e]),delete r[e]);const p={};for(const t of Object.keys(r))p[t]=(0,d.Lh)(e,t);y.length&&(r._helpers=y,p._helpers=e("ui.panel.lovelace.strategy.original-states.helpers")),Object.keys(r).sort(((e,t)=>(0,c.$K)(p[e],p[t]))).forEach((e=>{l.push(..._(s,r[e].sort(((e,t)=>(0,c.$K)((0,a.C)(s[e]),(0,a.C)(s[t])))),{title:p[e]}))}));const f={path:t,title:i,cards:l};return n&&(f.icon=n),f})(r,"default_view","Home",undefined,w.ungrouped),x=[],O=Object.keys(C.areasWithEntities).sort((0,l.a)(e,m?.order));for(const t of O){const i=C.areasWithEntities[t],s=e[t];x.push(..._(n,i.map((e=>e.entity_id)),{title:s.name}))}const j=[],z=Object.entries(C.devicesWithEntities).sort(((e,i)=>{const n=t[e[0]],s=t[i[0]];return(0,c.$K)(n.name_by_user||n.name||"",s.name_by_user||s.name||"")}));for(const[e,i]of z){const s=t[e];j.push(..._(n,i.map((e=>e.entity_id)),{title:s.name_by_user||s.name||r("ui.panel.config.devices.unnamed_device",{type:r(`ui.panel.config.devices.type.${s.entry_type||"device"}`)})}))}let S;if(f&&!b){const e=f.energy_sources.find((e=>"grid"===e.type));e&&e.flow_from.length>0&&(S={title:r("ui.panel.lovelace.cards.energy.energy_distribution.title_today"),type:"energy-distribution",link_dashboard:!0})}return E.cards.unshift(...x,...$,...S?[S]:[]),E.cards.push(...j),E}},71971:function(e,t,i){i.a(e,(async function(e,t){try{var n=i(44249),s=i(57243),o=i(15093),a=i(27486),r=i(36522),c=(i(93288),i(5460)),l=i(95975),d=e([c,l]);[c,l]=d.then?(await d)():d;(0,n.Z)([(0,o.Mo)("hui-entity-picker-table")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,o.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,o.Cb)({type:Boolean})],key:"narrow",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)({type:Boolean,attribute:"no-label-float"})],key:"noLabelFloat",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)({type:Array})],key:"entities",value:void 0},{kind:"method",key:"render",value:function(){return s.dy` <ha-data-table .hass="${this.hass}" selectable .id="${"entity_id"}" .columns="${this._columns(this.narrow)}" .data="${this.entities}" .searchLabel="${this.hass.localize("ui.panel.lovelace.unused_entities.search")}" .noLabelFloat="${this.noLabelFloat}" .noDataText="${this.hass.localize("ui.panel.lovelace.unused_entities.no_data")}" @selection-changed="${this._handleSelectionChanged}"></ha-data-table> `}},{kind:"field",key:"_columns",value(){return(0,a.Z)((e=>{const t={icon:{title:"",label:this.hass.localize("ui.panel.lovelace.unused_entities.state_icon"),type:"icon",template:e=>s.dy` <state-badge @click="${this._handleEntityClicked}" .hass="${this.hass}" .stateObj="${e.stateObj}"></state-badge> `},name:{title:this.hass.localize("ui.panel.lovelace.unused_entities.entity"),sortable:!0,filterable:!0,flex:2,main:!0,direction:"asc",template:t=>s.dy` <div @click="${this._handleEntityClicked}" style="cursor:pointer"> ${t.name} ${e?s.dy` <div class="secondary">${t.entity_id}</div> `:""} </div> `}};return t.entity_id={title:this.hass.localize("ui.panel.lovelace.unused_entities.entity_id"),sortable:!0,filterable:!0,hidden:e},t.domain={title:this.hass.localize("ui.panel.lovelace.unused_entities.domain"),sortable:!0,filterable:!0,hidden:e},t.last_changed={title:this.hass.localize("ui.panel.lovelace.unused_entities.last_changed"),type:"numeric",sortable:!0,hidden:e,template:e=>s.dy` <ha-relative-time .hass="${this.hass}" .datetime="${e.last_changed}" capitalize></ha-relative-time> `},t}))}},{kind:"method",key:"_handleSelectionChanged",value:function(e){const t=e.detail.value;(0,r.B)(this,"selected-changed",{selectedEntities:t})}},{kind:"method",key:"_handleEntityClicked",value:function(e){const t=e.target.closest(".mdc-data-table__row").rowId;(0,r.B)(this,"hass-more-info",{entityId:t})}},{kind:"field",static:!0,key:"styles",value:()=>s.iv`ha-data-table{--data-table-border-width:0;height:100%}`}]}}),s.oi);t()}catch(e){t(e)}}))}};
//# sourceMappingURL=52876.d158f79493b1dc60.js.map