Skip to content

Commit

Permalink
fix(bermuda): enhance device address validation and null check for ti…
Browse files Browse the repository at this point in the history
…mestamp comparison
  • Loading branch information
skrashevich authored and agittins committed May 9, 2024
1 parent 7c4d8fe commit 57090a5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions custom_components/bermuda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 57090a5

Please sign in to comment.