diff --git a/homeassistant/components/metoffice/weather.py b/homeassistant/components/metoffice/weather.py index a5e3a13a68ac..595db00eacee 100644 --- a/homeassistant/components/metoffice/weather.py +++ b/homeassistant/components/metoffice/weather.py @@ -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