UNPKG

iobroker.lovelace

Version:

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

2 lines 3.12 kB
"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["11569"],{17712:function(t,e,a){a.a(t,(async function(t,n){try{a.r(e);var i=a(61701),o=a(72621),s=(a(52247),a(71695),a(40251),a(47021),a(72700),a(8038),a(71513),a(75656),a(50100),a(18084),a(57243)),r=a(50778),d=(a(68424),a(29095)),c=a(96194),l=a(58014),h=a(72473),u=a(34798),f=t([d]);d=(f.then?(await f)():f)[0];let p,b,k=t=>t,m=(0,i.Z)(null,(function(t,e){class a extends e{constructor(...e){super(...e),t(this)}}return{F:a,d:[{kind:"field",decorators:[(0,r.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,r.Cb)({attribute:!1})],key:"stateObj",value:void 0},{kind:"field",decorators:[(0,r.SB)()],key:"_attached",value(){return!1}},{kind:"field",decorators:[(0,r.SB)()],key:"_waiting",value(){return!1}},{kind:"method",key:"connectedCallback",value:function(){(0,o.Z)(a,"connectedCallback",this,3)([]),this._attached=!0}},{kind:"method",key:"disconnectedCallback",value:function(){(0,o.Z)(a,"disconnectedCallback",this,3)([]),this._attached=!1}},{kind:"method",key:"render",value:function(){return this._attached&&this.stateObj?(0,s.dy)(p||(p=k` <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}"> ${0} </ha-progress-button> </div> `),this.hass,this.stateObj,this._downloadSnapshot,this._waiting,this.stateObj.state===c.nZ,this.hass.localize("ui.dialogs.more_info_control.camera.download_snapshot")):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(),n=`snapshot_${(0,u.l)(this.stateObj.entity_id)}_${a}.${e}`,i=await t.blob(),o=window.URL.createObjectURL(i);(0,l.N)(o,n)}catch(a){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(){return(0,s.iv)(b||(b=k`: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",m),n()}catch(p){n(p)}}))},58014:function(t,e,a){a.d(e,{N:()=>i,G:()=>o});var n=a(18117);const i=(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)},o=t=>{var e;return!(t=>!!t.auth.external&&n.G)(t)||!(null===(e=t.auth.external)||void 0===e||!e.config.downloadFileSupported)}},18117:function(t,e,a){a.d(e,{G:()=>n});a(19134),a(5740);const n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}}]); //# sourceMappingURL=11569.b93bcd72b29cb656.js.map