diff --git a/dist/weather-card.js b/dist/weather-card.js index 32939505..db191712 100644 --- a/dist/weather-card.js +++ b/dist/weather-card.js @@ -280,7 +280,10 @@ class WeatherCard extends LitElement {
@@ -318,18 +321,26 @@ class WeatherCard extends LitElement { `; } - getWeatherIcon(condition, sun) { + getWeatherIcon(condition, sun, hourly, dt) { return `${ this._config.icons ? this._config.icons : "https://cdn.jsdelivr.net/gh/bramkragten/weather-card/dist/icons/" }${ - sun && sun.state == "below_horizon" + sun && ((!dt && sun.state == "below_horizon") || (dt && hourly && this.getIsNight(sun, dt))) ? weatherIconsNight[condition] : weatherIconsDay[condition] }.svg`; } + getIsNight(sun, dt) + { + const time = new Date(dt).getHours(); + const afterSetting = time > new Date(sun.attributes.next_setting).getHours(); + const beforeRising = time < new Date(sun.attributes.next_rising).getHours(); + return beforeRising || afterSetting; + } + getUnit(measure) { const lengthUnit = this.hass.config.unit_system.length; switch (measure) {