UNPKG

iobroker.lovelace

Version:

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

1 lines 6.19 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[82691],{66639:function(e,n,t){t.d(n,{Vu:function(){return a},Xz:function(){return o},cs:function(){return r}});t(44114),t(18111),t(61701),t(45367),t(92731),t(62953);const r=(e,n)=>{const t=new Map,r=[];for(const o of n)o.floor_id?(t.has(o.floor_id)||t.set(o.floor_id,[]),t.get(o.floor_id).push(o.area_id)):r.push(o.area_id);return{floors:e.map(e=>({id:e.floor_id,areas:t.get(e.floor_id)||[]})),areas:r}},o=e=>{const n=[];for(const t of e.floors)n.push(...t.areas);return n.push(...e.areas),n},a=e=>e.floors.map(e=>e.id)},4423:function(e,n,t){t.d(n,{B:function(){return l},r:function(){return s}});t(44114),t(18111),t(13579),t(17642),t(58004),t(33853),t(45876),t(32475),t(15024),t(31698),t(62953);var r=t(44537),o=t(71727),a=t(28455);const i=e=>{if(void 0!==e)return null===e?new Set([null]):new Set((0,r.e)(e))},s=(e,n)=>{const t=n.domain?new Set((0,r.e)(n.domain)):void 0,s=n.hidden_domains?new Set((0,r.e)(n.hidden_domains)):void 0,l=n.device_class?new Set((0,r.e)(n.device_class)):void 0,c=i(n.floor),u=i(n.area),d=i(n.device),f=n.entity_category?new Set((0,r.e)(n.entity_category)):void 0,h=n.label?new Set((0,r.e)(n.label)):void 0,v=n.hidden_platform?new Set((0,r.e)(n.hidden_platform)):void 0;return n=>{const r=e.states[n];if(!r)return!1;if(t||s){const e=(0,o.m)(n);if(t&&!t.has(e))return!1;if(s&&s.has(e))return!1}if(l){const e=r.attributes.device_class||"none";if(!l.has(e))return!1}const{area:i,floor:p,device:m,entity:H}=(0,a.ln)(r,e.entities,e.devices,e.areas,e.floors);if(H&&H.hidden)return!1;if(c){var g;const e=null!==(g=null==p?void 0:p.floor_id)&&void 0!==g?g:null;if(!c.has(e))return!1}if(u){var y;const e=null!==(y=null==i?void 0:i.area_id)&&void 0!==y?y:null;if(!u.has(e))return!1}if(d){var V;const e=null!==(V=null==m?void 0:m.id)&&void 0!==V?V:null;if(!d.has(e))return!1}if(h){if(!H)return!1;if(!H.labels.some(e=>h.has(e)))return!1}if(f){const e=(null==H?void 0:H.entity_category)||"none";if(!f.has(e))return!1}if(v){if(!H)return!1;if(H.platform&&v.has(H.platform))return!1}return!0}},l=(e,n)=>{const t=new Set,r=[];for(const o of n)for(const n of e)o(n)&&!t.has(n)&&(t.add(n),r.push(n));return r}},18198:function(e,n,t){t.d(n,{Dc:function(){return u},Si:function(){return c}});var r=t(40445),o=t(5124),a=t(67576);t(47680),t(67094);let i,s,l=e=>e;const c=e=>{switch(e.level){case 0:return"M11,10H13V16H11V10M22,12H19V20H5V12H2L12,3L22,12M15,10A2,2 0 0,0 13,8H11A2,2 0 0,0 9,10V16A2,2 0 0,0 11,18H13A2,2 0 0,0 15,16V10Z";case 1:return"M12,3L2,12H5V20H19V12H22L12,3M10,8H14V18H12V10H10V8Z";case 2:return"M12,3L2,12H5V20H19V12H22L12,3M9,8H13A2,2 0 0,1 15,10V12A2,2 0 0,1 13,14H11V16H15V18H9V14A2,2 0 0,1 11,12H13V10H9V8Z";case 3:return"M12,3L22,12H19V20H5V12H2L12,3M15,11.5V10C15,8.89 14.1,8 13,8H9V10H13V12H11V14H13V16H9V18H13A2,2 0 0,0 15,16V14.5A1.5,1.5 0 0,0 13.5,13A1.5,1.5 0 0,0 15,11.5Z";case-1:return"M12,3L2,12H5V20H19V12H22L12,3M11,15H7V13H11V15M15,18H13V10H11V8H15V18Z"}return"M10,20V14H14V20H19V12H22L12,3L2,12H5V20H10Z"},u=e=>{switch(e.level){case 0:return"mdi:home-floor-0";case 1:return"mdi:home-floor-1";case 2:return"mdi:home-floor-2";case 3:return"mdi:home-floor-3";case-1:return"mdi:home-floor-negative-1"}return"mdi:home"};class d extends o.WF{render(){if(!this.floor)return o.s6;if(this.floor.icon)return(0,o.qy)(i||(i=l`<ha-icon .icon="${0}"></ha-icon>`),this.floor.icon);const e=c(this.floor);return(0,o.qy)(s||(s=l`<ha-svg-icon .path="${0}"></ha-svg-icon>`),e)}}(0,r.Cg)([(0,a.MZ)({attribute:!1})],d.prototype,"floor",void 0),(0,r.Cg)([(0,a.MZ)()],d.prototype,"icon",void 0),d=(0,r.Cg)([(0,a.EM)("ha-floor-icon")],d)},78030:function(e,n,t){t.r(n),t.d(n,{MaintenanceViewStrategy:function(){return p},filterLowBatteryEntities:function(){return d},filterUnavailableBatteryEntities:function(){return f},maintenanceEntityFilters:function(){return u}});t(44114),t(18111),t(22489),t(3362),t(62953);var r=t(40445),o=t(5124),a=t(67576),i=t(66639),s=t(4423),l=t(18198),c=(t(46190),t(71727));const u=[{domain:"sensor",device_class:["battery"]},{domain:"binary_sensor",device_class:["battery"],entity_category:"none"}],d=(e,n)=>n.filter(n=>{var t,r;const o=null!==(t=null===(r=e.states[n])||void 0===r?void 0:r.state)&&void 0!==t?t:"";if("binary_sensor"===(0,c.m)(n))return"on"===o;const a=parseFloat(o);return!isNaN(a)&&a<=20}),f=(e,n)=>n.filter(n=>{var t;return"unavailable"===(null===(t=e.states[n])||void 0===t?void 0:t.state)}),h=(e,n)=>{const t=e[n];return{type:"tile",entity:n,name:{type:(null==t?void 0:t.device_id)?"device":"entity"}}},v=(e,n,t)=>{const r=[];for(const o of e){const e=n.areas[o];if(!e)continue;const a=(0,s.r)(n,{area:e.area_id}),i=t.filter(a),l=[];for(const t of i)l.push(h(n.entities,t));l.length>0&&(r.push({heading_style:"subtitle",type:"heading",heading:e.name,tap_action:n.panels.home?{action:"navigate",navigation_path:`/home/areas-${e.area_id}`}:void 0}),r.push(...l))}return r};class p extends o.mN{static async generate(e,n){const t=Object.values(n.areas),r=Object.values(n.floors),o=(0,i.cs)(r,t),a=[],c=Object.keys(n.states),d=u.map(e=>(0,s.r)(n,e)),f=(0,s.B)(c,d),p=o.floors.length+(o.areas.length?1:0);for(const i of o.floors){const e=i.id,t=i.areas,r=n.floors[e],o={type:"grid",column_span:2,cards:[{type:"heading",heading:p>1?r.name:n.localize("ui.panel.lovelace.strategy.home.areas"),icon:r.icon||(0,l.Dc)(r)}]},s=v(t,n,f);s.length>0&&(o.cards.push(...s),a.push(o))}if(o.areas.length>0){const e={type:"grid",column_span:2,cards:[{type:"heading",heading:p>1?n.localize("ui.panel.lovelace.strategy.maintenance.other_devices"):n.localize("ui.panel.lovelace.strategy.home.areas")}]},t=v(o.areas,n,f);t.length>0&&(e.cards.push(...t),a.push(e))}const m=((e,n)=>{const t=(0,s.r)(e,{area:null}),r=n.filter(t),o=[];for(const a of r)o.push(h(e.entities,a));return o})(n,f);if(m.length>0){const e={type:"grid",column_span:2,cards:[{type:"heading",heading:a.length>0?n.localize("ui.panel.lovelace.strategy.maintenance.other_devices"):n.localize("ui.panel.lovelace.strategy.maintenance.devices")},...m]};a.push(e)}return{type:"sections",max_columns:2,sections:a}}}p=(0,r.Cg)([(0,a.EM)("maintenance-view-strategy")],p)}}]);