Skip to content

Commit

Permalink
Report correct weather condition at night for Met (#103334)
Browse files Browse the repository at this point in the history
* Report correct weather condition at night for Met, fixes #68369, fixes #89001

* Update homeassistant/components/met/weather.py

Co-authored-by: Jan-Philipp Benecke <[email protected]>

---------

Co-authored-by: Jan-Philipp Benecke <[email protected]>
  • Loading branch information
jrieger and jpbede authored Nov 4, 2023
1 parent 68471b6 commit bb8375d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions homeassistant/components/met/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,21 @@
UnitOfTemperature,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers import entity_registry as er, sun
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util.unit_system import METRIC_SYSTEM

from . import MetDataUpdateCoordinator
from .const import ATTR_MAP, CONDITIONS_MAP, CONF_TRACK_HOME, DOMAIN, FORECAST_MAP
from .const import (
ATTR_CONDITION_CLEAR_NIGHT,
ATTR_CONDITION_SUNNY,
ATTR_MAP,
CONDITIONS_MAP,
CONF_TRACK_HOME,
DOMAIN,
FORECAST_MAP,
)

DEFAULT_NAME = "Met.no"

Expand Down Expand Up @@ -141,6 +149,10 @@ def condition(self) -> str | None:
condition = self.coordinator.data.current_weather_data.get("condition")
if condition is None:
return None

if condition == ATTR_CONDITION_SUNNY and not sun.is_up(self.hass):
condition = ATTR_CONDITION_CLEAR_NIGHT

return format_condition(condition)

@property
Expand Down

1 comment on commit bb8375d

@chunkysteveo
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a shame the Home Assistant Weather integration doesn't have a night time partly clouded state, as that is possible, and available in the MDI icon set as a "moon & clouds" (weather-night-partly-cloudy). All the same - looks like the HA Weather integration isn't setup right with Material Design Icon set with the condition of ATTR_CONDITION_CLEAR_NIGHT being "clear-night", which doesn't exist in MDI.

Please sign in to comment.