iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 8.94 kB
JavaScript
(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[71508],{34370:function(e,t,s){s(18111),s(7588),e.exports=function e(t){return Object.freeze(t),Object.getOwnPropertyNames(t).forEach(function(s){!t.hasOwnProperty(s)||null===t[s]||"object"!=typeof t[s]&&"function"!=typeof t[s]||Object.isFrozen(t[s])||e(t[s])}),t}},99680:function(e,t,s){"use strict";s.d(t,{eX:function(){return n}});s(18111),s(81148),s(22489),s(61701),s(62953);var i=s(28918),o=s(35952),a=s(91984);const n=e=>{if((0,o.Wu)(e))return e;const t=Object.assign({},e);return t.views&&(t.views=t.views.map(h)),t},h=e=>{if((0,a.R6)(e))return e;const t=Object.assign({},e);return t.badges&&!t.badges.every(Boolean)&&(t.badges=t.badges.filter(Boolean)),t.sections&&(t.sections=t.sections.map(l)),t},l=e=>{const t=Object.assign({},e);if(e.title){if(!(0,i.H)(t)){const e={type:"heading",heading:t.title};t.cards=[e,...t.cards||[]]}delete t.title}return t}},15020:function(e,t,s){"use strict";s.a(e,async function(e,i){try{s.r(t),s.d(t,{LovelacePanel:function(){return R}});s(18111),s(20116),s(3362),s(62953);var o=s(40445),a=s(34370),n=s.n(a),h=s(5124),l=s(67576),r=s(22786),c=s(91926),d=s(51758),g=s(6030),u=s(9899),f=s(19459),v=s(18350),p=s(95350),_=s(99129),C=s(35952),w=s(25612),y=s(28794),m=s(23296),b=s(81619),N=s(99680),U=s(35697),P=s(1412),S=s(29994),$=s(15656),E=s(693),M=s(71730),k=e([v,y,m,S]);[v,y,m,S]=k.then?(await k)():k;let L,O,x,z,j=e=>e;window.loadCardHelpers=()=>Promise.all([s.e(99143),s.e(66990),s.e(86538)]).then(s.bind(s,33963));let W=!1,F=!1;class R extends h.WF{connectedCallback(){super.connectedCallback(),this.lovelace&&this.hass&&this.lovelace.locale!==this.hass.locale?this._setLovelaceConfig(this.lovelace.config,this.lovelace.rawConfig,this.lovelace.mode):this._fetchConfigOnConnect&&this._fetchConfig(!1),window.addEventListener("connection-status",this._handleConnectionStatus)}disconnectedCallback(){super.disconnectedCallback(),null!==this.urlPath&&this._unsubUpdates&&(this._unsubUpdates.then(e=>e()),this._unsubUpdates=void 0),window.removeEventListener("connection-status",this._handleConnectionStatus)}render(){const e=this._panelState;return"loaded"===e?(0,h.qy)(L||(L=j` <hui-root .panel="${0}" .hass="${0}" .lovelace="${0}" .route="${0}" .narrow="${0}" -refresh="${0}" -config-changed="${0}"></hui-root> `),this.panel,this.hass,this.lovelace,this.route,this.narrow,this._forceFetchConfig,this._strategyConfigChanged):"error"===e?(0,h.qy)(O||(O=j` <hass-error-screen .hass="${0}" title="${0}" .error="${0}"> <ha-button ="${0}"> ${0} </ha-button> </hass-error-screen> `),this.hass,(0,p.p$)(this.hass.localize,"lovelace"),this._errorMsg,this._forceFetchConfig,this.hass.localize("ui.panel.lovelace.reload_lovelace")):"yaml-editor"===e?(0,h.qy)(x||(x=j` <hui-editor .narrow="${0}" .hass="${0}" .lovelace="${0}" .closeEditor="${0}"></hui-editor> `),this.narrow,this.hass,this.lovelace,this._closeEditor):(0,h.qy)(z||(z=j` <hass-loading-screen rootnav .hass="${0}" .narrow="${0}"></hass-loading-screen> `),this.hass,this.narrow)}willUpdate(e){super.willUpdate(e),this.lovelace||"error"===this._panelState||this._loading||this._fetchConfig(!1)}firstUpdated(e){super.firstUpdated(e),this._unsubUpdates||this._subscribeUpdates()}updated(e){if(super.updated(e),!e.has("hass"))return;const t=e.get("hass");t&&this.hass&&this.lovelace&&(0,C.Wu)(this.lovelace.rawConfig)&&(t.entities===this.hass.entities&&t.devices===this.hass.devices&&t.areas===this.hass.areas&&t.floors===this.hass.floors||"RUNNING"===this.hass.config.state&&this._debounceRegistriesChanged(),"RUNNING"===this.hass.config.state&&"RUNNING"!==t.config.state&&this._regenerateStrategyConfig())}async _regenerateStrategyConfig(){if(!this.hass||!this.lovelace)return;const e=this.lovelace.rawConfig;if((0,C.Wu)(e))try{const t=await(0,$.uN)(e,this.hass);this._setLovelaceConfig(t,e,"generated")}catch(t){console.error(t)}}async _subscribeUpdates(){this._unsubUpdates=(0,_.EG)(this.hass.connection,this.urlPath,()=>this._lovelaceChanged())}_lovelaceChanged(){var e;this._ignoreNextUpdateEvent?this._ignoreNextUpdateEvent=!1:this.isConnected?null!==(e=this.lovelace)&&void 0!==e&&e.editMode||"yaml-editor"===this._panelState?(0,b.P)(this,{message:this.hass.localize("ui.panel.lovelace.externally_updated_toast.message"),action:{action:()=>this._fetchConfig(!1),text:this.hass.localize("ui.common.refresh")},duration:-1,dismissable:!1}):this._fetchConfig(!1):this._fetchConfigOnConnect=!0}get urlPath(){return this.panel.url_path}_forceFetchConfig(){this._fetchConfig(!0)}async _fetchConfig(e){var t;let s,i;this._loading=!0;const o=null===(t=this.panel.config)||void 0===t?void 0:t.mode;if(!o)return void(0,c.oo)("/home",{replace:!0});let a;const n=window;n.llConfProm&&(a=n.llConfProm,n.llConfProm=void 0),F||(F=!0,(n.llResProm||(0,w.kZ)(this.hass.connection)).then(e=>(0,U.n)(e,this.hass))),null===this.urlPath&&a||(this.lovelace&&"yaml"===this.lovelace.mode&&(this._ignoreNextUpdateEvent=!0),a=(0,C.Dz)(this.hass.connection,this.urlPath,e));try{if(i=await a,(0,C.Wu)(i)){var h;if(null===(h=this.hass)||void 0===h||!h.entities||!this.hass.devices||!this.hass.areas)return;s=await(0,$.uN)(i,this.hass)}else s=i}catch(l){if("config_not_found"!==l.code)return console.log(l),this._panelState="error",void(this._errorMsg=l.message);if("lovelace"===this.urlPath){if(!(await(0,M.SJ)(this.hass)).find(e=>"lovelace"===e.url_path))return void(0,c.oo)("/home",{replace:!0})}s=this._generateDefaultConfig(this.hass.localize),i=s}finally{this._loading=!1,this.lovelace&&"yaml"===this.lovelace.mode&&setTimeout(()=>{this._ignoreNextUpdateEvent=!1},2e3)}this._panelState="yaml-editor"===this._panelState?this._panelState:"loaded",this._setLovelaceConfig(s,i,o)}_checkLovelaceConfig(e){const t=(0,N.eX)(e);return n()(t)}_setLovelaceConfig(e,t,i){e=this._checkLovelaceConfig(e);const o=this.urlPath;this.lovelace={config:e,rawConfig:t,mode:i,urlPath:this.urlPath,editMode:!!this.lovelace&&this.lovelace.editMode,locale:this.hass.locale,enableFullEditMode:()=>{W||(W=!0,s.e(36584).then(s.bind(s,5435))),this._panelState="yaml-editor"},setEditMode:e=>{var t;"generated"===this.lovelace.mode&&e&&null!==(t=this.panel)&&void 0!==t&&t.config?(0,P.z)(this,{lovelace:this.lovelace,mode:this.panel.config.mode,narrow:this.narrow}):(0,C.Wu)(this.lovelace.rawConfig)&&e?this.lovelace.enableFullEditMode():this._updateLovelace({editMode:e})},saveConfig:async e=>{const{config:t,rawConfig:s,mode:i}=this.lovelace;let a;e=this._checkLovelaceConfig(e),a=(0,C.Wu)(e)?await(0,$.uN)(e,this.hass):e;try{this._updateLovelace({config:a,rawConfig:e,mode:"storage"}),this._ignoreNextUpdateEvent=!0,await(0,C.ql)(this.hass,o,e)}catch(n){throw console.error(n),this._updateLovelace({config:t,rawConfig:s,mode:i}),n}},deleteConfig:async()=>{const{config:e,rawConfig:t,mode:s}=this.lovelace;try{const e=this._generateDefaultConfig(this.hass.localize);this._updateLovelace({config:e,rawConfig:e,mode:"storage"}),this._ignoreNextUpdateEvent=!0,await(0,C.ql)(this.hass,o,e)}catch(i){throw console.error(i),this._updateLovelace({config:e,rawConfig:t,mode:s}),i}},showToast:e=>(0,b.P)(this,e)}}_updateLovelace(e){this.lovelace=Object.assign(Object.assign({},this.lovelace),e),"editMode"in e&&window.history.replaceState(null,"",(0,d.Z)(e.editMode?(0,g.$X)({edit:"1"}):(0,g.s8)("edit")))}constructor(...e){super(...e),this.narrow=!1,this._panelState="loading",this._ignoreNextUpdateEvent=!1,this._fetchConfigOnConnect=!1,this._loading=!1,this._debounceRegistriesChanged=(0,u.s)(()=>this._registriesChanged(),200),this._registriesChanged=async()=>{if(!this.hass||!this.lovelace)return;const e=this.lovelace.rawConfig;if(!(0,C.Wu)(e))return;const t=this.lovelace.config,s=await(0,$.uN)(e,this.hass),i=(0,N.eX)(s);(0,f.b)(i,t)||this._regenerateStrategyConfig()},this._strategyConfigChanged=e=>{e.stopPropagation(),this._regenerateStrategyConfig()},this._handleConnectionStatus=e=>{"connected"===e.detail&&this._fetchConfig(!1)},this._closeEditor=()=>{this._panelState="loaded"},this._generateDefaultConfig=(0,r.A)(e=>({views:[(0,E.c)(e,!0)]}))}}(0,o.Cg)([(0,l.MZ)({attribute:!1})],R.prototype,"panel",void 0),(0,o.Cg)([(0,l.MZ)({attribute:!1})],R.prototype,"hass",void 0),(0,o.Cg)([(0,l.MZ)({type:Boolean})],R.prototype,"narrow",void 0),(0,o.Cg)([(0,l.MZ)({attribute:!1})],R.prototype,"route",void 0),(0,o.Cg)([(0,l.wk)()],R.prototype,"_panelState",void 0),(0,o.Cg)([(0,l.wk)()],R.prototype,"_errorMsg",void 0),(0,o.Cg)([(0,l.wk)()],R.prototype,"lovelace",void 0),R=(0,o.Cg)([(0,l.EM)("ha-panel-lovelace")],R),i()}catch(L){i(L)}})},31481:function(e,t,s){"use strict";s.d(t,{Y:function(){return i}});const i=(e,t)=>({type:"grid",cards:t?[{type:"heading",heading:e("ui.panel.lovelace.editor.section.default_section_title")}]:[]})},693:function(e,t,s){"use strict";s.d(t,{c:function(){return o}});var i=s(31481);const o=(e,t)=>({type:"sections",sections:[(0,i.Y)(e,t)]})}}]);