diff --git a/dist/rpi-monitor-card.js b/dist/rpi-monitor-card.js index 33f8a13..86eebde 100644 --- a/dist/rpi-monitor-card.js +++ b/dist/rpi-monitor-card.js @@ -1,17 +1,3 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ function t(t,e,i,o){var s,n=arguments.length,r=n<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(r=(n<3?s(r):n>3?s(e,i,r):s(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r /** * @license @@ -28,13 +14,13 @@ 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,U=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),D=/'/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]?U:'"'===l[3]?R:D):r===R||r===D?r=U:r===T||r===k?r=E:(r=U,s=void 0);const d=r===U&&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,I=(t="")=>A.createComment(t),S=t=>null===t||"object"!=typeof t&&"function"!=typeof t,E=Array.isArray,x=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,T=/-->/g,k=/>/g,U=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),D=/'/g,R=/"/g,M=/^(?:script|style|textarea|title)$/i,F=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),P=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=x;for(let e=0;e"===l[0]?(r=null!=s?s:x,c=-1):void 0===l[1]?c=-2:(c=r.lastIndex-l[2].length,a=l[1],r=void 0===l[3]?U:'"'===l[3]?R:D):r===R||r===D?r=U:r===T||r===k?r=x:(r=U,s=void 0);const d=r===U&&t[e+1].startsWith("/>")?" ":"";n+=r===x?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;iE(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&&S(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 L(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){E(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(I()),this.O(I()),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=z(this,t,e,0),n=!S(t)||t!==this._$AH&&t!==P,n&&(this._$AH=t);else{const o=t;let r,a;for(t=s[0],r=0;r{var o,s;const n=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:e;let r=n._$litPart$;if(void 0===r){const t=null!==(s=null==i?void 0:i.renderBefore)&&void 0!==s?s:null;n._$litPart$=r=new j(e.insertBefore(S(),t),t,void 0,null!=i?i:{})}return r._$AI(t),r})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return F}}X.finalized=!0,X._$litElement$=!0,null===(Z=globalThis.litElementHydrateSupport)||void 0===Z||Z.call(globalThis,{LitElement:X});const tt=globalThis.litElementPolyfillSupport;null==tt||tt({LitElement:X}),(null!==(J=globalThis.litElementVersions)&&void 0!==J?J:globalThis.litElementVersions=[]).push("3.2.2"); +var J,Q;class X extends f{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,e;const i=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=i.firstChild),i}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,i)=>{var o,s;const n=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:e;let r=n._$litPart$;if(void 0===r){const t=null!==(s=null==i?void 0:i.renderBefore)&&void 0!==s?s:null;n._$litPart$=r=new j(e.insertBefore(I(),t),t,void 0,null!=i?i:{})}return r._$AI(t),r})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return P}}X.finalized=!0,X._$litElement$=!0,null===(J=globalThis.litElementHydrateSupport)||void 0===J||J.call(globalThis,{LitElement:X});const tt=globalThis.litElementPolyfillSupport;null==tt||tt({LitElement:X}),(null!==(Q=globalThis.litElementVersions)&&void 0!==Q?Q:globalThis.litElementVersions=[]).push("3.2.2"); /** * @license * Copyright 2017 Google LLC @@ -55,16 +41,16 @@ const et=t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e) * @license * Copyright 2021 Google LLC * SPDX-License-Identifier: BSD-3-Clause - */var nt;null===(nt=window.HTMLSlotElement)||void 0===nt||nt.prototype.assignedElements;var rt,at,lt=function(t,e){return ct(e).format(t)},ct=function(t){return new Intl.DateTimeFormat(t.language,{year:"numeric",month:"long",day:"numeric"})};!function(t){t.language="language",t.system="system",t.comma_decimal="comma_decimal",t.decimal_comma="decimal_comma",t.space_comma="space_comma",t.none="none"}(rt||(rt={})),function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(at||(at={}));var ht=function(t){if(t.time_format===at.language||t.time_format===at.system){var e=t.time_format===at.language?t.language:void 0,i=(new Date).toLocaleString(e);return i.includes("AM")||i.includes("PM")}return t.time_format===at.am_pm},dt=function(t,e){return ut(e).format(t)},ut=function(t){return new Intl.DateTimeFormat(t.language,{year:"numeric",month:"long",day:"numeric",hour:ht(t)?"numeric":"2-digit",minute:"2-digit",hour12:ht(t)})},pt=function(t,e){return mt(e).format(t)},mt=function(t){return new Intl.DateTimeFormat(t.language,{hour:"numeric",minute:"2-digit",hour12:ht(t)})};function _t(){return(_t=Object.assign||function(t){for(var e=1;e-1?t.split(".")[1].length:0;i.minimumFractionDigits=o,i.maximumFractionDigits=o}return i},yt=function(t,e,i,o){var s=void 0!==o?o:e.state;if("unknown"===s||"unavailable"===s)return t("state.default."+s);if(function(t){return!!t.attributes.unit_of_measurement||!!t.attributes.state_class}(e)){if("monetary"===e.attributes.device_class)try{return gt(s,i,{style:"currency",currency:e.attributes.unit_of_measurement})}catch(t){}return gt(s,i)+(e.attributes.unit_of_measurement?" "+e.attributes.unit_of_measurement:"")}var n=function(t){return ft(t.entity_id)}(e);if("input_datetime"===n){var r;if(void 0===o)return e.attributes.has_date&&e.attributes.has_time?(r=new Date(e.attributes.year,e.attributes.month-1,e.attributes.day,e.attributes.hour,e.attributes.minute),dt(r,i)):e.attributes.has_date?(r=new Date(e.attributes.year,e.attributes.month-1,e.attributes.day),lt(r,i)):e.attributes.has_time?((r=new Date).setHours(e.attributes.hour,e.attributes.minute),pt(r,i)):e.state;try{var a=o.split(" ");if(2===a.length)return dt(new Date(a.join("T")),i);if(1===a.length){if(o.includes("-"))return lt(new Date(o+"T00:00"),i);if(o.includes(":")){var l=new Date;return pt(new Date(l.toISOString().split("T")[0]+"T"+o),i)}}return o}catch(t){return o}}return"humidifier"===n&&"on"===s&&e.attributes.humidity?e.attributes.humidity+" %":"counter"===n||"number"===n||"input_number"===n?gt(s,i):e.attributes.device_class&&t("component."+n+".state."+e.attributes.device_class+"."+s)||t("component."+n+".state._."+s)||s},bt=["closed","locked","off"],$t=function(t,e,i,o){o=o||{},i=null==i?{}:i;var s=new Event(e,{bubbles:void 0===o.bubbles||o.bubbles,cancelable:Boolean(o.cancelable),composed:void 0===o.composed||o.composed});return s.detail=i,t.dispatchEvent(s),s},wt=function(t){$t(window,"haptic",t)},Ct=function(t,e){return function(t,e,i){void 0===i&&(i=!0);var o,s=ft(e),n="group"===s?"homeassistant":s;switch(s){case"lock":o=i?"unlock":"lock";break;case"cover":o=i?"open_cover":"close_cover";break;default:o=i?"turn_on":"turn_off"}return t.callService(n,o,{entity_id:e})}(t,e,bt.includes(t.states[e].state))},At=function(t,e,i,o){if(o||(o={action:"more-info"}),!o.confirmation||o.confirmation.exemptions&&o.confirmation.exemptions.some((function(t){return t.user===e.user.id}))||(wt("warning"),confirm(o.confirmation.text||"Are you sure you want to "+o.action+"?")))switch(o.action){case"more-info":(i.entity||i.camera_image)&&$t(t,"hass-more-info",{entityId:i.entity?i.entity:i.camera_image});break;case"navigate":o.navigation_path&&function(t,e,i){void 0===i&&(i=!1),i?history.replaceState(null,"",e):history.pushState(null,"",e),$t(window,"location-changed",{replace:i})}(0,o.navigation_path);break;case"url":o.url_path&&window.open(o.url_path);break;case"toggle":i.entity&&(Ct(e,i.entity),wt("success"));break;case"call-service":if(!o.service)return void wt("failure");var s=o.service.split(".",2);e.callService(s[0],s[1],o.service_data,o.target),wt("success");break;case"fire-dom-event":$t(t,"ll-custom",o)}};function St(t){return void 0!==t&&"none"!==t.action}const xt={required:{icon:"tune",name:"Required",secondary:"Required options for this card to function",show:!0},actions:{icon:"gesture-tap-hold",name:"Actions",secondary:"Perform actions based on tapping/clicking",show:!1,options:{tap:{icon:"gesture-tap",name:"Tap",secondary:"Set the action to perform on tap",show:!1},hold:{icon:"gesture-tap-hold",name:"Hold",secondary:"Set the action to perform on hold",show:!1},double_tap:{icon:"gesture-double-tap",name:"Double Tap",secondary:"Set the action to perform on double tap",show:!1}}},appearance:{icon:"palette",name:"Appearance",secondary:"Customize the name, icon, etc",show:!1}};let It=class extends X{constructor(){super(...arguments),this._initialized=!1}setConfig(t){this._config=t,this.loadCardHelpers()}shouldUpdate(){return this._initialized||this._initialize(),!0}get _name(){var t;return(null===(t=this._config)||void 0===t?void 0:t.name)||""}get _entity(){var t;return(null===(t=this._config)||void 0===t?void 0:t.entity)||""}get _show_warning(){var t;return(null===(t=this._config)||void 0===t?void 0:t.show_warning)||!1}get _show_error(){var t;return(null===(t=this._config)||void 0===t?void 0:t.show_error)||!1}get _tap_action(){var t;return(null===(t=this._config)||void 0===t?void 0:t.tap_action)||{action:"more-info"}}get _hold_action(){var t;return(null===(t=this._config)||void 0===t?void 0:t.hold_action)||{action:"none"}}get _double_tap_action(){var t;return(null===(t=this._config)||void 0===t?void 0:t.double_tap_action)||{action:"none"}}render(){if(!this.hass||!this._helpers)return P``;this._helpers.importMoreInfoControl("climate");const t=Object.keys(this.hass.states).filter((t=>"sun"===t.substr(0,t.indexOf("."))));return P` + */var nt;null===(nt=window.HTMLSlotElement)||void 0===nt||nt.prototype.assignedElements;var rt,at,lt=function(t,e){return ct(e).format(t)},ct=function(t){return new Intl.DateTimeFormat(t.language,{year:"numeric",month:"long",day:"numeric"})};!function(t){t.language="language",t.system="system",t.comma_decimal="comma_decimal",t.decimal_comma="decimal_comma",t.space_comma="space_comma",t.none="none"}(rt||(rt={})),function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(at||(at={}));var ht=function(t){if(t.time_format===at.language||t.time_format===at.system){var e=t.time_format===at.language?t.language:void 0,i=(new Date).toLocaleString(e);return i.includes("AM")||i.includes("PM")}return t.time_format===at.am_pm},dt=function(t,e){return ut(e).format(t)},ut=function(t){return new Intl.DateTimeFormat(t.language,{year:"numeric",month:"long",day:"numeric",hour:ht(t)?"numeric":"2-digit",minute:"2-digit",hour12:ht(t)})},pt=function(t,e){return mt(e).format(t)},mt=function(t){return new Intl.DateTimeFormat(t.language,{hour:"numeric",minute:"2-digit",hour12:ht(t)})};function _t(){return(_t=Object.assign||function(t){for(var e=1;e-1?t.split(".")[1].length:0;i.minimumFractionDigits=o,i.maximumFractionDigits=o}return i},yt=function(t,e,i,o){var s=void 0!==o?o:e.state;if("unknown"===s||"unavailable"===s)return t("state.default."+s);if(function(t){return!!t.attributes.unit_of_measurement||!!t.attributes.state_class}(e)){if("monetary"===e.attributes.device_class)try{return gt(s,i,{style:"currency",currency:e.attributes.unit_of_measurement})}catch(t){}return gt(s,i)+(e.attributes.unit_of_measurement?" "+e.attributes.unit_of_measurement:"")}var n=function(t){return ft(t.entity_id)}(e);if("input_datetime"===n){var r;if(void 0===o)return e.attributes.has_date&&e.attributes.has_time?(r=new Date(e.attributes.year,e.attributes.month-1,e.attributes.day,e.attributes.hour,e.attributes.minute),dt(r,i)):e.attributes.has_date?(r=new Date(e.attributes.year,e.attributes.month-1,e.attributes.day),lt(r,i)):e.attributes.has_time?((r=new Date).setHours(e.attributes.hour,e.attributes.minute),pt(r,i)):e.state;try{var a=o.split(" ");if(2===a.length)return dt(new Date(a.join("T")),i);if(1===a.length){if(o.includes("-"))return lt(new Date(o+"T00:00"),i);if(o.includes(":")){var l=new Date;return pt(new Date(l.toISOString().split("T")[0]+"T"+o),i)}}return o}catch(t){return o}}return"humidifier"===n&&"on"===s&&e.attributes.humidity?e.attributes.humidity+" %":"counter"===n||"number"===n||"input_number"===n?gt(s,i):e.attributes.device_class&&t("component."+n+".state."+e.attributes.device_class+"."+s)||t("component."+n+".state._."+s)||s},bt=["closed","locked","off"],$t=function(t,e,i,o){o=o||{},i=null==i?{}:i;var s=new Event(e,{bubbles:void 0===o.bubbles||o.bubbles,cancelable:Boolean(o.cancelable),composed:void 0===o.composed||o.composed});return s.detail=i,t.dispatchEvent(s),s},wt=function(t){$t(window,"haptic",t)},Ct=function(t,e){return function(t,e,i){void 0===i&&(i=!0);var o,s=ft(e),n="group"===s?"homeassistant":s;switch(s){case"lock":o=i?"unlock":"lock";break;case"cover":o=i?"open_cover":"close_cover";break;default:o=i?"turn_on":"turn_off"}return t.callService(n,o,{entity_id:e})}(t,e,bt.includes(t.states[e].state))},At=function(t,e,i,o){if(o||(o={action:"more-info"}),!o.confirmation||o.confirmation.exemptions&&o.confirmation.exemptions.some((function(t){return t.user===e.user.id}))||(wt("warning"),confirm(o.confirmation.text||"Are you sure you want to "+o.action+"?")))switch(o.action){case"more-info":(i.entity||i.camera_image)&&$t(t,"hass-more-info",{entityId:i.entity?i.entity:i.camera_image});break;case"navigate":o.navigation_path&&function(t,e,i){void 0===i&&(i=!1),i?history.replaceState(null,"",e):history.pushState(null,"",e),$t(window,"location-changed",{replace:i})}(0,o.navigation_path);break;case"url":o.url_path&&window.open(o.url_path);break;case"toggle":i.entity&&(Ct(e,i.entity),wt("success"));break;case"call-service":if(!o.service)return void wt("failure");var s=o.service.split(".",2);e.callService(s[0],s[1],o.service_data,o.target),wt("success");break;case"fire-dom-event":$t(t,"ll-custom",o)}};function It(t){return void 0!==t&&"none"!==t.action}const St={required:{icon:"tune",name:"Required",secondary:"Required options for this card to function",show:!0},actions:{icon:"gesture-tap-hold",name:"Actions",secondary:"Perform actions based on tapping/clicking",show:!1,options:{tap:{icon:"gesture-tap",name:"Tap",secondary:"Set the action to perform on tap",show:!1},hold:{icon:"gesture-tap-hold",name:"Hold",secondary:"Set the action to perform on hold",show:!1},double_tap:{icon:"gesture-double-tap",name:"Double Tap",secondary:"Set the action to perform on double tap",show:!1}}},appearance:{icon:"palette",name:"Appearance",secondary:"Customize the name, icon, etc",show:!1}};let Et=class extends X{constructor(){super(...arguments),this._initialized=!1}setConfig(t){this._config=t,this.loadCardHelpers()}shouldUpdate(){return this._initialized||this._initialize(),!0}get _name(){var t;return(null===(t=this._config)||void 0===t?void 0:t.name)||""}get _entity(){var t;return(null===(t=this._config)||void 0===t?void 0:t.entity)||""}get _show_warning(){var t;return(null===(t=this._config)||void 0===t?void 0:t.show_warning)||!1}get _show_error(){var t;return(null===(t=this._config)||void 0===t?void 0:t.show_error)||!1}get _tap_action(){var t;return(null===(t=this._config)||void 0===t?void 0:t.tap_action)||{action:"more-info"}}get _hold_action(){var t;return(null===(t=this._config)||void 0===t?void 0:t.hold_action)||{action:"none"}}get _double_tap_action(){var t;return(null===(t=this._config)||void 0===t?void 0:t.double_tap_action)||{action:"none"}}render(){if(!this.hass||!this._helpers)return F``;this._helpers.importMoreInfoControl("climate");const t=Object.keys(this.hass.states).filter((t=>"sun"===t.substr(0,t.indexOf("."))));return F`
- -
${xt.required.name}
+ +
${St.required.name}
-
${xt.required.secondary}
+
${St.required.secondary}
- ${xt.required.show?P` + ${St.required.show?F`
e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e) .configValue=${"entity"} > - ${t.map((t=>P` ${t} `))} + ${t.map((t=>F` ${t} `))}
`:""}
- -
${xt.actions.name}
+ +
${St.actions.name}
-
${xt.actions.secondary}
+
${St.actions.secondary}
- ${xt.actions.show?P` + ${St.actions.show?F`
- -
${xt.actions.options.tap.name}
+ +
${St.actions.options.tap.name}
-
${xt.actions.options.tap.secondary}
+
${St.actions.options.tap.secondary}
- ${xt.actions.options.tap.show?P` + ${St.actions.options.tap.show?F`
Action Editors Coming Soon
`:""}
- -
${xt.actions.options.hold.name}
+ +
${St.actions.options.hold.name}
-
${xt.actions.options.hold.secondary}
+
${St.actions.options.hold.secondary}
- ${xt.actions.options.hold.show?P` + ${St.actions.options.hold.show?F`
Action Editors Coming Soon
`:""}
- -
${xt.actions.options.double_tap.name}
+ +
${St.actions.options.double_tap.name}
-
${xt.actions.options.double_tap.secondary}
+
${St.actions.options.double_tap.secondary}
- ${xt.actions.options.double_tap.show?P` + ${St.actions.options.double_tap.show?F`
Action Editors Coming Soon
@@ -126,12 +112,12 @@ const et=t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e) `:""}
- -
${xt.appearance.name}
+ +
${St.appearance.name}
-
${xt.appearance.secondary}
+
${St.appearance.secondary}
- ${xt.appearance.show?P` + ${St.appearance.show?F`
e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e)
`:""}
- `}_initialize(){void 0!==this.hass&&void 0!==this._config&&void 0!==this._helpers&&(this._initialized=!0)}async loadCardHelpers(){this._helpers=await window.loadCardHelpers()}_toggleAction(t){this._toggleThing(t,xt.actions.options)}_toggleOption(t){this._toggleThing(t,xt)}_toggleThing(t,e){const i=!e[t.target.option].show;for(const[t]of Object.entries(e))e[t].show=!1;e[t.target.option].show=i,this._toggle=!this._toggle}_valueChanged(t){if(!this._config||!this.hass)return;const e=t.target;if(this[`_${e.configValue}`]!==e.value){if(e.configValue)if(""===e.value){const t=Object.assign({},this._config);delete t[e.configValue],this._config=t}else this._config=Object.assign(Object.assign({},this._config),{[e.configValue]:void 0!==e.checked?e.checked:e.value});$t(this,"config-changed",{config:this._config})}}static get styles(){return r` + `}_initialize(){void 0!==this.hass&&void 0!==this._config&&void 0!==this._helpers&&(this._initialized=!0)}async loadCardHelpers(){this._helpers=await window.loadCardHelpers()}_toggleAction(t){this._toggleThing(t,St.actions.options)}_toggleOption(t){this._toggleThing(t,St)}_toggleThing(t,e){const i=!e[t.target.option].show;for(const[t]of Object.entries(e))e[t].show=!1;e[t.target.option].show=i,this._toggle=!this._toggle}_valueChanged(t){if(!this._config||!this.hass)return;const e=t.target;if(this[`_${e.configValue}`]!==e.value){if(e.configValue)if(""===e.value){const t=Object.assign({},this._config);delete t[e.configValue],this._config=t}else this._config=Object.assign(Object.assign({},this._config),{[e.configValue]:void 0!==e.checked?e.checked:e.value});$t(this,"config-changed",{config:this._config})}}static get styles(){return r` .option { padding: 4px 0px; cursor: pointer; @@ -185,11 +171,11 @@ const et=t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e) ha-formfield { padding-bottom: 8px; } - `}};t([ot({attribute:!1})],It.prototype,"hass",void 0),t([st()],It.prototype,"_config",void 0),t([st()],It.prototype,"_toggle",void 0),t([st()],It.prototype,"_helpers",void 0),It=t([et("rpi-monitor-card-editor")],It);class Et{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}const Tt="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.maxTouchPoints>0;class kt extends HTMLElement{constructor(){super(),this.holdTime=500,this.held=!1,this.ripple=document.createElement("mwc-ripple")}connectedCallback(){Object.assign(this.style,{position:"absolute",width:Tt?"100px":"50px",height:Tt?"100px":"50px",transform:"translate(-50%, -50%)",pointerEvents:"none",zIndex:"999"}),this.appendChild(this.ripple),this.ripple.primary=!0,["touchcancel","mouseout","mouseup","touchmove","mousewheel","wheel","scroll"].forEach((t=>{document.addEventListener(t,(()=>{clearTimeout(this.timer),this.stopAnimation(),this.timer=void 0}),{passive:!0})}))}bind(t,e){if(t.actionHandler)return;t.actionHandler=!0,t.addEventListener("contextmenu",(t=>{const e=t||window.event;return e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,e.returnValue=!1,!1}));const i=t=>{let e,i;this.held=!1,t.touches?(e=t.touches[0].pageX,i=t.touches[0].pageY):(e=t.pageX,i=t.pageY),this.timer=window.setTimeout((()=>{this.startAnimation(e,i),this.held=!0}),this.holdTime)},o=i=>{i.preventDefault(),["touchend","touchcancel"].includes(i.type)&&void 0===this.timer||(clearTimeout(this.timer),this.stopAnimation(),this.timer=void 0,this.held?$t(t,"action",{action:"hold"}):e.hasDoubleClick?"click"===i.type&&i.detail<2||!this.dblClickTimeout?this.dblClickTimeout=window.setTimeout((()=>{this.dblClickTimeout=void 0,$t(t,"action",{action:"tap"})}),250):(clearTimeout(this.dblClickTimeout),this.dblClickTimeout=void 0,$t(t,"action",{action:"double_tap"})):$t(t,"action",{action:"tap"}))};t.addEventListener("touchstart",i,{passive:!0}),t.addEventListener("touchend",o),t.addEventListener("touchcancel",o),t.addEventListener("mousedown",i,{passive:!0}),t.addEventListener("click",o),t.addEventListener("keyup",(t=>{13===t.keyCode&&o(t)}))}startAnimation(t,e){Object.assign(this.style,{left:`${t}px`,top:`${e}px`,display:null}),this.ripple.disabled=!1,this.ripple.active=!0,this.ripple.unbounded=!0}stopAnimation(){this.ripple.active=!1,this.ripple.disabled=!0,this.style.display="none"}}customElements.define("action-handler-rpi-monitor",kt);const Ut=(t,e)=>{const i=(()=>{const t=document.body;if(t.querySelector("action-handler-rpi-monitor"))return t.querySelector("action-handler-rpi-monitor");const e=document.createElement("action-handler-rpi-monitor");return t.appendChild(e),e})();i&&i.bind(t,e)},Dt=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends Et{update(t,[e]){return Ut(t.element,e),F}render(t){}}),Rt="ifaces",Mt="ux_release",Pt="last_update",Ft="up_time",Ot="fs_total_gb",Nt="fs_free_prcnt",Vt="temperature_c",Ht="show-os-parts",Lt="memory_percent";var zt={version:"Version",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",show_error:"Show Error"},jt={common:zt},Bt=Object.freeze({__proto__:null,common:zt,default:jt}),Gt={version:"Versjon",invalid_configuration:"Ikke gyldig konfiguration",show_warning:"Vis advarsel",show_error:"Vis feil"},Kt={common:Gt},qt=Object.freeze({__proto__:null,common:Gt,default:Kt}),Wt={version:"Version",invalid_configuration:"configuración no válida",show_warning:"Mostrar advertencia",show_error:"Mostrar error"},Yt={common:Wt};const Qt={en:Bt,es:Object.freeze({__proto__:null,common:Wt,default:Yt}),nb:qt};function Zt(t,e="",i=""){const o=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let s;try{s=t.split(".").reduce(((t,e)=>t[e]),Qt[o])}catch(e){s=t.split(".").reduce(((t,e)=>t[e]),Qt.en)}return void 0===s&&(s=t.split(".").reduce(((t,e)=>t[e]),Qt.en)),""!==e&&""!==i&&(s=s.replace(e,i)),s}console.info(`%c RPI-MONITOR-CARD \n%c ${Zt("common.version")} 1.3.0 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: dimgray"),window.customCards=window.customCards||[],window.customCards.push({type:"rpi-monitor-card",name:"RPi Monitor Card",description:"A template custom card for you to create something awesome"});let Jt=class extends X{constructor(){super(...arguments),this._cardSecondsSinceUpdate=0,this._cardUpdateString="",this._firstTime=!0,this._sensorAvailable=!1,this._hostname="",this.kREPLACE_WITH_TEMP_UNITS="replace-with-temp-units",this.kMQTT_DAEMON_RELEASE_URL="https://raw.githubusercontent.com/ironsheep/RPi-Reporter-MQTT2HA-Daemon/master/Release",this.latestDaemonVersions=["v1.6.1","v1.6.0"],this.currentDaemonVersion="",this._show_debug=!1,this._cardFullElements={"Storage Use":Nt,Storage:Ot,"Memory Use":Lt,Temperature:Vt,"Up-time":Ft,Updated:Pt,OS:Ht,Model:"rpi_model",Interfaces:Rt},this._cardFullIconNames={Storage:"sd","Storage Use":"file-percent","Memory Use":"memory",Temperature:"thermometer","Up-time":"clock-check-outline",Updated:"update",OS:"linux",Model:"raspberry-pi",Interfaces:""},this.kClassIdIconFSAvail="ico-fs-percent",this.kClassIdIconFSTotal="ico-fs-total",this.kClassIdIconSysTemp="ico-sys-temp",this.kClassIdIconUptime="ico-up-time",this.kClassIdIconUpdated="ico-last-update",this.kClassIdIconOS="ico-*nix",this.kClassIdIconRPiModel="ico-rpi-model",this.kClassIdIconInterfaces="ico-rpi-ifaces",this.kClassIdIconMemoryUsage="ico-memory-percent",this.kClassIdFSAvail="fs-percent",this.kClassIdFSTotal="fs-total",this.kClassIdSysTemp="sys-temp",this.kClassIdUptime="up-time",this.kClassIdUpdated="last-update",this.kClassIdOS="*nix",this.kClassIdRPiModel="rpi-model",this.kClassIdInterfaces="rpi-ifaces",this.kClassIdMemoryUsage="memory-percent",this.kClassIdTempScale="sys-temp-scale",this._cardFullCssIDs={"Storage Use":this.kClassIdFSAvail,Storage:this.kClassIdFSTotal,"Memory Use":this.kClassIdMemoryUsage,Temperature:this.kClassIdSysTemp,"Up-time":this.kClassIdUptime,Updated:this.kClassIdUpdated,OS:this.kClassIdOS,Model:this.kClassIdRPiModel,Interfaces:this.kClassIdInterfaces},this._cardFullIconCssIDs={"Storage Use":this.kClassIdIconFSAvail,Storage:this.kClassIdIconFSTotal,"Memory Use":this.kClassIdIconMemoryUsage,"Up-time":this.kClassIdIconUptime,Updated:this.kClassIdIconUpdated,Temperature:this.kClassIdIconSysTemp,OS:this.kClassIdIconOS,Model:this.kClassIdIconRPiModel,Interfaces:this.kClassIdIconInterfaces},this._cardGlanceElements={"%":Nt,GB:Ot,Mem:Lt,"replace-with-temp-units":Vt,UpTime:Ft,Upd:Pt},this._cardGlanceIconNames={"%":"file-percent",GB:"sd",Mem:"memory","replace-with-temp-units":"thermometer",UpTime:"clock-check-outline",Upd:"update"},this._cardGlanceCssIDs={"%":this.kClassIdFSAvail,GB:this.kClassIdFSTotal,Mem:this.kClassIdMemoryUsage,"replace-with-temp-units":this.kClassIdSysTemp,UpTime:this.kClassIdUptime,Upd:this.kClassIdUpdated},this._cardGlanceIconCssIDs={"%":this.kClassIdIconFSAvail,GB:this.kClassIdIconFSTotal,Mem:this.kClassIdIconMemoryUsage,"replace-with-temp-units":this.kClassIdIconSysTemp,UpTime:this.kClassIdIconUptime,Upd:this.kClassIdIconUpdated},this._circleIconsValueByName={"circle-outline":0,"circle-slice-1":13,"circle-slice-2":25,"circle-slice-3":38,"circle-slice-4":50,"circle-slice-5":63,"circle-slice-6":75,"circle-slice-7":88,"circle-slice-8":100},this._colorUsedSpaceDefault=[{color:"default",from:0,to:59},{color:"yellow",from:60,to:84},{color:"red",from:85,to:100}],this._colorTemperatureDefault=[{color:"default",from:0,to:59},{color:"yellow",from:60,to:79},{color:"red",from:85,to:100}],this._colorReportPeriodsAgoDefault=[{color:"default",from:0,to:3},{color:"yellow",from:4,to:4},{color:"red",from:5,to:100}],this._colorUsedMemoryDefault=[{color:"red",from:75,to:100},{color:"yellow",from:61,to:74},{color:"default",from:0,to:60}],this._colorReleaseDefault=[{color:"red",os:"stretch"},{color:"red",os:"jessie"},{color:"red",os:"wheezy"}]}static async getConfigElement(){return document.createElement("rpi-monitor-card-editor")}static getStubConfig(){return{}}setConfig(t){if(this._showDebug()&&console.log("- setConfig()"),!t||t.show_error)throw new Error(Zt("common.invalid_configuration"));if(null!=t.card_style){const e=t.card_style.toLocaleLowerCase();if("full"!=e&&"glance"!=e)throw console.log("Invalid configuration. INVALID card_style = ["+t.card_style+"]"),new Error("Illegal card_style: value (card_style: "+t.card_style+") must be [full or glance]")}if(null!=t.temp_scale){const e=t.temp_scale.toLocaleLowerCase();if("c"!=e&&"f"!=e)throw console.log("Invalid configuration. INVALID temp_scale = ["+t.temp_scale+"]"),new Error("Illegal temp_scale: value (temp_scale: "+t.temp_scale+") must be [F or C]")}if(!t.entity)throw console.log("Invalid configuration. If no entity provided, you'll need to provide a remote entity"),new Error("You need to associate an entity");t.test_gui&&function(){var t=document.querySelector("home-assistant");if(t=(t=(t=(t=(t=(t=(t=(t=t&&t.shadowRoot)&&t.querySelector("home-assistant-main"))&&t.shadowRoot)&&t.querySelector("app-drawer-layout partial-panel-resolver"))&&t.shadowRoot||t)&&t.querySelector("ha-panel-lovelace"))&&t.shadowRoot)&&t.querySelector("hui-root")){var e=t.lovelace;return e.current_view=t.___curView,e}return null}().setEditMode(!0),this._config=Object.assign({},t),console.log("- config=["+this._config+"]"),this._updateSensorAvailability()}async loadDaemonReleases(){this.latestDaemonVersions=await fetch(this.kMQTT_DAEMON_RELEASE_URL).then((t=>t.text().then(this._loadDaemonReleaseInfo))),console.log("LDR ("+this._hostname+") latestDaemonVersions=["+this.latestDaemonVersions+"]("+this.latestDaemonVersions.length+")")}shouldUpdate(t){if(this._updateSensorAvailability(),t.has("_config"))return!0;if(this.hass&&this._config){const e=t.get("hass");if(e){return e.states[this._config.entity]!==this.hass.states[this._config.entity]}}return!0}render(){if(this._showDebug()&&console.log("- render("+this._hostname+")"),this._config.show_warning)return this.showWarning(Zt("common.show_warning"));if(this._config.show_error)return this.showError(Zt("common.show_error"));const t=this._config.entity?this._config.entity:void 0;if(t&&!this._sensorAvailable){const e="Entity Unavailable: "+t;return this.showWarning(e)}const e=this._config.entity?this.hass.states[this._config.entity]:void 0;if(!t&&!e)return this.showWarning("Entity Unavailable");if(0==this._sensorAvailable)return void console.log("?? Render w/o sensor!! ("+this._hostname+")");if(this._firstTime){this._showDebug()&&console.log("- stateObj: ["+e+"]");const t=this._getAttributeValueForKey("reporter").split(" ");this.currentDaemonVersion=t.length>1?t[1]:"",this._startCardRefreshTimer(),this._showDebug()&&console.log("- 1st-time _config: ["+this._config+"]"),this._firstTime=!1}const i=null==this._config.show_os_age||this._config.show_os_age,o=null==this._config.show_update_age||this._config.show_update_age,s=null==this._config.show_daemon_upd||this._config.show_daemon_upd,n=null==this._config.show_title||this._config.show_title,r=this._getAttributeValueForKey("fqdn"),a=1==i?this._getAttributeValueForKey(Mt):"",l=s?this._calculateDaemonUpdMessage(this.currentDaemonVersion):"",c=1==o?this._cardUpdateString:"";let h="RPi monitor "+r;h=null!=this._config.name_prefix?this._config.name_prefix+" "+r:h,h=null!=this._config.name?this._config.name:h,0==n&&(h="");const d=0==n?"last-heard-full-notitle":"last-heard-full",u=0==n?"last-heard-notitle":"last-heard",p=0==n?"os-name-full-notitle":"os-name-full",m=0==n?"os-name-notitle":"os-name",_=0==n?"daemon-update-full-notitle":"daemon-update-full",f=0==n?"daemon-update-notitle":"daemon-update";if(this._useFullCard()){const t=this._generateFullsizeCardRows();return 0!=t.length&&t?P` + `}};t([ot({attribute:!1})],Et.prototype,"hass",void 0),t([st()],Et.prototype,"_config",void 0),t([st()],Et.prototype,"_toggle",void 0),t([st()],Et.prototype,"_helpers",void 0),Et=t([et("rpi-monitor-card-editor")],Et);class xt{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}const Tt="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.maxTouchPoints>0;class kt extends HTMLElement{constructor(){super(),this.holdTime=500,this.held=!1,this.ripple=document.createElement("mwc-ripple")}connectedCallback(){Object.assign(this.style,{position:"absolute",width:Tt?"100px":"50px",height:Tt?"100px":"50px",transform:"translate(-50%, -50%)",pointerEvents:"none",zIndex:"999"}),this.appendChild(this.ripple),this.ripple.primary=!0,["touchcancel","mouseout","mouseup","touchmove","mousewheel","wheel","scroll"].forEach((t=>{document.addEventListener(t,(()=>{clearTimeout(this.timer),this.stopAnimation(),this.timer=void 0}),{passive:!0})}))}bind(t,e){if(t.actionHandler)return;t.actionHandler=!0,t.addEventListener("contextmenu",(t=>{const e=t||window.event;return e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,e.returnValue=!1,!1}));const i=t=>{let e,i;this.held=!1,t.touches?(e=t.touches[0].pageX,i=t.touches[0].pageY):(e=t.pageX,i=t.pageY),this.timer=window.setTimeout((()=>{this.startAnimation(e,i),this.held=!0}),this.holdTime)},o=i=>{i.preventDefault(),["touchend","touchcancel"].includes(i.type)&&void 0===this.timer||(clearTimeout(this.timer),this.stopAnimation(),this.timer=void 0,this.held?$t(t,"action",{action:"hold"}):e.hasDoubleClick?"click"===i.type&&i.detail<2||!this.dblClickTimeout?this.dblClickTimeout=window.setTimeout((()=>{this.dblClickTimeout=void 0,$t(t,"action",{action:"tap"})}),250):(clearTimeout(this.dblClickTimeout),this.dblClickTimeout=void 0,$t(t,"action",{action:"double_tap"})):$t(t,"action",{action:"tap"}))};t.addEventListener("touchstart",i,{passive:!0}),t.addEventListener("touchend",o),t.addEventListener("touchcancel",o),t.addEventListener("mousedown",i,{passive:!0}),t.addEventListener("click",o),t.addEventListener("keyup",(t=>{13===t.keyCode&&o(t)}))}startAnimation(t,e){Object.assign(this.style,{left:`${t}px`,top:`${e}px`,display:null}),this.ripple.disabled=!1,this.ripple.active=!0,this.ripple.unbounded=!0}stopAnimation(){this.ripple.active=!1,this.ripple.disabled=!0,this.style.display="none"}}customElements.define("action-handler-rpi-monitor",kt);const Ut=(t,e)=>{const i=(()=>{const t=document.body;if(t.querySelector("action-handler-rpi-monitor"))return t.querySelector("action-handler-rpi-monitor");const e=document.createElement("action-handler-rpi-monitor");return t.appendChild(e),e})();i&&i.bind(t,e)},Dt=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends xt{update(t,[e]){return Ut(t.element,e),P}render(t){}}),Rt="ifaces",Mt="ux_release",Ft="last_update",Pt="up_time",Ot="fs_total_gb",Nt="fs_free_prcnt",Vt="temperature_c",Ht="show-os-parts",zt="memory_percent";var Lt={version:"Version",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",show_error:"Show Error"},jt={common:Lt},Bt=Object.freeze({__proto__:null,common:Lt,default:jt}),Gt={version:"Versjon",invalid_configuration:"Ikke gyldig konfiguration",show_warning:"Vis advarsel",show_error:"Vis feil"},Kt={common:Gt},qt=Object.freeze({__proto__:null,common:Gt,default:Kt}),Wt={version:"Version",invalid_configuration:"configuración no válida",show_warning:"Mostrar advertencia",show_error:"Mostrar error"},Yt={common:Wt};const Zt={en:Bt,es:Object.freeze({__proto__:null,common:Wt,default:Yt}),nb:qt};function Jt(t,e="",i=""){const o=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let s;try{s=t.split(".").reduce(((t,e)=>t[e]),Zt[o])}catch(e){s=t.split(".").reduce(((t,e)=>t[e]),Zt.en)}return void 0===s&&(s=t.split(".").reduce(((t,e)=>t[e]),Zt.en)),""!==e&&""!==i&&(s=s.replace(e,i)),s}console.info(`%c RPI-MONITOR-CARD \n%c ${Jt("common.version")} 1.3.1 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: dimgray"),window.customCards=window.customCards||[],window.customCards.push({type:"rpi-monitor-card",name:"RPi Monitor Card",description:"A template custom card for you to create something awesome"});let Qt=class extends X{constructor(){super(...arguments),this._cardSecondsSinceUpdate=0,this._cardUpdateString="",this._firstTime=!0,this._sensorAvailable=!1,this._updateTimerID=void 0,this._configEntityId=void 0,this._hostname="",this._showFullCard=!0,this._useTempsInC=!0,this.kREPLACE_WITH_TEMP_UNITS="replace-with-temp-units",this.kMQTT_DAEMON_RELEASE_URL="https://raw.githubusercontent.com/ironsheep/RPi-Reporter-MQTT2HA-Daemon/master/Release",this.latestDaemonVersions=["v1.7.2","v1.6.1"],this.currentDaemonVersion="",this._showDebug=!1,this._cardFullElements={"Storage Use":Nt,Storage:Ot,"Memory Use":zt,Temperature:Vt,"Up-time":Pt,Updated:Ft,OS:Ht,Model:"rpi_model",Interfaces:Rt},this._cardFullIconNames={Storage:"sd","Storage Use":"file-percent","Memory Use":"memory",Temperature:"thermometer","Up-time":"clock-check-outline",Updated:"update",OS:"linux",Model:"raspberry-pi",Interfaces:""},this.kClassIdIconFSAvail="ico-fs-percent",this.kClassIdIconFSTotal="ico-fs-total",this.kClassIdIconSysTemp="ico-sys-temp",this.kClassIdIconUptime="ico-up-time",this.kClassIdIconUpdated="ico-last-update",this.kClassIdIconOS="ico-*nix",this.kClassIdIconRPiModel="ico-rpi-model",this.kClassIdIconInterfaces="ico-rpi-ifaces",this.kClassIdIconMemoryUsage="ico-memory-percent",this.kClassIdFSAvail="fs-percent",this.kClassIdFSTotal="fs-total",this.kClassIdSysTemp="sys-temp",this.kClassIdUptime="up-time",this.kClassIdUpdated="last-update",this.kClassIdOS="*nix",this.kClassIdRPiModel="rpi-model",this.kClassIdInterfaces="rpi-ifaces",this.kClassIdMemoryUsage="memory-percent",this.kClassIdTempScale="sys-temp-scale",this._cardFullCssIDs={"Storage Use":this.kClassIdFSAvail,Storage:this.kClassIdFSTotal,"Memory Use":this.kClassIdMemoryUsage,Temperature:this.kClassIdSysTemp,"Up-time":this.kClassIdUptime,Updated:this.kClassIdUpdated,OS:this.kClassIdOS,Model:this.kClassIdRPiModel,Interfaces:this.kClassIdInterfaces},this._cardFullIconCssIDs={"Storage Use":this.kClassIdIconFSAvail,Storage:this.kClassIdIconFSTotal,"Memory Use":this.kClassIdIconMemoryUsage,"Up-time":this.kClassIdIconUptime,Updated:this.kClassIdIconUpdated,Temperature:this.kClassIdIconSysTemp,OS:this.kClassIdIconOS,Model:this.kClassIdIconRPiModel,Interfaces:this.kClassIdIconInterfaces},this._cardGlanceElements={"%":Nt,GB:Ot,Mem:zt,"replace-with-temp-units":Vt,UpTime:Pt,Upd:Ft},this._cardGlanceIconNames={"%":"file-percent",GB:"sd",Mem:"memory","replace-with-temp-units":"thermometer",UpTime:"clock-check-outline",Upd:"update"},this._cardGlanceCssIDs={"%":this.kClassIdFSAvail,GB:this.kClassIdFSTotal,Mem:this.kClassIdMemoryUsage,"replace-with-temp-units":this.kClassIdSysTemp,UpTime:this.kClassIdUptime,Upd:this.kClassIdUpdated},this._cardGlanceIconCssIDs={"%":this.kClassIdIconFSAvail,GB:this.kClassIdIconFSTotal,Mem:this.kClassIdIconMemoryUsage,"replace-with-temp-units":this.kClassIdIconSysTemp,UpTime:this.kClassIdIconUptime,Upd:this.kClassIdIconUpdated},this._circleIconsValueByName={"circle-outline":0,"circle-slice-1":13,"circle-slice-2":25,"circle-slice-3":38,"circle-slice-4":50,"circle-slice-5":63,"circle-slice-6":75,"circle-slice-7":88,"circle-slice-8":100},this._colorUsedSpaceDefault=[{color:"default",from:0,to:59},{color:"yellow",from:60,to:84},{color:"red",from:85,to:100}],this._colorTemperatureDefault=[{color:"default",from:0,to:59},{color:"yellow",from:60,to:79},{color:"red",from:85,to:100}],this._colorReportPeriodsAgoDefault=[{color:"default",from:0,to:3},{color:"orange",from:4,to:5},{color:"red",from:6,to:100}],this._colorUsedMemoryDefault=[{color:"red",from:75,to:100},{color:"yellow",from:61,to:74},{color:"default",from:0,to:60}],this._colorReleaseDefault=[{color:"red",os:"stretch"},{color:"red",os:"jessie"},{color:"red",os:"wheezy"}]}static async getConfigElement(){return console.log("- getConfigElement()"),document.createElement("rpi-monitor-card-editor")}static getStubConfig(){return{}}setConfig(t){if(null!=t.show_debug&&(this._showDebug=t.show_debug||this._showDebug),this._showDebug&&console.log("- setConfig()"),!t||t.show_error)throw new Error(Jt("common.invalid_configuration"));if(null!=t.card_style){const e=t.card_style.toLocaleLowerCase();if("full"!=e&&"glance"!=e)throw console.log("Invalid configuration. INVALID card_style = ["+t.card_style+"]"),new Error("Illegal card_style: value (card_style: "+t.card_style+") must be [full or glance]");this._showFullCard="full"===t.card_style.toLocaleLowerCase()}if(null!=t.temp_scale){const e=t.temp_scale.toLocaleLowerCase();if("c"!=e&&"f"!=e)throw console.log("Invalid configuration. INVALID temp_scale = ["+t.temp_scale+"]"),new Error("Illegal temp_scale: value (temp_scale: "+t.temp_scale+") must be [F or C]");this._useTempsInC="c"===t.temp_scale.toLocaleLowerCase()}if(!t.entity)throw console.log("Invalid configuration. If no entity provided, you'll need to provide a remote entity"),new Error("You need to associate an entity");t.test_gui&&function(){var t=document.querySelector("home-assistant");if(t=(t=(t=(t=(t=(t=(t=(t=t&&t.shadowRoot)&&t.querySelector("home-assistant-main"))&&t.shadowRoot)&&t.querySelector("app-drawer-layout partial-panel-resolver"))&&t.shadowRoot||t)&&t.querySelector("ha-panel-lovelace"))&&t.shadowRoot)&&t.querySelector("hui-root")){var e=t.lovelace;return e.current_view=t.___curView,e}return null}().setEditMode(!0),this._config=Object.assign({},t),console.log("- config=["+this._config+"]"),this._configEntityId=null!=this._config.entity?this._config.entity:void 0,this._updateSensorAvailability()}shouldUpdate(t){if(0==this._hostname.length||this._hostname==this._configEntityId){const t=this._getAttributeValueForKey("host_name");t&&t.length>0?this._hostname=t:this._hostname=this._configEntityId?this._configEntityId:"-not-set-"}let e=!0;if(this._updateSensorAvailability(),t.has("_config"))e=!0;else if(this.hass&&this._config){const i=t.get("hass");i&&this._configEntityId&&(e=i.states[this._configEntityId]!==this.hass.states[this._configEntityId])}return e}render(){if(this._showDebug&&console.log("- render("+this._hostname+")"),this._config.show_warning)return this.showWarning(Jt("common.show_warning"));if(this._config.show_error)return this.showError(Jt("common.show_error"));if(this._configEntityId&&!this._sensorAvailable){const t="Entity Unavailable: "+this._configEntityId;return this.showWarning(t)}const t=this._configEntityId?this.hass.states[this._configEntityId]:void 0;if(!this._configEntityId&&!t)return this.showWarning("Entity Unavailable");if(0==this._sensorAvailable)return void console.log("?? Render w/o sensor!! ("+this._hostname+")");let e=F``;this._firstTime&&(this._showDebug&&console.log("- stateObj: ["+t+"]"),this._startCardRefreshTimer(),this._showDebug&&console.log("- 1st-time _config: ["+this._config+"]"),this._firstTime=!1);const i=null==this._config.show_os_age||this._config.show_os_age,o=null==this._config.show_update_age||this._config.show_update_age,s=null==this._config.show_daemon_upd||this._config.show_daemon_upd,n=null==this._config.show_title||this._config.show_title;if(s){const t=this._getAttributeValueForKey("reporter").split(" ");this.currentDaemonVersion=t.length>1?t[1]:"";const e=this._getAttributeValueForKey("reporter_releases");if(e&&e.length>0&&"NOT-LOADED"!=e){const t=e.split(",");this.latestDaemonVersions=t}}const r=this._getAttributeValueForKey("fqdn"),a=1==i?this._getAttributeValueForKey(Mt):"",l=s?this._computeDaemonUpdMessage(this.currentDaemonVersion):"",c=1==o?this._cardUpdateString:"";let h="RPi monitor "+r;h=null!=this._config.name_prefix?this._config.name_prefix+" "+r:h,h=null!=this._config.name?this._config.name:h,0==n&&(h="");const d=0==n?"last-heard-full-notitle":"last-heard-full",u=0==n?"last-heard-notitle":"last-heard",p=0==n?"os-name-full-notitle":"os-name-full",m=0==n?"os-name-notitle":"os-name",_=0==n?"daemon-update-full-notitle":"daemon-update-full",f=0==n?"daemon-update-notitle":"daemon-update";if(this._showFullCard){const t=this._generateFullsizeCardRows();if(0==t.length||!t)return void console.log("ERROR: failed to generate full rows!");e=F` @@ -197,14 +183,14 @@ const et=t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e) ${t}
${c}
${a}
-
${l}
+
${l}
- `:void console.log("ERROR: failed to generate full rows!")}{const t=this._generateGlanceCardRows();return 0!=t.length&&t?P` + `}else{const t=this._generateGlanceCardRows();if(0==t.length||!t)return void console.log("ERROR: failed to generate glance rows!");e=F` @@ -212,10 +198,10 @@ const et=t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e) ${t}
${c}
${a}
-
${l}
+
${l}
- `:void console.log("ERROR: failed to generate glance rows!")}}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),this._showDebug()&&console.log("TIMER: ("+this._hostname+") started")}_stopCardRefreshTimer(){null!=this._updateTimerID&&(clearInterval(this._updateTimerID),this._updateTimerID=void 0,this._showDebug()&&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}_calculateDaemonUpdMessage(t){let e="";return this._showDebug()&&(console.log("- RNDR currentDaemonVersion=["+t+"]"),console.log("- RNDR latestDaemonVersions=["+this.latestDaemonVersions+"]")),this.latestDaemonVersions.length>0&&""!=t?this.currentDaemonVersion!=this.latestDaemonVersions[0]&&(e=t+" -- ("+this.latestDaemonVersions[0]+" avail.)"):e=""!=this.currentDaemonVersion?t+" {no info avail.}":"v?.?.? {no info avail.}",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._formatTimeAgo(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]}_formatTimeAgo(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}_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${t} `}showError(t){const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t,origConfig:this._config}),F` ${e} `}_startCardRefreshTimer(){this._updateTimerID=setInterval((()=>this._handleCardUpdateTimerExpiration()),1e3),this._showDebug&&console.log("TIMER: ("+this._hostname+") started")}_stopCardRefreshTimer(){null!=this._updateTimerID&&(clearInterval(this._updateTimerID),this._updateTimerID=void 0,this._showDebug&&console.log("TIMER: ("+this._hostname+") STOPPED"))}_handleCardUpdateTimerExpiration(){const[t,e]=this._getRelativeTimeSinceUpdate();if(t&&t.length>0){let i=t;t.includes("NaN")&&(console.log(" HCUTE (DBG) ("+this._hostname+") card_timestamp_value=["+t+"]"),i="{bad value}"),this._cardUpdateString!=i&&(this._cardUpdateString=i),this._cardSecondsSinceUpdate!=e&&(this._cardSecondsSinceUpdate=e)}}_logChangeMessage(t){const e="("+this._hostname+"): "+t;this._showDebug&&console.log(e)}_updateSensorAvailability(){let t=!1;if(this.hass&&this._config){const e=this._configEntityId?this.hass.states[this._configEntityId]:void 0;if(this._configEntityId||e){if(this._configEntityId)try{const e="unavailable"!=this.hass.states[this._configEntityId].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)}_computeDaemonUpdMessage(t){let e="";return this._showDebug&&(console.log("- RNDR currentDaemonVersion=["+t+"]"),console.log("- RNDR latestDaemonVersions=["+this.latestDaemonVersions+"]")),this.latestDaemonVersions.length>0&&""!=t?t!=this.latestDaemonVersions[0]&&(e=t+" ---\x3e "+this.latestDaemonVersions[0]):e=""!=this.currentDaemonVersion?"{no info avail.}":"v?.?.? {no info avail.}",e}_getRelativeTimeSinceUpdate(){var t;const e=this._configEntityId?this.hass.states[this._configEntityId]:void 0;let i="",o=0,s="";if(this.hass.locale&&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._formatTimeAgo(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]}_formatTimeAgo(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 min ago":i<3600?a=Math.floor(i/60)+" mins ago":i<7200?a="1 hr ago":i<86400&&(a=Math.floor(i/3600)+" hrs ago"):1==o?a="Yesterday":o<7?a=o+" days ago":o<31&&(a=Math.ceil(o/7)+" wks ago"),a}_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)?"orange":"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
@@ -225,7 +211,7 @@ const et=t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e)
${o}
- `)}return t}_generateGlanceCardRows(){const t=[];for(const e in this._cardGlanceElements){const i=this._cardGlanceElements[e],o=this._getGlanceCardValueForAttributeKey(i);let s=e;s==this.kREPLACE_WITH_TEMP_UNITS&&(s="n/a"!=o?this._getTemperatureScale():""),i==Lt&&(s="% Mem");let n=this._cardGlanceIconNames[e];i==Nt&&(n=this._getIconNameForPercent(o));const r=this._cardGlanceCssIDs[e],a=this._cardGlanceIconCssIDs[e];let l="units";i==Vt&&(l=this.kClassIdTempScale),t.push(P` + `)}return t}_generateGlanceCardRows(){const t=[];for(const e in this._cardGlanceElements){const i=this._cardGlanceElements[e],o=this._getGlanceCardValueForAttributeKey(i);let s=e;s==this.kREPLACE_WITH_TEMP_UNITS&&(s="n/a"!=o?this._getTemperatureScale():""),i==zt&&(s="% Mem");let n=this._cardGlanceIconNames[e];i==Nt&&(n=this._getIconNameForPercent(o));const r=this._cardGlanceCssIDs[e],a=this._cardGlanceIconCssIDs[e];let l="units";i==Vt&&(l=this.kClassIdTempScale),t.push(F`
@@ -233,7 +219,7 @@ const et=t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e)
${o}
${s}
- `)}return t}_getTemperatureScale(){return 1==this._useTempsInC()?"ºC":"ºF"}_getScaledTemperatureValue(t){let e=t;return"n/a"!=e&&0==this._useTempsInC()&&(e=(9*parseFloat(t)/5+32).toFixed(1)),e}_getFullCardValueForAttributeKey(t){const e=this._getAttributeValueForKey(t);let i=e;if(t==Lt)i=this._getPercentMemoryUsed()+" %";else if(t==Pt)i=this._getUIDateForTimestamp(e);else if(t==Vt){if(i=this._getScaledTemperatureValue(e),"n/a"!=i){i=i+" "+this._getTemperatureScale()}}else if(t==Ot)i=e+" GB";else if(t==Nt)i=e+" %";else if(t==Ft)i=this._filterUptime(i);else if(t==Ht){i=this._getAttributeValueForKey(Mt)+" v"+this._getAttributeValueForKey("ux_version")}else if(t==Rt){const t=[];e.includes("e")&&t.push("Ether"),e.includes("w")&&t.push("WiFi"),e.includes("b")&&t.push("Bluetooth"),i=t.join(", ")}return i}_getGlanceCardValueForAttributeKey(t){const e=this._getAttributeValueForKey(t);let i=e;return t==Lt?i=this._getPercentMemoryUsed():t==Pt?i=this._getUIDateForTimestamp(e):t==Vt?i=this._getScaledTemperatureValue(e):t==Ft&&(i=this._filterUptime(i)),i}_getUIDateForTimestamp(t){return new Date(t).toLocaleDateString("en-us")}_getPercentMemoryUsed(){const t=this._getAttributeValueForKey("memory"),e=t.size_mb,i=t.free_mb,o=Number(e);return((e-Number(i))/o*100).toFixed(0).toString()}_showDebug(){let t=this._show_debug;return this._config&&null!=this._config.show_debug&&(t=1==t||1==this._config.show_debug),t}static get styles(){return r` + `)}return t}_getTemperatureScale(){return 1==this._useTempsInC?"ºC":"ºF"}_getScaledTemperatureValue(t){let e=t;return"n/a"!=e&&0==this._useTempsInC&&(e=(9*parseFloat(t)/5+32).toFixed(1)),e}_getFullCardValueForAttributeKey(t){const e=this._getAttributeValueForKey(t);let i=e;if(t==zt)i=this._getPercentMemoryUsed()+" %";else if(t==Ft)i=this._getUIDateForTimestamp(e);else if(t==Vt){if(i=this._getScaledTemperatureValue(e),"n/a"!=i){i=i+" "+this._getTemperatureScale()}}else if(t==Ot)i=e+" GB";else if(t==Nt)i=e+" %";else if(t==Pt)i=this._filterUptime(i);else if(t==Ht){i=this._getAttributeValueForKey(Mt)+" v"+this._getAttributeValueForKey("ux_version")}else if(t==Rt){const t=[];e.includes("e")&&t.push("Ether"),e.includes("w")&&t.push("WiFi"),e.includes("b")&&t.push("Bluetooth"),i=t.join(", ")}return i}_getGlanceCardValueForAttributeKey(t){const e=this._getAttributeValueForKey(t);let i=e;return t==zt?i=this._getPercentMemoryUsed():t==Ft?i=this._getUIDateForTimestamp(e):t==Vt?i=this._getScaledTemperatureValue(e):t==Pt&&(i=this._filterUptime(i)),i}_getUIDateForTimestamp(t){return new Date(t).toLocaleDateString("en-us")}_getPercentMemoryUsed(){const t=this._getAttributeValueForKey("memory"),e=t.size_mb,i=t.free_mb,o=Number(e);return((e-Number(i))/o*100).toFixed(0).toString()}static get styles(){return r` ha-card { height: 100%; display: flex; @@ -301,6 +287,9 @@ const et=t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e) justify-content: space-between; padding: 16px 32px 24px 32px; } + .content { + text-align: center; + } .attributes { cursor: pointer; } @@ -320,85 +309,85 @@ const et=t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e) .last-heard-full { position: absolute; top: 45px; - right: 30px; + right: 5%; font-size: 12px; color: var(--primary-text-color); } .last-heard { position: absolute; top: 55px; - right: 30px; + right: 5%; font-size: 12px; color: var(--primary-text-color); } .last-heard-full-notitle { position: absolute; top: 3px; - right: 30px; + right: 5%; font-size: 12px; color: var(--primary-text-color); } .last-heard-notitle { position: absolute; bottom: 5px; - right: 90px; + right: 15%; font-size: 12px; color: var(--primary-text-color); } .os-name-full { position: absolute; top: 45px; - left: 30px; + left: 5%; font-size: 12px; color: var(--primary-text-color); } .os-name { position: absolute; top: 55px; - left: 30px; + left: 5%; font-size: 12px; color: var(--primary-text-color); } .os-name-full-notitle { position: absolute; top: 3px; - left: 30px; + left: 5%; font-size: 12px; color: var(--primary-text-color); } .os-name-notitle { position: absolute; bottom: 5px; - left: 90px; + left: 15%; font-size: 12px; color: var(--primary-text-color); } .daemon-update-full { position: absolute; top: 45px; - right: 150px; + right: 27%; font-size: 12px; color: var(--primary-text-color); } .daemon-update { position: absolute; top: 55px; - right: 150px; + right: 27%; font-size: 12px; color: var(--primary-text-color); } .daemon-update-full-notitle { position: absolute; top: 3px; - right: 150px; + right: 27%; font-size: 12px; color: var(--primary-text-color); } .daemon-update-notitle { position: absolute; bottom: 5px; - right: 210px; + right: 37%; font-size: 12px; color: var(--primary-text-color); } - `}};t([ot({attribute:!1})],Jt.prototype,"hass",void 0),t([st()],Jt.prototype,"_config",void 0),t([st()],Jt.prototype,"_cardSecondsSinceUpdate",void 0),t([st()],Jt.prototype,"_cardUpdateString",void 0),Jt=t([et("rpi-monitor-card")],Jt);export{Jt as RPiMonitorCard}; + `}};t([ot({attribute:!1})],Qt.prototype,"hass",void 0),t([st()],Qt.prototype,"_config",void 0),t([st()],Qt.prototype,"_cardSecondsSinceUpdate",void 0),t([st()],Qt.prototype,"_cardUpdateString",void 0),Qt=t([et("rpi-monitor-card")],Qt);export{Qt as RPiMonitorCard}; diff --git a/rollup.config.dev.js b/rollup.config.dev.js index e1b43f0..07e8b9d 100644 --- a/rollup.config.dev.js +++ b/rollup.config.dev.js @@ -2,7 +2,7 @@ import resolve from '@rollup/plugin-node-resolve'; import typescript from 'rollup-plugin-typescript2'; import babel from '@rollup/plugin-babel'; import serve from 'rollup-plugin-serve'; -import { terser } from 'rollup-plugin-terser'; +//import { terser } from 'rollup-plugin-terser'; import json from '@rollup/plugin-json'; export default { @@ -19,7 +19,7 @@ export default { exclude: 'node_modules/**', babelHelpers: 'runtime', }), - terser(), + // terser(), serve({ contentBase: './dist', host: '0.0.0.0', diff --git a/src/action-handler-directive.ts b/src/action-handler-directive.ts index 92970af..c54c0b5 100644 --- a/src/action-handler-directive.ts +++ b/src/action-handler-directive.ts @@ -192,7 +192,7 @@ export const actionHandler = directive( return noChange; } - // eslint-disable-next-line @typescript-eslint/no-empty-function + // eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-unused-vars render(_options?: ActionHandlerOptions) {} }, ); diff --git a/src/const.ts b/src/const.ts index 606ab8d..62531e5 100644 --- a/src/const.ts +++ b/src/const.ts @@ -48,6 +48,7 @@ export const CARD_VERSION = '1.3.1'; "temp_gpu_c": 40.1, "temp_cpu_c": 40.1, "reporter": "ISP-RPi-mqtt-daemon v1.5.4", + "reporter_releases": "v1.7.2,v1.6.2", "report_interval": 5 } }*/ @@ -68,6 +69,7 @@ export const RPI_FS_USED_PERCENT_KEY = 'fs_free_prcnt'; export const RPI_NETWORKING_KEY = 'networking'; export const RPI_TEMPERATURE_IN_C_KEY = 'temperature_c'; export const RPI_SCRIPT_VER_KEY = 'reporter'; +export const RPI_SCRIPT_RELEASE_LIST = 'reporter_releases'; export const RPI_SCRIPT_INTERVAL_KEY = 'report_interval'; export const SHOW_OS_PARTS_VALUE = 'show-os-parts'; diff --git a/src/rpi-monitor-card.ts b/src/rpi-monitor-card.ts index 35248ee..e03a0d5 100644 --- a/src/rpi-monitor-card.ts +++ b/src/rpi-monitor-card.ts @@ -42,6 +42,7 @@ console.info( @customElement('rpi-monitor-card') export class RPiMonitorCard extends LitElement { public static async getConfigElement(): Promise { + console.log('- getConfigElement()'); return document.createElement('rpi-monitor-card-editor') as LovelaceCardEditor; } @@ -60,15 +61,18 @@ export class RPiMonitorCard extends LitElement { // and those that don't cause a re-render private _firstTime: boolean = true; private _sensorAvailable: boolean = false; - private _updateTimerID: NodeJS.Timeout | undefined; + private _updateTimerID: NodeJS.Timeout | undefined = undefined; + private _configEntityId: string | undefined = undefined; private _hostname: string = ''; + private _showFullCard: boolean = true; + private _useTempsInC: boolean = true; private kREPLACE_WITH_TEMP_UNITS: string = 'replace-with-temp-units'; private kMQTT_DAEMON_RELEASE_URL: string = 'https://raw.githubusercontent.com/ironsheep/RPi-Reporter-MQTT2HA-Daemon/master/Release'; - private latestDaemonVersions: string[] = ['v1.6.1', 'v1.6.0']; // REMOVE BEFORE FLIGHT (TEST DATA) + private latestDaemonVersions: string[] = ['v1.7.2', 'v1.6.1']; // REMOVE BEFORE FLIGHT (TEST DATA) private currentDaemonVersion: string = ''; // WARNING set following to false before commit! - private _show_debug: boolean = false; // REMOVE BEFORE FLIGHT (set to false!) + private _showDebug: boolean = false; // REMOVE BEFORE FLIGHT (!set to false before check-in!) // // FULL-SIZE CARD tables @@ -258,13 +262,13 @@ export class RPiMonitorCard extends LitElement { to: 3, }, { - color: 'yellow', + color: 'orange', from: 4, - to: 4, + to: 5, }, { color: 'red', - from: 5, + from: 6, to: 100, }, ]; @@ -318,7 +322,14 @@ export class RPiMonitorCard extends LitElement { ]; public setConfig(config: RPiMonitorCardConfig): void { - if (this._showDebug()) { + //console.log('- setConfig() - ENTRY'); + + // use user debug flag or override with internal flag if set + if (config.show_debug != undefined) { + this._showDebug = config.show_debug || this._showDebug; + } + + if (this._showDebug) { console.log('- setConfig()'); } // Optional: Check for required fields and that they are of the proper format @@ -332,6 +343,7 @@ export class RPiMonitorCard extends LitElement { console.log('Invalid configuration. INVALID card_style = [' + config.card_style + ']'); throw new Error('Illegal card_style: value (card_style: ' + config.card_style + ') must be [full or glance]'); } + this._showFullCard = config.card_style.toLocaleLowerCase() === 'full' ? true : false; } if (config.temp_scale != undefined) { @@ -340,6 +352,7 @@ export class RPiMonitorCard extends LitElement { console.log('Invalid configuration. INVALID temp_scale = [' + config.temp_scale + ']'); throw new Error('Illegal temp_scale: value (temp_scale: ' + config.temp_scale + ') must be [F or C]'); } + this._useTempsInC = config.temp_scale.toLocaleLowerCase() === 'c' ? true : false; } if (!config.entity) { @@ -352,59 +365,58 @@ export class RPiMonitorCard extends LitElement { } this._config = { + //name: 'RPi Monitor', (causes name overwrite, don't do this!!!) ...config, }; console.log('- config=[' + this._config + ']'); + this._configEntityId = this._config.entity != undefined ? this._config.entity : undefined; + this._updateSensorAvailability(); // request the release info from the DAEMON repository //this.loadDaemonReleases(); + //console.log('- setConfig() - EXIT'); } - private async loadDaemonReleases(): Promise { - this.latestDaemonVersions = await fetch(this.kMQTT_DAEMON_RELEASE_URL).then((response) => response.text().then(this._loadDaemonReleaseInfo)); - console.log('LDR (' + this._hostname + ') latestDaemonVersions=[' + this.latestDaemonVersions + '](' + this.latestDaemonVersions.length + ')'); - } - - /* - public getCardSize(): number { - // adjust this based on glance or full card type - return this._useFullCard() == true ? 3 : 1; - } - */ - - // https://lit.dev/docs/components/lifecycle/#reactive-update-cycle-performing protected shouldUpdate(changedProps: PropertyValues): boolean { + // https://lit.dev/docs/components/lifecycle/#reactive-update-cycle-performing //return hasConfigOrEntityChanged(this, changedProps, false); - //console.log('shouldUpdate(' + this._hostname + ') changedProps= [' + changedProps.keys() + ']'); + if (this._hostname.length == 0 || this._hostname == this._configEntityId) { + const tempHostname: string = this._getAttributeValueForKey(Constants.RPI_HOST_NAME_KEY); + if (tempHostname && tempHostname.length > 0) { + this._hostname = tempHostname; + } else { + this._hostname = this._configEntityId ? this._configEntityId : '-not-set-'; + } + } + //console.log('----- shouldUpdate(' + this._hostname + ') - ENTRY'); + let bShouldStatus: boolean = true; this._updateSensorAvailability(); if (changedProps.has('_config')) { //console.log('shouldUpdate(' + this._hostname + ') = [' + true + '] - CONFIG'); - return true; - } - - if (this.hass && this._config) { + bShouldStatus = true; + } else if (this.hass && this._config) { const oldHass = changedProps.get('hass') as HomeAssistant | undefined; - if (oldHass && this._config.entity) { - const bShouldStatus: boolean = oldHass.states[this._config.entity] !== this.hass.states[this._config.entity]; + if (oldHass && this._configEntityId) { + bShouldStatus = oldHass.states[this._configEntityId] !== this.hass.states[this._configEntityId]; //console.log('shouldUpdate(' + this._hostname + ') = [' + bShouldStatus + '] HASS'); - return bShouldStatus; } } //console.log('shouldUpdate(' + this._hostname + ') = [' + true + '] other'); - return true; + //console.log('----- shouldUpdate(' + this._hostname + ') - EXIT'); + return bShouldStatus; } // https://lit.dev/docs/components/rendering/ protected render(): TemplateResult | void { // Check for stateObj or other necessary things and render a warning if missing - if (this._showDebug()) { + if (this._showDebug) { console.log('- render(' + this._hostname + ')'); } if (this._config.show_warning) { @@ -415,16 +427,14 @@ export class RPiMonitorCard extends LitElement { return this.showError(localize('common.show_error')); } - const entityId = this._config.entity ? this._config.entity : undefined; - - if (entityId && !this._sensorAvailable) { - const warningMessage = 'Entity Unavailable: ' + entityId; + if (this._configEntityId && !this._sensorAvailable) { + const warningMessage = 'Entity Unavailable: ' + this._configEntityId; return this.showWarning(warningMessage); } - const stateObj = this._config.entity ? this.hass.states[this._config.entity] : undefined; + const stateObj = this._configEntityId ? this.hass.states[this._configEntityId] : undefined; - if (!entityId && !stateObj) { + if (!this._configEntityId && !stateObj) { return this.showWarning('Entity Unavailable'); } @@ -434,21 +444,19 @@ export class RPiMonitorCard extends LitElement { return; } + let cardHtml: TemplateResult = html``; + //console.log('----- render(' + this._hostname + ') - ENTRY'); + if (this._firstTime) { - if (this._showDebug()) { + if (this._showDebug) { console.log('- stateObj: [' + stateObj + ']'); } - const reporter_version: string = this._getAttributeValueForKey(Constants.RPI_SCRIPT_VER_KEY); - const reportParts: string[] = reporter_version.split(' '); - this.currentDaemonVersion = reportParts.length > 1 ? reportParts[1] : ''; - //console.log('- 1st-time currentDaemonVersion=[' + this.currentDaemonVersion + ']'); - // set timer so our card updates timestamp every 5 seconds : 5000 (1 second: 1000) // FIXME: UNDONE remember to clear this interval when entity NOT avail. and restore when comes avail again... this._startCardRefreshTimer(); - if (this._showDebug()) { + if (this._showDebug) { console.log('- 1st-time _config: [' + this._config + ']'); } this._firstTime = false; @@ -461,11 +469,28 @@ export class RPiMonitorCard extends LitElement { const showDaemonUpdNeed = this._config.show_daemon_upd != undefined ? this._config.show_daemon_upd : true; const showCardName = this._config.show_title != undefined ? this._config.show_title : true; + if (showDaemonUpdNeed) { + // get Daemon current version + const reporter_version: string = this._getAttributeValueForKey(Constants.RPI_SCRIPT_VER_KEY); + const reportParts: string[] = reporter_version.split(' '); + this.currentDaemonVersion = reportParts.length > 1 ? reportParts[1] : ''; + //console.log('- 1st-time currentDaemonVersion=[' + this.currentDaemonVersion + ']'); + + // get version list from Daemon (if provided) + const reporter_version_set: string = this._getAttributeValueForKey(Constants.RPI_SCRIPT_RELEASE_LIST); + if (reporter_version_set && reporter_version_set.length > 0 && reporter_version_set != 'NOT-LOADED') { + // parse set into list of versions then replace our built-in set + const newVersions: string[] = reporter_version_set.split(','); + this.latestDaemonVersions = newVersions; + } + } + const rpi_fqdn: string = this._getAttributeValueForKey(Constants.RPI_FQDN_KEY); const ux_release: string = showOsAge == true ? this._getAttributeValueForKey(Constants.RPI_NIX_RELEASE_KEY) : ''; - const daemon_update_status: string = showDaemonUpdNeed ? this._calculateDaemonUpdMessage(this.currentDaemonVersion) : ''; - const card_timestamp = showCardAge == true ? this._cardUpdateString : ''; + const daemon_update_status: string = showDaemonUpdNeed ? this._computeDaemonUpdMessage(this.currentDaemonVersion) : ''; + const card_timestamp: string = showCardAge == true ? this._cardUpdateString : ''; + //const card_timestamp: string = '{bad value}'; let cardName: string = 'RPi monitor ' + rpi_fqdn; cardName = this._config.name_prefix != undefined ? this._config.name_prefix + ' ' + rpi_fqdn : cardName; @@ -484,7 +509,7 @@ export class RPiMonitorCard extends LitElement { const daemon_update_full_class = showCardName == false ? 'daemon-update-full-notitle' : 'daemon-update-full'; const daemon_update_class = showCardName == false ? 'daemon-update-notitle' : 'daemon-update'; - if (this._useFullCard()) { + if (this._showFullCard) { // our FULL card const fullRows = this._generateFullsizeCardRows(); if (fullRows.length == 0 || !fullRows) { @@ -492,7 +517,7 @@ export class RPiMonitorCard extends LitElement { return; } - return html` + cardHtml = html` `; } + //console.log('----- render(' + this._hostname + ') - EXIT'); + return cardHtml; } - // Here we need to refresh the rings and titles after it has been initially rendered + // Here we need to refresh the values after card has been initially rendered protected updated(changedProps: PropertyValues): void { - if (this._showDebug()) { + //console.log('----- updated(' + this._hostname + ') - ENTRY'); + if (this._showDebug) { console.log('- updated(' + this._hostname + ')'); } - if (!this._config) { - return; - } - - // update cards' theme if changed - if (this.hass) { - const oldHass = changedProps.get('hass') as HomeAssistant; - if (!oldHass || (oldHass && oldHass.themes !== this.hass.themes)) { - applyThemesOnElement(this, this.hass.themes, this._config.theme); + if (this._config) { + // update cards' theme if changed + if (this.hass) { + const oldHass = changedProps.get('hass') as HomeAssistant; + if (!oldHass || (oldHass && oldHass.themes !== this.hass.themes)) { + applyThemesOnElement(this, this.hass.themes, this._config.theme); + } } - } - if (this.hass && this._config.entity) { - const stateObj = this.hass.states[this._config.entity]; - if (!stateObj) { - this._stopCardRefreshTimer(); + if (this.hass && this._configEntityId) { + const stateObj = this.hass.states[this._configEntityId]; + if (!stateObj) { + this._stopCardRefreshTimer(); + } } - } - //console.log('- changed Props: [' + changedProps + ']'); + //console.log('- changed Props: [' + changedProps + ']'); - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const root: any = this.shadowRoot; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const root: any = this.shadowRoot; - if (this._sensorAvailable) { - // update common label(s) - const ux_release: string = this._getAttributeValueForKey(Constants.RPI_NIX_RELEASE_KEY); - const rlsNameColor = this._computeOsReleaseColor(ux_release); - if (rlsNameColor != '') { - const labelElement = root.getElementById('os-name'); - labelElement.style.setProperty('color', rlsNameColor); - } + if (this._sensorAvailable) { + // update common label(s) + const ux_release: string = this._getAttributeValueForKey(Constants.RPI_NIX_RELEASE_KEY); + const rlsNameColor = this._computeOsReleaseColor(ux_release); + if (rlsNameColor != '') { + const labelElement = root.getElementById('os-name'); + labelElement.style.setProperty('color', rlsNameColor); + } - // apply color if RPi daemon should be updated - const daemonUpdColor = this._computeDaemonUpdateVersionColor(this.currentDaemonVersion); - if (daemonUpdColor != '') { - const labelElement = root.getElementById('daemon-update'); - labelElement.style.setProperty('color', daemonUpdColor); - } + // apply color if RPi daemon should be updated + const daemonUpdColor = this._computeDaemonUpdateVersionColor(this.currentDaemonVersion); + if (daemonUpdColor != '') { + const labelElement = root.getElementById('daemon-update'); + labelElement.style.setProperty('color', daemonUpdColor); + } - // now apply color if our entry is OLD - const intervalColor = this._computeReporterAgeColor(this._cardSecondsSinceUpdate); - if (intervalColor != '' && intervalColor != undefined) { - const labelElement = root.getElementById('card-timestamp'); - labelElement.style.setProperty('color', intervalColor); - } + // now apply color if our entry is OLD + const intervalColor = this._computeReporterAgeColor(this._cardSecondsSinceUpdate); + if (intervalColor != '' && intervalColor != undefined) { + const labelElement = root.getElementById('card-timestamp'); + labelElement.style.setProperty('color', intervalColor); + } - if (this._useFullCard()) { - // update our FULL card - for (const currName in this._cardFullCssIDs) { - const currLabelID = this._cardFullCssIDs[currName]; - const currAttrKey = this._cardFullElements[currName]; - const rawValue = this._getAttributeValueForKey(currAttrKey); - const latestValue = this._getFullCardValueForAttributeKey(currAttrKey); - // if (currAttrKey == Constants.RPI_MEMORY_USED_PERCENT_KEY) { - // console.log('- FULL memory latestValue=[' + latestValue + ']'); - // } - const labelElement = root.getElementById(currLabelID); - labelElement.textContent = latestValue; - const currIconCssID = this._cardFullIconCssIDs[currName]; - const iconElement = root.getElementById(currIconCssID); - if (currAttrKey == Constants.RPI_FS_USED_PERCENT_KEY) { - const color = this._computeFileSystemUsageColor(rawValue); - if (color != '') { - labelElement.style.setProperty('color', color); - iconElement.style.setProperty('color', color); - } - } - if (currAttrKey == Constants.RPI_MEMORY_USED_PERCENT_KEY) { - const color = this._computeMemoryUsageColor(latestValue.replace(' %', '')); - if (color != '') { - labelElement.style.setProperty('color', color); - iconElement.style.setProperty('color', color); + if (this._showFullCard) { + // update our FULL card + for (const currName in this._cardFullCssIDs) { + const currLabelID = this._cardFullCssIDs[currName]; + const currAttrKey = this._cardFullElements[currName]; + const rawValue = this._getAttributeValueForKey(currAttrKey); + const latestValue = this._getFullCardValueForAttributeKey(currAttrKey); + // if (currAttrKey == Constants.RPI_MEMORY_USED_PERCENT_KEY) { + // console.log('- FULL memory latestValue=[' + latestValue + ']'); + // } + const labelElement = root.getElementById(currLabelID); + labelElement.textContent = latestValue; + const currIconCssID = this._cardFullIconCssIDs[currName]; + const iconElement = root.getElementById(currIconCssID); + if (currAttrKey == Constants.RPI_FS_USED_PERCENT_KEY) { + const color = this._computeFileSystemUsageColor(rawValue); + if (color != '') { + labelElement.style.setProperty('color', color); + iconElement.style.setProperty('color', color); + } } - } - if (currAttrKey == Constants.RPI_TEMPERATURE_IN_C_KEY) { - const color = this._computeTemperatureColor(rawValue); - if (color != '') { - labelElement.style.setProperty('color', color); - iconElement.style.setProperty('color', color); + if (currAttrKey == Constants.RPI_MEMORY_USED_PERCENT_KEY) { + const color = this._computeMemoryUsageColor(latestValue.replace(' %', '')); + if (color != '') { + labelElement.style.setProperty('color', color); + iconElement.style.setProperty('color', color); + } } - } - } - } else { - // update our GLANCE card - for (const currName in this._cardGlanceCssIDs) { - const currLabelID = this._cardGlanceCssIDs[currName]; - const currAttrKey = this._cardGlanceElements[currName]; - const rawValue = this._getAttributeValueForKey(currAttrKey); - const latestValue = this._getGlanceCardValueForAttributeKey(currAttrKey); - // if (currAttrKey == Constants.RPI_MEMORY_USED_PERCENT_KEY) { - // console.log('- GLNC memory latestValue=[' + latestValue + ']'); - // } - const labelElement = root.getElementById(currLabelID); - labelElement.textContent = latestValue; - const currIconCssID = this._cardGlanceIconCssIDs[currName]; - const iconElement = root.getElementById(currIconCssID); - if (currAttrKey == Constants.RPI_FS_USED_PERCENT_KEY) { - const color = this._computeFileSystemUsageColor(rawValue); - if (color != '') { - labelElement.style.setProperty('color', color); - iconElement.style.setProperty('color', color); + if (currAttrKey == Constants.RPI_TEMPERATURE_IN_C_KEY) { + const color = this._computeTemperatureColor(rawValue); + if (color != '') { + labelElement.style.setProperty('color', color); + iconElement.style.setProperty('color', color); + } } } - if (currAttrKey == Constants.RPI_MEMORY_USED_PERCENT_KEY) { - const color = this._computeMemoryUsageColor(latestValue); - if (color != '') { - labelElement.style.setProperty('color', color); - iconElement.style.setProperty('color', color); + } else { + // update our GLANCE card + for (const currName in this._cardGlanceCssIDs) { + const currLabelID = this._cardGlanceCssIDs[currName]; + const currAttrKey = this._cardGlanceElements[currName]; + const rawValue = this._getAttributeValueForKey(currAttrKey); + const latestValue = this._getGlanceCardValueForAttributeKey(currAttrKey); + // if (currAttrKey == Constants.RPI_MEMORY_USED_PERCENT_KEY) { + // console.log('- GLNC memory latestValue=[' + latestValue + ']'); + // } + const labelElement = root.getElementById(currLabelID); + labelElement.textContent = latestValue; + const currIconCssID = this._cardGlanceIconCssIDs[currName]; + const iconElement = root.getElementById(currIconCssID); + if (currAttrKey == Constants.RPI_FS_USED_PERCENT_KEY) { + const color = this._computeFileSystemUsageColor(rawValue); + if (color != '') { + labelElement.style.setProperty('color', color); + iconElement.style.setProperty('color', color); + } } - } - if (currAttrKey == Constants.RPI_TEMPERATURE_IN_C_KEY) { - // don't place temp scale (C or F) when 'n/a' - if (latestValue != 'n/a') { - const color = this._computeTemperatureColor(rawValue); + if (currAttrKey == Constants.RPI_MEMORY_USED_PERCENT_KEY) { + const color = this._computeMemoryUsageColor(latestValue); if (color != '') { labelElement.style.setProperty('color', color); iconElement.style.setProperty('color', color); } - const scaleLabelElement = root.getElementById(this.kClassIdTempScale); - scaleLabelElement.textContent = this._getTemperatureScale(); + } + if (currAttrKey == Constants.RPI_TEMPERATURE_IN_C_KEY) { + // don't place temp scale (C or F) when 'n/a' + if (latestValue != 'n/a') { + const color = this._computeTemperatureColor(rawValue); + if (color != '') { + labelElement.style.setProperty('color', color); + iconElement.style.setProperty('color', color); + } + const scaleLabelElement = root.getElementById(this.kClassIdTempScale); + scaleLabelElement.textContent = this._getTemperatureScale(); + } } } } } } + //console.log('----- updated(' + this._hostname + ') - EXIT'); } private _handleAction(ev: ActionHandlerEvent): void { @@ -703,7 +730,7 @@ export class RPiMonitorCard extends LitElement { private _startCardRefreshTimer(): void { this._updateTimerID = setInterval(() => this._handleCardUpdateTimerExpiration(), 1000); - if (this._showDebug()) { + if (this._showDebug) { console.log('TIMER: (' + this._hostname + ') started'); } } @@ -712,7 +739,7 @@ export class RPiMonitorCard extends LitElement { if (this._updateTimerID != undefined) { clearInterval(this._updateTimerID); this._updateTimerID = undefined; - if (this._showDebug()) { + if (this._showDebug) { console.log('TIMER: (' + this._hostname + ') STOPPED'); } } @@ -722,13 +749,10 @@ export class RPiMonitorCard extends LitElement { // // timestamp portion of card // - //console.log('TIMER: (' + this._hostname + ') timeout'); + //console.log('TIMER: (' + this._hostname + ') timeout ENTRY'); const [card_timestamp_value, sinceInMinutes] = this._getRelativeTimeSinceUpdate(); - if (this._cardSecondsSinceUpdate != sinceInMinutes) { - this._cardSecondsSinceUpdate = sinceInMinutes; - } //console.log('-- card_timestamp_value=[' + card_timestamp_value + '] sinceInMinutes=[' + sinceInMinutes + ']'); - if (card_timestamp_value) { + if (card_timestamp_value && card_timestamp_value.length > 0) { let card_timestamp = card_timestamp_value; //console.log(' HCUTE (' + this._hostname + ') card_timestamp_value=[' + card_timestamp_value + ']'); // BUGFIX let's NOT show 'in NaN weeks' message on reload... @@ -736,42 +760,22 @@ export class RPiMonitorCard extends LitElement { console.log(' HCUTE (DBG) (' + this._hostname + ') card_timestamp_value=[' + card_timestamp_value + ']'); //card_timestamp = 'waiting for report...'; //needCardFlush = true; // we have a system bug causing a mis-fire... don't clear the card... - card_timestamp = '{unexpected value}...'; + card_timestamp = '{bad value}'; } + // set properties which should cause our card update if (this._cardUpdateString != card_timestamp) { this._cardUpdateString = card_timestamp; } - } - } - - private _useFullCard(): boolean { - let useFullCardStatus = true; - if (this._config) { - if (this._config.card_style != undefined) { - // NOTE this depends upon full validation of the two legal values [full|glance] above - useFullCardStatus = this._config.card_style.toLocaleLowerCase() == 'full' ? true : false; - } - } - return useFullCardStatus; - } - - private _useTempsInC(): boolean { - let useTempsInCStatus = true; - if (this._config) { - if (this._config.temp_scale != undefined) { - // NOTE this depends upon full validation of the two legal values [full|glance] above - useTempsInCStatus = this._config.temp_scale.toLocaleLowerCase() == 'c' ? true : false; + if (this._cardSecondsSinceUpdate != sinceInMinutes) { + this._cardSecondsSinceUpdate = sinceInMinutes; } } - return useTempsInCStatus; + //console.log('TIMER: (' + this._hostname + ') timeout EXIT'); } private _logChangeMessage(message: string): void { - if (this._hostname == '') { - this._hostname = this._getAttributeValueForKey(Constants.RPI_HOST_NAME_KEY); - } const logMessage = '(' + this._hostname + '): ' + message; - if (this._showDebug()) { + if (this._showDebug) { console.log(logMessage); } } @@ -779,16 +783,15 @@ export class RPiMonitorCard extends LitElement { private _updateSensorAvailability(): void { let availChanged: boolean = false; if (this.hass && this._config) { - const entityId = this._config.entity ? this._config.entity : undefined; - const stateObj = this._config.entity ? this.hass.states[this._config.entity] : undefined; + const stateObj = this._configEntityId ? this.hass.states[this._configEntityId] : undefined; - if (!entityId && !stateObj) { + if (!this._configEntityId && !stateObj) { this._sensorAvailable = false; availChanged = true; // force output in this case } else { - if (this._config.entity) { + if (this._configEntityId) { try { - const tmpAvail = this.hass.states[this._config.entity].state != 'unavailable'; + const tmpAvail = this.hass.states[this._configEntityId].state != 'unavailable'; availChanged = this._sensorAvailable != tmpAvail ? true : false; this._sensorAvailable = tmpAvail; } catch (error) { @@ -806,6 +809,12 @@ export class RPiMonitorCard extends LitElement { } } + /* + private async loadDaemonReleases(): Promise { + this.latestDaemonVersions = await fetch(this.kMQTT_DAEMON_RELEASE_URL).then((response) => response.text().then(this._loadDaemonReleaseInfo)); + console.log('LDR (' + this._hostname + ') latestDaemonVersions=[' + this.latestDaemonVersions + '](' + this.latestDaemonVersions.length + ')'); + } + private _loadDaemonReleaseInfo(retrievedText: string): string[] { //console.log('LDRI retrievedText=[' + retrievedText + ']'); let foundVersions: string[] = []; @@ -831,17 +840,18 @@ export class RPiMonitorCard extends LitElement { //console.log('* foundVersions=[' + foundVersions + ']'); return foundVersions; } + */ - private _calculateDaemonUpdMessage(currentReporterVersion: string): string { + private _computeDaemonUpdMessage(currentReporterVersion: string): string { let updateStatusMessage: string = ''; - if (this._showDebug()) { + if (this._showDebug) { console.log('- RNDR currentDaemonVersion=[' + currentReporterVersion + ']'); console.log('- RNDR latestDaemonVersions=[' + this.latestDaemonVersions + ']'); } if (this.latestDaemonVersions.length > 0 && currentReporterVersion != '') { - if (this.currentDaemonVersion != this.latestDaemonVersions[0]) { + if (currentReporterVersion != this.latestDaemonVersions[0]) { // reporter version is not latest - updateStatusMessage = 'Upd: ' + this.latestDaemonVersions[0]; + updateStatusMessage = currentReporterVersion + ' ---> ' + this.latestDaemonVersions[0]; } } else { if (this.currentDaemonVersion != '') { @@ -854,11 +864,11 @@ export class RPiMonitorCard extends LitElement { } private _getRelativeTimeSinceUpdate(): [string, number] { - const stateObj = this._config.entity ? this.hass.states[this._config.entity] : undefined; + const stateObj = this._configEntityId ? this.hass.states[this._configEntityId] : undefined; let desiredValue: string = ''; let desiredMinutes: number = 0; let minutesValue: string = ''; - if (this.hass.locale != undefined && stateObj != undefined) { + if (this.hass.locale && stateObj) { try { const stateStrInterp = computeStateDisplay(this.hass?.localize, stateObj, this.hass.locale); // console.log('- grtsu card stateStrInterp=[' + stateStrInterp + ']'); @@ -961,7 +971,7 @@ export class RPiMonitorCard extends LitElement { sections.forEach((section) => { if (numberValue >= section.from && numberValue <= section.to) { color = section.color; - if (this._showDebug()) { + if (this._showDebug) { const logMessage = '_computeTemperatureColor() - value=[' + value + '] matched(from=' + section.from + ', to=' + section.to + ', color=' + color + ')'; console.log(logMessage); @@ -969,7 +979,7 @@ export class RPiMonitorCard extends LitElement { } }); } - if (this._showDebug()) { + if (this._showDebug) { const logMessage = '_computeTemperatureColor() - value=[' + value + '] returns(color=' + color + ')'; console.log(logMessage); } @@ -991,7 +1001,7 @@ export class RPiMonitorCard extends LitElement { sections.forEach((section) => { if (numberValue >= section.from && numberValue <= section.to) { color = section.color; - if (this._showDebug()) { + if (this._showDebug) { const logMessage = '_computeFileSystemUsageColor() - value=[' + value + '] matched(from=' + section.from + ', to=' + section.to + ', color=' + color + ')'; console.log(logMessage); @@ -999,7 +1009,7 @@ export class RPiMonitorCard extends LitElement { } }); } - if (this._showDebug()) { + if (this._showDebug) { const logMessage = '_computeFileSystemUsageColor() - value=[' + value + '] returns(color=' + color + ')'; console.log(logMessage); } @@ -1019,7 +1029,7 @@ export class RPiMonitorCard extends LitElement { sections.forEach((section) => { if (numberValue >= section.from && numberValue <= section.to) { color = section.color; - if (this._showDebug()) { + if (this._showDebug) { const logMessage = '_computeMemoryUsageColor() - value=[' + value + '] matched(from=' + section.from + ', to=' + section.to + ', color=' + color + ')'; console.log(logMessage); @@ -1027,7 +1037,7 @@ export class RPiMonitorCard extends LitElement { } }); } - if (this._showDebug()) { + if (this._showDebug) { const logMessage = '_computeMemoryUsageColor() - value=[' + value + '] returns(color=' + color + ')'; console.log(logMessage); } @@ -1048,13 +1058,13 @@ export class RPiMonitorCard extends LitElement { sections.forEach((section) => { if (osName === section.os) { color = section.color; - if (this._showDebug()) { + if (this._showDebug) { const logMessage = '_computeOsReleaseColor() - value=[' + osName + '] matched(os=' + section.os + ', color=' + color + ')'; console.log(logMessage); } } }); - if (this._showDebug()) { + if (this._showDebug) { const logMessage = '_computeOsReleaseColor() - value=[' + osName + '] returns(color=' + color + ')'; console.log(logMessage); } @@ -1074,7 +1084,7 @@ export class RPiMonitorCard extends LitElement { color = 'default'; } else if (this.latestDaemonVersions.includes(currentReporterVersion)) { // daemon is recent - color = 'yellow'; + color = 'orange'; } else { // daemon is old (not even in latest or stable) color = 'red'; @@ -1083,7 +1093,7 @@ export class RPiMonitorCard extends LitElement { // daemon values are missing??? color = 'orange'; } - if (this._showDebug()) { + if (this._showDebug) { const logMessage = '_computeDaemonUpdateVersionColor() - value=[' + currentReporterVersion + '] returns(color=' + color + ')'; console.log(logMessage); } @@ -1111,26 +1121,25 @@ export class RPiMonitorCard extends LitElement { private _getAttributeValueForKey(key: string): string { // HELPER UTILITY: get requested named value from config - if (!this.hass || !this._config) { - return ''; - } - const entityId = this._config.entity ? this._config.entity : undefined; - const stateObj = this._config.entity ? this.hass.states[this._config.entity] : undefined; - - if (!entityId && !stateObj) { - return ''; - } - - if (stateObj?.attributes == undefined) { - return ''; - } - - let desired_value: string = ''; // empty string - if (key in stateObj?.attributes) { - desired_value = stateObj?.attributes[key]; + let desiredValue: string = ''; + try { + // FIXME added try/catch during hunt + if (this.hass && this._config && this._configEntityId) { + const stateObj = this._configEntityId ? this.hass.states[this._configEntityId] : undefined; + + if (stateObj) { + if (stateObj.attributes != undefined) { + if (key in stateObj.attributes) { + desiredValue = stateObj?.attributes[key]; + } + } + } + } + } catch (error) { + console.error(error); } //console.log('- getAttr key=[' + key + '], value=[' + desired_value + ']'); - return desired_value; + return desiredValue; } private _emptyCardValuesWhileWaitingForSensor(): void { @@ -1138,7 +1147,7 @@ export class RPiMonitorCard extends LitElement { const root: any = this.shadowRoot; if (this._sensorAvailable) { - if (this._useFullCard()) { + if (this._showFullCard) { // clear values for our FULL card for (const currName in this._cardFullCssIDs) { const currLabelID = this._cardFullCssIDs[currName]; @@ -1247,8 +1256,8 @@ export class RPiMonitorCard extends LitElement { } private _getTemperatureScale(): string { - const scaleInterp = this._useTempsInC() == true ? 'ºC' : 'ºF'; - // if (this._showDebug()) { + const scaleInterp = this._useTempsInC == true ? 'ºC' : 'ºF'; + // if (this._showDebug) { // const logMessage = '_getTemperatureScale() scaleInterp=(' + scaleInterp + ')'; // console.log(logMessage); // } @@ -1258,12 +1267,12 @@ export class RPiMonitorCard extends LitElement { private _getScaledTemperatureValue(temperature_raw: string): string { let interpValue = temperature_raw; if (interpValue != 'n/a') { - if (this._useTempsInC() == false) { + if (this._useTempsInC == false) { // if not inC convert to F interpValue = ((parseFloat(temperature_raw) * 9) / 5 + 32.0).toFixed(1); } } - // if (this._showDebug()) { + // if (this._showDebug) { // const logMessage = '_getScaledTemperatureValue(' + temperature_raw + ') scaleInterp=(' + interpValue + ')'; // console.log(logMessage); // } @@ -1358,17 +1367,6 @@ export class RPiMonitorCard extends LitElement { return interpValue; } - private _showDebug(): boolean { - // we show debug if enabled in code or if found enabled in config for this card! - let showDebugStatus = this._show_debug; - if (this._config) { - if (this._config.show_debug != undefined) { - showDebugStatus = showDebugStatus == true || this._config.show_debug == true; - } - } - return showDebugStatus; - } - static get styles(): CSSResultGroup { // style our GLANCE card return css` @@ -1517,28 +1515,28 @@ export class RPiMonitorCard extends LitElement { .daemon-update-full { position: absolute; top: 45px; - right: 25%; + right: 27%; font-size: 12px; color: var(--primary-text-color); } .daemon-update { position: absolute; top: 55px; - right: 25%; + right: 27%; font-size: 12px; color: var(--primary-text-color); } .daemon-update-full-notitle { position: absolute; top: 3px; - right: 25%; + right: 27%; font-size: 12px; color: var(--primary-text-color); } .daemon-update-notitle { position: absolute; bottom: 5px; - right: 35%; + right: 37%; font-size: 12px; color: var(--primary-text-color); }