UNPKG

iobroker.lovelace

Version:

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

1 lines 13.7 kB
export const __rspack_esm_id=59532;export const __rspack_esm_ids=[59532];export const __webpack_modules__={30879(t,e,i){i.a(t,async function(t,e){try{i(74423),i(44114),i(18111),i(22489),i(20116),i(7588),i(61701),i(45367),i(92731),i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698);var a=i(62826),o=i(78648),s=i(5124),n=i(22441),r=i(22786),c=i(36312),l=i(1087),h=i(58139),d=i(52220),p=i(77423),u=i(38395),_=i(35952),v=i(99774),g=i(45435),m=i(71606),b=i(49406),y=i(39985),A=i(59653),f=i(38508),H=i(59174),C=(i(47680),i(49639)),V=t([f,H,b,y,C]);[f,H,b,y,C]=V.then?(await V)():V;const M={area_view:"0_area_view",area:"1_area_settings",device:"2_device"},w=(...t)=>t.filter(Boolean).map(t=>t.startsWith("/")?`zzz${t}`:t).join("_");class $ extends s.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 s.qy` <ha-generic-picker .hass="${this.hass}" .value="${this._loading?void 0:this.value}" allow-custom-value .placeholder="${this.label}" .helper="${this.helper}" .disabled="${this._loading||this.disabled}" .required="${this.required}" .getItems="${this._getItems}" .valueRenderer="${this._valueRenderer}" .rowRenderer="${this._rowRenderer}" .sections="${t}" .customValueLabel="${this.hass.localize("ui.components.navigation-picker.add_custom_path")}" .addButtonLabel="${this.addButtonLabel}" @value-changed="${this._valueChanged}"> </ha-generic-picker> `}async _loadNavigationItems(){await this._loadConfigEntries();const t=Object.entries(this.hass.panels).map(([t,e])=>({id:t,...e})),e=t.filter(t=>"lovelace"===t.component_name),i=await Promise.all(e.map(t=>(0,_.Dz)(this.hass.connection,t.url_path,!0).then(e=>[t.id,e]).catch(e=>[t.id,void 0]))),a=new Map(i),o=this._navigationGroups.related,s=[],n=[],r=[],l=[];for(const e of t){if(v.qx.includes(e.id))continue;if("app"===e.component_name)continue;const t=`/${e.url_path}`,i=(0,g.Z5)(this.hass,t),o="lovelace"===e.component_name||b.PANEL_DASHBOARDS.includes(e.id),r={id:t,primary:i.label,secondary:i.label!==t?t:void 0,icon:i.icon||"mdi:view-dashboard",sorting_label:w(i.label,t),group:o?"dashboards":"other_routes"};o?s.push(r):l.push(r);const c=a.get(e.id);c&&"views"in c&&c.views.forEach((t,i)=>{const a=`/${e.url_path}/${t.path??i}`,o=(0,g.Z5)(this.hass,a,c);n.push({id:a,secondary:a,icon:o.icon||"mdi:view-compact",primary:o.label,sorting_label:w(o.label,a),group:"views"})})}if((0,c.x)(this.hass.config,"hassio"))try{const t=await(0,h.t)((0,u.gh)(this.hass.connection));for(const e of Object.keys(t)){const i=`/app/${e}`,a=(0,g.Z5)(this.hass,i,void 0,t);r.push({id:i,primary:a.label,secondary:i,icon:a.icon,icon_path:a.iconPath,sorting_label:w(a.label,i),group:"apps"})}}catch(t){}for(const[t,e]of Object.entries(g.X1)){const i=`/config/${t}`,a=this.hass.localize(e.translationKey)||t;l.push({id:i,primary:a,secondary:i,icon_path:e.iconPath,sorting_label:w(a,i),group:"other_routes"})}this._navigationGroups={related:o,dashboards:s,views:n,apps:r,other_routes:l},this._navigationItems=[...o,...s,...n,...r,...l],this._loading=!1}updated(t){t.has("context")&&this._loadRelatedItems()}async _loadRelatedItems(){const t=t=>{this._navigationGroups={...this._navigationGroups,related:t},this._navigationItems=[...t,...this._navigationGroups.dashboards,...this._navigationGroups.views,...this._navigationGroups.apps,...this._navigationGroups.other_routes]};if(!this.hass||!this.context?.entity_id&&!this.context?.area_id)return void t([]);const e=this.context,i=await this._getRelatedItems(`${e.entity_id??""}|${e.area_id??""}`,e);(()=>this.context?.entity_id===e?.entity_id&&this.context?.area_id===e?.area_id)()&&t(i)}async _fetchRelatedItems(t){let e;try{e=t.entity_id?await(0,m.f)(this.hass,"entity",t.entity_id):await(0,m.f)(this.hass,"area",t.area_id)}catch(t){return console.error("Error fetching related items for navigation picker",t),[]}const i=new Set(e?.device??[]),a=new Set(e?.area??[]);t.area_id&&a.add(t.area_id);const o=[];for(const t of i){const e=this.hass.devices[t],i=`/config/devices/device/${t}`,a=(0,g.Z5)(this.hass,i);o.push({id:i,primary:a.label,secondary:i,icon:a.icon,icon_path:a.iconPath,sorting_label:w(M.device,a.label,i),group:"related",domain:e?.primary_config_entry?this._configEntryLookup[e.primary_config_entry]?.domain:void 0})}for(const t of a){const e=`/home/${(0,y.W8)(t)}`,i=(0,g.Z5)(this.hass,e);o.push({id:e,primary:i.label,secondary:e,icon:i.icon,icon_path:i.icon?void 0:i.iconPath,sorting_label:w(M.area_view,i.label,e),group:"related"});const a=`/config/areas/area/${t}`;o.push({id:a,primary:this.hass.localize("ui.components.navigation-picker.area_settings",{area:i.label}),secondary:a,icon:i.icon,icon_path:i.icon?void 0:i.iconPath,sorting_label:w(M.area,i.label,a),group:"related"})}return o}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,e)=>this._fetchRelatedItems(e),(t,e)=>t[0]===e[0]),this._valueRenderer=t=>{const e=this._navigationItems.find(e=>e.id===t);return s.qy` ${e?.domain?s.qy` <ha-domain-icon slot="start" .domain="${e.domain}" brand-fallback></ha-domain-icon> `:e?.icon?s.qy`<ha-icon slot="start" .icon="${e.icon}"></ha-icon>`:e?.icon_path?s.qy`<ha-svg-icon slot="start" .path="${e.icon_path}"></ha-svg-icon>`:s.s6} <span slot="headline">${e?.primary||t}</span> ${e?.primary?s.qy`<span slot="supporting-text">${t}</span>`:s.s6} `},this._rowRenderer=t=>s.qy` <ha-combo-box-item type="button" compact="compact"> ${t.domain?s.qy` <ha-domain-icon slot="start" .domain="${t.domain}" brand-fallback></ha-domain-icon> `:t.icon?s.qy`<ha-icon slot="start" .icon="${t.icon}"></ha-icon>`:t.icon_path?s.qy`<ha-svg-icon slot="start" .path="${t.icon_path}"></ha-svg-icon>`:s.s6} <span slot="headline">${t.primary}</span> ${t.secondary?s.qy`<span slot="supporting-text">${t.secondary}</span>`:s.s6} </ha-combo-box-item> `,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,e)=>{const i=this.excludePaths?new Set(this.excludePaths):void 0,a=e=>{let a=[...this._navigationGroups[e]].sort(this._sortBySortingLabel);if(i&&(a=a.filter(t=>!i.has(t.id))),t){const i=this._fuseIndexes[e](a);a=(0,A.x)(a,t,C.A1,t=>t.id,i)}return a},o=[],s=a("related"),n=a("dashboards"),r=a("views"),c=a("apps"),l=a("other_routes"),h=(t,i)=>{e&&e!==t||(!e&&i.length&&o.push(this.hass.localize(`ui.components.navigation-picker.${t}`)),o.push(...i))};return h("related",s),h("dashboards",n),h("views",r),h("apps",c),h("other_routes",l),o},this._sortBySortingLabel=(t,e)=>(0,d.SH)(t.sorting_label,e.sorting_label,this.hass.locale.language)}}(0,a.Cg)([(0,n.MZ)({attribute:!1})],$.prototype,"hass",void 0),(0,a.Cg)([(0,n.MZ)()],$.prototype,"label",void 0),(0,a.Cg)([(0,n.MZ)()],$.prototype,"value",void 0),(0,a.Cg)([(0,n.MZ)()],$.prototype,"helper",void 0),(0,a.Cg)([(0,n.MZ)({type:Boolean})],$.prototype,"disabled",void 0),(0,a.Cg)([(0,n.MZ)({type:Boolean})],$.prototype,"required",void 0),(0,a.Cg)([(0,n.MZ)({attribute:!1})],$.prototype,"excludePaths",void 0),(0,a.Cg)([(0,n.MZ)({attribute:"add-button-label"})],$.prototype,"addButtonLabel",void 0),(0,a.Cg)([(0,n.wk)()],$.prototype,"_loading",void 0),(0,a.Cg)([(0,n.MZ)({attribute:!1})],$.prototype,"context",void 0),$=(0,a.Cg)([(0,n.EM)("ha-navigation-picker")],$),e()}catch(t){e(t)}})},45435(t,e,i){i.d(e,{Mw:()=>p,X1:()=>_,Z5:()=>v,sy:()=>y});var a=i(36312),o=i(37981),s=i(38395),n=i(99129),r=i(91984),c=i(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",h="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",d="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:h},u="areas-",_={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:d},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"}},v=(t,e,i,a)=>{const o=e.replace(/^\//,"").split(/[/?]/),s=o[0],n=o[1];if("config"===s&&"areas"===o[1]&&"area"===o[2]&&o[3])return g(t,o[3]);if("config"===s&&"devices"===o[1]&&"device"===o[2]&&o[3])return m(t,o[3]);if("app"===s&&n)return b(n,a);if("config"===s&&n&&n in _){const e=_[n];return{label:t.localize(e.translationKey)||n,iconPath:e.iconPath}}const l=s?t.panels[s]:void 0,d=l?(0,c.Q)(l):void 0,p=l?(0,c.FW)(l):void 0;if(n?.startsWith(u)){const e=n.slice(6);return g(t,e)}const v="lovelace"===l?.component_name,y={label:(0,c.vI)(t,s)||s,icon:d||(v?"mdi:view-dashboard":void 0),iconPath:p||h};if(n&&i&&"views"in i){const t=i.views.findIndex((t,e)=>(t.path??String(e))===n);if(-1!==t){const e=i.views[t];return{...y,label:(0,r.TQ)(e,t),icon:(0,r.cg)(e)}}}return y},g=(t,e)=>{const i=t.areas[e];return{label:i?.name||e,icon:i?.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"}},m=(t,e)=>{const i=t.devices[e];return{label:(i?(0,o.xn)(i):void 0)||e,iconPath:l}},b=(t,e)=>{const i=e?.[t];return{label:i?.title||t,icon:i?.icon||void 0,iconPath:d}},y=(t,e,i)=>{const o=e.replace(/^\//,"").split(/[/?]/),r=o[0];if("app"===r&&o[1]&&(0,a.x)(t.config,"hassio"))try{const a=(0,s.gh)(t.connection),o=v(t,e,void 0,a.state);i(o);let n=o;return a.subscribe(a=>{const o=v(t,e,void 0,a);o.label===n.label&&o.icon===n.icon||(n=o,i(o))})}catch(t){}const c=v(t,e);i(c);const l=r?t.panels[r]:void 0;if(o[1]&&"lovelace"===l?.component_name){let a=c;return(0,n.ML)(t.connection,r).subscribe(o=>{const s=v(t,e,o);s.label===a.label&&s.icon===a.icon||(a=s,i(s))})}}},61557(t,e,i){i.d(e,{uw:()=>o});const a={type:"supervisor/api",method:"GET"},o=(t,e)=>t.sendMessagePromise({...a,...e})}};