iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 7.92 kB
JavaScript
export const __rspack_esm_id=97524;export const __rspack_esm_ids=[97524];export const __webpack_modules__={96986(t,e,i){i.d(e,{LR:()=>s,m9:()=>o});const a={10:"mdi:battery-10",20:"mdi:battery-20",30:"mdi:battery-30",40:"mdi:battery-40",50:"mdi:battery-50",60:"mdi:battery-60",70:"mdi:battery-70",80:"mdi:battery-80",90:"mdi:battery-90",100:"mdi:battery"},r={10:"M16,18H8V6H16M16.67,4H15V2H9V4H7.33A1.33,1.33 0 0,0 6,5.33V20.67C6,21.4 6.6,22 7.33,22H16.67A1.33,1.33 0 0,0 18,20.67V5.33C18,4.6 17.4,4 16.67,4Z",20:"M16,17H8V6H16M16.67,4H15V2H9V4H7.33A1.33,1.33 0 0,0 6,5.33V20.67C6,21.4 6.6,22 7.33,22H16.67A1.33,1.33 0 0,0 18,20.67V5.33C18,4.6 17.4,4 16.67,4Z",30:"M16,15H8V6H16M16.67,4H15V2H9V4H7.33A1.33,1.33 0 0,0 6,5.33V20.67C6,21.4 6.6,22 7.33,22H16.67A1.33,1.33 0 0,0 18,20.67V5.33C18,4.6 17.4,4 16.67,4Z",40:"M16,14H8V6H16M16.67,4H15V2H9V4H7.33A1.33,1.33 0 0,0 6,5.33V20.67C6,21.4 6.6,22 7.33,22H16.67A1.33,1.33 0 0,0 18,20.67V5.33C18,4.6 17.4,4 16.67,4Z",50:"M16,13H8V6H16M16.67,4H15V2H9V4H7.33A1.33,1.33 0 0,0 6,5.33V20.67C6,21.4 6.6,22 7.33,22H16.67A1.33,1.33 0 0,0 18,20.67V5.33C18,4.6 17.4,4 16.67,4Z",60:"M16,12H8V6H16M16.67,4H15V2H9V4H7.33A1.33,1.33 0 0,0 6,5.33V20.67C6,21.4 6.6,22 7.33,22H16.67A1.33,1.33 0 0,0 18,20.67V5.33C18,4.6 17.4,4 16.67,4Z",70:"M16,10H8V6H16M16.67,4H15V2H9V4H7.33A1.33,1.33 0 0,0 6,5.33V20.67C6,21.4 6.6,22 7.33,22H16.67A1.33,1.33 0 0,0 18,20.67V5.33C18,4.6 17.4,4 16.67,4Z",80:"M16,9H8V6H16M16.67,4H15V2H9V4H7.33A1.33,1.33 0 0,0 6,5.33V20.67C6,21.4 6.6,22 7.33,22H16.67A1.33,1.33 0 0,0 18,20.67V5.33C18,4.6 17.4,4 16.67,4Z",90:"M16,8H8V6H16M16.67,4H15V2H9V4H7.33A1.33,1.33 0 0,0 6,5.33V20.67C6,21.4 6.6,22 7.33,22H16.67A1.33,1.33 0 0,0 18,20.67V5.33C18,4.6 17.4,4 16.67,4Z",100:"M16.67,4H15V2H9V4H7.33A1.33,1.33 0 0,0 6,5.33V20.67C6,21.4 6.6,22 7.33,22H16.67A1.33,1.33 0 0,0 18,20.67V5.33C18,4.6 17.4,4 16.67,4Z"},n={10:"mdi:battery-charging-10",20:"mdi:battery-charging-20",30:"mdi:battery-charging-30",40:"mdi:battery-charging-40",50:"mdi:battery-charging-50",60:"mdi:battery-charging-60",70:"mdi:battery-charging-70",80:"mdi:battery-charging-80",90:"mdi:battery-charging-90",100:"mdi:battery-charging"},s=(t,e)=>{const i=Number(t);if(isNaN(i))return"off"===t?"mdi:battery":"on"===t?"mdi:battery-alert":"mdi:battery-unknown";const r=10*Math.round(i/10);return e&&i>=10?n[r]:e?"mdi:battery-charging-outline":i<=5?"mdi:battery-alert-variant-outline":a[r]},o=t=>{const e=Number(t);if(isNaN(e))return"M15.07,12.25L14.17,13.17C13.63,13.71 13.25,14.18 13.09,15H11.05C11.16,14.1 11.56,13.28 12.17,12.67L13.41,11.41C13.78,11.05 14,10.55 14,10C14,8.89 13.1,8 12,8A2,2 0 0,0 10,10H8A4,4 0 0,1 12,6A4,4 0 0,1 16,10C16,10.88 15.64,11.68 15.07,12.25M13,19H11V17H13M16.67,4H15V2H9V4H7.33A1.33,1.33 0 0,0 6,5.33V20.66C6,21.4 6.6,22 7.33,22H16.67C17.4,22 18,21.4 18,20.66V5.33C18,4.59 17.4,4 16.67,4Z";if(e<=5)return"M14 20H6V6H14M14.67 4H13V2H7V4H5.33C4.6 4 4 4.6 4 5.33V20.67C4 21.4 4.6 22 5.33 22H14.67C15.4 22 16 21.4 16 20.67V5.33C16 4.6 15.4 4 14.67 4M21 7H19V13H21V8M21 15H19V17H21V15Z";const i=10*Math.round(e/10);return r[i]}},89759(t,e,i){i.a(t,async function(t,a){try{i.r(e);i(18111),i(22489),i(61701);var r=i(62826),n=i(5124),s=i(22441),o=i(42372),h=i(1087),d=i(96986),c=(i(76776),i(67094),i(19037)),H=i(13632),g=i(784),u=i(85979),m=t([u]);u=(m.then?(await m)():m)[0];const V={moisture:"M12,3.25C12,3.25 6,10 6,14C6,17.32 8.69,20 12,20A6,6 0 0,0 18,14C18,10 12,3.25 12,3.25M14.47,9.97L15.53,11.03L9.53,17.03L8.47,15.97M9.75,10A1.25,1.25 0 0,1 11,11.25A1.25,1.25 0 0,1 9.75,12.5A1.25,1.25 0 0,1 8.5,11.25A1.25,1.25 0 0,1 9.75,10M14.25,14.5A1.25,1.25 0 0,1 15.5,15.75A1.25,1.25 0 0,1 14.25,17A1.25,1.25 0 0,1 13,15.75A1.25,1.25 0 0,1 14.25,14.5Z",temperature:"M15 13V5A3 3 0 0 0 9 5V13A5 5 0 1 0 15 13M12 4A1 1 0 0 1 13 5V8H11V5A1 1 0 0 1 12 4Z",brightness:"M3.55 19.09L4.96 20.5L6.76 18.71L5.34 17.29M12 6C8.69 6 6 8.69 6 12S8.69 18 12 18 18 15.31 18 12C18 8.68 15.31 6 12 6M20 13H23V11H20M17.24 18.71L19.04 20.5L20.45 19.09L18.66 17.29M20.45 5L19.04 3.6L17.24 5.39L18.66 6.81M13 1H11V4H13M6.76 5.39L4.96 3.6L3.55 5L5.34 6.81L6.76 5.39M1 13H4V11H1M13 20H11V23H13",conductivity:"M2,22V20C2,20 7,18 12,18C17,18 22,20 22,20V22H2M11.3,9.1C10.1,5.2 4,6.1 4,6.1C4,6.1 4.2,13.9 9.9,12.7C9.5,9.8 8,9 8,9C10.8,9 11,12.4 11,12.4V17C11.3,17 11.7,17 12,17C12.3,17 12.7,17 13,17V12.8C13,12.8 13,8.9 16,7.9C16,7.9 14,10.9 14,12.9C21,13.6 21,4 21,4C21,4 12.1,3 11.3,9.1Z",battery:void 0};class b extends n.WF{static async getConfigElement(){return await i.e(57607).then(i.bind(i,76730)),document.createElement("hui-plant-status-card-editor")}static getStubConfig(t,e,i){return{type:"plant-status",entity:(0,H.B)(t,1,e,i,["plant"])[0]||""}}getCardSize(){return 3}setConfig(t){if(!t.entity||"plant"!==t.entity.split(".")[0])throw new Error("Specify an entity from within the plant domain");this._config=t}shouldUpdate(t){return(0,g.LX)(this,t)}updated(t){if(super.updated(t),!this._config||!this.hass)return;const e=t.get("hass"),i=t.get("_config");e&&i&&e.themes===this.hass.themes&&i.theme===this._config.theme||(0,o.Q)(this,this.hass.themes,this._config.theme)}render(){if(!this.hass||!this._config)return n.s6;const t=this.hass.states[this._config.entity];return t?n.qy` <ha-card class="${t.attributes.entity_picture?"has-plant-image":""}"> <div class="banner" style="background-image:url(${t.attributes.entity_picture})"> <div class="header"> ${this.hass.formatEntityName(t,this._config.name)} </div> </div> <div class="content"> ${this._computeAttributes(t).map(e=>n.qy` <div class="attributes" ="${this._handleMoreInfo}" .actionHandler="${(0,c.T)()}" tabindex="0" .value="${e}"> <div class="icon"> ${"battery"===e?n.qy`<ha-icon .icon="${(0,d.LR)(t.attributes.battery)}"></ha-icon>`:n.qy`<ha-svg-icon .path="${V[e]}"></ha-svg-icon>`} </div> <div class="${-1===t.attributes.problem.indexOf(e)?"":"problem"}"> ${this._formatSensorValue(t,e)} </div> <div class="uom"> ${t.attributes.unit_of_measurement_dict[e]||""} </div> </div> `)} </div> </ha-card> `:n.qy` <hui-warning .hass="${this.hass}"> ${(0,u.j)(this.hass,this._config.entity)} </hui-warning> `}_formatSensorValue(t,e){const i=t.attributes.sensors?.[e],a=i?this.hass.states[i]:void 0;return a?this.hass.formatEntityStateToParts(a).filter(t=>"unit"!==t.type).map(t=>t.value).join(""):t.attributes[e]??""}_computeAttributes(t){return Object.keys(V).filter(e=>e in t.attributes)}_handleMoreInfo(t){const e=t.currentTarget,i=this.hass.states[this._config.entity];e.value&&(0,h.r)(this,"hass-more-info",{entityId:i.attributes.sensors[e.value]})}}b.styles=n.AH`ha-card{height:100%;box-sizing:border-box}.banner{display:flex;align-items:flex-end;background-repeat:no-repeat;background-size:cover;background-position:center;padding-top:12px}.has-plant-image .banner{padding-top:30%}.header{font-family:var(--ha-font-family-body);-webkit-font-smoothing:var(--ha-font-smoothing);-moz-osx-font-smoothing:var(--ha-moz-osx-font-smoothing);font-size:var(--ha-font-size-2xl);font-weight:var(--ha-font-weight-normal);line-height:var(--ha-line-height-normal);padding:8px 16px}.has-plant-image .header{font-size:var(--ha-font-size-l);font-weight:var(--ha-font-weight-medium);line-height:16px;padding:16px;color:#fff;width:100%;background:rgba(0,0,0,var(--dark-secondary-opacity))}.content{display:flex;justify-content:space-between;padding:16px 32px 24px 32px}.has-plant-image .content{padding-bottom:16px}.icon{margin-bottom:8px}ha-icon,ha-svg-icon{color:var(--state-icon-color)}.attributes{cursor:pointer}.attributes:focus{outline:0;background:var(--divider-color);border-radius:var(--ha-border-radius-pill)}.attributes div{text-align:center}.problem{color:var(--error-color);font-weight:var(--ha-font-weight-bold)}.uom{color:var(--secondary-text-color)}`,(0,r.Cg)([(0,s.MZ)({attribute:!1})],b.prototype,"hass",void 0),(0,r.Cg)([(0,s.wk)()],b.prototype,"_config",void 0),b=(0,r.Cg)([(0,s.EM)("hui-plant-status-card")],b),a()}catch(t){a(t)}})}};