Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 320df10

Browse files
authored
Use _attr_last_reset to set last_reset (home-assistant#65648)
1 parent 98a7125 commit 320df10

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

‎homeassistant/components/iotawatt/sensor.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from iotawattpy.sensor import Sensor
99

1010
from homeassistant.components.sensor import (
11-
ATTR_LAST_RESET,
1211
SensorDeviceClass,
1312
SensorEntity,
1413
SensorEntityDescription,
@@ -211,6 +210,12 @@ def _handle_coordinator_update(self) -> None:
211210
else:
212211
self.hass.async_create_task(self.async_remove())
213212
return
213+
214+
if (begin := self._sensor_data.getBegin()) and (
215+
last_reset := dt.parse_datetime(begin)
216+
):
217+
self._attr_last_reset = last_reset
218+
214219
super()._handle_coordinator_update()
215220

216221
@property
@@ -220,8 +225,6 @@ def extra_state_attributes(self) -> dict[str, str]:
220225
attrs = {"type": data.getType()}
221226
if attrs["type"] == "Input":
222227
attrs["channel"] = data.getChannel()
223-
if (begin := data.getBegin()) and (last_reset := dt.parse_datetime(begin)):
224-
attrs[ATTR_LAST_RESET] = last_reset.isoformat()
225228

226229
return attrs
227230

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /