UNPKG

iobroker.lovelace

Version:

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

5 lines 14.2 kB
"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["55964"],{73729:function(e,t,i){i.d(t,{i:()=>v});var o=i(61701),a=i(72621),r=(i(22152),i(71695),i(47021),i(74966)),s=i(51408),l=i(57243),n=i(50778),d=i(76525);i(23334);let c,h,u,p=e=>e;const y=["button","ha-list-item"],v=(e,t)=>{var i;return(0,l.dy)(c||(c=p` <div class="header_title"> <ha-icon-button .label="${0}" .path="${0}" dialogAction="close" class="header_button"></ha-icon-button> <span>${0}</span> </div> `),null!==(i=null==e?void 0:e.localize("ui.common.close"))&&void 0!==i?i:"Close","M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",t)};(0,o.Z)([(0,n.Mo)("ha-dialog")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",key:d.gA,value:void 0},{kind:"method",key:"scrollToPos",value:function(e,t){var i;null===(i=this.contentElement)||void 0===i||i.scrollTo(e,t)}},{kind:"method",key:"renderHeading",value:function(){return(0,l.dy)(h||(h=p`<slot name="heading"> ${0} </slot>`),(0,a.Z)(i,"renderHeading",this,3)([]))}},{kind:"method",key:"firstUpdated",value:function(){var e;(0,a.Z)(i,"firstUpdated",this,3)([]),this.suppressDefaultPressSelector=[this.suppressDefaultPressSelector,y].join(", "),this._updateScrolledAttribute(),null===(e=this.contentElement)||void 0===e||e.addEventListener("scroll",this._onScroll,{passive:!0})}},{kind:"method",key:"disconnectedCallback",value:function(){(0,a.Z)(i,"disconnectedCallback",this,3)([]),this.contentElement.removeEventListener("scroll",this._onScroll)}},{kind:"field",key:"_onScroll",value(){return()=>{this._updateScrolledAttribute()}}},{kind:"method",key:"_updateScrolledAttribute",value:function(){this.contentElement&&this.toggleAttribute("scrolled",0!==this.contentElement.scrollTop)}},{kind:"field",static:!0,key:"styles",value(){return[s.W,(0,l.iv)(u||(u=p`:host([scrolled]) ::slotted(ha-dialog-header){border-bottom:1px solid var(--mdc-dialog-scroll-divider-color,rgba(0,0,0,.12))}.mdc-dialog{--mdc-dialog-scroll-divider-color:var( --dialog-scroll-divider-color, var(--divider-color) );z-index:var(--dialog-z-index,8);-webkit-backdrop-filter:var(--ha-dialog-scrim-backdrop-filter,var(--dialog-backdrop-filter,none));backdrop-filter:var(--ha-dialog-scrim-backdrop-filter,var(--dialog-backdrop-filter,none));--mdc-dialog-box-shadow:var(--dialog-box-shadow, none);--mdc-typography-headline6-font-weight:400;--mdc-typography-headline6-font-size:1.574rem}.mdc-dialog__actions{justify-content:var(--justify-action-buttons,flex-end);padding-bottom:max(env(safe-area-inset-bottom),24px)}.mdc-dialog__actions span:first-child{flex:var(--secondary-action-button-flex,unset)}.mdc-dialog__actions span:nth-child(2){flex:var(--primary-action-button-flex,unset)}.mdc-dialog__container{align-items:var(--vertical-align-dialog,center)}.mdc-dialog__title{padding:24px 24px 0 24px}.mdc-dialog__title:has(span){padding:12px 12px 0}.mdc-dialog__actions{padding:12px 24px 12px 24px}.mdc-dialog__title::before{content:unset}.mdc-dialog .mdc-dialog__content{position:var(--dialog-content-position,relative);padding:var(--dialog-content-padding,24px)}:host([hideactions]) .mdc-dialog .mdc-dialog__content{padding-bottom:max(var(--dialog-content-padding,24px),env(safe-area-inset-bottom))}.mdc-dialog .mdc-dialog__surface{position:var(--dialog-surface-position,relative);top:var(--dialog-surface-top);margin-top:var(--dialog-surface-margin-top);min-height:var(--mdc-dialog-min-height,auto);border-radius:var(--ha-dialog-border-radius,28px);-webkit-backdrop-filter:var(--ha-dialog-surface-backdrop-filter,none);backdrop-filter:var(--ha-dialog-surface-backdrop-filter,none);background:var(--ha-dialog-surface-background,var(--mdc-theme-surface,#fff))}:host([flexContent]) .mdc-dialog .mdc-dialog__content{display:flex;flex-direction:column}.header_title{display:flex;align-items:center;direction:var(--direction)}.header_title span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;padding-left:4px}.header_button{text-decoration:none;color:inherit;inset-inline-start:initial;inset-inline-end:-12px;direction:var(--direction)}.dialog-actions{inset-inline-start:initial!important;inset-inline-end:0px!important;direction:var(--direction)}`))]}}]}}),r.M)},96e3:function(e,t,i){var o=i(61701),a=i(72621),r=(i(19083),i(71695),i(40251),i(19134),i(61006),i(47021),i(72700),i(8038),i(71513),i(75656),i(50100),i(18084),i(57243)),s=i(50778),l=i(36522),n=i(76320),d=(i(99426),i(47844)),c=i(72344);let h,u,p,y,v=e=>e;(0,o.Z)([(0,s.Mo)("ha-hls-player")],(function(e,t){class o extends t{constructor(...t){super(...t),e(this)}}return{F:o,d:[{kind:"field",decorators:[(0,s.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,s.Cb)()],key:"entityid",value:void 0},{kind:"field",decorators:[(0,s.Cb)()],key:"url",value:void 0},{kind:"field",decorators:[(0,s.Cb)({attribute:"poster-url"})],key:"posterUrl",value:void 0},{kind:"field",decorators:[(0,s.Cb)({type:Boolean,attribute:"controls"})],key:"controls",value(){return!1}},{kind:"field",decorators:[(0,s.Cb)({type:Boolean,attribute:"muted"})],key:"muted",value(){return!1}},{kind:"field",decorators:[(0,s.Cb)({type:Boolean,attribute:"autoplay"})],key:"autoPlay",value(){return!1}},{kind:"field",decorators:[(0,s.Cb)({type:Boolean,attribute:"playsinline"})],key:"playsInline",value(){return!1}},{kind:"field",decorators:[(0,s.Cb)({type:Boolean,attribute:"allow-exoplayer"})],key:"allowExoPlayer",value(){return!1}},{kind:"field",decorators:[(0,s.IO)("video")],key:"_videoEl",value:void 0},{kind:"field",decorators:[(0,s.SB)()],key:"_error",value:void 0},{kind:"field",decorators:[(0,s.SB)()],key:"_errorIsFatal",value(){return!1}},{kind:"field",decorators:[(0,s.SB)()],key:"_url",value:void 0},{kind:"field",key:"_hlsPolyfillInstance",value:void 0},{kind:"field",key:"_exoPlayer",value(){return!1}},{kind:"field",static:!0,key:"streamCount",value(){return 0}},{kind:"method",key:"connectedCallback",value:function(){(0,a.Z)(o,"connectedCallback",this,3)([]),o.streamCount+=1,this.hasUpdated&&(this._resetError(),this._startHls())}},{kind:"method",key:"disconnectedCallback",value:function(){(0,a.Z)(o,"disconnectedCallback",this,3)([]),o.streamCount-=1,this._cleanUp()}},{kind:"method",key:"render",value:function(){return(0,r.dy)(h||(h=v` ${0} ${0} `),this._error?(0,r.dy)(u||(u=v`<ha-alert alert-type="error" class="${0}"> ${0} </ha-alert>`),this._errorIsFatal?"fatal":"retry",this._error):"",this._errorIsFatal?"":(0,r.dy)(p||(p=v`<video .poster="${0}" ?autoplay="${0}" .muted="${0}" ?playsinline="${0}" ?controls="${0}" @loadeddata="${0}"></video>`),this.posterUrl,this.autoPlay,this.muted,this.playsInline,this.controls,this._loadedData))}},{kind:"method",key:"updated",value:function(e){(0,a.Z)(o,"updated",this,3)([e]);const t=e.has("entityid"),i=e.has("url");t?this._getStreamUrlFromEntityId():i&&this.url&&(this._cleanUp(),this._resetError(),this._url=this.url,this._startHls())}},{kind:"method",key:"_getStreamUrlFromEntityId",value:async function(){if(this._cleanUp(),this._resetError(),(0,c.p)(this.hass,"stream")){if(this.entityid)try{const{url:e}=await(0,d.Lr)(this.hass,this.entityid);this._url=this.hass.hassUrl(e),this._cleanUp(),this._resetError(),this._startHls()}catch(e){console.error(e),(0,l.B)(this,"streams",{hasAudio:!1,hasVideo:!1})}}else this._setFatalError("Streaming component is not loaded.")}},{kind:"method",key:"_startHls",value:async function(){var e;const t=fetch(this._url),o=(await Promise.all([i.e("2142"),i.e("66095")]).then(i.bind(i,17231))).default;if(!this.isConnected)return;let a=o.isSupported();if(a||(a=""!==this._videoEl.canPlayType("application/vnd.apple.mpegurl")),!a)return void this._setFatalError(this.hass.localize("ui.components.media-browser.video_not_supported"));const r=this.allowExoPlayer&&(null===(e=this.hass.auth.external)||void 0===e?void 0:e.config.hasExoPlayer),s=await(await t).text();if(!this.isConnected)return;const l=/#EXT-X-STREAM-INF:.*?(?:CODECS=".*?([^.]*)?\..*?,([^.]*)?\..*?".*?)?(?:\n|\r\n)(.+)/g,n=l.exec(s),d=l.exec(s);let c;c=null!==n&&null===d?new URL(n[3],this._url).href:this._url;const h=n?`${n[1]},${n[2]}`:void 0;this._reportStreams(h),r&&(null!=h&&h.includes("hevc")||null!=h&&h.includes("hev1"))?this._renderHLSExoPlayer(c):o.isSupported()?this._renderHLSPolyfill(this._videoEl,o,c):this._renderHLSNative(this._videoEl,c)}},{kind:"method",key:"_renderHLSExoPlayer",value:async function(e){this._exoPlayer=!0,window.addEventListener("resize",this._resizeExoPlayer),this.updateComplete.then((()=>(0,n.y)())).then(this._resizeExoPlayer),this._videoEl.style.visibility="hidden",await this.hass.auth.external.fireMessage({type:"exoplayer/play_hls",payload:{url:e,muted:this.muted}})}},{kind:"field",key:"_resizeExoPlayer",value(){return()=>{if(!this._videoEl)return;const e=this._videoEl.getBoundingClientRect();this.hass.auth.external.fireMessage({type:"exoplayer/resize",payload:{left:e.left,top:e.top,right:e.right,bottom:e.bottom}})}}},{kind:"method",key:"_isLLHLSSupported",value:function(){if(o.streamCount<=2)return!0;if(!("performance"in window)||0===performance.getEntriesByType("resource").length)return!1;const e=performance.getEntriesByType("resource")[0];return"nextHopProtocol"in e&&"h2"===e.nextHopProtocol}},{kind:"method",key:"_renderHLSPolyfill",value:async function(e,t,i){const o=new t({backBufferLength:60,fragLoadingTimeOut:3e4,manifestLoadingTimeOut:3e4,levelLoadingTimeOut:3e4,maxLiveSyncPlaybackRate:2,lowLatencyMode:this._isLLHLSSupported()});this._hlsPolyfillInstance=o,o.attachMedia(e),o.on(t.Events.MEDIA_ATTACHED,(()=>{this._resetError(),o.loadSource(i)})),o.on(t.Events.FRAG_LOADED,((e,t)=>{this._resetError()})),o.on(t.Events.ERROR,((e,i)=>{if(i.fatal)if(i.type===t.ErrorTypes.NETWORK_ERROR){switch(i.details){case t.ErrorDetails.MANIFEST_LOAD_ERROR:{let e="Error starting stream, see logs for details";void 0!==i.response&&void 0!==i.response.code&&(i.response.code>=500?e+=" (Server failure)":i.response.code>=400?e+=" (Stream never started)":e+=" ("+i.response.code+")"),this._setRetryableError(e);break}case t.ErrorDetails.MANIFEST_LOAD_TIMEOUT:this._setRetryableError("Timeout while starting stream");break;default:this._setRetryableError("Stream network error")}o.startLoad()}else i.type===t.ErrorTypes.MEDIA_ERROR?(this._setRetryableError("Error with media stream contents"),o.recoverMediaError()):this._setFatalError("Error playing stream")}))}},{kind:"method",key:"_renderHLSNative",value:async function(e,t){e.src=t,e.addEventListener("loadedmetadata",(()=>{e.play()}))}},{kind:"method",key:"_cleanUp",value:function(){this._hlsPolyfillInstance&&(this._hlsPolyfillInstance.destroy(),this._hlsPolyfillInstance=void 0),this._exoPlayer&&(window.removeEventListener("resize",this._resizeExoPlayer),this.hass.auth.external.fireMessage({type:"exoplayer/stop"}),this._exoPlayer=!1),this._videoEl&&(this._videoEl.removeAttribute("src"),this._videoEl.load())}},{kind:"method",key:"_resetError",value:function(){this._error=void 0,this._errorIsFatal=!1}},{kind:"method",key:"_setFatalError",value:function(e){this._error=e,this._errorIsFatal=!0,(0,l.B)(this,"streams",{hasAudio:!1,hasVideo:!1})}},{kind:"method",key:"_setRetryableError",value:function(e){this._error=e,this._errorIsFatal=!1,(0,l.B)(this,"streams",{hasAudio:!1,hasVideo:!1})}},{kind:"method",key:"_reportStreams",value:function(e){var t;const i=null==e?void 0:e.split(",");(0,l.B)(this,"streams",{hasAudio:null!==(t=null==i?void 0:i.includes("mp4a"))&&void 0!==t&&t,hasVideo:null!=i&&i.includes("mp4a")?(null==i?void 0:i.length)>1:Boolean(null==i?void 0:i.length)})}},{kind:"method",key:"_loadedData",value:function(){(0,l.B)(this,"load")}},{kind:"field",static:!0,key:"styles",value(){return(0,r.iv)(y||(y=v`:host,video{display:block}video{width:100%;max-height:var(--video-max-height,calc(100vh - 97px))}.fatal{display:block;padding:100px 16px}.retry{display:block}`))}}]}}),r.oi)},5486:function(e,t,i){i.r(t),i.d(t,{HuiDialogWebBrowserPlayMedia:()=>_});var o=i(61701),a=(i(71695),i(47021),i(57243)),r=i(50778),s=i(36522),l=i(73729),n=(i(96e3),i(28008));let d,c,h,u,p,y,v,m=e=>e,_=(0,o.Z)([(0,r.Mo)("hui-dialog-web-browser-play-media")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,r.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,r.SB)()],key:"_params",value:void 0},{kind:"method",key:"showDialog",value:function(e){this._params=e}},{kind:"method",key:"closeDialog",value:function(){this._params=void 0,(0,s.B)(this,"dialog-closed",{dialog:this.localName})}},{kind:"method",key:"render",value:function(){if(!this._params||!this._params.sourceType||!this._params.sourceUrl)return a.Ld;const e=this._params.sourceType.split("/",1)[0];return(0,a.dy)(d||(d=m` <ha-dialog open hideActions .heading="${0}" @closed="${0}"> ${0} </ha-dialog> `),(0,l.i)(this.hass,this._params.title||this.hass.localize("ui.components.media-browser.media_player")),this.closeDialog,"audio"===e?(0,a.dy)(c||(c=m` <audio controls autoplay> <source src="${0}" type="${0}"> ${0} </audio> `),this._params.sourceUrl,this._params.sourceType,this.hass.localize("ui.components.media-browser.audio_not_supported")):"video"===e?(0,a.dy)(h||(h=m` <video controls autoplay playsinline> <source src="${0}" type="${0}"> ${0} </video> `),this._params.sourceUrl,this._params.sourceType,this.hass.localize("ui.components.media-browser.video_not_supported")):"application/x-mpegURL"===this._params.sourceType?(0,a.dy)(u||(u=m` <ha-hls-player controls autoplay playsinline .hass="${0}" .url="${0}"></ha-hls-player> `),this.hass,this._params.sourceUrl):"image"===e?(0,a.dy)(p||(p=m`<img alt="${0}" src="${0}">`),this._params.title||a.Ld,this._params.sourceUrl):(0,a.dy)(y||(y=m`${0}`),this.hass.localize("ui.components.media-browser.media_not_supported")))}},{kind:"get",static:!0,key:"styles",value:function(){return[n.yu,(0,a.iv)(v||(v=m`@media (min-width:800px){ha-dialog{--mdc-dialog-max-width:800px;--mdc-dialog-min-width:400px}}audio,img,video{outline:0;width:100%}`))]}}]}}),a.oi)}}]); //# sourceMappingURL=55964.6f5457fbb7226868.js.map