iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 3.03 kB
JavaScript
;(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[65742],{16869:function(t,e,a){a.d(e,{B:function(){return o},g:function(){return s}});var n;a(74423),a(27495);const s=window.externalAppV2||window.externalApp||(null===(n=window.webkit)||void 0===n||null===(n=n.messageHandlers)||void 0===n?void 0:n.getExternalAuth)||location.search.includes("external_auth=1"),o=window.externalApp||window.externalAppV2},16349:function(t,e,a){a.a(t,async function(t,n){try{a.r(e);a(16280),a(3362),a(62953),a(3296),a(27208),a(48408),a(14603),a(47566),a(98721);var s=a(40445),o=a(5124),i=a(67576),r=a(80880),c=a(89300),d=a(13062),l=a(22675),h=a(30039),p=a(81619),u=t([c,d]);[c,d]=u.then?(await u)():u;let w,b,g=t=>t;class _ extends o.WF{connectedCallback(){super.connectedCallback(),this._attached=!0}disconnectedCallback(){super.disconnectedCallback(),this._attached=!1}render(){return this._attached&&this.stateObj?(0,o.qy)(w||(w=g` <ha-camera-stream .hass="${0}" .stateObj="${0}" allow-exoplayer controls></ha-camera-stream> <div class="actions"> <ha-progress-button @click="${0}" .progress="${0}" .disabled="${0}" appearance="filled"> ${0} </ha-progress-button> </div> `),this.hass,this.stateObj,this._downloadSnapshot,this._waiting,this.stateObj.state===l.Hh,this.hass.localize("ui.dialogs.more_info_control.camera.download_snapshot")):o.s6}async _downloadSnapshot(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(),n=`snapshot_${(0,r.Y)(this.stateObj.entity_id)}_${a}.${e}`,s=await t.blob(),o=window.URL.createObjectURL(s);(0,h.R)(o,n)}catch(a){return this._waiting=!1,e.actionError(),void(0,p.P)(this,{message:this.hass.localize("ui.dialogs.more_info_control.camera.failed_to_download")})}this._waiting=!1,e.actionSuccess()}constructor(...t){super(...t),this._attached=!1,this._waiting=!1}}_.styles=(0,o.AH)(b||(b=g`:host{display:block}.actions{width:100%;display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-end;box-sizing:border-box;padding:var(--ha-space-4);z-index:1;gap:var(--ha-space-2)}`)),(0,s.Cg)([(0,i.MZ)({attribute:!1})],_.prototype,"hass",void 0),(0,s.Cg)([(0,i.MZ)({attribute:!1})],_.prototype,"stateObj",void 0),(0,s.Cg)([(0,i.wk)()],_.prototype,"_attached",void 0),(0,s.Cg)([(0,i.wk)()],_.prototype,"_waiting",void 0),_=(0,s.Cg)([(0,i.EM)("more-info-camera")],_),n()}catch(w){n(w)}})},30039:function(t,e,a){a.d(e,{R:function(){return s}});a(62953),a(3296),a(27208),a(48408),a(14603),a(47566),a(98721);var n=a(16869);const s=(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),t.startsWith("blob:")&&(n.B?setTimeout(()=>URL.revokeObjectURL(t),1e4):URL.revokeObjectURL(t))}}}]);