Skip to content

Commit

Permalink
Fix userfriendlyname key error
Browse files Browse the repository at this point in the history
  • Loading branch information
cyr-ius committed Jan 7, 2024
1 parent eea497b commit 0f5a5d5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions custom_components/bbox/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ async def async_setup_entry(

description = SensorEntityDescription(key="tracker", translation_key="tracker")

devices = coordinator.data.get("devices", {}).get("hosts", {}).get("list", [])

entities = [
BboxDeviceTracker(coordinator, description, device)
for device in coordinator.data.get("devices", {})
.get("hosts", {})
.get("list", [])
for device in devices
if device.get("macaddress")
]

async_add_entities(entities)
Expand Down Expand Up @@ -77,9 +78,9 @@ def is_connected(self):
@property
def name(self):
"""Return name."""
if self._device["userfriendlyname"] != "":
if self._device.get("userfriendlyname") != "":
name = self._device["userfriendlyname"]
elif self._device["hostname"] != "":
elif self._device.get("hostname") != "":
name = self._device["hostname"]
else:
name = self._device["macaddress"]
Expand Down

0 comments on commit 0f5a5d5

Please sign in to comment.