Use enums in openweathermap (#62086)

This commit is contained in:
Robert Hillis 2021-12-16 16:25:49 -05:00 committed by GitHub
parent 5a268419f5
commit 2ab13f3603
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 27 deletions

View file

@ -4,7 +4,7 @@ from __future__ import annotations
from datetime import datetime
from homeassistant.components.sensor import (
DEVICE_CLASS_TIMESTAMP,
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
)
@ -157,7 +157,10 @@ class OpenWeatherMapForecastSensor(AbstractOpenWeatherMapSensor):
return None
value = forecasts[0].get(self.entity_description.key, None)
if value and self.entity_description.device_class == DEVICE_CLASS_TIMESTAMP:
if (
value
and self.entity_description.device_class is SensorDeviceClass.TIMESTAMP
):
return dt_util.parse_datetime(value)
return value