iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
4 lines • 4.47 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[18344],{38043:function(o,t,e){e.a(o,async function(o,i){try{e.r(t);e(44114),e(18111),e(61701),e(3362),e(62953);var s=e(40445),a=e(5124),l=e(67576),r=e(6412),h=e(1087),c=e(18350),d=(e(93444),e(62501)),n=e(72554),_=e(57264),g=e(14503),p=e(43612),m=e(68737),u=o([c,d,n,p,m]);[c,d,n,p,m]=u.then?(await u)():u;let v,y,b,f,C,k,$=o=>o;class x extends a.WF{async showDialog(o){var t;this._entry=o.entry,this._dialogParams=o,this._color=null!==(t=o.initialColor)&&void 0!==t?t:this._computeCurrentColor(),this._updateModes(),this._open=!0}closeDialog(){this._open=!1}_updateModes(){const o=(0,_.ti)(this.stateObj,_.NC.COLOR_TEMP),t=[];(0,_.Aw)(this.stateObj)&&t.push("color"),o&&t.push("color_temp"),this._modes=t,this._color?this._mode="color_temp_kelvin"in this._color?"color_temp":"color":this._mode=this._modes[0]}_computeCurrentColor(){const o=this.stateObj.attributes,t=o.color_mode;let e;return t===_.NC.XY?o.hs_color?e={hs_color:o.hs_color}:o.rgb_color&&(e={rgb_color:o.rgb_color}):t===_.NC.COLOR_TEMP&&o.color_temp_kelvin?e={color_temp_kelvin:o.color_temp_kelvin}:o[t+"_color"]&&(e={[t+"_color"]:o[t+"_color"]}),e}_colorChanged(o){this._color=o.detail}get stateObj(){return this._entry&&this.hass.states[this._entry.entity_id]}_dialogClosed(){this._open=!1,this._dialogParams=void 0,this._entry=void 0,this._color=void 0,(0,h.r)(this,"dialog-closed",{dialog:this.localName})}async _save(){var o,t;this._color?(null===(o=this._dialogParams)||void 0===o||null===(t=o.submit)||void 0===t||t.call(o,this._color),this.closeDialog()):this.closeDialog()}_modeChanged(o){const t=o.currentTarget.mode;t!==this._mode&&(this._mode=t)}render(){var o;return this._entry&&this.stateObj?(0,a.qy)(v||(v=$` <ha-dialog .open="${0}" .headerTitle="${0}" ="${0}"> <div class="header"> ${0} </div> <div class="content"> ${0} ${0} </div> <ha-dialog-footer slot="footer"> <ha-button slot="secondaryAction" appearance="plain" ="${0}"> ${0} </ha-button> <ha-button slot="primaryAction" ="${0}" .disabled="${0}"> ${0} </ha-button> </ha-dialog-footer> </ha-dialog> `),this._open,null===(o=this._dialogParams)||void 0===o?void 0:o.title,this._dialogClosed,this._modes.length>1?(0,a.qy)(y||(y=$` <div class="modes"> ${0} </div> `),this._modes.map(o=>(0,a.qy)(b||(b=$` <ha-icon-button-toggle border-only .selected="${0}" .label="${0}" .mode="${0}" ="${0}"> <span class="wheel ${0}"></span> </ha-icon-button-toggle> `),o===this._mode,this.hass.localize(`ui.dialogs.more_info_control.light.color_picker.mode.${o}`),o,this._modeChanged,(0,r.H)({[o]:!0})))):a.s6,"color_temp"===this._mode?(0,a.qy)(f||(f=$` <light-color-temp-picker .hass="${0}" .stateObj="${0}" -changed="${0}"> </light-color-temp-picker> `),this.hass,this.stateObj,this._colorChanged):a.s6,"color"===this._mode?(0,a.qy)(C||(C=$` <light-color-rgb-picker .hass="${0}" .stateObj="${0}" -changed="${0}"> </light-color-rgb-picker> `),this.hass,this.stateObj,this._colorChanged):a.s6,this.closeDialog,this.hass.localize("ui.common.cancel"),this._save,!this._color,this.hass.localize("ui.common.save")):a.s6}static get styles(){return[g.nA,(0,a.AH)(k||(k=$`ha-dialog{--ha-dialog-width-md:420px;--ha-dialog-max-height:min(
600px,
100% - 48px
)} all and (max-width:450px),all and (max-height:500px){ha-dialog{--ha-dialog-width-md:100vw;--ha-dialog-max-height:calc(100% - 100px)}}.content{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:var(--ha-space-6);flex:1}.modes{display:flex;flex-direction:row;justify-content:flex-end;padding:0 var(--ha-space-6)}.wheel{width:30px;height:30px;flex:none;border-radius:var(--ha-border-radius-xl)}.wheel.color{background-image:url("/static/images/color_wheel.png");background-size:cover}.wheel.color_temp{background:linear-gradient(0,#a6d1ff 0%,#fff 50%,#ffa000 100%)}`))]}constructor(...o){super(...o),this._modes=[],this._open=!1}}(0,s.Cg)([(0,l.MZ)({attribute:!1})],x.prototype,"hass",void 0),(0,s.Cg)([(0,l.wk)()],x.prototype,"_dialogParams",void 0),(0,s.Cg)([(0,l.wk)()],x.prototype,"_entry",void 0),(0,s.Cg)([(0,l.wk)()],x.prototype,"_color",void 0),(0,s.Cg)([(0,l.wk)()],x.prototype,"_mode",void 0),(0,s.Cg)([(0,l.wk)()],x.prototype,"_modes",void 0),(0,s.Cg)([(0,l.wk)()],x.prototype,"_open",void 0),x=(0,s.Cg)([(0,l.EM)("dialog-light-color-favorite")],x),i()}catch(v){i(v)}})}}]);