UNPKG

iobroker.lovelace

Version:

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

2 lines 2.89 kB
export const __webpack_ids__=["11569"];export const __webpack_modules__={17712:function(t,e,a){a.a(t,(async function(t,o){try{a.r(e);var n=a(44249),i=a(72621),s=(a(75656),a(50100),a(18084),a(57243)),d=a(15093),c=(a(68424),a(29095)),r=a(96194),l=a(58014),h=a(72473),u=a(34798),p=t([c]);c=(p.then?(await p)():p)[0];let _=(0,n.Z)(null,(function(t,e){class a extends e{constructor(...e){super(...e),t(this)}}return{F:a,d:[{kind:"field",decorators:[(0,d.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,d.Cb)({attribute:!1})],key:"stateObj",value:void 0},{kind:"field",decorators:[(0,d.SB)()],key:"_attached",value:()=>!1},{kind:"field",decorators:[(0,d.SB)()],key:"_waiting",value:()=>!1},{kind:"method",key:"connectedCallback",value:function(){(0,i.Z)(a,"connectedCallback",this,3)([]),this._attached=!0}},{kind:"method",key:"disconnectedCallback",value:function(){(0,i.Z)(a,"disconnectedCallback",this,3)([]),this._attached=!1}},{kind:"method",key:"render",value:function(){return this._attached&&this.stateObj?s.dy` <ha-camera-stream .hass="${this.hass}" .stateObj="${this.stateObj}" allow-exoplayer controls></ha-camera-stream> <div class="actions"> <ha-progress-button @click="${this._downloadSnapshot}" .progress="${this._waiting}" .disabled="${this.stateObj.state===r.nZ}"> ${this.hass.localize("ui.dialogs.more_info_control.camera.download_snapshot")} </ha-progress-button> </div> `:s.Ld}},{kind:"method",key:"_downloadSnapshot",value:async function(t){const e=t.currentTarget;this._waiting=!0;try{const t=await this.hass.callApiRaw("GET",`camera_proxy/${this.stateObj.entity_id}`);if(!t)throw new Error("No response from API");const e="image/png"===t.headers.get("content-type")?"png":"jpg",a=(new Date).toLocaleString(),o=`snapshot_${(0,u.l)(this.stateObj.entity_id)}_${a}.${e}`,n=await t.blob(),i=window.URL.createObjectURL(n);(0,l.N)(i,o)}catch(t){return this._waiting=!1,e.actionError(),void(0,h.C)(this,{message:this.hass.localize("ui.dialogs.more_info_control.camera.failed_to_download")})}this._waiting=!1,e.actionSuccess()}},{kind:"field",static:!0,key:"styles",value:()=>s.iv`:host{display:block}.actions{width:100%;display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-end;box-sizing:border-box;padding:12px;z-index:1;gap:8px}`}]}}),s.oi);customElements.define("more-info-camera",_),o()}catch(t){o(t)}}))},58014:function(t,e,a){a.d(e,{N:()=>n,G:()=>i});var o=a(18117);const n=(t,e="")=>{const a=document.createElement("a");a.target="_blank",a.href=t,a.download=e,a.style.display="none",document.body.appendChild(a),a.dispatchEvent(new MouseEvent("click")),document.body.removeChild(a)},i=t=>!(t=>!!t.auth.external&&o.G)(t)||!!t.auth.external?.config.downloadFileSupported},18117:function(t,e,a){a.d(e,{G:()=>o});const o=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}}; //# sourceMappingURL=11569.a3d0fe260716d1e4.js.map