Skip to content

Commit

Permalink
Remove deprecated datetime.utcfromtimestamp() and fix UnitOfTemperatu…
Browse files Browse the repository at this point in the history
…re error
  • Loading branch information
Limych committed May 8, 2024
1 parent eed0686 commit f286474
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions custom_components/snowtire/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
CONF_NAME,
CONF_UNIQUE_ID,
EVENT_HOMEASSISTANT_START,
TEMP_CELSIUS,
UnitOfTemperature,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
Expand Down Expand Up @@ -144,9 +144,9 @@ def _temp2c(
temperature: float | None, temperature_unit: str | None
) -> float | None:
"""Convert weather temperature to Celsius degree."""
if temperature is not None and temperature_unit != TEMP_CELSIUS:
if temperature is not None and temperature_unit != UnitOfTemperature.CELSIUS:
temperature = TemperatureConverter.convert(
temperature, temperature_unit, TEMP_CELSIUS
temperature, temperature_unit, UnitOfTemperature.CELSIUS
)

return temperature
Expand Down Expand Up @@ -197,7 +197,7 @@ async def async_update(
fc_date = fcast.get(ATTR_FORECAST_TIME)
if isinstance(fc_date, int):
fc_date = dt_util.as_local(
datetime.utcfromtimestamp(fc_date / 1000)
datetime.fromtimestamp(fc_date / 1000, dt_util.UTC)
).isoformat()
elif isinstance(fc_date, datetime):
fc_date = dt_util.as_local(fc_date).isoformat()
Expand Down

0 comments on commit f286474

Please sign in to comment.