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=66990;export const __rspack_esm_ids=[66990];export const __webpack_modules__={599(t,i,e){e.a(t,async function(t,i){try{var n=e(62826),a=e(5124),o=e(22441),s=e(65063),c=e(89300),r=e(1087),h=t([c]);c=(h.then?(await h)():h)[0];class l extends a.WF{render(){return a.qy` <ha-progress-button .progress="${this.progress}" .disabled="${this.disabled}" .appearance="${this.appearance}" @click="${this._buttonTapped}" tabindex="0"> <slot></slot></ha-progress-button> `}async _callService(){this.progress=!0;const t={domain:this.domain,service:this.service,data:this.data,target:this.target,success:!1},i=this.shadowRoot.querySelector("ha-progress-button");try{await this.hass.callService(this.domain,this.service,this.data,this.target),this.progress=!1,i.actionSuccess(),t.success=!0}catch(e){return this.progress=!1,i.actionError(),void(t.success=!1)}finally{(0,r.r)(this,"hass-service-called",t)}}_buttonTapped(){this.confirmation?(0,s.dk)(this,{text:this.confirmation,confirm:()=>this._callService()}):this._callService()}constructor(...t){super(...t),this.disabled=!1,this.progress=!1,this.data={},this.appearance="plain"}}(0,n.Cg)([(0,o.MZ)({attribute:!1})],l.prototype,"hass",void 0),(0,n.Cg)([(0,o.MZ)({type:Boolean})],l.prototype,"disabled",void 0),(0,n.Cg)([(0,o.MZ)({type:Boolean})],l.prototype,"progress",void 0),(0,n.Cg)([(0,o.MZ)()],l.prototype,"domain",void 0),(0,n.Cg)([(0,o.MZ)()],l.prototype,"service",void 0),(0,n.Cg)([(0,o.MZ)({type:Object})],l.prototype,"target",void 0),(0,n.Cg)([(0,o.MZ)({type:Object})],l.prototype,"data",void 0),(0,n.Cg)([(0,o.MZ)()],l.prototype,"confirmation",void 0),(0,n.Cg)([(0,o.MZ)()],l.prototype,"appearance",void 0),l=(0,n.Cg)([(0,o.EM)("ha-call-service-button")],l),i()}catch(t){i(t)}})},25618(t,i,e){e.a(t,async function(t,n){try{e.d(i,{M:()=>s});e(18111),e(7588);var a=e(84043),o=t([a]);function s(t){const i=(0,a.d)(t);return"HUI-CONDITIONAL-ELEMENT"!==i.tagName&&i.classList.add("element"),t.style&&Object.keys(t.style).forEach(e=>{i.style.setProperty(e,t.style[e])}),i}a=(o.then?(await o)():o)[0],n()}catch(c){n(c)}})},27722(t,i,e){e.d(i,{d:()=>o});var n=e(28978);function a(t,i,e,n){if(!e||!e.action||"none"===e.action)return"";let a=n?t.localize("ui.panel.lovelace.cards.picture-elements.hold"):t.localize("ui.panel.lovelace.cards.picture-elements.tap");switch(e.action){case"navigate":a+=` ${t.localize("ui.panel.lovelace.cards.picture-elements.navigate_to",{location:e.navigation_path})}`;break;case"url":a+=` ${t.localize("ui.panel.lovelace.cards.picture-elements.url",{url_path:e.url_path})}`;break;case"toggle":a+=` ${t.localize("ui.panel.lovelace.cards.picture-elements.toggle",{name:i})}`;break;case"call-service":a+=`${t.localize("ui.panel.lovelace.cards.picture-elements.perform_action",{name:e.service})}`;break;case"more-info":a+=`${t.localize("ui.panel.lovelace.cards.picture-elements.more_info",{name:i})}`}return a}const o=(t,i)=>{if(null===i.title)return"";if(i.title)return i.title;let e="";if(i.entity&&(e=i.entity in t.states?(0,n.u)(t.states[i.entity]):i.entity),!i.tap_action&&!i.hold_action)return e;const o=i.tap_action?a(t,e,i.tap_action,!1):"",s=i.hold_action?a(t,e,i.hold_action,!0):"";return o+(o&&s?"\n":"")+s}},98743(t,i,e){e.a(t,async function(t,i){try{e(44114),e(18111),e(7588);var n=e(62826),a=e(22441),o=e(25618),s=e(14487),c=t([o,s]);[o,s]=c.then?(await c)():c;class r extends HTMLElement{static async getConfigElement(){return await Promise.all([e.e(18377),e.e(74981)]).then(e.bind(e,98852)),document.createElement("hui-conditional-element-editor")}setConfig(t){if(!(t.conditions&&Array.isArray(t.conditions)&&t.elements&&Array.isArray(t.elements)&&(0,s.db)(t.conditions)))throw new Error("Invalid configuration");this._elements.length>0&&(this._elements.forEach(t=>{t.parentElement&&t.parentElement.removeChild(t)}),this._elements=[]),this._config=t,this._config.elements.forEach(t=>{this._elements.push((0,o.M)(t))}),this._updateElements()}set hass(t){this._hass=t,this._updateElements()}_updateElements(){if(!this._hass||!this._config)return;const t=(0,s.XH)(this._config.conditions,this._hass,{});this._elements.forEach(i=>{t?(i.hass=this._hass,i.parentElement||this.appendChild(i)):i.parentElement&&i.parentElement.removeChild(i)})}constructor(...t){super(...t),this._elements=[]}}r=(0,n.Cg)([(0,a.EM)("hui-conditional-element")],r),i()}catch(t){i(t)}})},16732(t,i,e){var n=e(62826),a=e(5124),o=e(22441),s=e(63672),c=(e(47680),e(27722)),r=e(19037),h=e(22064),l=e(97176);class d extends a.WF{static async getConfigElement(){return await e.e(28588).then(e.bind(e,59559)),document.createElement("hui-icon-element-editor")}static getStubConfig(){return{type:"icon",icon:"mdi:alert-circle"}}setConfig(t){if(!t.icon)throw Error("Icon required");this._config={tap_action:{action:"more-info"},hold_action:{action:"more-info"},...t}}render(){return this._config&&this.hass?a.qy` <ha-icon .icon="${this._config.icon}" .title="${(0,c.d)(this.hass,this._config)}" @action="${this._handleAction}" .actionHandler="${(0,r.T)({hasHold:(0,l.h)(this._config.hold_action),hasDoubleClick:(0,l.h)(this._config.double_tap_action)})}" tabindex="${(0,s.J)((0,l.h)(this._config.tap_action)?"0":void 0)}"></ha-icon> `:a.s6}_handleAction(t){(0,h.$)(this,this.hass,this._config,t.detail.action)}}d.styles=a.AH`:host{cursor:pointer}ha-icon:focus{outline:0;background:var(--divider-color);border-radius:var(--ha-border-radius-pill)}`,(0,n.Cg)([(0,o.wk)()],d.prototype,"_config",void 0),d=(0,n.Cg)([(0,o.EM)("hui-icon-element")],d)},9578(t,i,e){e.a(t,async function(t,i){try{e(18111),e(22489);var n=e(62826),a=e(5124),o=e(22441),s=e(63672),c=e(67013),r=e(27722),h=e(19037),l=e(22064),d=e(97176),g=e(57914),_=t([g]);g=(_.then?(await _)():_)[0];class u extends a.WF{static async getConfigElement(){return await e.e(29472).then(e.bind(e,63376)),document.createElement("hui-image-element-editor")}setConfig(t){if(!t)throw Error("Invalid configuration");this._config={tap_action:{action:"more-info"},hold_action:{action:"more-info"},...t},this.classList.toggle("clickable",this._config.tap_action&&"none"!==this._config.tap_action.action)}render(){if(!this._config||!this.hass)return a.s6;let t;this._config.image_entity&&(t=this.hass.states[this._config.image_entity]);const i=t?(0,c.e)(t):"object"==typeof this._config?.image&&this._config.image.media_content_id||this._config.image;return a.qy` <div @action="${this._handleAction}" .actionHandler="${(0,h.T)({hasHold:(0,d.h)(this._config.hold_action),hasDoubleClick:(0,d.h)(this._config.double_tap_action)})}" tabindex="${(0,s.J)((0,d.h)(this._config.tap_action)?"0":void 0)}" role="${(0,s.J)((0,d.h)(this._config.tap_action)?"button":void 0)}"> <hui-image .hass="${this.hass}" .entity="${this._config.entity}" .image="${i}" .stateImage="${this._config.state_image}" .cameraImage="${this._config.camera_image}" .cameraView="${this._config.camera_view}" .filter="${this._config.filter}" .stateFilter="${this._config.state_filter}" .title="${(0,r.d)(this.hass,this._config)}" .aspectRatio="${this._config.aspect_ratio}" .darkModeImage="${this._config.dark_mode_image}" .darkModeFilter="${this._config.dark_mode_filter}"></hui-image> </div> `}_handleAction(t){(0,l.$)(this,this.hass,this._config,t.detail.action)}}u.styles=a.AH`:host(.clickable){cursor:pointer;overflow:hidden;-webkit-touch-callout:none!important}hui-image{-webkit-user-select:none!important;pointer-events:none}div:focus{outline:0}div:focus hui-image{background:var(--divider-color);border-radius:var(--ha-border-radius-pill)}`,(0,n.Cg)([(0,o.MZ)({attribute:!1})],u.prototype,"hass",void 0),(0,n.Cg)([(0,o.wk)()],u.prototype,"_config",void 0),u=(0,n.Cg)([(0,o.EM)("hui-image-element")],u),i()}catch(t){i(t)}})},51007(t,i,e){e.a(t,async function(t,i){try{var n=e(62826),a=e(5124),o=e(22441),s=e(599),c=t([s]);s=(c.then?(await c)():c)[0];class r extends a.WF{static async getConfigElement(){return await e.e(21323).then(e.bind(e,42566)),document.createElement("hui-service-button-element-editor")}static getStubConfig(t){return{type:"action-button",action:"homeassistant.turn_on",title:t.localize("ui.card.common.turn_on")}}setConfig(t){if(!t||!t.action&&!t.service)throw Error("Action required");if([this._domain,this._service]=(t.action??t.service).split(".",2),!this._domain)throw Error("Action does not have a domain");if(!this._service)throw Error("Action does not have an action name");this._config=t}render(){if(!this._config||!this.hass)return a.s6;const{entity_id:t,label_id:i,floor_id:e,device_id:n,area_id:o}=this._config.service_data??this._config.data??{},s=this._config.target??{entity_id:t,label_id:i,floor_id:e,device_id:n,area_id:o};return a.qy` <ha-call-service-button .hass="${this.hass}" .domain="${this._domain}" .service="${this._service}" .data="${this._config.data??this._config.service_data}" .target="${s}"> ${this._config.title} </ha-call-service-button> `}}r.styles=a.AH`ha-call-service-button{color:var(--primary-color);white-space:nowrap}`,(0,n.Cg)([(0,o.wk)()],r.prototype,"_config",void 0),r=(0,n.Cg)([(0,o.EM)("hui-service-button-element")],r),i()}catch(t){i(t)}})},37696(t,i,e){e.a(t,async function(t,i){try{var n=e(62826),a=e(5124),o=e(22441),s=e(63672),c=e(28978),r=e(58234),h=e(22675),l=e(19037),d=e(13632),g=e(22064),_=e(97176),u=e(784),f=e(85979),p=(e(47046),t([r,f]));[r,f]=p.then?(await p)():p;class m extends a.WF{static async getConfigElement(){return await e.e(70610).then(e.bind(e,13129)),document.createElement("hui-state-badge-element-editor")}static getStubConfig(t,i,e){return{type:"state-badge",entity:(0,d.B)(t,1,i,e,["light","switch","sensor"],t=>t.state!==h.Hh&&t.state!==h.HV)[0]||""}}setConfig(t){if(!t.entity)throw Error("Entity required");this._config={tap_action:{action:"more-info"},hold_action:{action:"more-info"},...t}}shouldUpdate(t){return(0,u.LX)(this,t)}render(){if(!this._config||!this.hass)return a.s6;const t=this.hass.states[this._config.entity];return t?a.qy` <ha-state-label-badge .hass="${this.hass}" .state="${t}" .name="${void 0===this._config.name?(0,c.u)(t):null===this._config.name?"":this._config.name}" .title="${void 0===this._config.title?(0,c.u)(t):null===this._config.title?"":this._config.title}" show-name @action="${this._handleAction}" .actionHandler="${(0,l.T)({hasHold:(0,_.h)(this._config.hold_action),hasDoubleClick:(0,_.h)(this._config.double_tap_action)})}" tabindex="${(0,s.J)((0,_.h)(this._config.tap_action)?"0":void 0)}"></ha-state-label-badge> `:a.qy` <hui-warning-element .label="${(0,f.j)(this.hass,this._config.entity)}"></hui-warning-element> `}_handleAction(t){(0,g.$)(this,this.hass,this._config,t.detail.action)}}(0,n.Cg)([(0,o.MZ)({attribute:!1})],m.prototype,"hass",void 0),(0,n.Cg)([(0,o.wk)()],m.prototype,"_config",void 0),m=(0,n.Cg)([(0,o.EM)("hui-state-badge-element")],m),i()}catch(t){i(t)}})},10792(t,i,e){e.a(t,async function(t,i){try{var n=e(62826),a=e(5124),o=e(22441),s=e(63672),c=e(74281),r=e(22675),h=e(27722),l=e(19037),d=e(13632),g=e(22064),_=e(97176),u=e(784),f=e(85979),p=(e(47046),t([c,f]));[c,f]=p.then?(await p)():p;class m extends a.WF{static async getConfigElement(){return await e.e(12148).then(e.bind(e,91551)),document.createElement("hui-state-icon-element-editor")}static getStubConfig(t,i,e){return{type:"state-icon",entity:(0,d.B)(t,1,i,e,["light","switch","sensor"],t=>t.state!==r.Hh&&t.state!==r.HV)[0]||""}}setConfig(t){if(!t.entity)throw Error("Entity required");this._config={state_color:!0,tap_action:{action:"more-info"},hold_action:{action:"more-info"},...t}}shouldUpdate(t){return(0,u.LX)(this,t)}render(){if(!this._config||!this.hass)return a.s6;const t=this.hass.states[this._config.entity];return t?a.qy` <state-badge .hass="${this.hass}" .stateObj="${t}" .title="${(0,h.d)(this.hass,this._config)}" @action="${this._handleAction}" .actionHandler="${(0,l.T)({hasHold:(0,_.h)(this._config.hold_action),hasDoubleClick:(0,_.h)(this._config.double_tap_action)})}" tabindex="${(0,s.J)((0,_.h)(this._config.tap_action)?"0":void 0)}" .overrideIcon="${this._config.icon}" .stateColor="${this._config.state_color}"></state-badge> `:a.qy` <hui-warning-element .label="${(0,f.j)(this.hass,this._config.entity)}"></hui-warning-element> `}_handleAction(t){(0,g.$)(this,this.hass,this._config,t.detail.action)}}m.styles=a.AH`:host{cursor:pointer}state-badge:focus{outline:0;background:var(--divider-color);border-radius:var(--ha-border-radius-pill)}`,(0,n.Cg)([(0,o.MZ)({attribute:!1})],m.prototype,"hass",void 0),(0,n.Cg)([(0,o.wk)()],m.prototype,"_config",void 0),m=(0,n.Cg)([(0,o.EM)("hui-state-icon-element")],m),i()}catch(t){i(t)}})},14097(t,i,e){e.a(t,async function(t,i){try{var n=e(62826),a=e(5124),o=e(22441),s=e(63672),c=e(22675),r=e(27722),h=e(19037),l=e(13632),d=e(22064),g=e(97176),_=e(784),u=e(85979),f=(e(47046),t([u]));u=(f.then?(await f)():f)[0];class p extends a.WF{static async getConfigElement(){return await e.e(27431).then(e.bind(e,56474)),document.createElement("hui-state-label-element-editor")}static getStubConfig(t,i,e){return{type:"state-label",entity:(0,l.B)(t,1,i,e,["light","switch","sensor"],t=>t.state!==c.Hh&&t.state!==c.HV)[0]||""}}setConfig(t){if(!t.entity)throw Error("Entity required");this._config={tap_action:{action:"more-info"},hold_action:{action:"more-info"},...t}}shouldUpdate(t){return(0,_.LX)(this,t)}render(){if(!this._config||!this.hass)return a.s6;const t=this.hass.states[this._config.entity];return t?this._config.attribute&&!(this._config.attribute in t.attributes)?a.qy` <hui-warning-element label="${this.hass.localize("ui.panel.lovelace.warning.attribute_not_found",{attribute:this._config.attribute,entity:this._config.entity})}"></hui-warning-element> `:a.qy` <div .title="${(0,r.d)(this.hass,this._config)}" @action="${this._handleAction}" .actionHandler="${(0,h.T)({hasHold:(0,g.h)(this._config.hold_action),hasDoubleClick:(0,g.h)(this._config.double_tap_action)})}" tabindex="${(0,s.J)((0,g.h)(this._config.tap_action)?"0":void 0)}"> ${this._config.prefix}${this._config.attribute?t.attributes[this._config.attribute]:this.hass.formatEntityState(t)}${this._config.suffix} </div> `:a.qy` <hui-warning-element .label="${(0,u.j)(this.hass,this._config.entity)}"></hui-warning-element> `}_handleAction(t){(0,d.$)(this,this.hass,this._config,t.detail.action)}}p.styles=a.AH`:host{cursor:pointer}div{padding:8px;white-space:nowrap}div:focus{outline:0;background:var(--divider-color);border-radius:var(--ha-border-radius-pill)}`,(0,n.Cg)([(0,o.MZ)({attribute:!1})],p.prototype,"hass",void 0),(0,n.Cg)([(0,o.wk)()],p.prototype,"_config",void 0),p=(0,n.Cg)([(0,o.EM)("hui-state-label-element")],p),i()}catch(t){i(t)}})}};