mirror of
https://github.com/home-assistant/core.git
synced 2026-09-24 23:41:48 -05:00
refactor(metoffice): use dt_util.now in weather.py (#180902)
Co-authored-by: Gemini <200291788+gemini-code-assist@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
"""Support for UK Met Office weather service."""
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, cast, override
|
||||
|
||||
from homeassistant.components.weather import (
|
||||
@@ -30,6 +29,7 @@ from homeassistant.const import (
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from . import get_device_info
|
||||
from .const import (
|
||||
@@ -274,9 +274,9 @@ class MetOfficeWeather(
|
||||
self.forecast_coordinators["daily"],
|
||||
)
|
||||
timesteps = coordinator.data.timesteps
|
||||
start_datetime = datetime.now( # pylint: disable=home-assistant-enforce-now
|
||||
tz=timesteps[0]["time"].tzinfo
|
||||
).replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
start_datetime = dt_util.now(time_zone=timesteps[0]["time"].tzinfo).replace(
|
||||
hour=0, minute=0, second=0, microsecond=0
|
||||
)
|
||||
return [
|
||||
_build_daily_forecast_data(timestep)
|
||||
for timestep in timesteps
|
||||
@@ -293,9 +293,9 @@ class MetOfficeWeather(
|
||||
)
|
||||
|
||||
timesteps = coordinator.data.timesteps
|
||||
start_datetime = datetime.now( # pylint: disable=home-assistant-enforce-now
|
||||
tz=timesteps[0]["time"].tzinfo
|
||||
).replace(minute=0, second=0, microsecond=0)
|
||||
start_datetime = dt_util.now(time_zone=timesteps[0]["time"].tzinfo).replace(
|
||||
minute=0, second=0, microsecond=0
|
||||
)
|
||||
return [
|
||||
_build_hourly_forecast_data(timestep)
|
||||
for timestep in timesteps
|
||||
@@ -311,9 +311,9 @@ class MetOfficeWeather(
|
||||
self.forecast_coordinators["twice_daily"],
|
||||
)
|
||||
timesteps = coordinator.data.timesteps
|
||||
start_datetime = datetime.now( # pylint: disable=home-assistant-enforce-now
|
||||
tz=timesteps[0]["time"].tzinfo
|
||||
).replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
start_datetime = dt_util.now(time_zone=timesteps[0]["time"].tzinfo).replace(
|
||||
hour=0, minute=0, second=0, microsecond=0
|
||||
)
|
||||
return [
|
||||
_build_twice_daily_forecast_data(timestep)
|
||||
for timestep in timesteps
|
||||
|
||||
Reference in New Issue
Block a user