From 1b7532462c9eb5892ee6ccc8c711866a6d6ed2e3 Mon Sep 17 00:00:00 2001 From: Tor Inge Redalen Date: Thu, 18 Apr 2024 17:23:13 +0000 Subject: [PATCH] Fix deprecated constants datetime as string --- .../met_next_6_hours_forecast/weather.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/custom_components/met_next_6_hours_forecast/weather.py b/custom_components/met_next_6_hours_forecast/weather.py index b6b6bd9..3e2b2da 100755 --- a/custom_components/met_next_6_hours_forecast/weather.py +++ b/custom_components/met_next_6_hours_forecast/weather.py @@ -11,9 +11,9 @@ CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME, - TEMP_CELSIUS, - SPEED_METERS_PER_SECOND, - LENGTH_MILLIMETERS, + UnitOfTemperature, + UnitOfSpeed, + UnitOfLength, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -56,9 +56,9 @@ def format_condition(condition: str) -> str: class SixHoursWeather(WeatherEntity): """Representation of a Met.no next 6 hours forecast sensor.""" - _attr_native_temperature_unit = TEMP_CELSIUS - _attr_native_wind_speed_unit = SPEED_METERS_PER_SECOND - _attr_native_precipitation_unit = LENGTH_MILLIMETERS + _attr_native_temperature_unit = UnitOfTemperature.CELSIUS + _attr_native_wind_speed_unit = UnitOfSpeed.METERS_PER_SECOND + _attr_native_precipitation_unit = UnitOfLength.MILLIMETERS _attr_supported_features = WeatherEntityFeature.FORECAST_HOURLY def __init__( @@ -210,7 +210,7 @@ async def async_update(self): ] if "probability_of_precipitation" in details else None, - datetime=time, + datetime=time.strftime("%Y-%m-%dT%H:%M:%S+00:00"), condition=condition, native_pressure=current["air_pressure_at_sea_level"], wind_bearing=current["wind_from_direction"],