From 57090a5645433fb5709ea6a6e448ff945bb6dc7e Mon Sep 17 00:00:00 2001 From: Sergey Krashevich Date: Thu, 9 May 2024 05:41:00 +0300 Subject: [PATCH] fix(bermuda): enhance device address validation and null check for timestamp comparison --- custom_components/bermuda/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/custom_components/bermuda/__init__.py b/custom_components/bermuda/__init__.py index 3d008f2..ee95a5c 100644 --- a/custom_components/bermuda/__init__.py +++ b/custom_components/bermuda/__init__.py @@ -305,7 +305,9 @@ def update_advertisement( # In this dict all MAC address keys are upper-cased uppermac = device_address.upper() if uppermac in stamps: - if self.stamp is None or stamps[uppermac] > self.stamp: + if self.stamp is None or ( + stamps[uppermac] is not None and stamps[uppermac] > self.stamp + ): new_stamp = stamps[uppermac] else: # We have no updated advert in this run. @@ -984,7 +986,7 @@ async def _async_update_data(self): # Doesn't look like an actual MAC address # Mark it as such so we don't spend time testing it again. device.address_type = BDADDR_TYPE_NOT_MAC48 - elif device.address[0:1] in "4567": + elif len(device.address) > 0 and device.address[0:1] in "4567": # We're checking if the first char in the address # is one of 4, 5, 6, 7. Python is fun :-) _LOGGER.debug("Identified IRK address on %s", device.address)