iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 15.7 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[95351],{55134:function(t,e,i){i.a(t,async function(t,e){try{i(18111),i(22489),i(3362),i(42762),i(62953);var s=i(40445),o=i(5124),a=i(67576),n=i(6412),r=i(89784),l=i(1087),h=(i(48374),i(22675)),c=i(88827),d=i(59241),v=i(92326),u=i(84337),p=i(65063),b=(i(64841),t([c]));c=(b.then?(await b)():b)[0];let _,g,y,$,O=t=>t;class f extends o.WF{updated(t){var e,i;(t.has("entry")||t.has("stateObj"))&&this.entry&&this.stateObj&&(this._favoritePositions=(0,u.S)(null!==(e=null===(i=this.entry.options)||void 0===i||null===(i=i.valve)||void 0===i?void 0:i.favorite_positions)&&void 0!==e?e: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){var e,i;if(!this.entry)return;const s=Object.assign({},null!==(e=null===(i=this.entry.options)||void 0===i?void 0:i.valve)&&void 0!==e?e:{});s.favorite_positions=this._favoritePositions;const o=await(0,d.G_)(this.hass,this.entry.entity_id,{options_domain:"valve",options:Object.assign(Object.assign({},s),{},{favorite_positions:t})});(0,l.r)(this,"entity-entry-updated",o.entity_entry)}async _setFavorites(t){const e=(0,u.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,p.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,p.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(){var t,e;return this.editMode||0!==this._favoritePositions.length?(0,o.qy)(_||(_=O` <section class="group"> <ha-more-info-favorites .items="${0}" .renderItem="${0}" .deleteLabel="${0}" .editMode="${0}" .disabled="${0}" .isAdmin="${0}" .showDone="${0}" .addLabel="${0}" .doneLabel="${0}" -item-action="${0}" -item-moved="${0}" -item-delete="${0}" -item-add="${0}" -item-done="${0}"></ha-more-info-favorites> </section> `),this._favoritePositions,this._renderFavorite,this._deleteLabel,null!==(t=this.editMode)&&void 0!==t&&t,this.stateObj.state===h.Hh,Boolean(null===(e=this.hass.user)||void 0===e?void 0:e.is_admin),!0,this._localizeFavorite("add"),this.hass.localize("ui.dialogs.more_info_control.exit_edit_mode"),this._handleFavoriteAction,this._handleFavoriteMoved,this._handleFavoriteDelete,this._handleFavoriteAdd,this._handleFavoriteDone):o.s6}render(){return this.stateObj&&this.entry?(0,o.qy)(g||(g=O` <div class="groups">${0}</div> `),this._renderSection()):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(0,o.qy)(y||(y=O` <ha-control-button class="${0}" style="${0}" .label="${0}" .disabled="${0}"> ${0}% </ha-control-button> `),(0,n.H)({active:a}),(0,r.W)({"--control-button-border-radius":"var(--ha-border-radius-pill)",width:"72px",height:"36px"}),l,this.stateObj.state===h.Hh,s)},this._deleteLabel=t=>this._localizeFavorite("delete",{number:t+1}),this._handleFavoriteAction=t=>{var e;t.stopPropagation();const{action:i,index:s}=t.detail;"hold"===i&&null!==(e=this.hass.user)&&void 0!==e&&e.is_admin?(0,l.r)(this,"toggle-edit-mode",!0):this.editMode?this._editFavorite(s):this._applyFavorite(s)},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)}}}f.styles=(0,o.AH)($||($=O`: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})],f.prototype,"hass",void 0),(0,s.Cg)([(0,a.MZ)({attribute:!1})],f.prototype,"stateObj",void 0),(0,s.Cg)([(0,a.MZ)({attribute:!1})],f.prototype,"entry",void 0),(0,s.Cg)([(0,a.MZ)({attribute:!1})],f.prototype,"editMode",void 0),(0,s.Cg)([(0,a.wk)()],f.prototype,"_favoritePositions",void 0),f=(0,s.Cg)([(0,a.EM)("ha-more-info-valve-favorite-positions")],f),e()}catch(_){e(_)}})},5610:function(t,e,i){i.a(t,async function(t,s){try{i.r(e);var o=i(40445),a=i(5124),n=i(67576),r=i(82286),l=(i(39826),i(62501)),h=i(59241),c=i(92326),d=i(41198),v=i(19440),u=i(51647),p=i(55134),b=i(6531),_=i(37863),g=t([l,d,v,u,p,b]);[l,d,v,u,p,b]=g.then?(await g)():g;let y,$,O,f,m,j,M,F,x,H=t=>t;const w="M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z",V="M9,3L5,7H8V14H10V7H13M16,17V10H14V17H11L15,21L19,17H16Z";class C extends a.WF{_setMode(t){this._mode=t.currentTarget.mode}willUpdate(t){if(super.willUpdate(t),t.has("stateObj")&&this.stateObj){var e;const i=this.stateObj.entity_id,s=null===(e=t.get("stateObj"))||void 0===e?void 0:e.entity_id;this._mode&&i===s||(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(){var t;if(!this.hass||!this.stateObj)return a.s6;const e=(0,c.sA)(this.stateObj),i=Boolean(this.entry&&(this.editMode||e&&(0,h.fs)(null===(t=this.entry.options)||void 0===t||null===(t=t.valve)||void 0===t?void 0:t.favorite_positions))),s=(0,r.$)(this.stateObj,c.qm.OPEN)||(0,r.$)(this.stateObj,c.qm.CLOSE)||(0,r.$)(this.stateObj,c.qm.STOP),o=(0,r.$)(this.stateObj,c.qm.OPEN)&&(0,r.$)(this.stateObj,c.qm.CLOSE)&&!(0,r.$)(this.stateObj,c.qm.STOP)&&!e;return(0,a.qy)(y||(y=H` <ha-more-info-state-header .hass="${0}" .stateObj="${0}" .stateOverride="${0}"></ha-more-info-state-header> <div class="controls"> <div class="main-control"> ${0} ${0} </div> ${0} </div> ${0} `),this.hass,this.stateObj,this._stateOverride,"position"===this._mode?(0,a.qy)($||($=H` ${0} `),e?(0,a.qy)(O||(O=H` <ha-state-control-valve-position .stateObj="${0}" .hass="${0}"></ha-state-control-valve-position> `),this.stateObj,this.hass):a.s6):a.s6,"button"===this._mode?(0,a.qy)(f||(f=H` ${0} `),o?(0,a.qy)(m||(m=H` <ha-state-control-valve-toggle .stateObj="${0}" .hass="${0}"></ha-state-control-valve-toggle> `),this.stateObj,this.hass):s?(0,a.qy)(j||(j=H` <ha-state-control-valve-buttons .stateObj="${0}" .hass="${0}"></ha-state-control-valve-buttons> `),this.stateObj,this.hass):a.s6):a.s6,e&&s?(0,a.qy)(M||(M=H` <ha-icon-button-group> <ha-icon-button-toggle .label="${0}" .selected="${0}" .path="${0}" .mode="${0}" ="${0}"></ha-icon-button-toggle> <ha-icon-button-toggle .label="${0}" .selected="${0}" .path="${0}" .mode="${0}" ="${0}"></ha-icon-button-toggle> </ha-icon-button-group> `),this.hass.localize("ui.dialogs.more_info_control.valve.switch_mode.position"),"position"===this._mode,w,"position",this._setMode,this.hass.localize("ui.dialogs.more_info_control.valve.switch_mode.button"),"button"===this._mode,V,"button",this._setMode):a.s6,i?(0,a.qy)(F||(F=H` <ha-more-info-valve-favorite-positions .hass="${0}" .stateObj="${0}" .entry="${0}" .editMode="${0}"></ha-more-info-valve-favorite-positions> `),this.hass,this.stateObj,this.entry,this.editMode):a.s6)}static get styles(){return[_.K,(0,a.AH)(x||(x=H`.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})],C.prototype,"hass",void 0),(0,o.Cg)([(0,n.MZ)({attribute:!1})],C.prototype,"stateObj",void 0),(0,o.Cg)([(0,n.MZ)({attribute:!1})],C.prototype,"entry",void 0),(0,o.Cg)([(0,n.MZ)({attribute:!1})],C.prototype,"editMode",void 0),(0,o.Cg)([(0,n.wk)()],C.prototype,"_mode",void 0),C=(0,o.Cg)([(0,n.EM)("more-info-valve")],C),s()}catch(y){s(y)}})},41198:function(t,e,i){i.a(t,async function(t,e){try{i(44114);var s=i(40445),o=i(5124),a=i(67576),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];let v,u,p,b,_,g=t=>t;const y="M18,18H6V6H18V18Z",$="M22 2V22H20V13H14.82A3 3 0 0 1 9.18 13H4V22H2V2H4V11H9.18A3 3 0 0 1 14.82 11H20V2Z",O="M4 22H2V2H4M22 2H20V22H22M11 4V9.18A3 3 0 0 0 11 14.82V20H13V14.82A3 3 0 0 0 13 9.18V4Z",f=(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 m 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?(0,o.qy)(v||(v=g` <ha-control-button .label="${0}" ="${0}" .disabled="${0}" data-button="open"> <ha-svg-icon .path="${0}"></ha-svg-icon> </ha-control-button> `),this.hass.localize("ui.card.valve.open_valve"),this._onOpenTap,!(0,c.pc)(this.stateObj),O):"close"===t?(0,o.qy)(u||(u=g` <ha-control-button .label="${0}" ="${0}" .disabled="${0}" data-button="close"> <ha-svg-icon .path="${0}"></ha-svg-icon> </ha-control-button> `),this.hass.localize("ui.card.valve.close_valve"),this._onCloseTap,!(0,c.hJ)(this.stateObj),$):"stop"===t?(0,o.qy)(p||(p=g` <ha-control-button .label="${0}" ="${0}" .disabled="${0}" data-button="stop"> <ha-svg-icon .path="${0}"></ha-svg-icon> </ha-control-button> `),this.hass.localize("ui.card.valve.stop_valve"),this._onStopTap,!(0,c.lg)(this.stateObj),y):o.s6}render(){const t=f(this.stateObj);return(0,o.qy)(b||(b=g` <ha-control-button-group vertical> ${0} </ha-control-button-group> `),(0,n.u)(t,t=>t,t=>this.renderButton(t)))}}m.styles=(0,o.AH)(_||(_=g`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})],m.prototype,"hass",void 0),(0,s.Cg)([(0,a.MZ)({attribute:!1})],m.prototype,"stateObj",void 0),m=(0,s.Cg)([(0,a.EM)("ha-state-control-valve-buttons")],m),e()}catch(v){e(v)}})},19440:function(t,e,i){i.a(t,async function(t,e){try{var s=i(40445),o=i(5124),a=i(67576),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;let u,p,b=t=>t;class _ extends o.WF{updated(t){if(t.has("stateObj")){var e;const t=null===(e=this.stateObj)||void 0===e?void 0:e.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(0,o.qy)(u||(u=b` <ha-control-slider touch-action="none" vertical .value="${0}" min="0" max="100" show-handle -changed="${0}" .label="${0}" style="${0}" .disabled="${0}" .unit="${0}" .locale="${0}"> </ha-control-slider> `),this.value,this._valueChanged,(0,r.computeAttributeNameDisplay)(this.hass.localize,this.stateObj,this.hass.entities,"current_position"),(0,n.W)({"--control-slider-color":t,"--control-slider-background":t}),this.stateObj.state===c.Hh,d.rM.valve.current_position,this.hass.locale)}}_.styles=(0,o.AH)(p||(p=b`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})],_.prototype,"hass",void 0),(0,s.Cg)([(0,a.MZ)({attribute:!1})],_.prototype,"stateObj",void 0),(0,s.Cg)([(0,a.wk)()],_.prototype,"value",void 0),_=(0,s.Cg)([(0,a.EM)("ha-state-control-valve-position")],_),e()}catch(u){e(u)}})},51647:function(t,e,i){i.a(t,async function(t,e){try{i(3362);var s=i(40445),o=i(5124),a=i(67576),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),u=t([h]);h=(u.then?(await u)():u)[0];let p,b,_=t=>t;class g 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?(0,o.qy)(p||(p=_` <div class="buttons"> <ha-control-button .label="${0}" ="${0}" .disabled="${0}" class="${0}" style="${0}"> <ha-state-icon .stateObj="${0}" stateValue="open"></ha-state-icon> </ha-control-button> <ha-control-button .label="${0}" ="${0}" .disabled="${0}" class="${0}" style="${0}"> <ha-state-icon .stateObj="${0}" stateValue="closed"></ha-state-icon> </ha-control-button> </div> `),this.hass.localize("ui.card.valve.open_valve"),this._turnOn,this.stateObj.state===c.Hh,(0,n.H)({active:i}),(0,r.W)({"--color":t}),this.stateObj,this.hass.localize("ui.card.valve.close_valve"),this._turnOff,this.stateObj.state===c.Hh,(0,n.H)({active:s}),(0,r.W)({"--color":e}),this.stateObj):(0,o.qy)(b||(b=_` <ha-control-switch touch-action="none" vertical reversed .checked="${0}" ="${0}" .label="${0}" style="${0}" .disabled="${0}"> <ha-state-icon slot="icon-on" .stateObj="${0}" stateValue="open"></ha-state-icon> <ha-state-icon slot="icon-off" .stateObj="${0}" stateValue="closed"></ha-state-icon> </ha-control-switch> `),i,this._valueChanged,i?this.hass.localize("ui.card.valve.close_valve"):this.hass.localize("ui.card.valve.open_valve"),(0,r.W)({"--control-switch-on-color":t,"--control-switch-off-color":e}),this.stateObj.state===c.Hh,this.stateObj,this.stateObj)}}g.styles=[v.e],(0,s.Cg)([(0,a.MZ)({attribute:!1})],g.prototype,"hass",void 0),(0,s.Cg)([(0,a.MZ)({attribute:!1})],g.prototype,"stateObj",void 0),g=(0,s.Cg)([(0,a.EM)("ha-state-control-valve-toggle")],g),e()}catch(p){e(p)}})}}]);