iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 14.6 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[71572],{30879:function(t,i,e){e.a(t,async function(t,i){try{e(74423),e(44114),e(26910),e(18111),e(22489),e(20116),e(7588),e(61701),e(45367),e(92731),e(53921),e(3362),e(17642),e(58004),e(33853),e(45876),e(32475),e(15024),e(31698),e(62953);var a=e(40445),o=e(78648),n=e(5124),s=e(67576),r=e(22786),c=e(36312),l=e(1087),d=e(58139),h=e(52220),p=e(77423),u=e(38395),v=e(35952),g=e(99774),_=e(45435),b=e(71606),m=e(49406),y=e(39985),f=e(59653),A=e(38508),H=e(59174),C=(e(47680),e(49639)),V=t([A,H,m,y,C]);[A,H,m,y,C]=V.then?(await V)():V;let M,$,w,L,k,x,P,I,Z,q,z,R=t=>t;const E={area_view:"0_area_view",area:"1_area_settings",device:"2_device"},G=(...t)=>t.filter(Boolean).map(t=>t.startsWith("/")?`zzz${t}`:t).join("_");class j extends n.WF{firstUpdated(){this._loadNavigationItems()}render(){const t=[...this._navigationGroups.related.length?[{id:"related",label:this.hass.localize("ui.components.navigation-picker.related")}]:[],{id:"dashboards",label:this.hass.localize("ui.components.navigation-picker.dashboards")},{id:"views",label:this.hass.localize("ui.components.navigation-picker.views")},...this._navigationGroups.apps.length?[{id:"apps",label:this.hass.localize("ui.components.navigation-picker.apps")}]:[],{id:"other_routes",label:this.hass.localize("ui.components.navigation-picker.other_routes")}];return(0,n.qy)(M||(M=R` <ha-generic-picker .hass="${0}" .value="${0}" allow-custom-value .placeholder="${0}" .helper="${0}" .disabled="${0}" .required="${0}" .getItems="${0}" .valueRenderer="${0}" .rowRenderer="${0}" .sections="${0}" .customValueLabel="${0}" .addButtonLabel="${0}" -changed="${0}"> </ha-generic-picker> `),this.hass,this._loading?void 0:this.value,this.label,this.helper,this._loading||this.disabled,this.required,this._getItems,this._valueRenderer,this._rowRenderer,t,this.hass.localize("ui.components.navigation-picker.add_custom_path"),this.addButtonLabel,this._valueChanged)}async _loadNavigationItems(){await this._loadConfigEntries();const t=Object.entries(this.hass.panels).map(([t,i])=>Object.assign({id:t},i)),i=t.filter(t=>"lovelace"===t.component_name),e=await Promise.all(i.map(t=>(0,v.Dz)(this.hass.connection,t.url_path,!0).then(i=>[t.id,i]).catch(i=>[t.id,void 0]))),a=new Map(e),o=this._navigationGroups.related,n=[],s=[],r=[],l=[];for(const c of t){if(g.qx.includes(c.id))continue;if("app"===c.component_name)continue;const t=`/${c.url_path}`,i=(0,_.Z5)(this.hass,t),e="lovelace"===c.component_name||m.PANEL_DASHBOARDS.includes(c.id),o={id:t,primary:i.label,secondary:i.label!==t?t:void 0,icon:i.icon||"mdi:view-dashboard",sorting_label:G(i.label,t),group:e?"dashboards":"other_routes"};e?n.push(o):l.push(o);const r=a.get(c.id);r&&"views"in r&&r.views.forEach((t,i)=>{var e;const a=`/${c.url_path}/${null!==(e=t.path)&&void 0!==e?e:i}`,o=(0,_.Z5)(this.hass,a,r);s.push({id:a,secondary:a,icon:o.icon||"mdi:view-compact",primary:o.label,sorting_label:G(o.label,a),group:"views"})})}if((0,c.x)(this.hass.config,"hassio"))try{const t=await(0,d.t)((0,u.gh)(this.hass.connection));for(const i of Object.keys(t)){const e=`/app/${i}`,a=(0,_.Z5)(this.hass,e,void 0,t);r.push({id:e,primary:a.label,secondary:e,icon:a.icon,icon_path:a.iconPath,sorting_label:G(a.label,e),group:"apps"})}}catch(h){}for(const[c,d]of Object.entries(_.X1)){const t=`/config/${c}`,i=this.hass.localize(d.translationKey)||c;l.push({id:t,primary:i,secondary:t,icon_path:d.iconPath,sorting_label:G(i,t),group:"other_routes"})}this._navigationGroups={related:o,dashboards:n,views:s,apps:r,other_routes:l},this._navigationItems=[...o,...n,...s,...r,...l],this._loading=!1}updated(t){t.has("context")&&this._loadRelatedItems()}async _loadRelatedItems(){var t,i,e,a;const o=t=>{this._navigationGroups=Object.assign(Object.assign({},this._navigationGroups),{},{related:t}),this._navigationItems=[...t,...this._navigationGroups.dashboards,...this._navigationGroups.views,...this._navigationGroups.apps,...this._navigationGroups.other_routes]};if(!(this.hass&&(null!==(t=this.context)&&void 0!==t&&t.entity_id||null!==(i=this.context)&&void 0!==i&&i.area_id)))return void o([]);const n=this.context,s=await this._getRelatedItems(`${null!==(e=n.entity_id)&&void 0!==e?e:""}|${null!==(a=n.area_id)&&void 0!==a?a:""}`,n);(()=>{var t,i;return(null===(t=this.context)||void 0===t?void 0:t.entity_id)===(null==n?void 0:n.entity_id)&&(null===(i=this.context)||void 0===i?void 0:i.area_id)===(null==n?void 0:n.area_id)})()&&o(s)}async _fetchRelatedItems(t){var i,e,a,o;let n;try{n=t.entity_id?await(0,b.f)(this.hass,"entity",t.entity_id):await(0,b.f)(this.hass,"area",t.area_id)}catch(d){return console.error("Error fetching related items for navigation picker",d),[]}const s=new Set(null!==(i=null===(e=n)||void 0===e?void 0:e.device)&&void 0!==i?i:[]),r=new Set(null!==(a=null===(o=n)||void 0===o?void 0:o.area)&&void 0!==a?a:[]);t.area_id&&r.add(t.area_id);const c=[];for(const h of s){var l;const t=this.hass.devices[h],i=`/config/devices/device/${h}`,e=(0,_.Z5)(this.hass,i);c.push({id:i,primary:e.label,secondary:i,icon:e.icon,icon_path:e.iconPath,sorting_label:G(E.device,e.label,i),group:"related",domain:null!=t&&t.primary_config_entry?null===(l=this._configEntryLookup[t.primary_config_entry])||void 0===l?void 0:l.domain:void 0})}for(const h of r){const t=`/home/${(0,y.W8)(h)}`,i=(0,_.Z5)(this.hass,t);c.push({id:t,primary:i.label,secondary:t,icon:i.icon,icon_path:i.icon?void 0:i.iconPath,sorting_label:G(E.area_view,i.label,t),group:"related"});const e=`/config/areas/area/${h}`;c.push({id:e,primary:this.hass.localize("ui.components.navigation-picker.area_settings",{area:i.label}),secondary:e,icon:i.icon,icon_path:i.icon?void 0:i.iconPath,sorting_label:G(E.area,i.label,e),group:"related"})}return c}async _loadConfigEntries(){if(!Object.keys(this._configEntryLookup).length)try{const t=await(0,p.VN)(this.hass);this._configEntryLookup=Object.fromEntries(t.map(t=>[t.entry_id,t]))}catch(t){console.error("Error fetching config entries for navigation picker",t)}}_valueChanged(t){t.stopPropagation(),this._setValue(t.detail.value)}_setValue(t=""){this.value=t,(0,l.r)(this,"value-changed",{value:this.value},{bubbles:!1,composed:!1})}constructor(...t){super(...t),this.disabled=!1,this.required=!1,this._loading=!0,this._navigationItems=[],this._configEntryLookup={},this._navigationGroups={related:[],dashboards:[],views:[],apps:[],other_routes:[]},this._getRelatedItems=(0,r.A)(async(t,i)=>this._fetchRelatedItems(i),(t,i)=>t[0]===i[0]),this._valueRenderer=t=>{const i=this._navigationItems.find(i=>i.id===t);return(0,n.qy)($||($=R` ${0} <span slot="headline">${0}</span> ${0} `),null!=i&&i.domain?(0,n.qy)(w||(w=R` <ha-domain-icon slot="start" .domain="${0}" brand-fallback></ha-domain-icon> `),i.domain):null!=i&&i.icon?(0,n.qy)(L||(L=R`<ha-icon slot="start" .icon="${0}"></ha-icon>`),i.icon):null!=i&&i.icon_path?(0,n.qy)(k||(k=R`<ha-svg-icon slot="start" .path="${0}"></ha-svg-icon>`),i.icon_path):n.s6,(null==i?void 0:i.primary)||t,null!=i&&i.primary?(0,n.qy)(x||(x=R`<span slot="supporting-text">${0}</span>`),t):n.s6)},this._rowRenderer=t=>(0,n.qy)(P||(P=R` <ha-combo-box-item type="button" compact="compact"> ${0} <span slot="headline">${0}</span> ${0} </ha-combo-box-item> `),t.domain?(0,n.qy)(I||(I=R` <ha-domain-icon slot="start" .domain="${0}" brand-fallback></ha-domain-icon> `),t.domain):t.icon?(0,n.qy)(Z||(Z=R`<ha-icon slot="start" .icon="${0}"></ha-icon>`),t.icon):t.icon_path?(0,n.qy)(q||(q=R`<ha-svg-icon slot="start" .path="${0}"></ha-svg-icon>`),t.icon_path):n.s6,t.primary,t.secondary?(0,n.qy)(z||(z=R`<span slot="supporting-text">${0}</span>`),t.secondary):n.s6),this._fuseIndexes={related:(0,r.A)(t=>o.A.createIndex(C.A1,t)),dashboards:(0,r.A)(t=>o.A.createIndex(C.A1,t)),views:(0,r.A)(t=>o.A.createIndex(C.A1,t)),apps:(0,r.A)(t=>o.A.createIndex(C.A1,t)),other_routes:(0,r.A)(t=>o.A.createIndex(C.A1,t))},this._getItems=(t,i)=>{const e=this.excludePaths?new Set(this.excludePaths):void 0,a=i=>{let a=[...this._navigationGroups[i]].sort(this._sortBySortingLabel);if(e&&(a=a.filter(t=>!e.has(t.id))),t){const e=this._fuseIndexes[i](a);a=(0,f.x)(a,t,C.A1,t=>t.id,e)}return a},o=[],n=a("related"),s=a("dashboards"),r=a("views"),c=a("apps"),l=a("other_routes"),d=(t,e)=>{i&&i!==t||(!i&&e.length&&o.push(this.hass.localize(`ui.components.navigation-picker.${t}`)),o.push(...e))};return d("related",n),d("dashboards",s),d("views",r),d("apps",c),d("other_routes",l),o},this._sortBySortingLabel=(t,i)=>(0,h.SH)(t.sorting_label,i.sorting_label,this.hass.locale.language)}}(0,a.Cg)([(0,s.MZ)({attribute:!1})],j.prototype,"hass",void 0),(0,a.Cg)([(0,s.MZ)()],j.prototype,"label",void 0),(0,a.Cg)([(0,s.MZ)()],j.prototype,"value",void 0),(0,a.Cg)([(0,s.MZ)()],j.prototype,"helper",void 0),(0,a.Cg)([(0,s.MZ)({type:Boolean})],j.prototype,"disabled",void 0),(0,a.Cg)([(0,s.MZ)({type:Boolean})],j.prototype,"required",void 0),(0,a.Cg)([(0,s.MZ)({attribute:!1})],j.prototype,"excludePaths",void 0),(0,a.Cg)([(0,s.MZ)({attribute:"add-button-label"})],j.prototype,"addButtonLabel",void 0),(0,a.Cg)([(0,s.wk)()],j.prototype,"_loading",void 0),(0,a.Cg)([(0,s.MZ)({attribute:!1})],j.prototype,"context",void 0),j=(0,a.Cg)([(0,s.EM)("ha-navigation-picker")],j),i()}catch(M){i(M)}})},45435:function(t,i,e){e.d(i,{Mw:function(){return p},X1:function(){return v},Z5:function(){return g},sy:function(){return y}});e(27495),e(25440);var a=e(36312),o=e(37981),n=e(38395),s=e(99129),r=e(91984),c=e(99774);const l="M3 6H21V4H3C1.9 4 1 4.9 1 6V18C1 19.1 1.9 20 3 20H7V18H3V6M13 12H9V13.78C8.39 14.33 8 15.11 8 16C8 16.89 8.39 17.67 9 18.22V20H13V18.22C13.61 17.67 14 16.88 14 16S13.61 14.33 13 13.78V12M11 17.5C10.17 17.5 9.5 16.83 9.5 16S10.17 14.5 11 14.5 12.5 15.17 12.5 16 11.83 17.5 11 17.5M22 8H16C15.5 8 15 8.5 15 9V19C15 19.5 15.5 20 16 20H22C22.5 20 23 19.5 23 19V9C23 8.5 22.5 8 22 8M21 18H17V10H21V18Z",d="M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z",h="M20.5,11H19V7C19,5.89 18.1,5 17,5H13V3.5A2.5,2.5 0 0,0 10.5,1A2.5,2.5 0 0,0 8,3.5V5H4A2,2 0 0,0 2,7V10.8H3.5C5,10.8 6.2,12 6.2,13.5C6.2,15 5,16.2 3.5,16.2H2V20A2,2 0 0,0 4,22H7.8V20.5C7.8,19 9,17.8 10.5,17.8C12,17.8 13.2,19 13.2,20.5V22H17A2,2 0 0,0 19,20V16H20.5A2.5,2.5 0 0,0 23,13.5A2.5,2.5 0 0,0 20.5,11Z",p={label:"",iconPath:d},u="areas-",v={automation:{translationKey:"ui.components.navigation-picker.route.automations",iconPath:"M12,2A2,2 0 0,1 14,4C14,4.74 13.6,5.39 13,5.73V7H14A7,7 0 0,1 21,14H22A1,1 0 0,1 23,15V18A1,1 0 0,1 22,19H21V20A2,2 0 0,1 19,22H5A2,2 0 0,1 3,20V19H2A1,1 0 0,1 1,18V15A1,1 0 0,1 2,14H3A7,7 0 0,1 10,7H11V5.73C10.4,5.39 10,4.74 10,4A2,2 0 0,1 12,2M7.5,13A2.5,2.5 0 0,0 5,15.5A2.5,2.5 0 0,0 7.5,18A2.5,2.5 0 0,0 10,15.5A2.5,2.5 0 0,0 7.5,13M16.5,13A2.5,2.5 0 0,0 14,15.5A2.5,2.5 0 0,0 16.5,18A2.5,2.5 0 0,0 19,15.5A2.5,2.5 0 0,0 16.5,13Z"},scene:{translationKey:"ui.components.navigation-picker.route.scenes",iconPath:"M17.5,12A1.5,1.5 0 0,1 16,10.5A1.5,1.5 0 0,1 17.5,9A1.5,1.5 0 0,1 19,10.5A1.5,1.5 0 0,1 17.5,12M14.5,8A1.5,1.5 0 0,1 13,6.5A1.5,1.5 0 0,1 14.5,5A1.5,1.5 0 0,1 16,6.5A1.5,1.5 0 0,1 14.5,8M9.5,8A1.5,1.5 0 0,1 8,6.5A1.5,1.5 0 0,1 9.5,5A1.5,1.5 0 0,1 11,6.5A1.5,1.5 0 0,1 9.5,8M6.5,12A1.5,1.5 0 0,1 5,10.5A1.5,1.5 0 0,1 6.5,9A1.5,1.5 0 0,1 8,10.5A1.5,1.5 0 0,1 6.5,12M12,3A9,9 0 0,0 3,12A9,9 0 0,0 12,21A1.5,1.5 0 0,0 13.5,19.5C13.5,19.11 13.35,18.76 13.11,18.5C12.88,18.23 12.73,17.88 12.73,17.5A1.5,1.5 0 0,1 14.23,16H16A5,5 0 0,0 21,11C21,6.58 16.97,3 12,3Z"},script:{translationKey:"ui.components.navigation-picker.route.scripts",iconPath:"M17.8,20C17.4,21.2 16.3,22 15,22H5C3.3,22 2,20.7 2,19V18H5L14.2,18C14.6,19.2 15.7,20 17,20H17.8M19,2C20.7,2 22,3.3 22,5V6H20V5C20,4.4 19.6,4 19,4C18.4,4 18,4.4 18,5V18H17C16.4,18 16,17.6 16,17V16H5V5C5,3.3 6.3,2 8,2H19M8,6V8H15V6H8M8,10V12H14V10H8Z"},"developer-tools":{translationKey:"ui.components.navigation-picker.route.developer_tools",iconPath:"M2 19.63L13.43 8.2L12.72 7.5L14.14 6.07L12 3.89C13.2 2.7 15.09 2.7 16.27 3.89L19.87 7.5L18.45 8.91H21.29L22 9.62L18.45 13.21L17.74 12.5V9.62L16.27 11.04L15.56 10.33L4.13 21.76L2 19.63Z"},integrations:{translationKey:"ui.components.navigation-picker.route.integrations",iconPath:h},devices:{translationKey:"ui.components.navigation-picker.route.devices",iconPath:l},entities:{translationKey:"ui.components.navigation-picker.route.entities",iconPath:"M11,13.5V21.5H3V13.5H11M12,2L17.5,11H6.5L12,2M17.5,13C20,13 22,15 22,17.5C22,20 20,22 17.5,22C15,22 13,20 13,17.5C13,15 15,13 17.5,13Z"}},g=(t,i,e,a)=>{const o=i.replace(/^\//,"").split(/[/?]/),n=o[0],s=o[1];if("config"===n&&"areas"===o[1]&&"area"===o[2]&&o[3])return _(t,o[3]);if("config"===n&&"devices"===o[1]&&"device"===o[2]&&o[3])return b(t,o[3]);if("app"===n&&s)return m(s,a);if("config"===n&&s&&s in v){const i=v[s];return{label:t.localize(i.translationKey)||s,iconPath:i.iconPath}}const l=n?t.panels[n]:void 0,h=l?(0,c.Q)(l):void 0,p=l?(0,c.FW)(l):void 0;if(null!=s&&s.startsWith(u)){const i=s.slice(6);return _(t,i)}const g="lovelace"===(null==l?void 0:l.component_name),y={label:(0,c.vI)(t,n)||n,icon:h||(g?"mdi:view-dashboard":void 0),iconPath:p||d};if(s&&e&&"views"in e){const t=e.views.findIndex((t,i)=>{var e;return(null!==(e=t.path)&&void 0!==e?e:String(i))===s});if(-1!==t){const i=e.views[t];return Object.assign(Object.assign({},y),{},{label:(0,r.TQ)(i,t),icon:(0,r.cg)(i)})}}return y},_=(t,i)=>{const e=t.areas[i];return{label:(null==e?void 0:e.name)||i,icon:(null==e?void 0:e.icon)||void 0,iconPath:"M20 2H4C2.9 2 2 2.9 2 4V20C2 21.11 2.9 22 4 22H20C21.11 22 22 21.11 22 20V4C22 2.9 21.11 2 20 2M4 6L6 4H10.9L4 10.9V6M4 13.7L13.7 4H18.6L4 18.6V13.7M20 18L18 20H13.1L20 13.1V18M20 10.3L10.3 20H5.4L20 5.4V10.3Z"}},b=(t,i)=>{const e=t.devices[i];return{label:(e?(0,o.xn)(e):void 0)||i,iconPath:l}},m=(t,i)=>{const e=null==i?void 0:i[t];return{label:(null==e?void 0:e.title)||t,icon:(null==e?void 0:e.icon)||void 0,iconPath:h}},y=(t,i,e)=>{const o=i.replace(/^\//,"").split(/[/?]/),r=o[0];if("app"===r&&o[1]&&(0,a.x)(t.config,"hassio"))try{const a=(0,n.gh)(t.connection),o=g(t,i,void 0,a.state);e(o);let s=o;return a.subscribe(a=>{const o=g(t,i,void 0,a);o.label===s.label&&o.icon===s.icon||(s=o,e(o))})}catch(d){}const c=g(t,i);e(c);const l=r?t.panels[r]:void 0;if(o[1]&&"lovelace"===(null==l?void 0:l.component_name)){let a=c;return(0,s.ML)(t.connection,r).subscribe(o=>{const n=g(t,i,o);n.label===a.label&&n.icon===a.icon||(a=n,e(n))})}}}}]);