Use enums in openweathermap (#62086)
This commit is contained in:
parent
5a268419f5
commit
2ab13f3603
2 changed files with 27 additions and 27 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue