diff --git a/custom_components/mikrotik_router/config_flow.py b/custom_components/mikrotik_router/config_flow.py index ba8c4cf..25a2eec 100644 --- a/custom_components/mikrotik_router/config_flow.py +++ b/custom_components/mikrotik_router/config_flow.py @@ -25,7 +25,6 @@ from .const import ( DEFAULT_SCAN_INTERVAL, ) -from .exceptions import OldLibrouteros from .mikrotikapi import MikrotikAPI _LOGGER = logging.getLogger(__name__) @@ -73,18 +72,14 @@ class MikrotikControllerConfigFlow(ConfigFlow, domain=DOMAIN): errors["base"] = "name_exists" # Test connection - try: - api = MikrotikAPI(host=user_input["host"], - username=user_input["username"], - password=user_input["password"], - port=user_input["port"], - use_ssl=user_input["ssl"] - ) - except OldLibrouteros: - errors["base"] = "librouteros_invalid" - else: - if not api.connect(): - errors[CONF_HOST] = api.error + api = MikrotikAPI(host=user_input["host"], + username=user_input["username"], + password=user_input["password"], + port=user_input["port"], + use_ssl=user_input["ssl"] + ) + if not api.connect(): + errors[CONF_HOST] = api.error # Save instance if not errors: diff --git a/custom_components/mikrotik_router/exceptions.py b/custom_components/mikrotik_router/exceptions.py index 69278c4..ee4e2d3 100644 --- a/custom_components/mikrotik_router/exceptions.py +++ b/custom_components/mikrotik_router/exceptions.py @@ -1,9 +1,5 @@ """Exceptions for Mikrotik Router.""" -class OldLibrouteros(Exception): - """Old librouteros version.""" - - class ApiEntryNotFound(Exception): - """Old librouteros version.""" + """Api entry not found.""" diff --git a/custom_components/mikrotik_router/mikrotikapi.py b/custom_components/mikrotik_router/mikrotikapi.py index f5a6b3f..07817bc 100644 --- a/custom_components/mikrotik_router/mikrotikapi.py +++ b/custom_components/mikrotik_router/mikrotikapi.py @@ -5,7 +5,7 @@ import logging import os import sys import importlib -from .exceptions import OldLibrouteros, ApiEntryNotFound +from .exceptions import ApiEntryNotFound MODULE_PATH = os.path.join(os.path.dirname(__file__), "librouteros", "__init__.py") MODULE_NAME = "librouteros" @@ -38,24 +38,10 @@ class MikrotikAPI: self._connected = False self.error = "" - self.check_library() - # Default ports if not self._port: self._port = 8729 if self._use_ssl else 8728 - # --------------------------- - # check_library - # --------------------------- - def check_library(self): - if not hasattr(librouteros.exceptions, 'ConnectionClosed'): - error = "Invalid librouteros library version installed, possible conflict with other software." - raise OldLibrouteros(error) - - if not hasattr(librouteros.exceptions, 'ProtocolError'): - error = "Invalid librouteros library version installed, possible conflict with other software." - raise OldLibrouteros(error) - # --------------------------- # connect # ---------------------------