Skip to content

Commit cac9e18

Browse files
Fix last_replaced dates #2280
1 parent d783652 commit cac9e18

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

custom_components/battery_notes/device.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,13 @@ async def async_setup(self) -> bool:
193193
if entity.device_id:
194194
device_entry = device_registry.async_get(entity.device_id)
195195

196-
if device_entry.created_at.year > 1970:
196+
if device_entry and device_entry.created_at.year > 1970:
197197
last_replaced = device_entry.created_at.strftime(
198198
"%Y-%m-%dT%H:%M:%S:%f"
199199
)
200200
else:
201201
entity = entity_registry.async_get(source_entity_id)
202-
if entity.created_at.year > 1970:
202+
if entity and entity.created_at.year > 1970:
203203
last_replaced = entity.created_at.strftime("%Y-%m-%dT%H:%M:%S:%f")
204204

205205
_LOGGER.debug(

0 commit comments

Comments
 (0)