Map meteo_france weather condition codes once (#98513)
This commit is contained in:
parent
0bcc02e908
commit
e69090b943
2 changed files with 8 additions and 6 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Reference in a new issue