mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 12:45:28 +02:00
Only use sunny during daily forecast
This commit is contained in:
@@ -40,7 +40,7 @@ ATTR_NEXT_RAIN_DT_REF = "forecast_time_ref"
|
||||
|
||||
|
||||
CONDITION_CLASSES: dict[str, list[str]] = {
|
||||
ATTR_CONDITION_CLEAR_NIGHT: ["Nuit Claire", "Nuit claire"],
|
||||
ATTR_CONDITION_CLEAR_NIGHT: ["Nuit Claire", "Nuit claire", "Ciel clair"],
|
||||
ATTR_CONDITION_CLOUDY: ["Très nuageux", "Couvert"],
|
||||
ATTR_CONDITION_FOG: [
|
||||
"Brume ou bancs de brouillard",
|
||||
@@ -89,7 +89,7 @@ CONDITION_CLASSES: dict[str, list[str]] = {
|
||||
"Quelques flocons",
|
||||
],
|
||||
ATTR_CONDITION_SNOWY_RAINY: ["Pluie et neige", "Pluie verglaçante"],
|
||||
ATTR_CONDITION_SUNNY: ["Ensoleillé", "Ciel clair"],
|
||||
ATTR_CONDITION_SUNNY: ["Ensoleillé"],
|
||||
ATTR_CONDITION_WINDY: [],
|
||||
ATTR_CONDITION_WINDY_VARIANT: [],
|
||||
ATTR_CONDITION_EXCEPTIONAL: [],
|
||||
|
@@ -6,6 +6,8 @@ import time
|
||||
from meteofrance_api.model.forecast import Forecast as MeteoFranceForecast
|
||||
|
||||
from homeassistant.components.weather import (
|
||||
ATTR_CONDITION_CLEAR_NIGHT,
|
||||
ATTR_CONDITION_SUNNY,
|
||||
ATTR_FORECAST_CONDITION,
|
||||
ATTR_FORECAST_HUMIDITY,
|
||||
ATTR_FORECAST_NATIVE_PRECIPITATION,
|
||||
@@ -49,9 +51,12 @@ from .const import (
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def format_condition(condition: str):
|
||||
def format_condition(condition: str, force_day: bool = False) -> str:
|
||||
"""Return condition from dict CONDITION_MAP."""
|
||||
return CONDITION_MAP.get(condition, condition)
|
||||
mapped_condition = CONDITION_MAP.get(condition, condition)
|
||||
if force_day and mapped_condition == ATTR_CONDITION_CLEAR_NIGHT:
|
||||
return ATTR_CONDITION_SUNNY
|
||||
return mapped_condition
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
@@ -212,7 +217,7 @@ class MeteoFranceWeather(
|
||||
forecast["dt"]
|
||||
).isoformat(),
|
||||
ATTR_FORECAST_CONDITION: format_condition(
|
||||
forecast["weather12H"]["desc"]
|
||||
forecast["weather12H"]["desc"], force_day=True
|
||||
),
|
||||
ATTR_FORECAST_HUMIDITY: forecast["humidity"]["max"],
|
||||
ATTR_FORECAST_NATIVE_TEMP: forecast["T"]["max"],
|
||||
|
Reference in New Issue
Block a user