mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Fix unnecessary db entries for metro_france (#25957)
* fix #25911 avoid db unecessary entries * use UTC timestamp for forecast * simplify forecast timestamp
This commit is contained in:
parent
c55241960c
commit
ca74a23cf1
@ -121,7 +121,7 @@ def setup(hass, config):
|
|||||||
weather_alert_client.update_data()
|
weather_alert_client.update_data()
|
||||||
except VigilanceMeteoError as exp:
|
except VigilanceMeteoError as exp:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Unexpected error when creating the" "vigilance_meteoFrance proxy: %s ",
|
"Unexpected error when creating the vigilance_meteoFrance proxy: %s ",
|
||||||
exp,
|
exp,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"""Support for Meteo-France weather service."""
|
"""Support for Meteo-France weather service."""
|
||||||
from datetime import datetime, timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.weather import (
|
from homeassistant.components.weather import (
|
||||||
@ -9,6 +9,7 @@ from homeassistant.components.weather import (
|
|||||||
ATTR_FORECAST_TIME,
|
ATTR_FORECAST_TIME,
|
||||||
WeatherEntity,
|
WeatherEntity,
|
||||||
)
|
)
|
||||||
|
import homeassistant.util.dt as dt_util
|
||||||
from homeassistant.const import TEMP_CELSIUS
|
from homeassistant.const import TEMP_CELSIUS
|
||||||
|
|
||||||
from . import ATTRIBUTION, CONDITION_CLASSES, CONF_CITY, DATA_METEO_FRANCE
|
from . import ATTRIBUTION, CONDITION_CLASSES, CONF_CITY, DATA_METEO_FRANCE
|
||||||
@ -83,8 +84,9 @@ class MeteoFranceWeather(WeatherEntity):
|
|||||||
@property
|
@property
|
||||||
def forecast(self):
|
def forecast(self):
|
||||||
"""Return the forecast."""
|
"""Return the forecast."""
|
||||||
reftime = datetime.now().replace(hour=12, minute=00)
|
reftime = dt_util.utcnow().replace(hour=12, minute=0, second=0, microsecond=0)
|
||||||
reftime += timedelta(hours=24)
|
reftime += timedelta(hours=24)
|
||||||
|
_LOGGER.debug("reftime used for %s forecast: %s", self._data["name"], reftime)
|
||||||
forecast_data = []
|
forecast_data = []
|
||||||
for key in self._data["forecast"]:
|
for key in self._data["forecast"]:
|
||||||
value = self._data["forecast"][key]
|
value = self._data["forecast"][key]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user