Skip to content

Commit

Permalink
Fix last_replaced dates #2280
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-codechimp committed Nov 2, 2024
1 parent d783652 commit cac9e18
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions custom_components/battery_notes/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ async def async_setup(self) -> bool:
if entity.device_id:
device_entry = device_registry.async_get(entity.device_id)

if device_entry.created_at.year > 1970:
if device_entry and device_entry.created_at.year > 1970:
last_replaced = device_entry.created_at.strftime(
"%Y-%m-%dT%H:%M:%S:%f"
)
else:
entity = entity_registry.async_get(source_entity_id)
if entity.created_at.year > 1970:
if entity and entity.created_at.year > 1970:
last_replaced = entity.created_at.strftime("%Y-%m-%dT%H:%M:%S:%f")

_LOGGER.debug(
Expand Down

0 comments on commit cac9e18

Please sign in to comment.