UNPKG

iobroker.lovelace

Version:

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

4 lines 14.4 kB
export const __rspack_esm_id=85808;export const __rspack_esm_ids=[85808];export const __webpack_modules__={90433(e,t,o){o.d(t,{Vy:()=>r,fI:()=>a,ux:()=>n});var s=o(22786),i=o(79468);function r(e,t){const o=e%54+1;return t.getPropertyValue(`--color-${o}`)}function a(e,t){const o=t.getPropertyValue(`--graph-color-${e+1}`)||r(e,t);return(0,i.RQ)(o)}const n=(0,s.A)(e=>Array.from({length:54},(t,o)=>a(o,e)),(e,t)=>e[0].getPropertyValue("--graph-color-1")===t[0].getPropertyValue("--graph-color-1")&&e[0].getPropertyValue("--color-1")===t[0].getPropertyValue("--color-1"))},52943(e,t,o){o.d(t,{Z:()=>s});const s=e=>e.charAt(0).toUpperCase()+e.slice(1)},65829(e,t,o){o.a(e,async function(e,s){try{o.r(t),o.d(t,{HaSpinner:()=>l});var i=o(62826),r=o(55262),a=o(5124),n=o(22441),c=e([r]);r=(c.then?(await c)():c)[0];class l extends r.A{updated(e){if(super.updated(e),e.has("size"))switch(this.size){case"tiny":this.style.setProperty("--ha-spinner-size","16px");break;case"small":this.style.setProperty("--ha-spinner-size","28px");break;case"medium":this.style.setProperty("--ha-spinner-size","48px");break;case"large":this.style.setProperty("--ha-spinner-size","68px");break;case void 0:this.style.removeProperty("--ha-progress-ring-size")}}static get styles(){return[r.A.styles,a.AH`:host{--indicator-color:var( --ha-spinner-indicator-color, var(--primary-color) );--track-color:var(--ha-spinner-divider-color, var(--divider-color));--track-width:4px;--speed:3.5s;font-size:var(--ha-spinner-size, 48px)}`]}}(0,i.Cg)([(0,n.MZ)()],l.prototype,"size",void 0),l=(0,i.Cg)([(0,n.EM)("ha-spinner")],l),s()}catch(e){s(e)}})},82e3(e,t,o){o.d(t,{D5:()=>s,Fy:()=>a,Gk:()=>l,Hg:()=>i,Y_:()=>h,ds:()=>c,e0:()=>r,ec:()=>n});o(74423),o(18111),o(61701),o(33110);const s=14881==o.j?`${location.protocol}//${location.host}`:null,i=e=>e.map(e=>{if("string"!==e.type)return e;switch(e.name){case"username":return{...e,autocomplete:"username",autofocus:!0};case"password":return{...e,autocomplete:"current-password"};case"code":return{...e,autocomplete:"one-time-code",autofocus:!0};default:return e}}),r=(e,t)=>e.callWS({type:"auth/sign_path",path:t}),a=async(e,t,o,s)=>e.callWS({type:"config/auth_provider/homeassistant/create",user_id:t,username:o,password:s}),n=(e,t,o)=>e.callWS({type:"config/auth_provider/homeassistant/change_password",current_password:t,new_password:o}),c=(e,t,o)=>e.callWS({type:"config/auth_provider/homeassistant/admin_change_password",user_id:t,password:o}),l=(e,t,o)=>e.callWS({type:"config/auth_provider/homeassistant/admin_change_username",user_id:t,username:o}),h=(e,t,o)=>e.callWS({type:"auth/delete_all_refresh_tokens",token_type:t,delete_current_token:o})},93758(e,t,o){o.d(t,{CO:()=>h,NS:()=>l,f$:()=>r,ok:()=>a});var s=o(35518),i=o(9899);const r=async e=>(await e.callWS({type:"labs/list"})).features,a=(e,t,o,s,i)=>e.callWS({type:"labs/update",domain:t,preview_feature:o,enabled:s,...void 0!==i&&{create_backup:i}}),n=e=>e.sendMessagePromise({type:"labs/list"}).then(e=>e.features),c=(e,t)=>e.subscribeEvents((0,i.s)(()=>n(e).then(e=>t.setState(e,!0)),500,!0),"labs_updated"),l=(e,t)=>(0,s.N)("_labFeatures",n,c,e,t),h=(e,t,o,s)=>e.subscribeMessage(s,{type:"labs/subscribe",domain:t,preview_feature:o})},28669(e,t,o){o.d(t,{TK:()=>n,_2:()=>l,eR:()=>i,hG:()=>c,hU:()=>r,kg:()=>a,wj:()=>s,xg:()=>h});o(44114),o(18111),o(61701);const s="system-admin",i="system-users",r=async e=>e.callWS({type:"config/auth/list"}),a=async(e,t,o,s)=>e.callWS({type:"config/auth/create",name:t,group_ids:o,local_only:s}),n=async(e,t,o)=>e.callWS({...o,type:"config/auth/update",user_id:t}),c=async(e,t)=>e.callWS({type:"config/auth/delete",user_id:t}),l=e=>e?e.trim().split(" ").slice(0,3).map(e=>e.substring(0,1)).join(""):"?",h=(e,t,o)=>{const s=[],i=t=>e.localize(`ui.panel.config.users.${t}`);return t.is_owner&&s.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",i("is_owner")]),o&&t.system_generated&&s.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",i("is_system")]),t.local_only&&s.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",i("is_local")]),t.is_active||s.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",i("is_not_active")]),s}},41250(e,t,o){o.d(t,{B8:()=>u,S6:()=>h,b9:()=>l,cJ:()=>d});o(74423),o(18111),o(22489),o(61701),o(17642),o(58004),o(33853),o(45876),o(32475),o(15024),o(31698);var s=o(71727),i=o(91926),r=o(6030),a=o(34884),n=o(82405);const c=[{translation_key:"automation_trigger",icon:"mdi:robot-outline"},{translation_key:"automation_condition",icon:"mdi:playlist-check"},{translation_key:"automation_action",icon:"mdi:play-circle-outline"},{translation_key:"script_action",icon:"mdi:script-text-outline"}],l=()=>c.map(e=>({type:"default",key:e.translation_key,enabled:!0,nameKey:`ui.dialogs.more_info_control.add_to.action_options.${e.translation_key}`,icon:e.icon})),h=e=>{const t={};for(const o of e)t[o]="";return t},d=(e,t,o)=>{const i=new Set(e);return t.filter(e=>i.has(e.entity_id)).filter(e=>!e.entity_category&&!e.hidden_by&&!a.ac.includes((0,s.m)(e.entity_id))&&o[e.entity_id]).map(e=>e.entity_id)};function u(e,t){const o={};t.entity_id?o[n.jJ]=t.entity_id:t.device_id?o[n.yz]=t.device_id:t.area_id&&(o[n.ve]=t.area_id);const s=e=>`?${(0,r.KH)({[n.Ku]:e,...o})}`;switch(e){case"automation_trigger":return(0,i.oo)(`/config/automation/edit/new${s("trigger")}`);case"automation_condition":return(0,i.oo)(`/config/automation/edit/new${s("condition")}`);case"automation_action":return(0,i.oo)(`/config/automation/edit/new${s("action")}`);case"script_action":return(0,i.oo)(`/config/script/edit/new${s("action")}`);default:return Promise.reject(new Error(`Unknown action key ${e}`))}}},34023(e,t,o){o.d(t,{E:()=>i,J:()=>r});var s=o(1087);const i=()=>Promise.all([o.e(32450),o.e(7305),o.e(92769),o.e(3283),o.e(85010),o.e(89100),o.e(42209),o.e(26092),o.e(8851),o.e(66201),o.e(26295),o.e(52808),o.e(93e3),o.e(61023)]).then(o.bind(o,39803)),r=(e,t)=>{(0,s.r)(e,"show-dialog",{dialogTag:"dialog-area-registry-detail",dialogImport:i,dialogParams:t})}},82405(e,t,o){o.d(t,{II:()=>l,Ku:()=>r,gZ:()=>d,jJ:()=>a,uV:()=>i,ve:()=>c,yz:()=>n});o(14603),o(47566),o(98721);var s=o(1087);const i="__paste__",r="add_automation_element",a="target_entity_id",n="target_device_id",c="target_area_id",l=(e,t,o,s)=>{const i=new URLSearchParams(window.location.search);if(i.get(r)!==s)return;const l=i.get(a);if(l&&e[l])return{entity_id:l};const h=i.get(n);if(h&&t[h])return{device_id:h};const d=i.get(c);return d&&o[d]?{area_id:d}:void 0},h=()=>Promise.all([o.e(32450),o.e(7305),o.e(92769),o.e(3283),o.e(80131),o.e(70183),o.e(41144),o.e(33758),o.e(61864)]).then(o.bind(o,65467)),d=(e,t)=>{const o=new URLSearchParams(window.location.search);(0,s.r)(e,"show-dialog",{dialogTag:"add-automation-element-dialog",dialogImport:h,dialogParams:t,addHistory:o.get(r)!==t.type})}},89434(e,t,o){o.a(e,async function(e,t){try{o(74423),o(44114),o(18111),o(22489),o(7588),o(13579);var s=o(62826),i=o(5124),r=o(22441),a=o(36312),n=o(69093),c=o(77796),l=o(65829),h=o(86531),d=o(61165),u=o(28669),p=o(11184),_=e([l,p,h]);[l,p,h]=_.then?(await _)():_;const g=(e,t)=>new Date(e.getTime()-1e3*t).getTime()/1e3,y=(e,t)=>(void 0!==e||void 0!==t)&&(!e||!t||e.length!==t.length||e.some(e=>!t.includes(e))||t.some(t=>!e.includes(t)));class m extends i.WF{render(){return(0,a.x)(this.hass.config,"logbook")?this._error?i.qy`<div class="no-entries"> ${`${this.hass.localize("ui.components.logbook.retrieval_error")}: ${this._error}`} </div>`:void 0===this._logbookEntries?i.qy` <div class="progress-wrapper"> <ha-spinner></ha-spinner> </div> `:0===this._logbookEntries.length?i.qy`<div class="no-entries"> ${this.hass.localize("ui.components.logbook.entries_not_found")} </div>`:i.qy` <ha-logbook-renderer .hass="${this.hass}" .narrow="${this.narrow}" .virtualize="${this.virtualize}" .noIcon="${this.noIcon}" .noName="${this.noName}" .showIndicator="${this.showIndicator}" .relativeTime="${this.relativeTime}" .entries="${this._logbookEntries}" .traceContexts="${this._traceContexts}" .userIdToName="${this._userIdToName}" @hass-logbook-live="${this._handleLogbookLive}"></ha-logbook-renderer> `:i.s6}async refresh(e=!1){(e||!this._unsubLogbook&&void 0!==this._logbookEntries)&&(this._throttleGetLogbookEntries.cancel(),this._updateTraceContexts.cancel(),this._updateUsers.cancel(),this._unsubscribe(!0),this._liveUpdatesEnabled=!0,e?this._getLogBookData():this._throttleGetLogbookEntries())}shouldUpdate(e){if(1!==e.size||!e.has("hass"))return!0;const t=e.get("hass");return!t||t.localize!==this.hass.localize}willUpdate(e){let t=e.has("time");for(const o of["entityIds","deviceIds","stateFilter"]){if(!e.has(o))continue;const s=e.get(o),i=this[o];if(y(s,i)){t=!0;break}}t&&this.refresh(!0)}_handleLogbookLive(e){e.detail.enable&&!this._liveUpdatesEnabled&&(this._pendingStreamMessages.forEach(e=>this._processStreamMessage(e)),this._pendingStreamMessages=[]),this._liveUpdatesEnabled=e.detail.enable}get _filterAlwaysEmptyResults(){const e=this.entityIds,t=this.deviceIds;return Boolean(e||t)&&(!e||0===e.length)&&(!t||0===t.length)}_unsubscribe(e){this._unsubLogbook&&(this._unsubLogbook.then(e=>e()),this._unsubLogbook=void 0,this._logbookEntries=e?void 0:[],this._pendingStreamMessages=[])}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this._subscribeLogbookPeriod(this._calculateLogbookPeriod())}disconnectedCallback(){super.disconnectedCallback(),this._unsubscribe(!0)}_calculateLogbookPeriod(){const e=new Date;if("range"in this.time)return{now:e,startTime:this.time.range[0],endTime:this.time.range[1],purgeBeforePythonTime:void 0};if("recent"in this.time){const t=g(e,this.time.recent);return{now:e,startTime:new Date(1e3*t),endTime:new Date(e.getTime()+31536e6),purgeBeforePythonTime:g(e,this.time.recent)}}throw new Error("Unexpected time specified")}async _subscribeLogbookPeriod(e){if(!this._unsubLogbook)try{this._logbookSubscriptionId++,this._unsubLogbook=(0,h.gM)(this.hass,(e,t)=>{t===this._logbookSubscriptionId&&this._processOrQueueStreamMessage(e)},e.startTime.toISOString(),e.endTime.toISOString(),this._logbookSubscriptionId,this.entityIds,this.deviceIds),await this._unsubLogbook}catch(e){this._unsubLogbook=void 0,this._error=e}}async _getLogBookData(){if(this._error=void 0,this._filterAlwaysEmptyResults)return void this._unsubscribe(!1);const e=this._calculateLogbookPeriod();e.startTime>e.now?this._unsubscribe(!1):(this._updateUsers(),this.hass.user?.is_admin&&this._updateTraceContexts(),this._subscribeLogbookPeriod(e))}static get styles(){return[i.AH`:host{display:block}:host([virtualize]){height:100%}.no-entries{text-align:center;padding:16px;color:var(--secondary-text-color)}.progress-wrapper{display:flex;justify-content:center;height:100%;align-items:center}`]}constructor(...e){super(...e),this.narrow=!1,this.virtualize=!1,this.noIcon=!1,this.noName=!1,this.showIndicator=!1,this.relativeTime=!1,this.showMoreLink=!0,this._traceContexts={},this._userIdToName={},this._liveUpdatesEnabled=!0,this._pendingStreamMessages=[],this._throttleGetLogbookEntries=(0,c.n)(()=>this._getLogBookData(),1e3),this._logbookSubscriptionId=0,this._nonExpiredRecords=e=>this._logbookEntries?e?this._logbookEntries.filter(t=>t.when>e):this._logbookEntries:[],this._processOrQueueStreamMessage=e=>{this._liveUpdatesEnabled?this._processStreamMessage(e):this._pendingStreamMessages.push(e)},this._processStreamMessage=e=>{const t="recent"in this.time?g(new Date,this.time.recent):void 0;let o;o=this.stateFilter&&this.stateFilter.length>0?e.events.filter(e=>e.state&&this.stateFilter?.includes(e.state)):[...e.events];const s=o.reverse();if(!this._logbookEntries||!this._logbookEntries.length)return void(this._logbookEntries=s);if(!s.length)return;const i=this._nonExpiredRecords(t);i.length?s[s.length-1].when>i[0].when?this._logbookEntries=s.concat(i):i[i.length-1].when>s[0].when?this._logbookEntries=i.concat(s):this._logbookEntries=i.concat(s).sort((e,t)=>t.when-e.when):this._logbookEntries=s},this._updateTraceContexts=(0,c.n)(async()=>{this._traceContexts=await(0,d.gq)(this.hass)},6e4),this._updateUsers=(0,c.n)(async()=>{const e={},t=this.hass.user?.is_admin&&(0,u.hU)(this.hass);for(const t of Object.values(this.hass.states))t.attributes.user_id&&"person"===(0,n.t)(t)&&(e[t.attributes.user_id]=t.attributes.friendly_name);if(t){const o=await t;for(const t of o)t.id in e||(e[t.id]=t.name)}this._userIdToName=e},6e4)}}(0,s.Cg)([(0,r.MZ)({attribute:!1})],m.prototype,"hass",void 0),(0,s.Cg)([(0,r.MZ)({attribute:!1})],m.prototype,"time",void 0),(0,s.Cg)([(0,r.MZ)({attribute:!1})],m.prototype,"entityIds",void 0),(0,s.Cg)([(0,r.MZ)({attribute:!1})],m.prototype,"deviceIds",void 0),(0,s.Cg)([(0,r.MZ)({attribute:!1})],m.prototype,"stateFilter",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],m.prototype,"narrow",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean,reflect:!0})],m.prototype,"virtualize",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean,attribute:"no-icon"})],m.prototype,"noIcon",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean,attribute:"no-name"})],m.prototype,"noName",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean,attribute:"show-indicator"})],m.prototype,"showIndicator",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean,attribute:"relative-time"})],m.prototype,"relativeTime",void 0),(0,s.Cg)([(0,r.MZ)({attribute:"show-more-link",type:Boolean})],m.prototype,"showMoreLink",void 0),(0,s.Cg)([(0,r.wk)()],m.prototype,"_logbookEntries",void 0),(0,s.Cg)([(0,r.wk)()],m.prototype,"_traceContexts",void 0),(0,s.Cg)([(0,r.wk)()],m.prototype,"_userIdToName",void 0),(0,s.Cg)([(0,r.wk)()],m.prototype,"_error",void 0),m=(0,s.Cg)([(0,r.EM)("ha-logbook")],m),t()}catch(e){t(e)}})}};