From fc72213f7dfd9fa294a77e5162e202e3ca5c220f Mon Sep 17 00:00:00 2001 From: Stephen M Moraco Date: Wed, 8 Feb 2023 02:52:58 -0700 Subject: [PATCH] repair code error --- dist/rpi-monitor-card.js | 4 ++-- src/rpi-monitor-card.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dist/rpi-monitor-card.js b/dist/rpi-monitor-card.js index d04b182..796709f 100644 --- a/dist/rpi-monitor-card.js +++ b/dist/rpi-monitor-card.js @@ -28,7 +28,7 @@ function t(t,e,i,o){var s,n=arguments.length,r=n<3?e:null===o?o=Object.getOwnPro * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ -var g;f.finalized=!0,f.elementProperties=new Map,f.elementStyles=[],f.shadowRootOptions={mode:"open"},null==u||u({ReactiveElement:f}),(null!==(l=c.reactiveElementVersions)&&void 0!==l?l:c.reactiveElementVersions=[]).push("1.6.1");const v=window,y=v.trustedTypes,b=y?y.createPolicy("lit-html",{createHTML:t=>t}):void 0,$=`lit$${(Math.random()+"").slice(9)}$`,w="?"+$,C=`<${w}>`,A=document,S=(t="")=>A.createComment(t),x=t=>null===t||"object"!=typeof t&&"function"!=typeof t,I=Array.isArray,E=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,T=/-->/g,k=/>/g,D=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),U=/'/g,R=/"/g,M=/^(?:script|style|textarea|title)$/i,P=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),F=Symbol.for("lit-noChange"),O=Symbol.for("lit-nothing"),N=new WeakMap,V=A.createTreeWalker(A,129,null,!1);class H{constructor({strings:t,_$litType$:e},i){let o;this.parts=[];let s=0,n=0;const r=t.length-1,a=this.parts,[l,c]=((t,e)=>{const i=t.length-1,o=[];let s,n=2===e?"":"",r=E;for(let e=0;e"===l[0]?(r=null!=s?s:E,c=-1):void 0===l[1]?c=-2:(c=r.lastIndex-l[2].length,a=l[1],r=void 0===l[3]?D:'"'===l[3]?R:U):r===R||r===U?r=D:r===T||r===k?r=E:(r=D,s=void 0);const d=r===D&&t[e+1].startsWith("/>")?" ":"";n+=r===E?i+C:c>=0?(o.push(a),i.slice(0,c)+"$lit$"+i.slice(c)+$+d):i+$+(-2===c?(o.push(void 0),e):d)}const a=n+(t[i]||"")+(2===e?"":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==b?b.createHTML(a):a,o]})(t,e);if(this.el=H.createElement(l,i),V.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(o=V.nextNode())&&a.length0){o.textContent=y?y.emptyScript:"";for(let i=0;iI(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.k(t):this.g(t)}O(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}g(t){this._$AH!==O&&x(this._$AH)?this._$AA.nextSibling.data=t:this.T(A.createTextNode(t)),this._$AH=t}$(t){var e;const{values:i,_$litType$:o}=t,s="number"==typeof o?this._$AC(t):(void 0===o.el&&(o.el=H.createElement(o.h,this.options)),o);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===s)this._$AH.p(i);else{const t=new z(s,this),e=t.v(this.options);t.p(i),this.T(e),this._$AH=t}}_$AC(t){let e=N.get(t.strings);return void 0===e&&N.set(t.strings,e=new H(t)),e}k(t){I(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,o=0;for(const s of t)o===e.length?e.push(i=new j(this.O(S()),this.O(S()),this,this.options)):i=e[o],i._$AI(s),o++;o2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=O}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,o){const s=this.strings;let n=!1;if(void 0===s)t=L(this,t,e,0),n=!x(t)||t!==this._$AH&&t!==F,n&&(this._$AH=t);else{const o=t;let r,a;for(t=s[0],r=0;rt}):void 0,$=`lit$${(Math.random()+"").slice(9)}$`,w="?"+$,C=`<${w}>`,A=document,S=(t="")=>A.createComment(t),x=t=>null===t||"object"!=typeof t&&"function"!=typeof t,I=Array.isArray,E=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,T=/-->/g,k=/>/g,D=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),U=/'/g,R=/"/g,M=/^(?:script|style|textarea|title)$/i,P=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),F=Symbol.for("lit-noChange"),O=Symbol.for("lit-nothing"),N=new WeakMap,V=A.createTreeWalker(A,129,null,!1);class H{constructor({strings:t,_$litType$:e},i){let o;this.parts=[];let s=0,n=0;const r=t.length-1,a=this.parts,[l,c]=((t,e)=>{const i=t.length-1,o=[];let s,n=2===e?"":"",r=E;for(let e=0;e"===l[0]?(r=null!=s?s:E,c=-1):void 0===l[1]?c=-2:(c=r.lastIndex-l[2].length,a=l[1],r=void 0===l[3]?D:'"'===l[3]?R:U):r===R||r===U?r=D:r===T||r===k?r=E:(r=D,s=void 0);const d=r===D&&t[e+1].startsWith("/>")?" ":"";n+=r===E?i+C:c>=0?(o.push(a),i.slice(0,c)+"$lit$"+i.slice(c)+$+d):i+$+(-2===c?(o.push(void 0),e):d)}const a=n+(t[i]||"")+(2===e?"":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==b?b.createHTML(a):a,o]})(t,e);if(this.el=H.createElement(l,i),V.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(o=V.nextNode())&&a.length0){o.textContent=y?y.emptyScript:"";for(let i=0;iI(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.k(t):this.g(t)}O(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}g(t){this._$AH!==O&&x(this._$AH)?this._$AA.nextSibling.data=t:this.T(A.createTextNode(t)),this._$AH=t}$(t){var e;const{values:i,_$litType$:o}=t,s="number"==typeof o?this._$AC(t):(void 0===o.el&&(o.el=H.createElement(o.h,this.options)),o);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===s)this._$AH.p(i);else{const t=new z(s,this),e=t.v(this.options);t.p(i),this.T(e),this._$AH=t}}_$AC(t){let e=N.get(t.strings);return void 0===e&&N.set(t.strings,e=new H(t)),e}k(t){I(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,o=0;for(const s of t)o===e.length?e.push(i=new j(this.O(S()),this.O(S()),this,this.options)):i=e[o],i._$AI(s),o++;o2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=O}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,o){const s=this.strings;let n=!1;if(void 0===s)t=L(this,t,e,0),n=!x(t)||t!==this._$AH&&t!==F,n&&(this._$AH=t);else{const o=t;let r,a;for(t=s[0],r=0;re=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e)
${a}
- `:void console.log("ERROR: failed to generate glance rows!")}}prettyDate(t){const e=new Date((t||"").replace(/-/g,"/").replace(/[TZ]/g," ")),i=((new Date).getTime()-e.getTime())/1e3,o=Math.floor(i/86400),s=e.getFullYear(),n=e.getMonth()+1,r=e.getDate();if(isNaN(o)||o<0||o>=31)return s.toString()+"-"+(n<10?"0"+n.toString():n.toString())+"-"+(r<10?"0"+r.toString():r.toString());let a="{unknown}";return 0==o?i<60?a="just now":i<120?a="1 minute ago":i<3600?a=Math.floor(i/60)+" minutes ago":i<7200?a="1 hour ago":i<86400&&(a=Math.floor(i/3600)+" hours ago"):1==o?a="Yesterday":o<7?a=o+" days ago":o<31&&(a=Math.ceil(o/7)+" weeks ago"),a}updated(t){if(this._showDebug()&&console.log("- updated("+this._hostname+")"),!this._config)return;if(this.hass){const e=t.get("hass");(!e||e&&e.themes!==this.hass.themes)&&function(t,e,i,o){void 0===o&&(o=!1),t._themes||(t._themes={});var s=e.default_theme;("default"===i||i&&e.themes[i])&&(s=i);var n=_t({},t._themes);if("default"!==s){var r=e.themes[s];Object.keys(r).forEach((function(e){var i="--"+e;t._themes[i]="",n[i]=r[e]}))}if(t.updateStyles?t.updateStyles(n):window.ShadyCSS&&window.ShadyCSS.styleSubtree(t,n),o){var a=document.querySelector("meta[name=theme-color]");if(a){a.hasAttribute("default-content")||a.setAttribute("default-content",a.getAttribute("content"));var l=n["--primary-color"]||a.getAttribute("default-content");a.setAttribute("content",l)}}}(this,this.hass.themes,this._config.theme)}this.hass.states[this._config.entity]||this._stopCardRefreshTimer();const e=this.shadowRoot;if(this._sensorAvailable){const t=this._getAttributeValueForKey(Mt),i=this._computeOsReleaseColor(t);if(""!=i){e.getElementById("os-name").style.setProperty("color",i)}const o=this._computeDaemonUpdateVersionColor(this.currentDaemonVersion);if(""!=o){e.getElementById("daemon-update").style.setProperty("color",o)}const s=this._computeReporterAgeColor(this._cardSecondsSinceUpdate);if(""!=s&&null!=s){e.getElementById("card-timestamp").style.setProperty("color",s)}if(this._useFullCard())for(const t in this._cardFullCssIDs){const i=this._cardFullCssIDs[t],o=this._cardFullElements[t],s=this._getAttributeValueForKey(o),n=this._getFullCardValueForAttributeKey(o),r=e.getElementById(i);r.textContent=n;const a=this._cardFullIconCssIDs[t],l=e.getElementById(a);if(o==Nt){const t=this._computeFileSystemUsageColor(s);""!=t&&(r.style.setProperty("color",t),l.style.setProperty("color",t))}if(o==Lt){const t=this._computeMemoryUsageColor(n.replace(" %",""));""!=t&&(r.style.setProperty("color",t),l.style.setProperty("color",t))}if(o==Vt){const t=this._computeTemperatureColor(s);""!=t&&(r.style.setProperty("color",t),l.style.setProperty("color",t))}}else for(const t in this._cardGlanceCssIDs){const i=this._cardGlanceCssIDs[t],o=this._cardGlanceElements[t],s=this._getAttributeValueForKey(o),n=this._getGlanceCardValueForAttributeKey(o),r=e.getElementById(i);r.textContent=n;const a=this._cardGlanceIconCssIDs[t],l=e.getElementById(a);if(o==Nt){const t=this._computeFileSystemUsageColor(s);""!=t&&(r.style.setProperty("color",t),l.style.setProperty("color",t))}if(o==Lt){const t=this._computeMemoryUsageColor(n);""!=t&&(r.style.setProperty("color",t),l.style.setProperty("color",t))}if(o==Vt&&"n/a"!=n){const t=this._computeTemperatureColor(s);""!=t&&(r.style.setProperty("color",t),l.style.setProperty("color",t));e.getElementById(this.kClassIdTempScale).textContent=this._getTemperatureScale()}}}}_handleAction(t){this.hass&&this._config&&t.detail.action&&function(t,e,i,o){var s;"double_tap"===o&&i.double_tap_action?s=i.double_tap_action:"hold"===o&&i.hold_action?s=i.hold_action:"tap"===o&&i.tap_action&&(s=i.tap_action),At(t,e,i,s)}(this,this.hass,this._config,t.detail.action)}showWarning(t){return P` ${t} `}showError(t){const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t,origConfig:this._config}),P` ${e} `}_startCardRefreshTimer(){this._updateTimerID=setInterval((()=>this._handleCardUpdateTimerExpiration()),1e3),console.log("TIMER: ("+this._hostname+") started")}_stopCardRefreshTimer(){null!=this._updateTimerID&&(clearInterval(this._updateTimerID),this._updateTimerID=void 0,console.log("TIMER: ("+this._hostname+") STOPPED"))}_handleCardUpdateTimerExpiration(){const[t,e]=this._getRelativeTimeSinceUpdate();if(this._cardSecondsSinceUpdate!=e&&(this._cardSecondsSinceUpdate=e),t){let e=t;t.includes("NaN")&&(console.log(" HCUTE (DBG) ("+this._hostname+") card_timestamp_value=["+t+"]"),e="{unexpected value}..."),this._cardUpdateString!=e&&(this._cardUpdateString=e)}}_useFullCard(){let t=!0;return this._config&&null!=this._config.card_style&&(t="full"==this._config.card_style.toLocaleLowerCase()),t}_useTempsInC(){let t=!0;return this._config&&null!=this._config.temp_scale&&(t="c"==this._config.temp_scale.toLocaleLowerCase()),t}_logChangeMessage(t){""==this._hostname&&(this._hostname=this._getAttributeValueForKey("host_name"));const e="("+this._hostname+"): "+t;this._showDebug()&&console.log(e)}_updateSensorAvailability(){let t=!1;if(this.hass&&this._config){const e=this._config.entity?this._config.entity:void 0,i=this._config.entity?this.hass.states[this._config.entity]:void 0;if(e||i)try{const e="unavailable"!=this.hass.states[this._config.entity].state;t=this._sensorAvailable!=e,this._sensorAvailable=e}catch(e){this._sensorAvailable=!1,t=!0}else this._sensorAvailable=!1,t=!0}else this._sensorAvailable=!1,t=!0;t&&this._logChangeMessage("* SENSOR available: "+this._sensorAvailable)}_loadDaemonReleaseInfo(t){let e=[];if(t){const i=t.split("\n");for(let t=0;t0){const t=o.split(" ");t.length>0&&(e.includes(t[0])||e.push(t[0]))}}}return e}_getRelativeTimeSinceUpdate(){var t;const e=this._config.entity?this.hass.states[this._config.entity]:void 0;let i="",o=0,s="";if(null!=this.hass.locale&&null!=e){try{const o=yt(null===(t=this.hass)||void 0===t?void 0:t.localize,e,this.hass.locale),n=void 0===o?"{unknown}":this.prettyDate(o);i=this._sensorAvailable?n:"{unknown}";s=n.split(" ")[0]}catch(t){console.log("GRTSU - exception:"),console.error(t)}o=s.includes("just")||s.includes("unknown")?0:Number(s)}return[i,o]}_getIconNameForPercent(t){let e="";for(const i in this._circleIconsValueByName){if(t<=this._circleIconsValueByName[i]){e=i;break}}return e}_computeReporterAgeColor(t){let e;return this._colorReportPeriodsAgoDefault.forEach((i=>{t>=i.from&&t<=i.to&&(e=i.color)})),null!=e&&"default"!=e||(e=""),e}_computeTemperatureColor(t){const e=this._config,i=Number(t),o=e.temp_severity?e.temp_severity:this._colorTemperatureDefault;let s;if(isNaN(i)||o.forEach((e=>{if(i>=e.from&&i<=e.to&&(s=e.color,this._showDebug())){const i="_computeTemperatureColor() - value=["+t+"] matched(from="+e.from+", to="+e.to+", color="+s+")";console.log(i)}})),this._showDebug()){const e="_computeTemperatureColor() - value=["+t+"] returns(color="+s+")";console.log(e)}return null!=s&&"default"!=s||(s=""),s}_computeFileSystemUsageColor(t){const e=this._config,i=Number(t),o=e.fs_severity?e.fs_severity:this._colorUsedSpaceDefault;let s;if(isNaN(i)||o.forEach((e=>{if(i>=e.from&&i<=e.to&&(s=e.color,this._showDebug())){const i="_computeFileSystemUsageColor() - value=["+t+"] matched(from="+e.from+", to="+e.to+", color="+s+")";console.log(i)}})),this._showDebug()){const e="_computeFileSystemUsageColor() - value=["+t+"] returns(color="+s+")";console.log(e)}return null!=s&&"default"!=s||(s=""),s}_computeMemoryUsageColor(t){const e=this._config,i=Number(t),o=e.memory_severity?e.memory_severity:this._colorUsedMemoryDefault;let s;if(isNaN(i)||o.forEach((e=>{if(i>=e.from&&i<=e.to&&(s=e.color,this._showDebug())){const i="_computeMemoryUsageColor() - value=["+t+"] matched(from="+e.from+", to="+e.to+", color="+s+")";console.log(i)}})),this._showDebug()){const e="_computeMemoryUsageColor() - value=["+t+"] returns(color="+s+")";console.log(e)}return null!=s&&"default"!=s||(s=""),s}_computeOsReleaseColor(t){const e=this._config,i=e.os_age?e.os_age:this._colorReleaseDefault;let o="default";if(i.forEach((e=>{if(t===e.os&&(o=e.color,this._showDebug())){const i="_computeOsReleaseColor() - value=["+t+"] matched(os="+e.os+", color="+o+")";console.log(i)}})),this._showDebug()){const e="_computeOsReleaseColor() - value=["+t+"] returns(color="+o+")";console.log(e)}return null!=o&&"default"!=o||(o=""),o}_computeDaemonUpdateVersionColor(t){let e;if(e=this.latestDaemonVersions.length>0&&""!=t?this.latestDaemonVersions[0]==t?"default":this.latestDaemonVersions.includes(t)?"yellow":"red":"orange",this._showDebug()){const i="_computeDaemonUpdateVersionColor() - value=["+t+"] returns(color="+e+")";console.log(i)}return null!=e&&"default"!=e||(e=""),e}_filterUptime(t){const e=t.split(" ");let i=t;if(i.includes(":")){for(let t=0;t=31)return s.toString()+"-"+(n<10?"0"+n.toString():n.toString())+"-"+(r<10?"0"+r.toString():r.toString());let a="{unknown}";return 0==o?i<60?a="just now":i<120?a="1 minute ago":i<3600?a=Math.floor(i/60)+" minutes ago":i<7200?a="1 hour ago":i<86400&&(a=Math.floor(i/3600)+" hours ago"):1==o?a="Yesterday":o<7?a=o+" days ago":o<31&&(a=Math.ceil(o/7)+" weeks ago"),a}updated(t){if(this._showDebug()&&console.log("- updated("+this._hostname+")"),!this._config)return;if(this.hass){const e=t.get("hass");(!e||e&&e.themes!==this.hass.themes)&&function(t,e,i,o){void 0===o&&(o=!1),t._themes||(t._themes={});var s=e.default_theme;("default"===i||i&&e.themes[i])&&(s=i);var n=_t({},t._themes);if("default"!==s){var r=e.themes[s];Object.keys(r).forEach((function(e){var i="--"+e;t._themes[i]="",n[i]=r[e]}))}if(t.updateStyles?t.updateStyles(n):window.ShadyCSS&&window.ShadyCSS.styleSubtree(t,n),o){var a=document.querySelector("meta[name=theme-color]");if(a){a.hasAttribute("default-content")||a.setAttribute("default-content",a.getAttribute("content"));var l=n["--primary-color"]||a.getAttribute("default-content");a.setAttribute("content",l)}}}(this,this.hass.themes,this._config.theme)}this.hass.states[this._config.entity]||this._stopCardRefreshTimer();const e=this.shadowRoot;if(this._sensorAvailable){const t=this._getAttributeValueForKey(Mt),i=this._computeOsReleaseColor(t);if(""!=i){e.getElementById("os-name").style.setProperty("color",i)}const o=this._computeDaemonUpdateVersionColor(this.currentDaemonVersion);if(""!=o){e.getElementById("daemon-update").style.setProperty("color",o)}const s=this._computeReporterAgeColor(this._cardSecondsSinceUpdate);if(""!=s&&null!=s){e.getElementById("card-timestamp").style.setProperty("color",s)}if(this._useFullCard())for(const t in this._cardFullCssIDs){const i=this._cardFullCssIDs[t],o=this._cardFullElements[t],s=this._getAttributeValueForKey(o),n=this._getFullCardValueForAttributeKey(o),r=e.getElementById(i);r.textContent=n;const a=this._cardFullIconCssIDs[t],l=e.getElementById(a);if(o==Nt){const t=this._computeFileSystemUsageColor(s);""!=t&&(r.style.setProperty("color",t),l.style.setProperty("color",t))}if(o==Lt){const t=this._computeMemoryUsageColor(n.replace(" %",""));""!=t&&(r.style.setProperty("color",t),l.style.setProperty("color",t))}if(o==Vt){const t=this._computeTemperatureColor(s);""!=t&&(r.style.setProperty("color",t),l.style.setProperty("color",t))}}else for(const t in this._cardGlanceCssIDs){const i=this._cardGlanceCssIDs[t],o=this._cardGlanceElements[t],s=this._getAttributeValueForKey(o),n=this._getGlanceCardValueForAttributeKey(o),r=e.getElementById(i);r.textContent=n;const a=this._cardGlanceIconCssIDs[t],l=e.getElementById(a);if(o==Nt){const t=this._computeFileSystemUsageColor(s);""!=t&&(r.style.setProperty("color",t),l.style.setProperty("color",t))}if(o==Lt){const t=this._computeMemoryUsageColor(n);""!=t&&(r.style.setProperty("color",t),l.style.setProperty("color",t))}if(o==Vt&&"n/a"!=n){const t=this._computeTemperatureColor(s);""!=t&&(r.style.setProperty("color",t),l.style.setProperty("color",t));e.getElementById(this.kClassIdTempScale).textContent=this._getTemperatureScale()}}}}_handleAction(t){this.hass&&this._config&&t.detail.action&&function(t,e,i,o){var s;"double_tap"===o&&i.double_tap_action?s=i.double_tap_action:"hold"===o&&i.hold_action?s=i.hold_action:"tap"===o&&i.tap_action&&(s=i.tap_action),At(t,e,i,s)}(this,this.hass,this._config,t.detail.action)}showWarning(t){return P` ${t} `}showError(t){const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t,origConfig:this._config}),P` ${e} `}_startCardRefreshTimer(){this._updateTimerID=setInterval((()=>this._handleCardUpdateTimerExpiration()),1e3),console.log("TIMER: ("+this._hostname+") started")}_stopCardRefreshTimer(){null!=this._updateTimerID&&(clearInterval(this._updateTimerID),this._updateTimerID=void 0,console.log("TIMER: ("+this._hostname+") STOPPED"))}_handleCardUpdateTimerExpiration(){const[t,e]=this._getRelativeTimeSinceUpdate();if(this._cardSecondsSinceUpdate!=e&&(this._cardSecondsSinceUpdate=e),t){let e=t;t.includes("NaN")&&(console.log(" HCUTE (DBG) ("+this._hostname+") card_timestamp_value=["+t+"]"),e="{unexpected value}..."),this._cardUpdateString!=e&&(this._cardUpdateString=e)}}_useFullCard(){let t=!0;return this._config&&null!=this._config.card_style&&(t="full"==this._config.card_style.toLocaleLowerCase()),t}_useTempsInC(){let t=!0;return this._config&&null!=this._config.temp_scale&&(t="c"==this._config.temp_scale.toLocaleLowerCase()),t}_logChangeMessage(t){""==this._hostname&&(this._hostname=this._getAttributeValueForKey("host_name"));const e="("+this._hostname+"): "+t;this._showDebug()&&console.log(e)}_updateSensorAvailability(){let t=!1;if(this.hass&&this._config){const e=this._config.entity?this._config.entity:void 0,i=this._config.entity?this.hass.states[this._config.entity]:void 0;if(e||i)try{const e="unavailable"!=this.hass.states[this._config.entity].state;t=this._sensorAvailable!=e,this._sensorAvailable=e}catch(e){this._sensorAvailable=!1,t=!0}else this._sensorAvailable=!1,t=!0}else this._sensorAvailable=!1,t=!0;t&&this._logChangeMessage("* SENSOR available: "+this._sensorAvailable)}_loadDaemonReleaseInfo(t){let e=[];if(t){e=[];const i=t.split("\n");for(let t=0;t0){const t=o.split(" ");t.length>0&&(e.includes(t[0])||e.push(t[0]))}}}return e}_getRelativeTimeSinceUpdate(){var t;const e=this._config.entity?this.hass.states[this._config.entity]:void 0;let i="",o=0,s="";if(null!=this.hass.locale&&null!=e){try{const o=yt(null===(t=this.hass)||void 0===t?void 0:t.localize,e,this.hass.locale),n=void 0===o?"{unknown}":this.prettyDate(o);i=this._sensorAvailable?n:"{unknown}";s=n.split(" ")[0]}catch(t){console.log("GRTSU - exception:"),console.error(t)}o=s.includes("just")||s.includes("unknown")?0:Number(s)}return[i,o]}_getIconNameForPercent(t){let e="";for(const i in this._circleIconsValueByName){if(t<=this._circleIconsValueByName[i]){e=i;break}}return e}_computeReporterAgeColor(t){let e;return this._colorReportPeriodsAgoDefault.forEach((i=>{t>=i.from&&t<=i.to&&(e=i.color)})),null!=e&&"default"!=e||(e=""),e}_computeTemperatureColor(t){const e=this._config,i=Number(t),o=e.temp_severity?e.temp_severity:this._colorTemperatureDefault;let s;if(isNaN(i)||o.forEach((e=>{if(i>=e.from&&i<=e.to&&(s=e.color,this._showDebug())){const i="_computeTemperatureColor() - value=["+t+"] matched(from="+e.from+", to="+e.to+", color="+s+")";console.log(i)}})),this._showDebug()){const e="_computeTemperatureColor() - value=["+t+"] returns(color="+s+")";console.log(e)}return null!=s&&"default"!=s||(s=""),s}_computeFileSystemUsageColor(t){const e=this._config,i=Number(t),o=e.fs_severity?e.fs_severity:this._colorUsedSpaceDefault;let s;if(isNaN(i)||o.forEach((e=>{if(i>=e.from&&i<=e.to&&(s=e.color,this._showDebug())){const i="_computeFileSystemUsageColor() - value=["+t+"] matched(from="+e.from+", to="+e.to+", color="+s+")";console.log(i)}})),this._showDebug()){const e="_computeFileSystemUsageColor() - value=["+t+"] returns(color="+s+")";console.log(e)}return null!=s&&"default"!=s||(s=""),s}_computeMemoryUsageColor(t){const e=this._config,i=Number(t),o=e.memory_severity?e.memory_severity:this._colorUsedMemoryDefault;let s;if(isNaN(i)||o.forEach((e=>{if(i>=e.from&&i<=e.to&&(s=e.color,this._showDebug())){const i="_computeMemoryUsageColor() - value=["+t+"] matched(from="+e.from+", to="+e.to+", color="+s+")";console.log(i)}})),this._showDebug()){const e="_computeMemoryUsageColor() - value=["+t+"] returns(color="+s+")";console.log(e)}return null!=s&&"default"!=s||(s=""),s}_computeOsReleaseColor(t){const e=this._config,i=e.os_age?e.os_age:this._colorReleaseDefault;let o="default";if(i.forEach((e=>{if(t===e.os&&(o=e.color,this._showDebug())){const i="_computeOsReleaseColor() - value=["+t+"] matched(os="+e.os+", color="+o+")";console.log(i)}})),this._showDebug()){const e="_computeOsReleaseColor() - value=["+t+"] returns(color="+o+")";console.log(e)}return null!=o&&"default"!=o||(o=""),o}_computeDaemonUpdateVersionColor(t){let e;if(e=this.latestDaemonVersions.length>0&&""!=t?this.latestDaemonVersions[0]==t?"default":this.latestDaemonVersions.includes(t)?"yellow":"red":"orange",this._showDebug()){const i="_computeDaemonUpdateVersionColor() - value=["+t+"] returns(color="+e+")";console.log(i)}return null!=e&&"default"!=e||(e=""),e}_filterUptime(t){const e=t.split(" ");let i=t;if(i.includes(":")){for(let t=0;t
diff --git a/src/rpi-monitor-card.ts b/src/rpi-monitor-card.ts index 36b2cff..29ce36d 100644 --- a/src/rpi-monitor-card.ts +++ b/src/rpi-monitor-card.ts @@ -873,6 +873,7 @@ export class RPiMonitorCard extends LitElement { //console.log('LDRI retrievedText=[' + retrievedText + ']'); let foundVersions: string[] = []; if (retrievedText) { + foundVersions = []; // silence FALSE! compiler-detect error const lines: string[] = retrievedText.split('\n'); //console.log('FAR lines=[' + lines + '](' + lines.length + ')'); for (let index: number = 0; index < lines.length; index++) {