Fix smartthings timestamp sensor (#61254)

This commit is contained in:
Paulus Schoutsen 2021-12-08 11:44:53 -08:00 committed by GitHub
parent 7d256f56c5
commit 77a74a9bf4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -38,6 +38,7 @@ from homeassistant.const import (
TEMP_FAHRENHEIT,
VOLUME_CUBIC_METERS,
)
from homeassistant.util import dt as dt_util
from . import SmartThingsEntity
from .const import DATA_BROKERS, DOMAIN
@ -656,7 +657,12 @@ class SmartThingsSensor(SmartThingsEntity, SensorEntity):
@property
def native_value(self):
"""Return the state of the sensor."""
return self._device.status.attributes[self._attribute].value
value = self._device.status.attributes[self._attribute].value
if self._device_class != DEVICE_CLASS_TIMESTAMP:
return value
return dt_util.parse_datetime(value)
@property
def device_class(self):