diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a1a6e7..c982ee5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ - Fix unhandled WS session disconnection - Add support for special interfaces (vtun, switch, pppoe, openvpn) +**Please note:** +For now, special interface do not support to turn on / off + ## 2.0.14 **Debugging became easier (less IO and Disk Space)** diff --git a/custom_components/edgeos/component/managers/home_assistant.py b/custom_components/edgeos/component/managers/home_assistant.py index 1e44d50..3277f0f 100644 --- a/custom_components/edgeos/component/managers/home_assistant.py +++ b/custom_components/edgeos/component/managers/home_assistant.py @@ -245,7 +245,9 @@ def load_entities(self): for unique_id in self._interfaces: interface_item = self._interfaces.get(unique_id) - self._load_interface_monitor_switch(interface_item) + + if not interface_item.is_special: + self._load_interface_monitor_switch(interface_item) if self._system.user_level == USER_LEVEL_ADMIN: self._load_interface_status_switch(interface_item) @@ -306,7 +308,7 @@ async def _extract_ws_data(self): if interface_type_name is not None: interface_data = interfaces_data.get(name) - self._extract_interface(name, interface_type_name, interface_data) + self._extract_interface(name, interface_type_name, interface_data, True) interface_item = self._interfaces.get(name) self._update_interface_stats(interface_item, stats) @@ -455,7 +457,7 @@ def _extract_interfaces(self, data: dict): _LOGGER.error(f"Failed to extract Interfaces data, Error: {ex}, Line: {line_number}") - def _extract_interface(self, name: str, interface_type: str, data: dict): + def _extract_interface(self, name: str, interface_type: str, data: dict, is_special: bool = False): try: existing_interface_data = self._interfaces.get(name) @@ -465,6 +467,7 @@ def _extract_interface(self, name: str, interface_type: str, data: dict): else: interface = existing_interface_data + interface.is_special = is_special interface.description = data.get(INTERFACE_DATA_DESCRIPTION) interface.duplex = data.get(INTERFACE_DATA_DUPLEX) interface.speed = data.get(INTERFACE_DATA_SPEED) @@ -478,6 +481,9 @@ def _extract_interface(self, name: str, interface_type: str, data: dict): interface.promiscuous = data.get(INTERFACE_DATA_PROMISCUOUS) interface.stp = data.get(INTERFACE_DATA_STP, FALSE_STR).lower() == TRUE_STR + if is_special: + interface.up = True + self._interfaces[interface.unique_id] = interface except Exception as ex: diff --git a/custom_components/edgeos/component/models/edge_os_interface_data.py b/custom_components/edgeos/component/models/edge_os_interface_data.py index be4d7fd..3a4d6c1 100644 --- a/custom_components/edgeos/component/models/edge_os_interface_data.py +++ b/custom_components/edgeos/component/models/edge_os_interface_data.py @@ -25,6 +25,7 @@ class EdgeOSInterfaceData: up: bool | None l1up: bool | None mac: str | None + is_special: bool def __init__(self, name: str, interface_type: str): self.name = name @@ -48,6 +49,7 @@ def __init__(self, name: str, interface_type: str): self.up = None self.l1up = None self.mac = None + self.is_special = False @property def unique_id(self) -> str: