diff --git a/dist/weather-card.js b/dist/weather-card.js index 32939505..cf1b58aa 100644 --- a/dist/weather-card.js +++ b/dist/weather-card.js @@ -185,66 +185,76 @@ class WeatherCard extends LitElement { } renderDetails(stateObj, lang) { - const sun = this.hass.states["sun.sun"]; - let next_rising; - let next_setting; + this.numberElements++; + + const items = []; + + if (stateObj.attributes.humidity != null) { + items.push(html` + + ${stateObj.attributes.humidity} % + `); + } + + if (stateObj.attributes.wind_speed != null) { + items.push(html` + + ${stateObj.attributes.wind_bearing != null + ? windDirections[ + parseInt((stateObj.attributes.wind_bearing + 11.25) / 22.5) + ] + : ""} + ${stateObj.attributes.wind_speed} + ${this.getUnit("length")}/h + + `); + } + + if (stateObj.attributes.pressure != null) { + items.push(html` + + ${stateObj.attributes.pressure} + ${this.getUnit("air_pressure")} + `); + } + + if (stateObj.attributes.visibility != null) { + items.push(html` + ${stateObj.attributes + .visibility} ${this.getUnit("length")} + `); + } + const sun = this.hass.states['sun.sun']; if (sun) { - next_rising = new Date(sun.attributes.next_rising).toLocaleTimeString(lang, { - hour: "2-digit", - minute: "2-digit", - }); - next_setting = new Date(sun.attributes.next_setting).toLocaleTimeString(lang, { - hour: "2-digit", - minute: "2-digit", - }); + const next_rising = new Date(sun.attributes.next_rising).toLocaleTimeString(lang, { + hour: "2-digit", + minute: "2-digit", + }); + const next_setting = new Date(sun.attributes.next_setting).toLocaleTimeString(lang, { + hour: "2-digit", + minute: "2-digit", + }); + + if (items.length % 2 == 1) { + items.push(html`
`); + } + + items.push(html` + + ${next_rising} + `); + items.push(html` + + ${next_setting} + `); } - this.numberElements++; + const listItems = items.map(item => html`
  • ${item}
  • `); return html` `; }