restore float and not string (#56406)

pull/56445/head
Diogo Gomes 2021-09-20 06:31:58 +01:00 committed by GitHub
parent b060c025ce
commit b05c1b516e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -306,7 +306,11 @@ class UtilityMeterSensor(RestoreEntity, SensorEntity):
if state:
self._state = Decimal(state.state)
self._unit_of_measurement = state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
self._last_period = state.attributes.get(ATTR_LAST_PERIOD)
self._last_period = (
float(state.attributes.get(ATTR_LAST_PERIOD))
if state.attributes.get(ATTR_LAST_PERIOD)
else 0
)
self._last_reset = dt_util.as_utc(
dt_util.parse_datetime(state.attributes.get(ATTR_LAST_RESET))
)