diff --git a/homeassistant/components/meteo_france/const.py b/homeassistant/components/meteo_france/const.py index fad1a33e25c..f1e6ae8d0eb 100644 --- a/homeassistant/components/meteo_france/const.py +++ b/homeassistant/components/meteo_france/const.py @@ -89,3 +89,8 @@ CONDITION_CLASSES: dict[str, list[str]] = { ATTR_CONDITION_WINDY_VARIANT: [], ATTR_CONDITION_EXCEPTIONAL: [], } +CONDITION_MAP = { + cond_code: cond_ha + for cond_ha, cond_codes in CONDITION_CLASSES.items() + for cond_code in cond_codes +} diff --git a/homeassistant/components/meteo_france/weather.py b/homeassistant/components/meteo_france/weather.py index a2e9dc30c53..6459827b601 100644 --- a/homeassistant/components/meteo_france/weather.py +++ b/homeassistant/components/meteo_france/weather.py @@ -34,7 +34,7 @@ from homeassistant.util import dt as dt_util from .const import ( ATTRIBUTION, - CONDITION_CLASSES, + CONDITION_MAP, COORDINATOR_FORECAST, DOMAIN, FORECAST_MODE_DAILY, @@ -47,11 +47,8 @@ _LOGGER = logging.getLogger(__name__) def format_condition(condition: str): - """Return condition from dict CONDITION_CLASSES.""" - for key, value in CONDITION_CLASSES.items(): - if condition in value: - return key - return condition + """Return condition from dict CONDITION_MAP.""" + return CONDITION_MAP.get(condition, condition) async def async_setup_entry(