UNPKG

iobroker.lovelace

Version:

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

1 lines 3.4 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[94097],{90409:function(t,e,i){i.d(e,{A:function(){return n}});i(18111),i(61701);function n(t){const e=t.split(":").map(Number);return 3600*e[0]+60*e[1]+e[2]}},27167:function(t,e,i){i.d(e,{A:function(){return a}});const n=t=>t<10?`0${t}`:t;function a(t){const e=Math.floor(t/3600),i=Math.floor(t%3600/60),a=Math.floor(t%3600%60);return e>0?`${e}:${n(i)}:${n(a)}`:i>0?`${i}:${n(a)}`:a>0?""+a:null}},49141:function(t,e,i){i.d(e,{CR:function(){return r},PF:function(){return h},kL:function(){return s},ls:function(){return u},pZ:function(){return o},r9:function(){return c}});var n=i(90409),a=i(27167);const s=t=>t.callWS({type:"timer/list"}),r=(t,e)=>t.callWS(Object.assign({type:"timer/create"},e)),c=(t,e,i)=>t.callWS(Object.assign({type:"timer/update",timer_id:e},i)),o=(t,e)=>t.callWS({type:"timer/delete",timer_id:e}),u=t=>{if(!t.attributes.remaining)return;let e=(0,n.A)(t.attributes.remaining);if("active"===t.state){const i=(new Date).getTime(),n=new Date(t.attributes.finishes_at).getTime();e=Math.max((n-i)/1e3,0)}return e},h=(t,e,i)=>{if(!e)return null;if("idle"===e.state||0===i)return t.formatEntityState(e);let n=(0,a.A)(i||0)||"0";return"paused"===e.state&&(n=`${n} (${t.formatEntityState(e)})`),n}},6344:function(t,e,i){i.a(t,async function(t,n){try{i.r(e);i(16280);var a=i(40445),s=i(5124),r=i(67576),c=(i(5078),i(784)),o=i(79757),u=i(85979),h=t([o,u]);[o,u]=h.then?(await h)():h;let l,f,m=t=>t;class d extends s.WF{setConfig(t){if(!t)throw new Error("Invalid configuration");this._config=t}render(){if(!this._config||!this.hass)return s.s6;const t=this.hass.states[this._config.entity];return t?(0,s.qy)(f||(f=m` <hui-generic-entity-row .hass="${0}" .config="${0}"> <div class="text-content"> <ha-timer-remaining-time .hass="${0}" .stateObj="${0}"></ha-timer-remaining-time> </div> </hui-generic-entity-row> `),this.hass,this._config,this.hass,t):(0,s.qy)(l||(l=m` <hui-warning .hass="${0}"> ${0} </hui-warning> `),this.hass,(0,u.j)(this.hass,this._config.entity))}shouldUpdate(t){return(0,c.LX)(this,t)}}(0,a.Cg)([(0,r.MZ)({attribute:!1})],d.prototype,"hass",void 0),(0,a.Cg)([(0,r.wk)()],d.prototype,"_config",void 0),d=(0,a.Cg)([(0,r.EM)("hui-timer-entity-row")],d),n()}catch(l){n(l)}})},5078:function(t,e,i){i.r(e);var n=i(40445),a=i(5124),s=i(67576),r=i(49141);class c extends a.mN{createRenderRoot(){return this}update(t){var e;super.update(t),this.innerHTML=null!==(e=(0,r.PF)(this.hass,this.stateObj,this.timeRemaining))&&void 0!==e?e:"-"}connectedCallback(){super.connectedCallback(),this.stateObj&&this._startInterval(this.stateObj)}disconnectedCallback(){super.disconnectedCallback(),this._clearInterval()}willUpdate(t){super.willUpdate(t),t.has("stateObj")&&this._startInterval(this.stateObj)}_clearInterval(){this._updateRemaining&&(clearInterval(this._updateRemaining),this._updateRemaining=null)}_startInterval(t){this._clearInterval(),this._calculateRemaining(t),"active"===t.state&&(this._updateRemaining=setInterval(()=>this._calculateRemaining(this.stateObj),1e3))}_calculateRemaining(t){this.timeRemaining=(0,r.ls)(t)}}(0,n.Cg)([(0,s.MZ)({attribute:!1})],c.prototype,"hass",void 0),(0,n.Cg)([(0,s.MZ)({attribute:!1})],c.prototype,"stateObj",void 0),(0,n.Cg)([(0,s.wk)()],c.prototype,"timeRemaining",void 0),c=(0,n.Cg)([(0,s.EM)("ha-timer-remaining-time")],c)}}]);