From 6afa6cd1eb93495e70f372c06b77bc65f450e9d7 Mon Sep 17 00:00:00 2001 From: hawksj <58028821+hawksj@users.noreply.github.com> Date: Wed, 10 Jul 2024 09:41:24 +0100 Subject: [PATCH 1/3] fix: ignore ethernet devices if none connected --- custom_components/amplifi/coordinator.py | 29 ++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/custom_components/amplifi/coordinator.py b/custom_components/amplifi/coordinator.py index 5ad0aab..d2846e8 100644 --- a/custom_components/amplifi/coordinator.py +++ b/custom_components/amplifi/coordinator.py @@ -96,20 +96,21 @@ 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}") def extract_wan_speeds(self): if self.data is None: From 1b1c2353e062e789b06550dc648d5ac2cebe56ea Mon Sep 17 00:00:00 2001 From: hawksj <58028821+hawksj@users.noreply.github.com> Date: Wed, 10 Jul 2024 09:00:13 +0100 Subject: [PATCH 2/3] fix: wifi devices named after their mac have better friendly names. MAC attribute is no longer applied to Ethernet Port trackers --- custom_components/amplifi/device_tracker.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/custom_components/amplifi/device_tracker.py b/custom_components/amplifi/device_tracker.py index a77be62..85c6043 100644 --- a/custom_components/amplifi/device_tracker.py +++ b/custom_components/amplifi/device_tracker.py @@ -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 @@ -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): From 3569dbc7e00d4d88164b74f72810807a0f63611b Mon Sep 17 00:00:00 2001 From: hawksj <58028821+hawksj@users.noreply.github.com> Date: Wed, 10 Jul 2024 12:11:19 +0100 Subject: [PATCH 3/3] fix: adding debug message if no Ethernet devices found --- custom_components/amplifi/coordinator.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/custom_components/amplifi/coordinator.py b/custom_components/amplifi/coordinator.py index d2846e8..bc9a65d 100644 --- a/custom_components/amplifi/coordinator.py +++ b/custom_components/amplifi/coordinator.py @@ -111,6 +111,9 @@ def extract_ethernet_devices(self): 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: