Skip to content

Commit

Permalink
Merge pull request #57 from hawksj/2.1.2-bugfix
Browse files Browse the repository at this point in the history
2.1.2 bugfixes
  • Loading branch information
hawksj authored Jul 26, 2024
2 parents 8f435dd + 3569dbc commit 12f749f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
32 changes: 18 additions & 14 deletions custom_components/amplifi/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,24 @@ def extract_ethernet_devices(self):
return
router_mac_addr = self.get_router_mac_addr()

ethernet_devices = {}
raw_devices_info = self.data[DEVICES_INFO_IDX]
raw_device_to_eth_index = self.data[ETHERNET_PORT_TO_DEVICE_IDX][router_mac_addr]

if raw_device_to_eth_index and raw_devices_info:
for device in raw_device_to_eth_index:
device_info = raw_devices_info[device]
port = raw_device_to_eth_index[device]
device_info["connected_to_port"] = port
ethernet_devices[device] = device_info

self._ethernet_devices = ethernet_devices

_LOGGER.debug(f"ethernet_devices={self._ethernet_devices}")
if router_mac_addr in self.data[ETHERNET_PORT_TO_DEVICE_IDX]:
ethernet_devices = {}
raw_devices_info = self.data[DEVICES_INFO_IDX]
raw_device_to_eth_index = self.data[ETHERNET_PORT_TO_DEVICE_IDX][router_mac_addr]

if raw_device_to_eth_index and raw_devices_info:
for device in raw_device_to_eth_index:
device_info = raw_devices_info[device]
port = raw_device_to_eth_index[device]
device_info["connected_to_port"] = port
ethernet_devices[device] = device_info

self._ethernet_devices = ethernet_devices

_LOGGER.debug(f"ethernet_devices={self._ethernet_devices}")
else:
_LOGGER.debug(f"No ethernet devices found")
return

def extract_wan_speeds(self):
if self.data is None:
Expand Down
4 changes: 3 additions & 1 deletion custom_components/amplifi/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def __init__(
self._description = self._data['Address']
else:
self._name = f"{DOMAIN}_{self.unique_id}"
self._description = self.unique_id.upper()

self._name = re.sub("[^0-9a-zA-Z]+", "_", self._name).lower()
# Override the entity_id so we can provide a better friendly name
Expand Down Expand Up @@ -293,7 +294,8 @@ def icon(self):
@property
def mac_address(self):
"""Return the mac address of the device."""
return self.unique_id
if self._is_device:
return self.unique_id

@property
def extra_state_attributes(self):
Expand Down

0 comments on commit 12f749f

Please sign in to comment.