iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 2.73 kB
JavaScript
export const __rspack_esm_id=65742;export const __rspack_esm_ids=[65742];export const __webpack_modules__={16869(t,e,a){a.d(e,{B:()=>o,g:()=>s});a(74423);const s=window.externalAppV2||window.externalApp||window.webkit?.messageHandlers?.getExternalAuth||location.search.includes("external_auth=1"),o=window.externalApp||window.externalAppV2},16349(t,e,a){a.a(t,async function(t,s){try{a.r(e);a(14603),a(47566),a(98721);var o=a(62826),i=a(5124),n=a(22441),r=a(80880),c=a(89300),d=a(13062),l=a(22675),h=a(30039),p=a(81619),w=t([c,d]);[c,d]=w.then?(await w)():w;class _ extends i.WF{connectedCallback(){super.connectedCallback(),this._attached=!0}disconnectedCallback(){super.disconnectedCallback(),this._attached=!1}render(){return this._attached&&this.stateObj?i.qy` <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===l.Hh}" appearance="filled"> ${this.hass.localize("ui.dialogs.more_info_control.camera.download_snapshot")} </ha-progress-button> </div> `:i.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(),s=`snapshot_${(0,r.Y)(this.stateObj.entity_id)}_${a}.${e}`,o=await t.blob(),i=window.URL.createObjectURL(o);(0,h.R)(i,s)}catch(t){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=i.AH`: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,o.Cg)([(0,n.MZ)({attribute:!1})],_.prototype,"hass",void 0),(0,o.Cg)([(0,n.MZ)({attribute:!1})],_.prototype,"stateObj",void 0),(0,o.Cg)([(0,n.wk)()],_.prototype,"_attached",void 0),(0,o.Cg)([(0,n.wk)()],_.prototype,"_waiting",void 0),_=(0,o.Cg)([(0,n.EM)("more-info-camera")],_),s()}catch(t){s(t)}})},30039(t,e,a){a.d(e,{R:()=>o});a(14603),a(47566),a(98721);var s=a(16869);const o=(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:")&&(s.B?setTimeout(()=>URL.revokeObjectURL(t),1e4):URL.revokeObjectURL(t))}}};