Skip to content

Commit 2b6bc72

Browse files
Rename to last_modified
1 parent df9510b commit 2b6bc72

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

custom_components/periodic_min_max/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424

2525
CONF_ENTITY_ID = "entity_id"
2626

27-
ATTR_LAST_CHANGED_VALUE = "last_changed_value"
27+
ATTR_LAST_MODIFIED = "last_modified"

custom_components/periodic_min_max/sensor.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from homeassistant.util import dt as dt_util
4040

4141
from .const import (
42-
ATTR_LAST_CHANGED_VALUE,
42+
ATTR_LAST_MODIFIED,
4343
CONF_ENTITY_ID,
4444
DOMAIN,
4545
LOGGER,
@@ -197,7 +197,7 @@ class PeriodicMinMaxSensor(SensorEntity, RestoreEntity):
197197
_attr_should_poll = False
198198
_attr_state_class = SensorStateClass.MEASUREMENT
199199
_state_had_real_change = False
200-
_attr_last_changed_value: datetime = dt_util.utcnow().isoformat()
200+
_attr_last_modified: datetime = dt_util.utcnow().isoformat()
201201

202202
def __init__(
203203
self,
@@ -237,8 +237,8 @@ async def async_added_to_hass(self) -> None:
237237
last_state = await self.async_get_last_state()
238238
if last_state:
239239
last_attrs = last_state.attributes
240-
if last_attrs and ATTR_LAST_CHANGED_VALUE in last_attrs:
241-
self._attr_last_changed_value = last_attrs[ATTR_LAST_CHANGED_VALUE]
240+
if last_attrs and ATTR_LAST_MODIFIED in last_attrs:
241+
self._attr_last_modified = last_attrs[ATTR_LAST_MODIFIED]
242242

243243
self.async_on_remove(
244244
async_track_state_change_event(
@@ -313,7 +313,7 @@ def extra_state_attributes(self) -> dict[str, Any]:
313313
"""Return the device specific state attributes."""
314314
attributes: dict[str, Any] = {}
315315

316-
attributes[ATTR_LAST_CHANGED_VALUE] = self._attr_last_changed_value
316+
attributes[ATTR_LAST_MODIFIED] = self._attr_last_modified
317317

318318
return attributes
319319

@@ -365,7 +365,7 @@ def _async_min_max_sensor_state_listener(
365365
self._calc_values()
366366

367367
if self._state_had_real_change:
368-
self._attr_last_changed_value = dt_util.utcnow().isoformat(sep=" ")
368+
self._attr_last_modified = dt_util.utcnow().isoformat(sep=" ")
369369

370370
self.async_write_ha_state()
371371

0 commit comments

Comments
 (0)