UNPKG

iobroker.lovelace

Version:

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

1 lines 14.6 kB
export const __rspack_esm_id=95351;export const __rspack_esm_ids=[95351];export const __webpack_modules__={55134(t,e,i){i.a(t,async function(t,e){try{i(18111),i(22489);var s=i(62826),o=i(5124),a=i(22441),n=i(6412),r=i(89784),l=i(1087),h=(i(48374),i(22675)),c=i(88827),d=i(59241),v=i(92326),p=i(84337),u=i(65063),_=(i(64841),t([c]));c=(_.then?(await _)():_)[0];class b extends o.WF{updated(t){(t.has("entry")||t.has("stateObj"))&&this.entry&&this.stateObj&&(this._favoritePositions=(0,p.S)(this.entry.options?.valve?.favorite_positions??v.ph))}_localizeFavorite(t,e){return this.hass.localize(`ui.dialogs.more_info_control.valve.favorite_position.${t}`,e)}_currentValue(){const t=this.stateObj.attributes.current_position;return null==t?void 0:t}async _save(t){if(!this.entry)return;const e={...this.entry.options?.valve??{}};e.favorite_positions=this._favoritePositions;const i=await(0,d.G_)(this.hass,this.entry.entity_id,{options_domain:"valve",options:{...e,favorite_positions:t}});(0,l.r)(this,"entity-entry-updated",i.entity_entry)}async _setFavorites(t){const e=(0,p.S)(t);this._favoritePositions=e,await this._save(e)}_move(t,e){const i=this._favoritePositions.concat(),s=i.splice(t,1)[0];i.splice(e,0,s),this._setFavorites(i)}_applyFavorite(t){const e=this._favoritePositions[t];void 0!==e&&this.hass.callService("valve","set_valve_position",{entity_id:this.stateObj.entity_id,position:e})}async _promptFavoriteValue(t){const e=await(0,u.an)(this,{title:this._localizeFavorite(void 0===t?"add_title":"edit_title"),inputLabel:this.hass.localize("ui.card.valve.position"),inputType:"number",inputMin:"0",inputMax:"100",inputSuffix:c.rM.valve.current_position,defaultValue:void 0===t?void 0:String(t)});if(null===e||""===e.trim())return;const i=Number(e);return isNaN(i)?void 0:Math.max(0,Math.min(100,i))}async _addFavorite(){const t=await this._promptFavoriteValue();void 0!==t&&await this._setFavorites([...this._favoritePositions,t])}async _editFavorite(t){const e=this._favoritePositions[t];if(void 0===e)return;const i=await this._promptFavoriteValue(e);if(void 0===i)return;const s=[...this._favoritePositions];s[t]=i,await this._setFavorites(s)}async _deleteFavorite(t){await(0,u.dk)(this,{destructive:!0,title:this._localizeFavorite("delete_confirm_title"),text:this._localizeFavorite("delete_confirm_text"),confirmText:this._localizeFavorite("delete_confirm_action")})&&await this._setFavorites(this._favoritePositions.filter((e,i)=>i!==t))}_renderSection(){return this.editMode||0!==this._favoritePositions.length?o.qy` <section class="group"> <ha-more-info-favorites .items="${this._favoritePositions}" .renderItem="${this._renderFavorite}" .deleteLabel="${this._deleteLabel}" .editMode="${this.editMode??!1}" .disabled="${this.stateObj.state===h.Hh}" .isAdmin="${Boolean(this.hass.user?.is_admin)}" .showDone="${!0}" .addLabel="${this._localizeFavorite("add")}" .doneLabel="${this.hass.localize("ui.dialogs.more_info_control.exit_edit_mode")}" @favorite-item-action="${this._handleFavoriteAction}" @favorite-item-moved="${this._handleFavoriteMoved}" @favorite-item-delete="${this._handleFavoriteDelete}" @favorite-item-add="${this._handleFavoriteAdd}" @favorite-item-done="${this._handleFavoriteDone}"></ha-more-info-favorites> </section> `:o.s6}render(){return this.stateObj&&this.entry?o.qy` <div class="groups">${this._renderSection()}</div> `:o.s6}constructor(...t){super(...t),this._favoritePositions=[],this._renderFavorite=(t,e,i)=>{const s=t,a=this._currentValue()===s,l=this._localizeFavorite(i?"edit":"set",{value:`${s}%`});return o.qy` <ha-control-button class="${(0,n.H)({active:a})}" style="${(0,r.W)({"--control-button-border-radius":"var(--ha-border-radius-pill)",width:"72px",height:"36px"})}" .label="${l}" .disabled="${this.stateObj.state===h.Hh}"> ${s}% </ha-control-button> `},this._deleteLabel=t=>this._localizeFavorite("delete",{number:t+1}),this._handleFavoriteAction=t=>{t.stopPropagation();const{action:e,index:i}=t.detail;"hold"===e&&this.hass.user?.is_admin?(0,l.r)(this,"toggle-edit-mode",!0):this.editMode?this._editFavorite(i):this._applyFavorite(i)},this._handleFavoriteMoved=t=>{t.stopPropagation(),this._move(t.detail.oldIndex,t.detail.newIndex)},this._handleFavoriteDelete=t=>{t.stopPropagation(),this._deleteFavorite(t.detail.index)},this._handleFavoriteAdd=t=>{t.stopPropagation(),this._addFavorite()},this._handleFavoriteDone=t=>{t.stopPropagation(),(0,l.r)(this,"toggle-edit-mode",!1)}}}b.styles=o.AH`:host{display:block;width:100%}.groups{display:flex;flex-direction:column;align-items:center;gap:var(--ha-space-3)}.group{width:100%;max-width:384px;margin:0}.group ha-more-info-favorites{--favorite-items-max-width:384px;--favorite-item-active-background-color:var(--state-valve-active-color)}`,(0,s.Cg)([(0,a.MZ)({attribute:!1})],b.prototype,"hass",void 0),(0,s.Cg)([(0,a.MZ)({attribute:!1})],b.prototype,"stateObj",void 0),(0,s.Cg)([(0,a.MZ)({attribute:!1})],b.prototype,"entry",void 0),(0,s.Cg)([(0,a.MZ)({attribute:!1})],b.prototype,"editMode",void 0),(0,s.Cg)([(0,a.wk)()],b.prototype,"_favoritePositions",void 0),b=(0,s.Cg)([(0,a.EM)("ha-more-info-valve-favorite-positions")],b),e()}catch(t){e(t)}})},5610(t,e,i){i.a(t,async function(t,s){try{i.r(e);var o=i(62826),a=i(5124),n=i(22441),r=i(82286),l=(i(39826),i(62501)),h=i(59241),c=i(92326),d=i(41198),v=i(19440),p=i(51647),u=i(55134),_=i(6531),b=i(37863),y=t([l,d,v,p,u,_]);[l,d,v,p,u,_]=y.then?(await y)():y;const g="M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z",$="M9,3L5,7H8V14H10V7H13M16,17V10H14V17H11L15,21L19,17H16Z";class m extends a.WF{_setMode(t){this._mode=t.currentTarget.mode}willUpdate(t){if(super.willUpdate(t),t.has("stateObj")&&this.stateObj){const e=this.stateObj.entity_id,i=t.get("stateObj")?.entity_id;this._mode&&e===i||(this._mode=(0,c.sA)(this.stateObj)?"position":"button")}}get _stateOverride(){const t=this.hass.formatEntityState(this.stateObj),e=(0,c.Cp)(this.stateObj,this.hass);return e?`${t} · ${e}`:t}render(){if(!this.hass||!this.stateObj)return a.s6;const t=(0,c.sA)(this.stateObj),e=Boolean(this.entry&&(this.editMode||t&&(0,h.fs)(this.entry.options?.valve?.favorite_positions))),i=(0,r.$)(this.stateObj,c.qm.OPEN)||(0,r.$)(this.stateObj,c.qm.CLOSE)||(0,r.$)(this.stateObj,c.qm.STOP),s=(0,r.$)(this.stateObj,c.qm.OPEN)&&(0,r.$)(this.stateObj,c.qm.CLOSE)&&!(0,r.$)(this.stateObj,c.qm.STOP)&&!t;return a.qy` <ha-more-info-state-header .hass="${this.hass}" .stateObj="${this.stateObj}" .stateOverride="${this._stateOverride}"></ha-more-info-state-header> <div class="controls"> <div class="main-control"> ${"position"===this._mode?a.qy` ${t?a.qy` <ha-state-control-valve-position .stateObj="${this.stateObj}" .hass="${this.hass}"></ha-state-control-valve-position> `:a.s6} `:a.s6} ${"button"===this._mode?a.qy` ${s?a.qy` <ha-state-control-valve-toggle .stateObj="${this.stateObj}" .hass="${this.hass}"></ha-state-control-valve-toggle> `:i?a.qy` <ha-state-control-valve-buttons .stateObj="${this.stateObj}" .hass="${this.hass}"></ha-state-control-valve-buttons> `:a.s6} `:a.s6} </div> ${t&&i?a.qy` <ha-icon-button-group> <ha-icon-button-toggle .label="${this.hass.localize("ui.dialogs.more_info_control.valve.switch_mode.position")}" .selected="${"position"===this._mode}" .path="${g}" .mode="${"position"}" @click="${this._setMode}"></ha-icon-button-toggle> <ha-icon-button-toggle .label="${this.hass.localize("ui.dialogs.more_info_control.valve.switch_mode.button")}" .selected="${"button"===this._mode}" .path="${$}" .mode="${"button"}" @click="${this._setMode}"></ha-icon-button-toggle> </ha-icon-button-group> `:a.s6} </div> ${e?a.qy` <ha-more-info-valve-favorite-positions .hass="${this.hass}" .stateObj="${this.stateObj}" .entry="${this.entry}" .editMode="${this.editMode}"></ha-more-info-valve-favorite-positions> `:a.s6} `}static get styles(){return[b.K,a.AH`.main-control{display:flex;flex-direction:row;align-items:center}.main-control>*{margin:0 var(--ha-space-2)}`]}}(0,o.Cg)([(0,n.MZ)({attribute:!1})],m.prototype,"hass",void 0),(0,o.Cg)([(0,n.MZ)({attribute:!1})],m.prototype,"stateObj",void 0),(0,o.Cg)([(0,n.MZ)({attribute:!1})],m.prototype,"entry",void 0),(0,o.Cg)([(0,n.MZ)({attribute:!1})],m.prototype,"editMode",void 0),(0,o.Cg)([(0,n.wk)()],m.prototype,"_mode",void 0),m=(0,o.Cg)([(0,n.EM)("more-info-valve")],m),s()}catch(t){s(t)}})},41198(t,e,i){i.a(t,async function(t,e){try{i(44114);var s=i(62826),o=i(5124),a=i(22441),n=i(75751),r=i(22786),l=i(82286),h=(i(48374),i(28624),i(10223)),c=(i(67094),i(92326)),d=t([h]);h=(d.then?(await d)():d)[0];const v="M18,18H6V6H18V18Z",p="M22 2V22H20V13H14.82A3 3 0 0 1 9.18 13H4V22H2V2H4V11H9.18A3 3 0 0 1 14.82 11H20V2Z",u="M4 22H2V2H4M22 2H20V22H22M11 4V9.18A3 3 0 0 0 11 14.82V20H13V14.82A3 3 0 0 0 13 9.18V4Z",_=(0,r.A)(t=>{const e=(0,l.$)(t,c.qm.OPEN),i=(0,l.$)(t,c.qm.CLOSE),s=(0,l.$)(t,c.qm.STOP),o=[];return e&&o.push("open"),s&&o.push("stop"),i&&o.push("close"),o});class b extends o.WF{_onOpenTap(t){t.stopPropagation(),this.hass.callService("valve","open_valve",{entity_id:this.stateObj.entity_id})}_onCloseTap(t){t.stopPropagation(),this.hass.callService("valve","close_valve",{entity_id:this.stateObj.entity_id})}_onStopTap(t){t.stopPropagation(),this.hass.callService("valve","stop_valve",{entity_id:this.stateObj.entity_id})}renderButton(t){return"open"===t?o.qy` <ha-control-button .label="${this.hass.localize("ui.card.valve.open_valve")}" @click="${this._onOpenTap}" .disabled="${!(0,c.pc)(this.stateObj)}" data-button="open"> <ha-svg-icon .path="${u}"></ha-svg-icon> </ha-control-button> `:"close"===t?o.qy` <ha-control-button .label="${this.hass.localize("ui.card.valve.close_valve")}" @click="${this._onCloseTap}" .disabled="${!(0,c.hJ)(this.stateObj)}" data-button="close"> <ha-svg-icon .path="${p}"></ha-svg-icon> </ha-control-button> `:"stop"===t?o.qy` <ha-control-button .label="${this.hass.localize("ui.card.valve.stop_valve")}" @click="${this._onStopTap}" .disabled="${!(0,c.lg)(this.stateObj)}" data-button="stop"> <ha-svg-icon .path="${v}"></ha-svg-icon> </ha-control-button> `:o.s6}render(){const t=_(this.stateObj);return o.qy` <ha-control-button-group vertical> ${(0,n.u)(t,t=>t,t=>this.renderButton(t))} </ha-control-button-group> `}}b.styles=o.AH`ha-control-button-group{height:45vh;max-height:320px;min-height:200px;--control-button-group-spacing:10px;--control-button-group-thickness:100px}ha-control-button{--control-button-border-radius:var(--ha-border-radius-6xl);--mdc-icon-size:24px}`,(0,s.Cg)([(0,a.MZ)({attribute:!1})],b.prototype,"hass",void 0),(0,s.Cg)([(0,a.MZ)({attribute:!1})],b.prototype,"stateObj",void 0),b=(0,s.Cg)([(0,a.EM)("ha-state-control-valve-buttons")],b),e()}catch(t){e(t)}})},19440(t,e,i){i.a(t,async function(t,e){try{var s=i(62826),o=i(5124),a=i(22441),n=i(89784),r=i(53610),l=i(52658),h=i(10223),c=i(22675),d=i(88827),v=t([h,r,d]);[h,r,d]=v.then?(await v)():v;class p extends o.WF{updated(t){if(t.has("stateObj")){const t=this.stateObj?.attributes.current_position;this.value=null!=t?Math.round(t):void 0}}_valueChanged(t){const{value:e}=t.detail;"number"!=typeof e||isNaN(e)||this.hass.callService("valve","set_valve_position",{entity_id:this.stateObj.entity_id,position:e})}render(){const t=(0,l.Se)(this.stateObj);return o.qy` <ha-control-slider touch-action="none" vertical .value="${this.value}" min="0" max="100" show-handle @value-changed="${this._valueChanged}" .label="${(0,r.computeAttributeNameDisplay)(this.hass.localize,this.stateObj,this.hass.entities,"current_position")}" style="${(0,n.W)({"--control-slider-color":t,"--control-slider-background":t})}" .disabled="${this.stateObj.state===c.Hh}" .unit="${d.rM.valve.current_position}" .locale="${this.hass.locale}"> </ha-control-slider> `}}p.styles=o.AH`ha-control-slider{height:45vh;max-height:320px;min-height:200px;--control-slider-thickness:130px;--control-slider-border-radius:var(--ha-border-radius-6xl);--control-slider-color:var(--primary-color);--control-slider-background:var(--disabled-color);--control-slider-background-opacity:0.2;--control-slider-tooltip-font-size:var(--ha-font-size-xl)}`,(0,s.Cg)([(0,a.MZ)({attribute:!1})],p.prototype,"hass",void 0),(0,s.Cg)([(0,a.MZ)({attribute:!1})],p.prototype,"stateObj",void 0),(0,s.Cg)([(0,a.wk)()],p.prototype,"value",void 0),p=(0,s.Cg)([(0,a.EM)("ha-state-control-valve-position")],p),e()}catch(t){e(t)}})},51647(t,e,i){i.a(t,async function(t,e){try{var s=i(62826),o=i(5124),a=i(22441),n=i(6412),r=i(89784),l=i(52658),h=(i(48374),i(25094),i(93367)),c=i(22675),d=i(88360),v=i(59815),p=t([h]);h=(p.then?(await p)():p)[0];class u extends o.WF{_valueChanged(t){t.target.checked?this._turnOn():this._turnOff()}_turnOn(){this._callService(!0)}_turnOff(){this._callService(!1)}async _callService(t){this.hass&&this.stateObj&&((0,d.j)(this,"light"),await this.hass.callService("valve",t?"open_valve":"close_valve",{entity_id:this.stateObj.entity_id}))}render(){const t=(0,l.Se)(this.stateObj,"open"),e=(0,l.Se)(this.stateObj,"closed"),i="open"===this.stateObj.state||"closing"===this.stateObj.state||"opening"===this.stateObj.state,s="closed"===this.stateObj.state;return this.stateObj.attributes.assumed_state||this.stateObj.state===c.HV?o.qy` <div class="buttons"> <ha-control-button .label="${this.hass.localize("ui.card.valve.open_valve")}" @click="${this._turnOn}" .disabled="${this.stateObj.state===c.Hh}" class="${(0,n.H)({active:i})}" style="${(0,r.W)({"--color":t})}"> <ha-state-icon .stateObj="${this.stateObj}" stateValue="open"></ha-state-icon> </ha-control-button> <ha-control-button .label="${this.hass.localize("ui.card.valve.close_valve")}" @click="${this._turnOff}" .disabled="${this.stateObj.state===c.Hh}" class="${(0,n.H)({active:s})}" style="${(0,r.W)({"--color":e})}"> <ha-state-icon .stateObj="${this.stateObj}" stateValue="closed"></ha-state-icon> </ha-control-button> </div> `:o.qy` <ha-control-switch touch-action="none" vertical reversed .checked="${i}" @change="${this._valueChanged}" .label="${i?this.hass.localize("ui.card.valve.close_valve"):this.hass.localize("ui.card.valve.open_valve")}" style="${(0,r.W)({"--control-switch-on-color":t,"--control-switch-off-color":e})}" .disabled="${this.stateObj.state===c.Hh}"> <ha-state-icon slot="icon-on" .stateObj="${this.stateObj}" stateValue="open"></ha-state-icon> <ha-state-icon slot="icon-off" .stateObj="${this.stateObj}" stateValue="closed"></ha-state-icon> </ha-control-switch> `}}u.styles=[v.e],(0,s.Cg)([(0,a.MZ)({attribute:!1})],u.prototype,"hass",void 0),(0,s.Cg)([(0,a.MZ)({attribute:!1})],u.prototype,"stateObj",void 0),u=(0,s.Cg)([(0,a.EM)("ha-state-control-valve-toggle")],u),e()}catch(t){e(t)}})}};