mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Change utility_meter last_reset timestamps to UTC (#51067)
This commit is contained in:
parent
67804ee5df
commit
ae8652217c
@ -131,7 +131,7 @@ class UtilityMeterSensor(RestoreEntity, SensorEntity):
|
|||||||
self._sensor_source_id = source_entity
|
self._sensor_source_id = source_entity
|
||||||
self._state = 0
|
self._state = 0
|
||||||
self._last_period = 0
|
self._last_period = 0
|
||||||
self._last_reset = dt_util.now()
|
self._last_reset = dt_util.utcnow()
|
||||||
self._collecting = None
|
self._collecting = None
|
||||||
if name:
|
if name:
|
||||||
self._name = name
|
self._name = name
|
||||||
@ -237,7 +237,7 @@ class UtilityMeterSensor(RestoreEntity, SensorEntity):
|
|||||||
if self._tariff_entity != entity_id:
|
if self._tariff_entity != entity_id:
|
||||||
return
|
return
|
||||||
_LOGGER.debug("Reset utility meter <%s>", self.entity_id)
|
_LOGGER.debug("Reset utility meter <%s>", self.entity_id)
|
||||||
self._last_reset = dt_util.now()
|
self._last_reset = dt_util.utcnow()
|
||||||
self._last_period = str(self._state)
|
self._last_period = str(self._state)
|
||||||
self._state = 0
|
self._state = 0
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
@ -284,8 +284,8 @@ class UtilityMeterSensor(RestoreEntity, SensorEntity):
|
|||||||
self._state = Decimal(state.state)
|
self._state = Decimal(state.state)
|
||||||
self._unit_of_measurement = state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
self._unit_of_measurement = state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
||||||
self._last_period = state.attributes.get(ATTR_LAST_PERIOD)
|
self._last_period = state.attributes.get(ATTR_LAST_PERIOD)
|
||||||
self._last_reset = dt_util.parse_datetime(
|
self._last_reset = dt_util.as_utc(
|
||||||
state.attributes.get(ATTR_LAST_RESET)
|
dt_util.parse_datetime(state.attributes.get(ATTR_LAST_RESET))
|
||||||
)
|
)
|
||||||
if state.attributes.get(ATTR_STATUS) == COLLECTING:
|
if state.attributes.get(ATTR_STATUS) == COLLECTING:
|
||||||
# Fake cancellation function to init the meter in similar state
|
# Fake cancellation function to init the meter in similar state
|
||||||
|
Loading…
x
Reference in New Issue
Block a user