From cac9e1806e94c1df6467fc3e2009450ef61a792c Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Sat, 2 Nov 2024 09:54:04 +0000 Subject: [PATCH] Fix last_replaced dates #2280 --- custom_components/battery_notes/device.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/battery_notes/device.py b/custom_components/battery_notes/device.py index bdc127c1..70540bb6 100644 --- a/custom_components/battery_notes/device.py +++ b/custom_components/battery_notes/device.py @@ -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(