iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
10 lines • 18.2 kB
JavaScript
export const __webpack_ids__=["90564"];export const __webpack_modules__={82062:function(e,t,i){i.a(e,(async function(e,t){try{var s=i(44249),a=i(72621),o=(i(9359),i(70104),i(57243)),n=i(15093),r=i(69634),l=i(50602),d=i(45061),c=i(76320),u=i(10916),h=e([l]);l=(h.then?(await h)():h)[0];const p=(e,t,i)=>180*(0,u.Ff)((0,u.Fv)(e,t,i),t,i)/100;(0,s.Z)([(0,n.Mo)("ha-gauge")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[(0,n.Cb)({type:Number})],key:"min",value:()=>0},{kind:"field",decorators:[(0,n.Cb)({type:Number})],key:"max",value:()=>100},{kind:"field",decorators:[(0,n.Cb)({type:Number})],key:"value",value:()=>0},{kind:"field",decorators:[(0,n.Cb)({attribute:!1})],key:"formatOptions",value:void 0},{kind:"field",decorators:[(0,n.Cb)({attribute:!1,type:String})],key:"valueText",value:void 0},{kind:"field",decorators:[(0,n.Cb)({attribute:!1})],key:"locale",value:void 0},{kind:"field",decorators:[(0,n.Cb)({type:Boolean})],key:"needle",value:()=>!1},{kind:"field",decorators:[(0,n.Cb)({type:Array})],key:"levels",value:void 0},{kind:"field",decorators:[(0,n.Cb)()],key:"label",value:()=>""},{kind:"field",decorators:[(0,n.SB)()],key:"_angle",value:()=>0},{kind:"field",decorators:[(0,n.SB)()],key:"_updated",value:()=>!1},{kind:"field",decorators:[(0,n.SB)()],key:"_segment_label",value:()=>""},{kind:"method",key:"firstUpdated",value:function(e){(0,a.Z)(i,"firstUpdated",this,3)([e]),(0,c.T)((()=>{this._updated=!0,this._angle=p(this.value,this.min,this.max),this._segment_label=this._getSegmentLabel(),this._rescaleSvg()}))}},{kind:"method",key:"updated",value:function(e){(0,a.Z)(i,"updated",this,3)([e]),this._updated&&(e.has("value")||e.has("valueText")||e.has("label")||e.has("_segment_label"))&&(this._angle=p(this.value,this.min,this.max),this._segment_label=this._getSegmentLabel(),this._rescaleSvg())}},{kind:"method",key:"render",value:function(){return o.YP` <svg viewBox="-50 -50 100 50" class="gauge"> ${this.needle&&this.levels?"":o.YP`<path class="dial" d="M -40 0 A 40 40 0 0 1 40 0"></path>`} ${this.levels?this.levels.sort(((e,t)=>e.level-t.level)).map(((e,t)=>{let i;if(0===t&&e.level!==this.min){const e=p(this.min,this.min,this.max);i=o.YP`<path stroke="var(--info-color)" class="level" d="M
${0-40*Math.cos(e*Math.PI/180)}
${0-40*Math.sin(e*Math.PI/180)}
A 40 40 0 0 1 40 0
"></path>`}const s=p(e.level,this.min,this.max);return o.YP`${i}<path stroke="${e.stroke}" class="level" d="M
${0-40*Math.cos(s*Math.PI/180)}
${0-40*Math.sin(s*Math.PI/180)}
A 40 40 0 0 1 40 0
"></path>`})):""} ${this.needle?o.YP`<path class="needle" d="M -25 -2.5 L -47.5 0 L -25 2.5 z" style="${(0,r.V)({transform:`rotate(${this._angle}deg)`})}"> </path>`:o.YP`<path class="value" d="M -40 0 A 40 40 0 1 0 40 0" style="${(0,r.V)({transform:`rotate(${this._angle}deg)`})}"></path>`} </svg> <svg class="text"> <text class="value-text"> ${this._segment_label?this._segment_label:this.valueText||(0,l.uf)(this.value,this.locale,this.formatOptions)}${this._segment_label?"":"%"===this.label?(0,d.K)(this.locale)+"%":` ${this.label}`} </text> </svg>`}},{kind:"method",key:"_rescaleSvg",value:function(){const e=this.shadowRoot.querySelector(".text"),t=e.querySelector("text").getBBox();e.setAttribute("viewBox",`${t.x} ${t.y} ${t.width} ${t.height}`)}},{kind:"method",key:"_getSegmentLabel",value:function(){if(this.levels){this.levels.sort(((e,t)=>e.level-t.level));for(let e=this.levels.length-1;e>=0;e--)if(this.value>=this.levels[e].level)return this.levels[e].label}return""}},{kind:"field",static:!0,key:"styles",value:()=>o.iv`:host{position:relative}.dial{fill:none;stroke:var(--primary-background-color);stroke-width:15}.value{fill:none;stroke-width:15;stroke:var(--gauge-color);transition:all 1s ease 0s}.needle{fill:var(--primary-text-color);transition:all 1s ease 0s}.level{fill:none;stroke-width:15}.gauge{display:block}.text{position:absolute;max-height:40%;max-width:55%;left:50%;bottom:-6%;transform:translate(-50%,0%)}.value-text{font-size:50px;fill:var(--primary-text-color);text-anchor:middle;direction:ltr}`}]}}),o.oi);t()}catch(e){t(e)}}))},56032:function(e,t,i){i.a(e,(async function(e,t){try{var s=i(44249),a=i(80519),o=i(1261),n=i(57243),r=i(15093),l=i(85605),d=e([a]);a=(d.then?(await d)():d)[0],(0,l.jx)("tooltip.show",{keyframes:[{opacity:0},{opacity:1}],options:{duration:150,easing:"ease"}}),(0,l.jx)("tooltip.hide",{keyframes:[{opacity:1},{opacity:0}],options:{duration:400,easing:"ease"}});(0,s.Z)([(0,r.Mo)("ha-tooltip")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",static:!0,key:"styles",value:()=>[o.Z,n.iv`:host{--sl-tooltip-background-color:var(--secondary-background-color);--sl-tooltip-color:var(--primary-text-color);--sl-tooltip-font-family:Roboto,sans-serif;--sl-tooltip-font-size:12px;--sl-tooltip-font-weight:normal;--sl-tooltip-line-height:1;--sl-tooltip-padding:8px;--sl-tooltip-border-radius:var(--ha-tooltip-border-radius, 4px);--sl-tooltip-arrow-size:var(--ha-tooltip-arrow-size, 8px);--sl-z-index-tooltip:var(--ha-tooltip-z-index, 1000)}`]}]}}),a.Z);t()}catch(e){t(e)}}))},17705:function(e,t,i){i.d(t,{Cj:()=>h,F7:()=>a,Hs:()=>w,Kd:()=>k,Kj:()=>v,Nw:()=>f,PA:()=>o,Py:()=>l,Qm:()=>S,Z0:()=>y,_Y:()=>c,_m:()=>n,dL:()=>d,dO:()=>x,hN:()=>p,h_:()=>u,j2:()=>b,q6:()=>g,uR:()=>r});i(9359),i(52924);var s=i(47194);let a=function(e){return e[e.NONE=0]="NONE",e[e.ARITHMETIC=1]="ARITHMETIC",e[e.CIRCULAR=2]="CIRCULAR",e}({});const o=99387==i.j?["entity_not_recorded","entity_no_longer_recorded","state_class_removed","units_changed","mean_type_changed","no_state"]:null,n=e=>e.sendMessagePromise({type:"recorder/info"}),r=(e,t)=>e.callWS({type:"recorder/list_statistic_ids",statistic_type:t}),l=(e,t)=>e.callWS({type:"recorder/get_statistics_metadata",statistic_ids:t}),d=(e,t,i,s,a="hour",o,n)=>e.callWS({type:"recorder/statistics_during_period",start_time:t.toISOString(),end_time:i?.toISOString(),statistic_ids:s,period:a,units:o,types:n}),c=(e,t,i,s)=>e.callWS({type:"recorder/statistic_during_period",statistic_id:t,units:s,fixed_period:i.fixed_period?{start_time:i.fixed_period.start instanceof Date?i.fixed_period.start.toISOString():i.fixed_period.start,end_time:i.fixed_period.end instanceof Date?i.fixed_period.end.toISOString():i.fixed_period.end}:void 0,calendar:i.calendar,rolling_window:i.rolling_window}),u=e=>e.callWS({type:"recorder/validate_statistics"}),h=(e,t,i)=>e.callWS({type:"recorder/update_statistics_metadata",statistic_id:t,unit_of_measurement:i}),p=(e,t)=>e.callWS({type:"recorder/clear_statistics",statistic_ids:t}),v=e=>{let t=null;if(!e)return null;for(const i of e)null!==i.change&&void 0!==i.change&&(null===t?t=i.change:t+=i.change);return t},g=(e,t)=>{let i=null;for(const s of t){if(!(s in e))continue;const t=v(e[s]);null!==t&&(null===i?i=t:i+=t)}return i},f=(e,t)=>e.some((e=>void 0!==e[t]&&null!==e[t])),m=["mean","min","max"],_=["sum","state","change"],y=(e,t)=>!(!m.includes(t)||e.mean_type===a.NONE)||!(!_.includes(t)||!e.has_sum),b=(e,t,i,s,a)=>{const o=new Date(i).toISOString();return e.callWS({type:"recorder/adjust_sum_statistics",statistic_id:t,start_time:o,adjustment:s,adjustment_unit_of_measurement:a})},k=(e,t,i)=>{const a=e.states[t];return a?(0,s.C)(a):i?.name||t},x=(e,t,i)=>{let s;return t&&(s=e.states[t]?.attributes.unit_of_measurement),void 0===s?i?.statistics_unit_of_measurement:s},w=e=>e.includes(":"),S=e=>e.callWS({type:"recorder/update_statistics_issues"})},6736:function(e,t,i){i.d(t,{f:()=>n});var s=i(44249),a=i(72621),o=(i(9359),i(52924),i(15093));const n=e=>(0,s.Z)(null,(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[(0,o.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",key:"hassSubscribeRequiredHostProps",value:void 0},{kind:"field",key:"__unsubs",value:void 0},{kind:"method",key:"connectedCallback",value:function(){(0,a.Z)(i,"connectedCallback",this,3)([]),this._checkSubscribed()}},{kind:"method",key:"disconnectedCallback",value:function(){if((0,a.Z)(i,"disconnectedCallback",this,3)([]),this.__unsubs){for(;this.__unsubs.length;){const e=this.__unsubs.pop();e instanceof Promise?e.then((e=>e())):e()}this.__unsubs=void 0}}},{kind:"method",key:"updated",value:function(e){if((0,a.Z)(i,"updated",this,3)([e]),e.has("hass"))this._checkSubscribed();else if(this.hassSubscribeRequiredHostProps)for(const t of e.keys())if(this.hassSubscribeRequiredHostProps.includes(t))return void this._checkSubscribed()}},{kind:"method",key:"hassSubscribe",value:function(){return[]}},{kind:"method",key:"_checkSubscribed",value:function(){void 0===this.__unsubs&&this.isConnected&&void 0!==this.hass&&!this.hassSubscribeRequiredHostProps?.some((e=>void 0===this[e]))&&(this.__unsubs=this.hassSubscribe())}}]}}),e)},4117:function(e,t,i){i.a(e,(async function(e,s){try{i.r(t);var a=i(44249),o=(i(9359),i(1331),i(70104),i(57243)),n=i(15093),r=i(50602),l=(i(54977),i(82062)),d=(i(37583),i(56032)),c=i(1118),u=i(17705),h=i(6736),p=i(93331),v=e([l,d,c,r]);[l,d,c,r]=v.then?(await v)():v;const g="M13,9H11V7H13M13,17H11V11H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z",f=[{level:-1,stroke:"var(--energy-grid-consumption-color)"},{level:0,stroke:"var(--energy-grid-return-color)"}];(0,a.Z)([(0,n.Mo)("hui-energy-grid-neutrality-gauge-card")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,n.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,n.SB)()],key:"_config",value:void 0},{kind:"field",decorators:[(0,n.SB)()],key:"_data",value:void 0},{kind:"field",key:"hassSubscribeRequiredHostProps",value:()=>["_config"]},{kind:"method",key:"hassSubscribe",value:function(){return[(0,c.UB)(this.hass,{key:this._config?.collection_key}).subscribe((e=>{this._data=e}))]}},{kind:"method",key:"getCardSize",value:function(){return 4}},{kind:"method",key:"setConfig",value:function(e){this._config=e}},{kind:"method",key:"shouldUpdate",value:function(e){return(0,p.SN)(this,e)||e.size>1||!e.has("hass")}},{kind:"method",key:"render",value:function(){if(!this._config||!this.hass)return o.Ld;if(!this._data)return o.dy`${this.hass.localize("ui.panel.lovelace.cards.energy.loading")}`;const e=this._data.prefs.energy_sources.find((e=>"grid"===e.type));let t;if(!e)return o.Ld;const i=(0,u.q6)(this._data.stats,e.flow_from.map((e=>e.stat_energy_from))),s=(0,u.q6)(this._data.stats,e.flow_to.map((e=>e.stat_energy_to)));return null!==i&&null!==s&&(t=s>i?1-i/s:s<i?-1*(1-s/i):0),o.dy` <ha-card> ${void 0!==t?o.dy` <ha-gauge min="-1" max="1" .value="${t}" .valueText="${(0,r.uf)(Math.abs(s-i),this.hass.locale,{maximumFractionDigits:2})}" .locale="${this.hass.locale}" .levels="${f}" label="kWh" needle></ha-gauge> <ha-tooltip placement="left" hoist> <span slot="content"> ${this.hass.localize("ui.panel.lovelace.cards.energy.grid_neutrality_gauge.energy_dependency")} <br><br> ${this.hass.localize("ui.panel.lovelace.cards.energy.grid_neutrality_gauge.color_explain")} </span> <ha-svg-icon .path="${g}"></ha-svg-icon> </ha-tooltip> <div class="name"> ${s>=i?this.hass.localize("ui.panel.lovelace.cards.energy.grid_neutrality_gauge.net_returned_grid"):this.hass.localize("ui.panel.lovelace.cards.energy.grid_neutrality_gauge.net_consumed_grid")} </div> `:this.hass.localize("ui.panel.lovelace.cards.energy.grid_neutrality_gauge.grid_neutrality_not_calculated")} </ha-card> `}},{kind:"field",static:!0,key:"styles",value:()=>o.iv`ha-card{height:100%;overflow:hidden;padding:16px;display:flex;align-items:center;justify-content:center;flex-direction:column;box-sizing:border-box}ha-gauge{width:100%;max-width:250px;direction:ltr}.name{text-align:center;line-height:initial;color:var(--primary-text-color);width:100%;font-size:15px;margin-top:8px}ha-svg-icon{position:absolute;right:4px;inset-inline-end:4px;inset-inline-start:initial;top:4px;color:var(--secondary-text-color)}ha-tooltip::part(base__popup){margin-top:4px}`}]}}),(0,h.f)(o.oi));s()}catch(e){s(e)}}))},10916:function(e,t,i){i.d(t,{Ff:()=>a,Fv:()=>s,IU:()=>o});const s=(e,t,i)=>isNaN(e)||isNaN(t)||isNaN(i)?0:e>i?i:e<t?t:e,a=(e,t,i)=>100*(e-t)/(i-t),o=e=>Math.round(10*e)/10},48734:function(e,t,i){i.a(e,(async function(e,s){try{i.d(t,{P5:()=>h,Ve:()=>v});var a=i(16485),o=(i(9359),i(70104),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),e([a]));a=(o.then?(await o)():o)[0];const n=new Set,r=new Map;let l,d="ltr",c="en";const u="undefined"!=typeof MutationObserver&&"undefined"!=typeof document&&void 0!==document.documentElement;if(u){const g=new MutationObserver(p);d=document.documentElement.dir||"ltr",c=document.documentElement.lang||navigator.language,g.observe(document.documentElement,{attributes:!0,attributeFilter:["dir","lang"]})}function h(...e){e.map((e=>{const t=e.$code.toLowerCase();r.has(t)?r.set(t,Object.assign(Object.assign({},r.get(t)),e)):r.set(t,e),l||(l=e)})),p()}function p(){u&&(d=document.documentElement.dir||"ltr",c=document.documentElement.lang||navigator.language),[...n.keys()].map((e=>{"function"==typeof e.requestUpdate&&e.requestUpdate()}))}class v{constructor(e){this.host=e,this.host.addController(this)}hostConnected(){n.add(this.host)}hostDisconnected(){n.delete(this.host)}dir(){return`${this.host.dir||d}`.toLowerCase()}lang(){return`${this.host.lang||c}`.toLowerCase()}getTranslationData(e){var t,i;const s=new Intl.Locale(e.replace(/_/g,"-")),a=null==s?void 0:s.language.toLowerCase(),o=null!==(i=null===(t=null==s?void 0:s.region)||void 0===t?void 0:t.toLowerCase())&&void 0!==i?i:"";return{locale:s,language:a,region:o,primary:r.get(`${a}-${o}`),secondary:r.get(a)}}exists(e,t){var i;const{primary:s,secondary:a}=this.getTranslationData(null!==(i=t.lang)&&void 0!==i?i:this.lang());return t=Object.assign({includeFallback:!1},t),!!(s&&s[e]||a&&a[e]||t.includeFallback&&l&&l[e])}term(e,...t){const{primary:i,secondary:s}=this.getTranslationData(this.lang());let a;if(i&&i[e])a=i[e];else if(s&&s[e])a=s[e];else{if(!l||!l[e])return console.error(`No translation found for: ${String(e)}`),String(e);a=l[e]}return"function"==typeof a?a(...t):a}date(e,t){return e=new Date(e),new Intl.DateTimeFormat(this.lang(),t).format(e)}number(e,t){return e=Number(e),isNaN(e)?"":new Intl.NumberFormat(this.lang(),t).format(e)}relativeTime(e,t,i){return new Intl.RelativeTimeFormat(this.lang(),i).format(e,t)}}s()}catch(f){s(f)}}))},31027:function(e,t,i){i.d(t,{P:()=>r});i(9359),i(31526);var s,a=i(52812),o=i(57243),n=i(15093),r=class extends o.oi{constructor(){super(),(0,a.Ko)(this,s,!1),this.initialReflectedProperties=new Map,Object.entries(this.constructor.dependencies).forEach((([e,t])=>{this.constructor.define(e,t)}))}emit(e,t){const i=new CustomEvent(e,(0,a.ih)({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));return this.dispatchEvent(i),i}static define(e,t=this,i={}){const s=customElements.get(e);if(!s){try{customElements.define(e,t,i)}catch(s){customElements.define(e,class extends t{},i)}return}let a=" (unknown version)",o=a;"version"in t&&t.version&&(a=" v"+t.version),"version"in s&&s.version&&(o=" v"+s.version),a&&o&&a===o||console.warn(`Attempted to register <${e}>${a}, but <${e}>${o} has already been registered.`)}attributeChangedCallback(e,t,i){(0,a.ac)(this,s)||(this.constructor.elementProperties.forEach(((e,t)=>{e.reflect&&null!=this[t]&&this.initialReflectedProperties.set(t,this[t])})),(0,a.qx)(this,s,!0)),super.attributeChangedCallback(e,t,i)}willUpdate(e){super.willUpdate(e),this.initialReflectedProperties.forEach(((t,i)=>{e.has(i)&&null==this[i]&&(this[i]=t)}))}};s=new WeakMap,r.version="2.20.1",r.dependencies={},(0,a.u2)([(0,n.Cb)()],r.prototype,"dir",2),(0,a.u2)([(0,n.Cb)()],r.prototype,"lang",2)},15073:function(e,t,i){i.a(e,(async function(e,s){try{i.d(t,{V:()=>r});var a=i(21262),o=i(48734),n=e([o,a]);[o,a]=n.then?(await n)():n;var r=class extends o.Ve{};(0,o.P5)(a.K),s()}catch(e){s(e)}}))},21262:function(e,t,i){i.a(e,(async function(e,s){try{i.d(t,{K:()=>r});var a=i(48734),o=e([a]);a=(o.then?(await o)():o)[0];var n={$code:"en",$name:"English",$dir:"ltr",carousel:"Carousel",clearEntry:"Clear entry",close:"Close",copied:"Copied",copy:"Copy",currentValue:"Current value",error:"Error",goToSlide:(e,t)=>`Go to slide ${e} of ${t}`,hidePassword:"Hide password",loading:"Loading",nextSlide:"Next slide",numOptionsSelected:e=>0===e?"No options selected":1===e?"1 option selected":`${e} options selected`,previousSlide:"Previous slide",progress:"Progress",remove:"Remove",resize:"Resize",scrollToEnd:"Scroll to end",scrollToStart:"Scroll to start",selectAColorFromTheScreen:"Select a color from the screen",showPassword:"Show password",slideNum:e=>`Slide ${e}`,toggleColorFormat:"Toggle color format"};(0,a.P5)(n);var r=n;s()}catch(e){s(e)}}))},52812:function(e,t,i){i.d(t,{EZ:()=>p,Ko:()=>m,ac:()=>f,ih:()=>h,qx:()=>_,u2:()=>v});var s=Object.defineProperty,a=Object.defineProperties,o=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyDescriptors,r=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,c=e=>{throw TypeError(e)},u=(e,t,i)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,h=(e,t)=>{for(var i in t||(t={}))l.call(t,i)&&u(e,i,t[i]);if(r)for(var i of r(t))d.call(t,i)&&u(e,i,t[i]);return e},p=(e,t)=>a(e,n(t)),v=(e,t,i,a)=>{for(var n,r=a>1?void 0:a?o(t,i):t,l=e.length-1;l>=0;l--)(n=e[l])&&(r=(a?n(t,i,r):n(r))||r);return a&&r&&s(t,i,r),r},g=(e,t,i)=>t.has(e)||c("Cannot "+i),f=(e,t,i)=>(g(e,t,"read from private field"),i?i.call(e):t.get(e)),m=(e,t,i)=>t.has(e)?c("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),_=(e,t,i,s)=>(g(e,t,"write to private field"),s?s.call(e,i):t.set(e,i),i)},81048:function(e,t,i){i.d(t,{N:()=>s});var s=i(57243).iv`:host{box-sizing:border-box}:host *,:host ::after,:host ::before{box-sizing:inherit}[hidden]{display:none!important}`}};
//# sourceMappingURL=90564.712f46ae855c3ed8.js.map