UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

1 lines 12.3 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[67785],{99939:function(t,e,i){i.d(e,{S_:function(){return r},Xd:function(){return c},lZ:function(){return l}});i(74423),i(18111),i(7588),i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698),i(62953);const n=["zone","persistent_notification"],s=(t,e)=>{var i,n,s,a,o,r,c,l;if(!("call-service"===e.action&&(null!==(i=e.target)&&void 0!==i&&i.entity_id||null!==(n=e.service_data)&&void 0!==n&&n.entity_id||null!==(s=e.data)&&void 0!==s&&s.entity_id)))return;let d=null!==(a=null!==(o=null===(r=e.service_data)||void 0===r?void 0:r.entity_id)&&void 0!==o?o:null===(c=e.data)||void 0===c?void 0:c.entity_id)&&void 0!==a?a:null===(l=e.target)||void 0===l?void 0:l.entity_id;Array.isArray(d)||(d=[d]);for(const h of d)t.add(h)},a=(t,e)=>{e&&("string"!=typeof e?(e.entity&&t.add(e.entity),e.camera_image&&t.add(e.camera_image),e.tap_action&&s(t,e.tap_action),e.hold_action&&s(t,e.hold_action)):t.add(e))},o=(t,e)=>{e.entity&&a(t,e.entity),e.entities&&Array.isArray(e.entities)&&e.entities.forEach(e=>a(t,e)),e.card&&o(t,e.card),e.cards&&Array.isArray(e.cards)&&e.cards.forEach(e=>o(t,e)),e.elements&&Array.isArray(e.elements)&&e.elements.forEach(e=>o(t,e)),e.badges&&Array.isArray(e.badges)&&e.badges.forEach(e=>a(t,e)),e.sections&&Array.isArray(e.sections)&&e.sections.forEach(e=>o(t,e))},r=t=>{const e=new Set;return t.views.forEach(t=>{o(e,t)}),e},c=(t,e)=>{const i=new Set;for(const s of Object.keys(t.states))e.has(s)||n.includes(s.split(".",1)[0])||i.add(s);return i},l=(t,e)=>{const i=r(e);return c(t,i)}},40747:function(t,e,i){i.d(e,{KT:function(){return f},Bi:function(){return _},ZI:function(){return p},Yp:function(){return m}});i(74423),i(44114),i(26910),i(13609),i(18111),i(22489),i(20116),i(7588),i(61701),i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698),i(42762),i(62953);var n=i(46190),s=i(71727),a=i(69093),o=i(28978);var r=i(79461),c=i(52220),l=i(95350),d=i(28669),h=i(24367);const u=new Set(["ai_task","automation","configurator","device_tracker","event","geo_location","notify","persistent_notification","script","sun","tag","todo","zone",...n.gt]),y=new Set(["backup","mobile_app"]),p=(t,e)=>Object.assign({type:"grid",cards:t.map(t=>({type:"tile",entity:t,show_entity_picture:["camera","image","person"].includes((0,s.m)(t))||void 0}))},e),_=(t,e,i,a=!0)=>{const l=[],d=t.states,h=[],u=i.title?i.title.toLowerCase():void 0,y=[];for(const n of e){const t=d[n],e=(0,s.m)(n);if("alarm_control_panel"===e){const t={type:"alarm-panel",entity:n};l.push(t)}else if("camera"===e){const t={type:"picture-entity",entity:n};l.push(t)}else if("image"===e){const t={type:"picture",image_entity:n};l.push(t)}else if("climate"===e){var p,f,m;const t={type:"thermostat",entity:n,features:(null!==(p=null===(f=d[n])||void 0===f||null===(f=f.attributes)||void 0===f||null===(f=f.hvac_modes)||void 0===f?void 0:f.length)&&void 0!==p?p:0)>1?[{type:"climate-hvac-modes",hvac_modes:null===(m=d[n])||void 0===m||null===(m=m.attributes)||void 0===m?void 0:m.hvac_modes}]:void 0};l.push(t)}else if("humidifier"===e){const t={type:"humidifier",entity:n,features:[{type:"humidifier-toggle"}]};l.push(t)}else if("media_player"===e){const t={type:"media-control",entity:n};l.push(t)}else if("plant"===e){const t={type:"plant-status",entity:n};l.push(t)}else if("weather"===e){const t={type:"weather-forecast",entity:n,show_forecast:!1};l.push(t)}else if(!a||"scene"!==e&&"script"!==e){let e;const i=u&&t&&(e=(0,r.p)((0,o.u)(t),u))?{entity:n,name:e}:n;h.push(i)}else{const e={entity:n,show_icon:!0,show_name:!0};let i;u&&t&&(i=(0,r.p)((0,o.u)(t),u))&&(e.name=i),y.push(e)}}if(h.sort((e,i)=>{const a="string"==typeof e?e:e.entity,r="string"==typeof i?i:i.entity,l=n.JF.includes((0,s.m)(a))?"sensor":"control";return l!==(n.JF.includes((0,s.m)(r))?"sensor":"control")?"sensor"===l?1:-1:(0,c.xL)("string"==typeof e?d[e]?(0,o.u)(d[e]):"":d[e.entity]?t.formatEntityName(d[e.entity],e.name):"","string"==typeof i?d[i]?(0,o.u)(d[i]):"":d[i.entity]?t.formatEntityName(d[i.entity],i.name):"")}),0===h.length&&y.length>0)return _(t,e,i,!1);if(h.length>0||y.length>0){const t=Object.assign({type:"entities",entities:h},i);y.length>0&&(t.footer={type:"buttons",entities:y}),l.unshift(t)}return l.length<2?l:[{type:"grid",square:!1,columns:1,cards:l}]},f=(t,e)=>{const i=[];for(const n of e){const t={type:"entity",entity:n};i.push(t)}return i},m=(t,e,i,n,r,p)=>{const f=t.states,m=t.areas,v=t.devices,g=t.entities,b=((t,e)=>{const i={},n=new Set(Object.values(e).filter(t=>t.entity_category||t.platform&&y.has(t.platform)||t.hidden).map(t=>t.entity_id));for(const s of Object.keys(t)){const e=t[s];u.has((0,a.t)(e))||n.has(e.entity_id)||(i[s]=t[s])}return i})(f,g),w={};for(const s of Object.keys(b)){const t=b[s];t.attributes.order&&(w[s]=t.attributes.order)}const E=((t,e,i,n)=>{const s=Object.assign({},n),a={},o={};for(const c of Object.values(i)){var r;const i=c.area_id||c.device_id&&(null===(r=e[c.device_id])||void 0===r?void 0:r.area_id);i&&i in t&&c.entity_id in s?(i in a||(a[i]=[]),a[i].push(s[c.entity_id]),delete s[c.entity_id]):c.device_id&&c.device_id in e&&c.entity_id in s&&(c.device_id in o||(o[c.device_id]=[]),o[c.device_id].push(s[c.entity_id]),delete s[c.entity_id])}for(const[c,l]of Object.entries(o))1===l.length&&(s[l[0].entity_id]=l[0],delete o[c]);return{areasWithEntities:a,devicesWithEntities:o,otherEntities:s}})(m,v,g,b);if(null!=n&&n.hidden)for(const s of n.hidden)delete E.areasWithEntities[s];r&&(E.devicesWithEntities={},E.otherEntities={});const k=(t=>{const e=[],i={};return Object.keys(t).forEach(n=>{const a=t[n];"group"===(0,s.m)(n)?e.push(a):i[n]=a}),e.forEach(t=>t.attributes.entity_id.forEach(t=>{delete i[t]})),{groups:e,ungrouped:i}})(E.otherEntities);k.groups.sort((t,e)=>w[t.entity_id]-w[e.entity_id]);const $=[];for(const s of k.groups)$.push(..._(t,s.attributes.entity_id,{title:(0,o.u)(s),show_header_toggle:"hidden"!==s.attributes.control}));const C=((t,e,i,n,s,r)=>{const u={},{localize:y}=t;for(const o of Object.keys(r)){const t=r[o],e=(0,a.t)(t);e in u||(u[e]=[]),u[e].push(t.entity_id)}const p=[];if("person"in u){const t=[];if(1===u.person.length)p.push({type:"entities",entities:u.person});else{let e,i="";for(const n of u.person){const s=r[n];let a=s.attributes.entity_picture;if(!a){if(void 0===e){const t=getComputedStyle(document.body);e=encodeURIComponent(t.getPropertyValue("--light-primary-color").trim()),i=encodeURIComponent((t.getPropertyValue("--text-light-primary-color")||t.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:${e}'%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,d._2)(s.attributes.friendly_name||"")}%3C/text%3E%3C/g%3E%3C/svg%3E`}t.push({type:"picture-entity",entity:n,aspect_ratio:"1",show_name:!1,image:a})}p.push({type:"grid",square:!0,columns:3,cards:t})}delete u.person}const f=[];for(const a of h.L)a in u&&(f.push(...u[a]),delete u[a]);const m={};for(const a of Object.keys(u))m[a]=(0,l.p$)(y,a);f.length&&(u._helpers=f,m._helpers=y("ui.panel.lovelace.strategy.original-states.helpers")),Object.keys(u).sort((t,e)=>(0,c.xL)(m[t],m[e])).forEach(e=>{p.push(..._(t,u[e].sort((t,e)=>(0,c.xL)((0,o.u)(r[t]),(0,o.u)(r[e]))),{title:m[e]}))});const v={path:e,title:i,cards:p};return n&&(v.icon=n),s&&(v.show_icon_and_title=s),v})(t,"default_view","Home",void 0,void 0,k.ungrouped),j=[],O=Object.keys(m);if(null!=n&&n.order){const t=n.order;O.sort((0,c.u1)(t))}for(const s of O){if(!(s in E.areasWithEntities))continue;const e=E.areasWithEntities[s],i=m[s];j.push(..._(t,e.map(t=>t.entity_id),{title:i.name}))}const x=[],A=Object.entries(E.devicesWithEntities).sort((t,e)=>{const i=v[t[0]],n=v[e[0]];return(0,c.xL)(i.name_by_user||i.name||"",n.name_by_user||n.name||"")});for(const[s,a]of A){const i=v[s];x.push(..._(t,a.map(t=>t.entity_id),{title:i.name_by_user||i.name||e("ui.panel.config.devices.unnamed_device",{type:e(`ui.panel.config.devices.type.${i.entry_type||"device"}`)})}))}let z;if(i&&!p){const t=i.energy_sources.find(t=>"grid"===t.type);t&&t.stat_energy_from&&(z={title:e("ui.panel.lovelace.cards.energy.energy_distribution.title_today"),type:"energy-distribution",link_dashboard:!0})}return C.cards.unshift(...j,...$,...z?[z]:[]),C.cards.push(...x),C}},83824:function(t,e,i){i.a(t,async function(t,e){try{i(18111),i(61701),i(62953);var n=i(40445),s=i(5124),a=i(67576),o=i(89784),r=i(22786),c=i(1087),l=i(71727),d=i(74705),h=i(15638),u=i(48091),y=i(74281),p=i(36158),_=i(95350),f=t([u,y,p]);[u,y,p]=f.then?(await f)():f;let m,v,g,b,w,E,k,$=t=>t;const C=(0,o.W)({fontFamily:"var(--ha-font-family-code)",fontSize:"var(--ha-font-size-xs)"});class j extends s.WF{firstUpdated(t){super.firstUpdated(t),this.hass.loadBackendTranslation("title")}render(){var t;const e=this._data(this.hass.states,this.hass.localize,this.entities),i=Boolean(null===(t=this.hass.userData)||void 0===t?void 0:t.showEntityIdPicker),n=this._columns(this.narrow,(0,h.qC)(this.hass.language,this.hass.translationMetadata.translations),i);return(0,s.qy)(m||(m=$` <ha-data-table class="${0}" selectable .id="${0}" .columns="${0}" .data="${0}" .searchLabel="${0}" .noDataText="${0}" @selection-changed="${0}"></ha-data-table> `),i?"show-entity-id":"","entity_id",n,e,this.hass.localize("ui.panel.lovelace.unused_entities.search"),this.hass.localize("ui.panel.lovelace.unused_entities.no_data"),this._handleSelectionChanged)}_handleSelectionChanged(t){const e=t.detail.value;(0,c.r)(this,"selected-changed",{selectedEntities:e})}_handleEntityClicked(t){const e=t.target.closest(".mdc-data-table__row").rowId;(0,c.r)(this,"hass-more-info",{entityId:e})}constructor(...t){super(...t),this.narrow=!1,this._data=(0,r.A)((t,e,i)=>(i||Object.keys(t)).map(t=>{const i=this.hass.states[t],[n,s,a]=(0,d.Cf)(i,[{type:"entity"},{type:"device"},{type:"area"}],this.hass.entities,this.hass.devices,this.hass.areas,this.hass.floors),o=[s,n].filter(Boolean).join(" "),r=(0,l.m)(t);return{icon:"",entity_id:t,stateObj:i,name:o,entity_name:n,device_name:s,area_name:a,domain_name:(0,_.p$)(e,r),last_changed:i.last_changed}})),this._columns=(0,r.A)((t,e,i)=>{const n={icon:{title:"",label:this.hass.localize("ui.panel.lovelace.unused_entities.state_icon"),type:"icon",template:t=>(0,s.qy)(v||(v=$` <state-badge @click="${0}" .hass="${0}" .stateObj="${0}"></state-badge> `),this._handleEntityClicked,this.hass,t.stateObj)},name:{title:this.hass.localize("ui.panel.lovelace.unused_entities.entity"),sortable:!0,filterable:!0,flex:2,main:!0,direction:"asc",template:n=>{const a=n.entity_name||n.device_name||n.entity_id,o=[n.area_name,n.entity_name?n.device_name:void 0].filter(Boolean).join(e?" ◂ ":" ▸ ");return(0,s.qy)(g||(g=$` <div @click="${0}" style="cursor:pointer"> ${0} ${0} ${0} </div> `),this._handleEntityClicked,a,o?(0,s.qy)(b||(b=$`<div class="secondary">${0}</div>`),o):s.s6,t&&i?(0,s.qy)(w||(w=$` <div class="secondary" style="${0}"> ${0} </div> `),C,n.entity_id):s.s6)}},entity_name:{title:"entity_name",filterable:!0,hidden:!0},device_name:{title:"device_name",filterable:!0,hidden:!0},area_name:{title:"area_name",filterable:!0,hidden:!0}};return n.entity_id={title:this.hass.localize("ui.panel.lovelace.unused_entities.entity_id"),sortable:!0,filterable:!0,hidden:t||!i},n.domain_name={title:this.hass.localize("ui.panel.lovelace.unused_entities.domain"),sortable:!0,filterable:!0,hidden:t||i},n.last_changed={title:this.hass.localize("ui.panel.lovelace.unused_entities.last_changed"),type:"numeric",sortable:!0,hidden:t,template:t=>(0,s.qy)(E||(E=$` <ha-relative-time .hass="${0}" .datetime="${0}" capitalize></ha-relative-time> `),this.hass,t.last_changed)},n})}}j.styles=(0,s.AH)(k||(k=$`ha-data-table{--data-table-border-width:0;height:100%}ha-data-table.show-entity-id{--data-table-row-height:64px}`)),(0,n.Cg)([(0,a.MZ)({attribute:!1})],j.prototype,"hass",void 0),(0,n.Cg)([(0,a.MZ)({type:Boolean})],j.prototype,"narrow",void 0),(0,n.Cg)([(0,a.MZ)({type:Array})],j.prototype,"entities",void 0),j=(0,n.Cg)([(0,a.EM)("hui-entity-picker-table")],j),e()}catch(m){e(m)}})}}]);