mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Map meteo_france weather condition codes once (#98513)
This commit is contained in:
parent
0bcc02e908
commit
e69090b943
@ -89,3 +89,8 @@ CONDITION_CLASSES: dict[str, list[str]] = {
|
|||||||
ATTR_CONDITION_WINDY_VARIANT: [],
|
ATTR_CONDITION_WINDY_VARIANT: [],
|
||||||
ATTR_CONDITION_EXCEPTIONAL: [],
|
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 (
|
from .const import (
|
||||||
ATTRIBUTION,
|
ATTRIBUTION,
|
||||||
CONDITION_CLASSES,
|
CONDITION_MAP,
|
||||||
COORDINATOR_FORECAST,
|
COORDINATOR_FORECAST,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
FORECAST_MODE_DAILY,
|
FORECAST_MODE_DAILY,
|
||||||
@ -47,11 +47,8 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def format_condition(condition: str):
|
def format_condition(condition: str):
|
||||||
"""Return condition from dict CONDITION_CLASSES."""
|
"""Return condition from dict CONDITION_MAP."""
|
||||||
for key, value in CONDITION_CLASSES.items():
|
return CONDITION_MAP.get(condition, condition)
|
||||||
if condition in value:
|
|
||||||
return key
|
|
||||||
return condition
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user