iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 5.81 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[48412],{58548:function(t,i,e){e.d(i,{A:function(){return o}});e(16280),e(27495),e(25440);const n=t=>{const i=parseFloat(t);if(isNaN(i))throw new Error(`${t} is not a number`);return i};function o(t){if(!t)return null;try{if(t.endsWith("%"))return{w:100,h:n(t.slice(0,-1))};const i=t.replace(":","x").split("x");return 0===i.length?null:1===i.length?{w:n(i[0]),h:1}:{w:n(i[0]),h:n(i[1])}}catch(i){}return null}},17022:function(t,i,e){e.d(i,{A1:function(){return n},CY:function(){return a},Fn:function(){return o},Jz:function(){return c},St:function(){return r},VA:function(){return u},WI:function(){return d},iY:function(){return h},xw:function(){return s}});e(16280),e(3362);const n=(t,i)=>t.callWS({type:"media_source/resolve_media",media_content_id:i}),o=(t,i)=>t.callWS({type:"media_source/browse_media",media_content_id:i}),s="__MANUAL_ENTRY__",a=t=>t.startsWith(s),r=t=>t.startsWith("media-source://"),c=t=>t.startsWith("media-source://media_source"),h=t=>t.startsWith("media-source://image_upload"),u=async(t,i,e)=>{const n=new FormData;n.append("media_content_id",i),n.append("file",e);const o=await t.fetchWithAuth("/api/media_source/local_source/upload",{method:"POST",body:n});if(413===o.status)throw new Error(`Uploaded file is too large (${e.name})`);if(200!==o.status)throw new Error("Unknown error");return o.json()},d=async(t,i)=>t.callWS({type:"media_source/local_source/remove",media_content_id:i})},86063:function(t,i,e){e.a(t,async function(t,n){try{e.r(i),e.d(i,{STUB_IMAGE:function(){return W}});e(16280),e(74423),e(3362),e(62953);var o=e(40445),s=e(5124),a=e(67576),r=e(6412),c=e(63672),h=e(42372),u=e(71727),d=(e(76776),e(67013)),f=e(19037),_=e(13632),g=e(22064),l=e(97176),m=e(784),p=e(57914),y=e(85979),w=t([p,y]);[p,y]=w.then?(await w)():w;let v,b,$,x,E,k,C=t=>t;const W="https://demo.home-assistant.io/stub_config/bedroom.png";class A extends s.WF{static async getConfigElement(){return await e.e(76999).then(e.bind(e,98458)),document.createElement("hui-picture-entity-card-editor")}static getStubConfig(t,i,e){return{type:"picture-entity",entity:(0,_.B)(t,1,i,e,["light","switch"])[0]||"",image:W}}getCardSize(){return 3}setConfig(t){if(!t||!t.entity)throw new Error("Entity must be specified");if(!(["camera","image","person"].includes((0,u.m)(t.entity))||t.image||t.state_image||t.camera_image||t.show_entity_picture))throw new Error("No image source configured");this._config=Object.assign({show_name:!0,show_state:!0,tap_action:{action:"more-info"}},t)}shouldUpdate(t){return(0,m.LX)(this,t)}updated(t){if(super.updated(t),!this._config||!this.hass)return;const i=t.get("hass"),e=t.get("_config");i&&e&&i.themes===this.hass.themes&&e.theme===this._config.theme||(0,h.Q)(this,this.hass.themes,this._config.theme)}render(){var t;if(!this._config||!this.hass)return s.s6;const i=this.hass.states[this._config.entity];if(!i)return(0,s.qy)(v||(v=C` <hui-warning .hass="${0}"> ${0} </hui-warning> `),this.hass,(0,y.j)(this.hass,this._config.entity));const e=this.hass.formatEntityName(i,this._config.name),n=this.hass.formatEntityState(i);let o="";this._config.show_name&&this._config.show_state?o=(0,s.qy)(b||(b=C` <div class="footer both"> <div>${0}</div> <div>${0}</div> </div> `),e,n):this._config.show_name?o=(0,s.qy)($||($=C`<div class="footer single">${0}</div>`),e):this._config.show_state&&(o=(0,s.qy)(x||(x=C`<div class="footer single">${0}</div>`),n));const a=(0,u.m)(this._config.entity);let h;var _;(this._config.show_entity_picture&&(h=i.attributes.entity_picture_local||i.attributes.entity_picture),h)||(h="object"==typeof(null===(_=this._config)||void 0===_?void 0:_.image)&&this._config.image.media_content_id||this._config.image);if(!h)switch(a){case"image":h=(0,d.e)(i);break;case"person":i.attributes.entity_picture&&(h=i.attributes.entity_picture)}const g="grid"===this.layout&&"number"==typeof(null===(t=this._config.grid_options)||void 0===t?void 0:t.rows),m=(0,l.h)(this._config.tap_action)||Boolean(!this._config.tap_action&&this._config.entity);return(0,s.qy)(E||(E=C` <ha-card> <div class="image-container ${0}" ="${0}" .actionHandler="${0}" tabindex="${0}" role="${0}"> <hui-image .hass="${0}" .image="${0}" .stateImage="${0}" .stateFilter="${0}" .cameraImage="${0}" .cameraView="${0}" .entity="${0}" .aspectRatio="${0}" .fitMode="${0}"></hui-image> </div> ${0} </ha-card> `),(0,r.H)({clickable:m}),this._handleAction,(0,f.T)({hasHold:(0,l.h)(this._config.hold_action),hasDoubleClick:(0,l.h)(this._config.double_tap_action)}),(0,c.J)(m?"0":void 0),(0,c.J)(m?"0":void 0),this.hass,h,this._config.state_image,this._config.state_filter,"camera"===a?this._config.entity:this._config.camera_image,this._config.camera_view,this._config.entity,g?void 0:this._config.aspect_ratio,this._config.fit_mode,o)}_handleAction(t){(0,g.$)(this,this.hass,this._config,t.detail.action)}}A.styles=(0,s.AH)(k||(k=C`ha-card{min-height:75px;overflow:hidden;position:relative;height:100%;box-sizing:border-box}.image-container{height:100%}.image-container.clickable{cursor:pointer}hui-image{pointer-events:none;height:100%}.footer{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;position:absolute;left:0;right:0;bottom:0;background-color:var(--ha-picture-card-background-color,rgba(0,0,0,.3));padding:16px;font-size:var(--ha-font-size-l);line-height:16px;color:var(--ha-picture-card-text-color,#fff);pointer-events:none}.both{display:flex;justify-content:space-between}.single{text-align:center}`)),(0,o.Cg)([(0,a.MZ)({attribute:!1})],A.prototype,"hass",void 0),(0,o.Cg)([(0,a.MZ)({attribute:!1})],A.prototype,"layout",void 0),(0,o.Cg)([(0,a.wk)()],A.prototype,"_config",void 0),A=(0,o.Cg)([(0,a.EM)("hui-picture-entity-card")],A),n()}catch(v){n(v)}})}}]);