Return native timestamps for home connect (#61116)

This commit is contained in:
Paulus Schoutsen 2021-12-06 10:08:52 -08:00 committed by GitHub
parent d802f3a82f
commit e712b80650
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,16 +63,14 @@ class HomeConnectSensor(HomeConnectEntity, SensorEntity):
elif ( elif (
self._state is not None self._state is not None
and self._sign == 1 and self._sign == 1
and dt_util.parse_datetime(self._state) < dt_util.utcnow() and self._state < dt_util.utcnow()
): ):
# if the date is supposed to be in the future but we're # if the date is supposed to be in the future but we're
# already past it, set state to None. # already past it, set state to None.
self._state = None self._state = None
else: else:
seconds = self._sign * float(status[self._key][ATTR_VALUE]) seconds = self._sign * float(status[self._key][ATTR_VALUE])
self._state = ( self._state = dt_util.utcnow() + timedelta(seconds=seconds)
dt_util.utcnow() + timedelta(seconds=seconds)
).isoformat()
else: else:
self._state = status[self._key].get(ATTR_VALUE) self._state = status[self._key].get(ATTR_VALUE)
if self._key == BSH_OPERATION_STATE: if self._key == BSH_OPERATION_STATE: