UNPKG

iobroker.lovelace

Version:

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

1 lines 4.7 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[85030],{67013:function(t,i,e){e.d(i,{e:function(){return s}});const s=t=>t.attributes.access_token?`/api/image_proxy/${t.entity_id}?token=${t.attributes.access_token}&state=${t.state}`:void 0},17022:function(t,i,e){e.d(i,{A1:function(){return s},CY:function(){return o},Fn:function(){return n},Jz:function(){return c},St:function(){return r},VA:function(){return _},WI:function(){return d},iY:function(){return h},xw:function(){return a}});e(16280),e(3362);const s=(t,i)=>t.callWS({type:"media_source/resolve_media",media_content_id:i}),n=(t,i)=>t.callWS({type:"media_source/browse_media",media_content_id:i}),a="__MANUAL_ENTRY__",o=t=>t.startsWith(a),r=t=>t.startsWith("media-source://"),c=t=>t.startsWith("media-source://media_source"),h=t=>t.startsWith("media-source://image_upload"),_=async(t,i,e)=>{const s=new FormData;s.append("media_content_id",i),s.append("file",e);const n=await t.fetchWithAuth("/api/media_source/local_source/upload",{method:"POST",body:s});if(413===n.status)throw new Error(`Uploaded file is too large (${e.name})`);if(200!==n.status)throw new Error("Unknown error");return n.json()},d=async(t,i)=>t.callWS({type:"media_source/local_source/remove",media_content_id:i})},30789:function(t,i,e){e.a(t,async function(t,s){try{e.r(i),e.d(i,{HuiPictureCard:function(){return C}});e(16280),e(3362),e(62953);var n=e(40445),a=e(5124),o=e(67576),r=e(6412),c=e(63672),h=e(42372),_=e(71727),d=(e(76776),e(67013)),u=e(19037),g=e(22064),f=e(97176),l=e(784),m=e(85979),p=e(17022),y=t([m]);m=(y.then?(await y)():y)[0];let v,w,b,k=t=>t;class C extends a.WF{static async getConfigElement(){return await e.e(87367).then(e.bind(e,75930)),document.createElement("hui-picture-card-editor")}static getStubConfig(){return{type:"picture",image:"https://demo.home-assistant.io/stub_config/t-shirt-promo.png"}}getCardSize(){return 5}setConfig(t){if(!t||!t.image&&!t.image_entity)throw new Error("Image required");t.image_entity?this._config=Object.assign({tap_action:{action:"more-info"}},t):this._config=Object.assign({tap_action:{action:"none"}},t)}shouldUpdate(t){if(!this._config||(0,l.xP)(this,t)||t.has("_resolvedImage"))return!0;if(this._config.image_entity&&t.has("hass")){const i=t.get("hass");if(!i||i.states[this._config.image_entity]!==this.hass.states[this._config.image_entity])return!0}return!1}willUpdate(t){var i,e,s;if(super.willUpdate(t),!this._config||!this.hass)return;const n=t.has("hass")&&void 0===t.get("hass"),a=t.has("_config")&&(null===(i=t.get("_config"))||void 0===i?void 0:i.image)!==(null===(e=this._config)||void 0===e?void 0:e.image),o="object"==typeof(null===(s=this._config)||void 0===s?void 0:s.image)&&this._config.image.media_content_id||this._config.image;(n||a)&&"string"==typeof o&&(0,p.St)(o)?(this._resolvedImage=void 0,(0,p.A1)(this.hass,o).then(t=>{this._resolvedImage=t.url})):a&&(this._resolvedImage=o)}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 a.s6;let i;if(this._config.image_entity&&(i=this.hass.states[this._config.image_entity],!i))return(0,a.qy)(v||(v=k`<hui-warning .hass="${0}"> ${0} </hui-warning>`),this.hass,(0,m.j)(this.hass,this._config.image_entity));let e=this._resolvedImage;if(this._config.image_entity){switch((0,_.m)(this._config.image_entity)){case"image":e=(0,d.e)(i);break;case"person":i.attributes.entity_picture&&(e=i.attributes.entity_picture)}}if(void 0===e)return a.s6;const s=Boolean(this._config.image_entity&&!this._config.tap_action||(0,f.A)(this._config));return(0,a.qy)(w||(w=k` <ha-card @action="${0}" .actionHandler="${0}" tabindex="${0}" class="${0}"> <img alt="${0}" src="${0}"> </ha-card> `),this._handleAction,(0,u.T)({hasHold:(0,f.h)(this._config.hold_action),hasDoubleClick:(0,f.h)(this._config.double_tap_action)}),(0,c.J)((0,f.h)(this._config.tap_action)||this._config.image_entity?"0":void 0),(0,r.H)({clickable:s}),(0,c.J)(this._config.alt_text||(null===(t=i)||void 0===t?void 0:t.attributes.friendly_name)),this.hass.hassUrl(e))}_handleAction(t){(0,g.$)(this,this.hass,this._config,t.detail.action)}}C.styles=(0,a.AH)(b||(b=k`ha-card{overflow:hidden;height:100%}ha-card.clickable{cursor:pointer}img{display:block;width:100%}`)),(0,n.Cg)([(0,o.MZ)({attribute:!1})],C.prototype,"hass",void 0),(0,n.Cg)([(0,o.wk)()],C.prototype,"_config",void 0),(0,n.Cg)([(0,o.wk)()],C.prototype,"_resolvedImage",void 0),C=(0,n.Cg)([(0,o.EM)("hui-picture-card")],C),s()}catch(v){s(v)}})}}]);