UNPKG

iobroker.lovelace

Version:

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

2 lines 13.3 kB
export const __webpack_ids__=["72544"];export const __webpack_modules__={92636:function(t,e,n){n.d(e,{z:()=>i});const i=t=>(e,n)=>t.includes(e,n)},19631:function(t,e,n){n.d(e,{Bt:()=>r,T8:()=>a});var i=n(88977),o=n(20382);const s=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],r=t=>t.first_weekday===o.FS.language?"weekInfo"in Intl.Locale.prototype?new Intl.Locale(t.language).weekInfo.firstDay%7:(0,i.L)(t.language)%7:s.includes(t.first_weekday)?s.indexOf(t.first_weekday):1,a=t=>{const e=r(t);return s[e]}},33570:function(t,e,n){n.a(t,(async function(t,i){try{n.d(e,{Vu:()=>l,Zs:()=>p,mr:()=>u,xO:()=>y});var o=n(16485),s=n(27486),r=n(11104),a=n(16922),c=t([o,r]);[o,r]=c.then?(await c)():c;const u=(t,e,n)=>d(e,n.time_zone).format(t),d=(0,s.Z)(((t,e)=>new Intl.DateTimeFormat(t.language,{hour:"numeric",minute:"2-digit",hourCycle:(0,a.y)(t)?"h12":"h23",timeZone:(0,r.f)(t.time_zone,e)}))),l=(t,e,n)=>m(e,n.time_zone).format(t),m=(0,s.Z)(((t,e)=>new Intl.DateTimeFormat(t.language,{hour:(0,a.y)(t)?"numeric":"2-digit",minute:"2-digit",second:"2-digit",hourCycle:(0,a.y)(t)?"h12":"h23",timeZone:(0,r.f)(t.time_zone,e)}))),y=(t,e,n)=>f(e,n.time_zone).format(t),f=(0,s.Z)(((t,e)=>new Intl.DateTimeFormat(t.language,{weekday:"long",hour:(0,a.y)(t)?"numeric":"2-digit",minute:"2-digit",hourCycle:(0,a.y)(t)?"h12":"h23",timeZone:(0,r.f)(t.time_zone,e)}))),p=(t,e,n)=>h(e,n.time_zone).format(t),h=(0,s.Z)(((t,e)=>new Intl.DateTimeFormat("en-GB",{hour:"numeric",minute:"2-digit",hour12:!1,timeZone:(0,r.f)(t.time_zone,e)})));i()}catch(t){i(t)}}))},11104:function(t,e,n){n.a(t,(async function(t,i){try{n.d(e,{f:()=>u});var o=n(16485),s=n(20382),r=t([o]);o=(r.then?(await r)():r)[0];const a=Intl.DateTimeFormat?.().resolvedOptions?.().timeZone,c=a??"UTC",u=(t,e)=>t===s.c_.local&&a?c:e;i()}catch(t){i(t)}}))},16922:function(t,e,n){n.d(e,{y:()=>s});var i=n(27486),o=n(20382);const s=(0,i.Z)((t=>{if(t.time_format===o.zt.language||t.time_format===o.zt.system){const e=t.time_format===o.zt.language?t.language:void 0;return new Date("January 1, 2023 22:00:00").toLocaleString(e).includes("10")}return t.time_format===o.zt.am_pm}))},59847:function(t,e,n){n.d(e,{N:()=>o});var i=n(73850);const o=t=>(0,i.M)(t.entity_id)},12753:function(t,e,n){n.d(e,{N:()=>o});const i=[" ",": "," - "],o=(t,e)=>{const n=t.toLowerCase(),o=e.toLowerCase();for(const e of i){const i=`${o}${e}`;if(n.startsWith(i)){const e=t.substring(i.length);if(e.length)return s(e.substr(0,e.indexOf(" ")))?e:e[0].toUpperCase()+e.slice(1)}}},s=t=>t.toLowerCase()!==t},50602:function(t,e,n){n.a(t,(async function(t,i){try{n.d(e,{SL:()=>c,l4:()=>m,sJ:()=>u,uf:()=>l});var o=n(16485),s=n(20382),r=n(34618),a=t([o]);o=(a.then?(await a)():a)[0];const c=t=>u(t.attributes),u=(t,e)=>!!t.unit_of_measurement||!!t.state_class||(e||[]).includes(t.device_class||""),d=t=>{switch(t.number_format){case s.y4.comma_decimal:return["en-US","en"];case s.y4.decimal_comma:return["de","es","it"];case s.y4.space_comma:return["fr","sv","cs"];case s.y4.system:return;default:return t.language}},l=(t,e,n)=>{const i=e?d(e):void 0;return Number.isNaN=Number.isNaN||function t(e){return"number"==typeof e&&t(e)},e?.number_format===s.y4.none||Number.isNaN(Number(t))?Number.isNaN(Number(t))||""===t||e?.number_format!==s.y4.none?"string"==typeof t?t:`${(0,r.N)(t,n?.maximumFractionDigits).toString()}${"currency"===n?.style?` ${n.currency}`:""}`:new Intl.NumberFormat("en-US",y(t,{...n,useGrouping:!1})).format(Number(t)):new Intl.NumberFormat(i,y(t,n)).format(Number(t))},m=(t,e)=>{const n=e?.display_precision;return null!=n?{maximumFractionDigits:n,minimumFractionDigits:n}:Number.isInteger(Number(t?.attributes?.step))&&Number.isInteger(Number(t?.state))?{maximumFractionDigits:0}:void 0},y=(t,e)=>{const n={maximumFractionDigits:2,...e};if("string"!=typeof t)return n;if(!e||void 0===e.minimumFractionDigits&&void 0===e.maximumFractionDigits){const e=t.indexOf(".")>-1?t.split(".")[1].length:0;n.minimumFractionDigits=e,n.maximumFractionDigits=e}return n};i()}catch(t){i(t)}}))},34618:function(t,e,n){n.d(e,{N:()=>i});const i=(t,e=2)=>Math.round(t*10**e)/10**e},4242:function(t,e,n){n.d(e,{CE:()=>o,FH:()=>d,Nq:()=>a,Pb:()=>i,fm:()=>u,h8:()=>c,r4:()=>r,uh:()=>s});n(92745),n(9359),n(70104);const i="system-admin",o="system-users",s=async t=>t.callWS({type:"config/auth/list"}),r=async(t,e,n,i)=>t.callWS({type:"config/auth/create",name:e,group_ids:n,local_only:i}),a=async(t,e,n)=>t.callWS({...n,type:"config/auth/update",user_id:e}),c=async(t,e)=>t.callWS({type:"config/auth/delete",user_id:e}),u=t=>t?t.trim().split(" ").slice(0,3).map((t=>t.substring(0,1))).join(""):"?",d=(t,e,n)=>{const i=[],o=e=>t.localize(`ui.panel.config.users.${e}`);return e.is_owner&&i.push(["M12 2C6.47 2 2 6.5 2 12C2 17.5 6.5 22 12 22S22 17.5 22 12 17.5 2 12 2M12 20C7.58 20 4 16.42 4 12C4 7.58 7.58 4 12 4S20 7.58 20 12C20 16.42 16.42 20 12 20M8 14L7 8L10 10L12 7L14 10L17 8L16 14H8M8.56 16C8.22 16 8 15.78 8 15.44V15H16V15.44C16 15.78 15.78 16 15.44 16H8.56Z",o("is_owner")]),n&&e.system_generated&&i.push(["M11,7H15V9H11V11H13A2,2 0 0,1 15,13V15A2,2 0 0,1 13,17H9V15H13V13H11A2,2 0 0,1 9,11V9A2,2 0 0,1 11,7M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4Z",o("is_system")]),e.local_only&&i.push(["M12 20C7.6 20 4 16.4 4 12S7.6 4 12 4 20 7.6 20 12 16.4 20 12 20M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M11 14H13V17H16V12H18L12 7L6 12H8V17H11V14",o("is_local")]),e.is_active||i.push(["M12 2C17.5 2 22 6.5 22 12S17.5 22 12 22 2 17.5 2 12 6.5 2 12 2M12 4C10.1 4 8.4 4.6 7.1 5.7L18.3 16.9C19.3 15.5 20 13.8 20 12C20 7.6 16.4 4 12 4M16.9 18.3L5.7 7.1C4.6 8.4 4 10.1 4 12C4 16.4 7.6 20 12 20C13.9 20 15.6 19.4 16.9 18.3Z",o("is_not_active")]),i}},96530:function(t,e,n){n.d(e,{X:()=>s,y:()=>o});var i=n(92636);const o=["input_boolean","input_button","input_text","input_number","input_datetime","input_select","counter","timer","schedule"],s=(0,i.z)(o)},20526:function(t,e,n){n.d(e,{oU:()=>g,lY:()=>p,VG:()=>h,AP:()=>_});n(92745),n(84283),n(9359),n(56475),n(1331),n(31526),n(70104),n(92519),n(42179),n(89256),n(24931),n(88463),n(57449),n(19814);var i=n(73358),o=n(73850),s=n(59847),r=n(47194);var a=n(12753),c=n(1416),u=n(82100),d=n(57816),l=n(4242),m=n(96530);const y=new Set(["automation","configurator","device_tracker","event","geo_location","notify","persistent_notification","script","sun","tag","todo","zone",...i.a5]),f=new Set(["backup","mobile_app"]),p=(t,e)=>({type:"grid",cards:t.map((t=>({type:"tile",entity:t,show_entity_picture:["camera","image","person"].includes((0,o.M)(t))||void 0}))),...e}),h=(t,e,n,s=!0)=>{const u=[],d=[],l=n.title?n.title.toLowerCase():void 0,m=[];for(const n of e){const e=t[n],i=(0,o.M)(n);if("alarm_control_panel"===i){const t={type:"alarm-panel",entity:n};u.push(t)}else if("camera"===i){const t={type:"picture-entity",entity:n};u.push(t)}else if("image"===i){const t={type:"picture",image_entity:n};u.push(t)}else if("climate"===i){const e={type:"thermostat",entity:n,features:(t[n]?.attributes?.hvac_modes?.length??0)>1?[{type:"climate-hvac-modes",hvac_modes:t[n]?.attributes?.hvac_modes}]:void 0};u.push(e)}else if("humidifier"===i){const t={type:"humidifier",entity:n,features:[{type:"humidifier-toggle"}]};u.push(t)}else if("media_player"===i){const t={type:"media-control",entity:n};u.push(t)}else if("plant"===i){const t={type:"plant-status",entity:n};u.push(t)}else if("weather"===i){const t={type:"weather-forecast",entity:n,show_forecast:!1};u.push(t)}else if(!s||"scene"!==i&&"script"!==i){let t;const i=l&&e&&(t=(0,a.N)((0,r.C)(e),l))?{entity:n,name:t}:n;d.push(i)}else{const t={entity:n,show_icon:!0,show_name:!0};let i;l&&e&&(i=(0,a.N)((0,r.C)(e),l))&&(t.name=i),m.push(t)}}if(d.sort(((e,n)=>{const s="string"==typeof e?e:e.entity,a="string"==typeof n?n:n.entity,u=i.zF.includes((0,o.M)(s))?"sensor":"control";return u!==(i.zF.includes((0,o.M)(a))?"sensor":"control")?"sensor"===u?1:-1:(0,c.$K)("string"==typeof e?t[e]?(0,r.C)(t[e]):"":e.name||"","string"==typeof n?t[n]?(0,r.C)(t[n]):"":n.name||"")})),0===d.length&&m.length>0)return h(t,e,n,!1);if(d.length>0||m.length>0){const t={type:"entities",entities:d,...n};m.length>0&&(t.footer={type:"buttons",entities:m}),u.unshift(t)}return u.length<2?u:[{type:"grid",square:!1,columns:1,cards:u}]},g=(t,e)=>{const n=[];for(const t of e){const e={type:"entity",entity:t};n.push(e)}return n},_=(t,e,n,i,a,p,g,_,b)=>{const v=((t,e)=>{const n={},i=new Set(Object.values(e).filter((t=>t.entity_category||t.platform&&f.has(t.platform)||t.hidden)).map((t=>t.entity_id)));for(const e of Object.keys(t)){const o=t[e];y.has((0,s.N)(o))||i.has(o.entity_id)||(n[e]=t[e])}return n})(i,n),w={};for(const t of Object.keys(v)){const e=v[t];e.attributes.order&&(w[t]=e.attributes.order)}const C=((t,e,n,i)=>{const o={...i},s={},r={};for(const i of Object.values(n)){const n=i.area_id||i.device_id&&e[i.device_id]?.area_id;n&&n in t&&i.entity_id in o?(n in s||(s[n]=[]),s[n].push(o[i.entity_id]),delete o[i.entity_id]):i.device_id&&i.device_id in e&&i.entity_id in o&&(i.device_id in r||(r[i.device_id]=[]),r[i.device_id].push(o[i.entity_id]),delete o[i.entity_id])}for(const[t,e]of Object.entries(r))1===e.length&&(o[e[0].entity_id]=e[0],delete r[t]);return{areasWithEntities:s,devicesWithEntities:r,otherEntities:o}})(t,e,n,v);if(g?.hidden)for(const t of g.hidden)delete C.areasWithEntities[t];_&&(C.devicesWithEntities={},C.otherEntities={});const N=(t=>{const e=[],n={};return Object.keys(t).forEach((i=>{const s=t[i];"group"===(0,o.M)(i)?e.push(s):n[i]=s})),e.forEach((t=>t.attributes.entity_id.forEach((t=>{delete n[t]})))),{groups:e,ungrouped:n}})(C.otherEntities);N.groups.sort(((t,e)=>w[t.entity_id]-w[e.entity_id]));const k=[];for(const t of N.groups)k.push(...h(i,t.attributes.entity_id,{title:(0,r.C)(t),show_header_toggle:"hidden"!==t.attributes.control}));const x=((t,e,n,i,o)=>{const a={};for(const t of Object.keys(o)){const e=o[t],n=(0,s.N)(e);n in a||(a[n]=[]),a[n].push(e.entity_id)}const u=[];if("person"in a){const t=[];if(1===a.person.length)u.push({type:"entities",entities:a.person});else{let e,n="";for(const i of a.person){const s=o[i];let r=s.attributes.entity_picture;if(!r){if(void 0===e){const t=getComputedStyle(document.body);e=encodeURIComponent(t.getPropertyValue("--light-primary-color").trim()),n=encodeURIComponent((t.getPropertyValue("--text-light-primary-color")||t.getPropertyValue("--primary-text-color")).trim())}r=`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='${n}' font-size='1.3em' dy='.3em'%3E${(0,l.fm)(s.attributes.friendly_name||"")}%3C/text%3E%3C/g%3E%3C/svg%3E`}t.push({type:"picture-entity",entity:i,aspect_ratio:"1",show_name:!1,image:r})}u.push({type:"grid",square:!0,columns:3,cards:t})}delete a.person}const y=[];for(const t of m.y)t in a&&(y.push(...a[t]),delete a[t]);const f={};for(const e of Object.keys(a))f[e]=(0,d.Lh)(t,e);y.length&&(a._helpers=y,f._helpers=t("ui.panel.lovelace.strategy.original-states.helpers")),Object.keys(a).sort(((t,e)=>(0,c.$K)(f[t],f[e]))).forEach((t=>{u.push(...h(o,a[t].sort(((t,e)=>(0,c.$K)((0,r.C)(o[t]),(0,r.C)(o[e])))),{title:f[t]}))}));const p={path:e,title:n,cards:u};return i&&(p.icon=i),p})(a,"default_view","Home",undefined,N.ungrouped),E=[],F=Object.keys(C.areasWithEntities).sort((0,u.a)(t,g?.order));for(const e of F){const n=C.areasWithEntities[e],o=t[e];E.push(...h(i,n.map((t=>t.entity_id)),{title:o.name}))}const M=[],S=Object.entries(C.devicesWithEntities).sort(((t,n)=>{const i=e[t[0]],o=e[n[0]];return(0,c.$K)(i.name_by_user||i.name||"",o.name_by_user||o.name||"")}));for(const[t,n]of S){const o=e[t];M.push(...h(i,n.map((t=>t.entity_id)),{title:o.name_by_user||o.name||a("ui.panel.config.devices.unnamed_device",{type:a(`ui.panel.config.devices.type.${o.entry_type||"device"}`)})}))}let L;if(p&&!b){const t=p.energy_sources.find((t=>"grid"===t.type));t&&t.flow_from.length>0&&(L={title:a("ui.panel.lovelace.cards.energy.energy_distribution.title_today"),type:"energy-distribution",link_dashboard:!0})}return x.cards.unshift(...E,...k,...L?[L]:[]),x.cards.push(...M),x}},96751:function(t,e,n){n.a(t,(async function(t,i){try{n.r(e),n.d(e,{OriginalStatesViewStrategy:()=>m});var o=n(44249),s=(n(92745),n(94277)),r=n(57243),a=n(15093),c=n(72344),u=n(1118),d=n(20526),l=t([u]);u=(l.then?(await l)():l)[0];let m=(0,o.Z)([(0,a.Mo)("original-states-view-strategy")],(function(t,e){return{F:class extends e{constructor(...e){super(...e),t(this)}},d:[{kind:"method",static:!0,key:"generate",value:async function(t,e){if(e.config.state===s.UE)return{cards:[{type:"starting"}]};if(e.config.recovery_mode)return{cards:[{type:"recovery-mode"}]};const[n,i]=await Promise.all([e.loadBackendTranslation("title"),(0,c.p)(e,"energy")?(0,u.ZC)(e).catch((()=>{})):void 0]),o=(0,d.AP)(e.areas,e.devices,e.entities,e.states,n,i,t.areas,t.hide_entities_without_area,t.hide_energy);return e.config.components.includes("geo_location")&&o&&o.cards&&o.cards.push({type:"map",geo_location_sources:["all"]}),0===o.cards.length&&o.cards.push({type:"empty-state"}),o}}]}}),r.fl);i()}catch(t){i(t)}}))}}; //# sourceMappingURL=72544.78aa669ac549febc.js.map