From 8c1c58dfd123553d9510926ba78d5b6b3f4b990e Mon Sep 17 00:00:00 2001 From: Florian Brinker Date: Wed, 15 Jan 2020 22:58:51 +0100 Subject: [PATCH] Add all humidity alerts, alert view in frontend, add auto-entities card --- config/alerts/humidity.yaml | 104 ++++++++++ config/alerts/windows.yaml | 7 +- config/sensors_binary/humidity.yaml | 22 +++ config/sensors_binary/misc.yaml | 3 + config/views/alerts.yaml | 25 +++ ui-lovelace.yaml | 5 +- www/lovelace/resources/auto-entities.js | 2 + www/lovelace/resources/weather-card.js | 247 ++++++++++++++++++++++++ 8 files changed, 412 insertions(+), 3 deletions(-) create mode 100644 config/alerts/humidity.yaml create mode 100644 config/sensors_binary/humidity.yaml create mode 100644 config/views/alerts.yaml create mode 100644 www/lovelace/resources/auto-entities.js create mode 100644 www/lovelace/resources/weather-card.js diff --git a/config/alerts/humidity.yaml b/config/alerts/humidity.yaml new file mode 100644 index 0000000..a6af1a0 --- /dev/null +++ b/config/alerts/humidity.yaml @@ -0,0 +1,104 @@ +# Elternbad +humidity_too_high_bathroom: + name: Elternbad Luftfeuchtigkeit zu hoch + message: "Zur Info: Die *Luftfeuchtigkeit* im *Elternbad* hat den Grenzwert überschritten ({{ states('sensor.hygro_bathroom_parents_humidity') }}%)!" + done_message: "Zur Info: Die *Luftfeuchtigkeit* im *Elternbad* ist wieder in Ordnung ({{ states('sensor.hygro_bathroom_parents_humidity') }}%)." + entity_id: binary_sensor.humidity_too_high_bathroom + state: "on" + repeat: + - 30 + - 180 + can_acknowledge: true + skip_first: true + notifiers: + - telegram_group + +# Kinderbad +humidity_too_high_bathroom_kids: + name: Kinderbad Luftfeuchtigkeit zu hoch + message: "Zur Info: Die *Luftfeuchtigkeit* im *Kinderbad* hat den Grenzwert überschritten ({{ states('sensor.hygro_bathroom_kids_humidity') }}%)!" + done_message: "Zur Info: Die *Luftfeuchtigkeit* im *Kinderbad* ist wieder in Ordnung ({{ states('sensor.hygro_bathroom_kids_humidity') }}%)." + entity_id: binary_sensor.humidity_too_high_bathroom_kids + state: "on" + repeat: + - 30 + - 180 + can_acknowledge: true + skip_first: true + notifiers: + - telegram_group + +# Schlafzimmer +humidity_too_high_bedroom: + name: Schlafzimmer Luftfeuchtigkeit zu hoch + message: "Zur Info: Die *Luftfeuchtigkeit* im *Schlafzimmer* hat den Grenzwert überschritten ({{ states('sensor.lumi_bedroom_humidity') }}%)!" + done_message: "Zur Info: Die *Luftfeuchtigkeit* im *Schlafzimmer* ist wieder in Ordnung ({{ states('sensor.lumi_bedroom_humidity') }}%)." + entity_id: binary_sensor.humidity_too_high_bedroom + state: "on" + repeat: + - 30 + - 180 + can_acknowledge: true + skip_first: true + notifiers: + - telegram_group + +# Wohnzimmer +humidity_too_high_livingroom: + name: Wohnzimmer Luftfeuchtigkeit zu hoch + message: "Zur Info: Die *Luftfeuchtigkeit* im *Wohnzimmer* hat den Grenzwert überschritten ({{ states('sensor.humidity_4') }}%)!" + done_message: "Zur Info: Die *Luftfeuchtigkeit* im *Wohnzimmer* ist wieder in Ordnung ({{ states('sensor.humidity_4') }}%)." + entity_id: binary_sensor.humidity_too_high_livingroom + state: "on" + repeat: + - 30 + - 180 + can_acknowledge: true + skip_first: true + notifiers: + - telegram_group + +# Gästezimmer +humidity_too_high_guestroom: + name: Gästezimmer Luftfeuchtigkeit zu hoch + message: "Zur Info: Die *Luftfeuchtigkeit* im *Gästezimmer* hat den Grenzwert überschritten ({{ states('sensor.lumi_guestroom_humidity') }}%)!" + done_message: "Zur Info: Die *Luftfeuchtigkeit* im *Gästezimmer* ist wieder in Ordnung ({{ states('sensor.lumi_guestroom_humidity') }}%)." + entity_id: binary_sensor.humidity_too_high_guestroom + state: "on" + repeat: + - 30 + - 180 + can_acknowledge: true + skip_first: true + notifiers: + - telegram_group + +# Büro +humidity_too_high_office: + name: Büro Luftfeuchtigkeit zu hoch + message: "Zur Info: Die *Luftfeuchtigkeit* im *Büro* hat den Grenzwert überschritten ({{ states('sensor.lumi_office_humidity') }}%)!" + done_message: "Zur Info: Die *Luftfeuchtigkeit* im *Büro* ist wieder in Ordnung ({{ states('sensor.lumi_office_humidity') }}%)." + entity_id: binary_sensor.humidity_too_high_office + state: "on" + repeat: + - 30 + - 180 + can_acknowledge: true + skip_first: true + notifiers: + - telegram_group + +# Dachboden +humidity_too_high_attic: + name: Dachboden Luftfeuchtigkeit zu hoch + message: "Zur Info: Die *Luftfeuchtigkeit* im *Dachboden* hat den Grenzwert überschritten ({{ states('sensor.attic_humidity_2') }}%)!" + done_message: "Zur Info: Die *Luftfeuchtigkeit* im *Dachboden* ist wieder in Ordnung ({{ states('sensor.attic_humidity_2') }}%)." + entity_id: binary_sensor.humidity_too_high_attic + state: "on" + repeat: + - 30 + - 180 + can_acknowledge: true + skip_first: true + notifiers: + - telegram_group \ No newline at end of file diff --git a/config/alerts/windows.yaml b/config/alerts/windows.yaml index e9e4ef2..3a11896 100644 --- a/config/alerts/windows.yaml +++ b/config/alerts/windows.yaml @@ -4,8 +4,11 @@ bathroom_window_open: done_message: "Zur Info: Das *Badezimmer-Fenster* ist wieder *geschlossen*." entity_id: binary_sensor.lumi_bathroom_window_magnet state: "on" - repeat: 10 - can_acknowledge: false + repeat: + - 15 + - 10 + - 30 + can_acknowledge: true skip_first: true notifiers: - telegram_group diff --git a/config/sensors_binary/humidity.yaml b/config/sensors_binary/humidity.yaml new file mode 100644 index 0000000..f685cd8 --- /dev/null +++ b/config/sensors_binary/humidity.yaml @@ -0,0 +1,22 @@ +- platform: template + sensors: + humidity_too_high_bathroom: + value_template: "{{ states('sensor.hygro_bathroom_parents_humidity') | float > 68 }}" + + humidity_too_high_bathroom_kids: + value_template: "{{ states('sensor.hygro_bathroom_kids_humidity') | float > 68 }}" + + humidity_too_high_bedroom: + value_template: "{{ states('sensor.lumi_bedroom_humidity') | float > 68 }}" + + humidity_too_high_livingroom: + value_template: "{{ states('.sensor.humidity_4') | float > 68 }}" + + humidity_too_high_guestroom: + value_template: "{{ states('sensor.lumi_guestroom_humidity') | float > 68 }}" + + humidity_too_high_office: + value_template: "{{ states('sensor.lumi_office_humidity') | float > 68 }}" + + humidity_too_high_attic: + value_template: "{{ states('sensor.attic_humidity_2') | float > 68 }}" \ No newline at end of file diff --git a/config/sensors_binary/misc.yaml b/config/sensors_binary/misc.yaml index e7e9434..9a1dc2f 100644 --- a/config/sensors_binary/misc.yaml +++ b/config/sensors_binary/misc.yaml @@ -2,15 +2,18 @@ country: DE province: NW workdays: [ mon, tue, wed, thu, fri ] + - platform: tod name: Morning after: '05:00' before: '11:00' + - platform: ping name: desktop_ping host: !secret desktop_ip count: 2 scan_interval: 15 + - platform: template sensors: anyone_home: diff --git a/config/views/alerts.yaml b/config/views/alerts.yaml new file mode 100644 index 0000000..bb6e825 --- /dev/null +++ b/config/views/alerts.yaml @@ -0,0 +1,25 @@ +icon: mdi:bell +path: alerts +cards: + - type: custom:auto-entities + show_empty: false + card: + type: entities + title: Active Alerts + show_header_toggle: false + filter: + include: + - domain: alert + exclude: + - state: "idle" + - type: custom:auto-entities + show_empty: false + card: + type: entities + title: Inactive Alerts + show_header_toggle: false + filter: + include: + - domain: alert + exclude: + - state: "on" \ No newline at end of file diff --git a/ui-lovelace.yaml b/ui-lovelace.yaml index cc3aa4d..df26a1c 100644 --- a/ui-lovelace.yaml +++ b/ui-lovelace.yaml @@ -10,7 +10,10 @@ views: - !include config/views/instagram.yaml - !include config/views/devices.yaml - !include config/views/cctv.yaml + - !include config/views/alerts.yaml resources: - - url: https://cdn.jsdelivr.net/gh/bramkragten/custom-ui@master/weather-card/weather-card.min.js + - url: /local/lovelace/resources/weather-card.js + type: module + - url: /local/lovelace/resources/auto-entities.js type: module diff --git a/www/lovelace/resources/auto-entities.js b/www/lovelace/resources/auto-entities.js new file mode 100644 index 0000000..7c37cdb --- /dev/null +++ b/www/lovelace/resources/auto-entities.js @@ -0,0 +1,2 @@ +!function(t){var e={};function i(r){if(e[r])return e[r].exports;var s=e[r]={i:r,l:!1,exports:{}};return t[r].call(s.exports,s,s.exports,i),s.l=!0,s.exports}i.m=t,i.c=e,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)i.d(r,s,function(e){return t[e]}.bind(null,s));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0)}([function(t,e,i){"use strict";i.r(e);const r=customElements.get("home-assistant-main")?Object.getPrototypeOf(customElements.get("home-assistant-main")):Object.getPrototypeOf(customElements.get("hui-view")),s=r.prototype.html;r.prototype.css;function n(){return document.querySelector("hc-main")?document.querySelector("hc-main").hass:document.querySelector("home-assistant")?document.querySelector("home-assistant").hass:void 0}const a=n().callWS({type:"config/area_registry/list"}),o=n().callWS({type:"config/device_registry/list"}),c=n().callWS({type:"config/entity_registry/list"});async function l(){return window.cardToolsData=window.cardToolsData||{areas:await a,devices:await o,entities:await c},window.cardToolsData}function u(t){const e=window.cardToolsData;let i=[];if(!t)return i;for(const r of e.devices)r.area_id===t.area_id&&i.push(r);return i}function f(t){const e=window.cardToolsData;let i=[];if(!t)return i;for(const r of e.entities)r.device_id===t.id&&i.push(r.entity_id);return i}function d(t,e){if("string"==typeof e&&"string"==typeof t&&(t.startsWith("/")&&t.endsWith("/")||-1!==t.indexOf("*"))){return t.startsWith("/")||(t=`/^${t=t.replace(/\./g,".").replace(/\*/g,".*")}$/`),new RegExp(t.slice(1,-1)).test(e)}if("string"==typeof t){if(t.startsWith("<="))return parseFloat(e)<=parseFloat(t.substr(2));if(t.startsWith(">="))return parseFloat(e)>=parseFloat(t.substr(2));if(t.startsWith("<"))return parseFloat(e)"))return parseFloat(e)>parseFloat(t.substr(1));if(t.startsWith("!"))return parseFloat(e)!=parseFloat(t.substr(1));if(t.startsWith("="))return parseFloat(e)==parseFloat(t.substr(1))}return t===e}function h(t,e){return function(i){const r="string"==typeof i?t.states[i]:t.states[i.entity];if(!i)return!1;for(const[s,n]of Object.entries(e))switch(s.split(" ")[0]){case"options":case"sort":break;case"domain":if(!d(n,r.entity_id.split(".")[0]))return!1;break;case"entity_id":if(!d(n,r.entity_id))return!1;break;case"state":if(!d(n,r.state))return!1;break;case"name":if(!r.attributes.friendly_name||!d(n,r.attributes.friendly_name))return!1;break;case"group":if(!(n.startsWith("group.")&&t.states[n]&&t.states[n].attributes.entity_id&&t.states[n].attributes.entity_id.includes(r.entity_id)))return!1;break;case"attributes":for(const[t,e]of Object.entries(n)){let i=t.trim(),s=r.attributes;for(;i&&s;){let t;[t,i]=i.split(":"),s=s[t]}if(void 0===s||void 0!==e&&!d(e,s))return!1}break;case"not":if(h(t,n)(i))return!1;break;case"device":if(!window.cardToolsData||!window.cardToolsData.devices)return!1;let e=!1;for(const t of window.cardToolsData.devices)d(n,t.name)&&f(t).includes(r.entity_id)&&(e=!0);if(!e)return!1;break;case"area":if(!window.cardToolsData||!window.cardToolsData.areas)return!1;let s=!1;for(const t of window.cardToolsData.areas)d(n,t.name)&&u(t).flatMap(f).includes(r.entity_id)&&(s=!0);if(!s)return!1;break;case"last_changed":if(!d(n,((new Date).getTime()-new Date(r.last_changed).getTime())/6e4))return!1;break;case"last_updated":if(!d(n,((new Date).getTime()-new Date(r.last_updated).getTime())/6e4))return!1;break;default:return!1}return!0}}function g(t,e){return"string"==typeof e&&(e={method:e}),function(i,r){const s="string"==typeof i?t.states[i]:t.states[i.entity],n="string"==typeof r?t.states[r]:t.states[r.entity];if(void 0===s||void 0===n)return 0;const[a,o]=e.reverse?[-1,1]:[1,-1];function c(t,i){return e.ignore_case&&t.toLowerCase&&(t=t.toLowerCase()),e.ignore_case&&i.toLowerCase&&(i=i.toLowerCase()),e.numeric&&(isNaN(parseFloat(t))&&isNaN(parseFloat(i))||(t=isNaN(parseFloat(t))?void 0:parseFloat(t),i=isNaN(parseFloat(i))?void 0:parseFloat(i))),void 0===t&&void 0===i?0:void 0===t?a:void 0===i?o:ti?a:0}switch(e.method){case"domain":return c(s.entity_id.split(".")[0],n.entity_id.split(".")[0]);case"entity_id":return c(s.entity_id,n.entity_id);case"friendly_name":case"name":return c(s.attributes.friendly_name||s.entity_id.split(".")[1],n.attributes.friendly_name||n.entity_id.split(".")[1]);case"state":return c(s.state,n.state);case"attribute":let t=s.attributes,i=n.attributes,r=e.attribute;for(;r;){let e;if([e,r]=r.split(":"),t=t[e],i=i[e],void 0===t&&void 0===i)return 0;if(void 0===t)return a;if(void 0===i)return o}return c(t,i);case"last_changed":case"last_updated":return e.numeric=!0,c(new Date(n.last_changed).getTime(),new Date(s.last_changed).getTime());case"last_triggered":return null==s.attributes.last_triggered||null==n.attributes.last_triggered?0:(e.numeric=!0,c(new Date(n.attributes.last_triggered).getTime(),new Date(s.attributes.last_triggered).getTime()));default:return 0}}}function p(t,e,i=null){if((t=new Event(t,{bubbles:!0,cancelable:!1,composed:!0})).detail=e||{},i)i.dispatchEvent(t);else{var r=function(){var t=document.querySelector("hc-main");return t=t?(t=(t=(t=t&&t.shadowRoot)&&t.querySelector("hc-lovelace"))&&t.shadowRoot)&&t.querySelector("hui-view"):(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=document.querySelector("home-assistant"))&&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"))&&t.shadowRoot)&&t.querySelector("ha-app-layout #view"))&&t.firstElementChild}();r&&r.dispatchEvent(t)}}l();function y(t,e){const i=document.createElement("hui-error-card");return i.setConfig({type:"error",error:t,origConfig:e}),i}function m(t,e){if(!e||"object"!=typeof e||!e.type)return y(`No ${t} type configured`,e);let i=e.type;if(i=i.startsWith("custom:")?i.substr("custom:".length):`hui-${i}-${t}`,customElements.get(i))return function(t,e){const i=document.createElement(t);try{i.setConfig(e)}catch(t){return y(t,e)}return i}(i,e);const r=y(`Custom element doesn't exist: ${i}.`,e);r.style.display="None";const s=setTimeout(()=>{r.style.display=""},2e3);return customElements.whenDefined(i).then(()=>{clearTimeout(s),p("ll-rebuild",{},r)}),r}let _=function(){if(window.fully&&"function"==typeof fully.getDeviceId)return fully.getDeviceId();if(!localStorage["lovelace-player-device-id"]){const t=()=>Math.floor(1e5*(1+Math.random())).toString(16).substring(1);localStorage["lovelace-player-device-id"]=`${t()}${t()}-${t()}${t()}`}return localStorage["lovelace-player-device-id"]}();customElements.define("auto-entities",class extends r{static get properties(){return{hass:{}}}setConfig(t){if(!t||!t.card)throw new Error("Invalid configuration");this._config?(this._config=t,this.hass=this.hass):(this._config=t,this.hass=n(),this._getEntities(),this.cardConfig={entities:this.entities,...t.card},this.card=function(t){return m("card",t)}(this.cardConfig)),t.filter&&t.filter.template&&(this.template="",(String(t.filter.template).includes("{%")||String(t.filter.template).includes("{{"))&&function(t,e,i){t||(t=n().connection);let r={user:n().user.name,browser:_,hash:location.hash.substr(1)||" ",...i.variables},s=i.template,a=i.entity_ids;t.subscribeMessage(t=>{let i=t.result;i=i.replace(/_\([^)]*\)/g,t=>n().localize(t.substring(2,t.length-1))||t),e(i)},{type:"render_template",template:s,variables:r,entity_ids:a})}(null,t=>{this.template=t,this._getEntities()},{template:t.filter.template,variables:{config:t},entity_ids:t.filter.entity_ids})),l().then(()=>this._getEntities())}_getEntities(){const t=t=>t?"string"==typeof t?{entity:t.trim()}:t:null;let e=[];if(this._config.entities&&(e=e.concat(this._config.entities.map(t))),!this.hass||!this._config.filter)return e;if(this.template&&(e=e.concat(this.template.split(/[\s,]+/).map(t))),e=e.filter(Boolean),this._config.filter.include){const i=Object.keys(this.hass.states).map(t);for(const t of this._config.filter.include){if(void 0!==t.type){e.push(t);continue}let r=i.filter(h(this.hass,t)).map(e=>JSON.parse(JSON.stringify(new Object({...e,...t.options})).replace(/this.entity_id/g,e.entity)));void 0!==t.sort&&(r=r.sort(g(this.hass,t.sort))),e=e.concat(r)}}if(this._config.filter.exclude)for(const t of this._config.filter.exclude)e=e.filter(e=>"string"!=typeof e&&void 0===e.entity||!h(this.hass,t)(e));if(this._config.sort&&(e=e.sort(g(this.hass,this._config.sort)),this._config.sort.count)){const t=this._config.sort.first||0;e=e.slice(t,t+this._config.sort.count)}if(this._config.unique){function i(t,e){return typeof t==typeof e&&("object"!=typeof t?t===e:!Object.keys(t).some(t=>!Object.keys(e).includes(t))&&Object.keys(t).every(r=>i(t[r],e[r])))}let t=[];for(const r of e)t.some(t=>i(t,r))||t.push(r);e=t}this.entities=e}set entities(t){(function(t,e){if(t===e)return!0;if(null==t||null==e)return!1;if(t.length!=e.length)return!1;for(var i=0;ithis._getEntities(),0))}createRenderRoot(){return this}render(){return s` + ${this.card}`}getCardSize(){let t=0;return this.card&&this.card.getCardSize&&(t=this.card.getCardSize()),1===t&&this.entities.length&&(t=this.entities.length),0===t&&this._config.filter&&this._config.filter.include&&(t=Object.keys(this._config.filter.include).length),t||1}}),p("ll-rebuild",{})}]); \ No newline at end of file diff --git a/www/lovelace/resources/weather-card.js b/www/lovelace/resources/weather-card.js new file mode 100644 index 0000000..215cf8d --- /dev/null +++ b/www/lovelace/resources/weather-card.js @@ -0,0 +1,247 @@ +/** + * Minified by jsDelivr using Terser v3.14.1. + * Original file: /gh/bramkragten/custom-ui@null/weather-card/weather-card.js + * + * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files + */ +const LitElement=Object.getPrototypeOf(customElements.get("ha-panel-lovelace")),html=LitElement.prototype.html,weatherIconsDay={clear:"day","clear-night":"night",cloudy:"cloudy",fog:"cloudy",hail:"rainy-7",lightning:"thunder","lightning-rainy":"thunder",partlycloudy:"cloudy-day-3",pouring:"rainy-6",rainy:"rainy-5",snowy:"snowy-6","snowy-rainy":"rainy-7",sunny:"day",windy:"cloudy","windy-variant":"cloudy-day-3",exceptional:"!!"},weatherIconsNight={...weatherIconsDay,clear:"night",sunny:"night",partlycloudy:"cloudy-night-3","windy-variant":"cloudy-night-3"},windDirections=["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW","N"],fireEvent=(t,e,i,n)=>{n=n||{},i=null==i?{}:i;const a=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});return a.detail=i,t.dispatchEvent(a),a};function hasConfigOrEntityChanged(t,e){if(e.has("_config"))return!0;const i=e.get("hass");return!i||(i.states[t._config.entity]!==t.hass.states[t._config.entity]||i.states["sun.sun"]!==t.hass.states["sun.sun"])}class WeatherCard extends LitElement{static get properties(){return{_config:{},hass:{}}}static async getConfigElement(){return await import("./weather-card-editor.js"),document.createElement("weather-card-editor")}static getStubConfig(){return{}}setConfig(t){if(!t.entity)throw new Error("Please define a weather entity");this._config=t}shouldUpdate(t){return hasConfigOrEntityChanged(this,t)}render(){if(!this._config||!this.hass)return html``;const t=this.hass.states[this._config.entity];if(!t)return html` + + +
+ Entity not available: ${this._config.entity} +
+
+ `;const e=this.hass.selectedLanguage||this.hass.language,i=new Date(this.hass.states["sun.sun"].attributes.next_rising),n=new Date(this.hass.states["sun.sun"].attributes.next_setting);return html` + ${this.renderStyle()} + + ${t.state} + + ${this._config.name?html` + ${this._config.name} + `:""} + ${"°F"==this.getUnit("temperature")?Math.round(t.attributes.temperature):t.attributes.temperature} + ${this.getUnit("temperature")} + +
    +
  • + + ${t.attributes.humidity} % +
    + + ${windDirections[parseInt((t.attributes.wind_bearing+11.25)/22.5)]} + ${t.attributes.wind_speed} + ${this.getUnit("length")}/h + +
    + + ${i.toLocaleTimeString()} +
  • +
  • + ${t.attributes.pressure} + ${this.getUnit("air_pressure")} + +
    + + ${t.attributes.visibility} + ${this.getUnit("length")} + +
    + + ${n.toLocaleTimeString()} +
  • +
+
+ ${t.attributes.forecast&&t.attributes.forecast.length>0?html` +
+ ${t.attributes.forecast.slice(0,5).map(t=>html` +
+ ${new Date(t.datetime).toLocaleDateString(e,{weekday:"short"})} +
+
${t.temperature}${this.getUnit("temperature")} + ${void 0!==t.templow?html` +
${t.templow}${this.getUnit("temperature")} + `:""} +
+ `)} +
+ `:""} +
+ `}getWeatherIcon(t,e){return`${this._config.icons?this._config.icons:"https://cdn.jsdelivr.net/gh/bramkragten/custom-ui@master/weather-card/icons/animated/"}${e&&"below_horizon"==e?weatherIconsNight[t]:weatherIconsDay[t]}.svg`}getUnit(t){const e=this.hass.config.unit_system.length;switch(t){case"air_pressure":return"km"===e?"hPa":"inHg";case"length":return e;case"precipitation":return"km"===e?"mm":"in";default:return this.hass.config.unit_system[t]||""}}_handleClick(){fireEvent(this,"hass-more-info",{entityId:this._config.entity})}getCardSize(){return 3}renderStyle(){return html` + + `}}customElements.define("weather-card",WeatherCard); \ No newline at end of file