mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-09 17:04:29 +02:00
removed library check since it is now included in the integration #2
This commit is contained in:
parent
b70bb9db92
commit
4f8c709488
3 changed files with 10 additions and 33 deletions
|
@ -25,7 +25,6 @@ from .const import (
|
||||||
DEFAULT_SCAN_INTERVAL,
|
DEFAULT_SCAN_INTERVAL,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .exceptions import OldLibrouteros
|
|
||||||
from .mikrotikapi import MikrotikAPI
|
from .mikrotikapi import MikrotikAPI
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -73,18 +72,14 @@ class MikrotikControllerConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
errors["base"] = "name_exists"
|
errors["base"] = "name_exists"
|
||||||
|
|
||||||
# Test connection
|
# Test connection
|
||||||
try:
|
api = MikrotikAPI(host=user_input["host"],
|
||||||
api = MikrotikAPI(host=user_input["host"],
|
username=user_input["username"],
|
||||||
username=user_input["username"],
|
password=user_input["password"],
|
||||||
password=user_input["password"],
|
port=user_input["port"],
|
||||||
port=user_input["port"],
|
use_ssl=user_input["ssl"]
|
||||||
use_ssl=user_input["ssl"]
|
)
|
||||||
)
|
if not api.connect():
|
||||||
except OldLibrouteros:
|
errors[CONF_HOST] = api.error
|
||||||
errors["base"] = "librouteros_invalid"
|
|
||||||
else:
|
|
||||||
if not api.connect():
|
|
||||||
errors[CONF_HOST] = api.error
|
|
||||||
|
|
||||||
# Save instance
|
# Save instance
|
||||||
if not errors:
|
if not errors:
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
"""Exceptions for Mikrotik Router."""
|
"""Exceptions for Mikrotik Router."""
|
||||||
|
|
||||||
|
|
||||||
class OldLibrouteros(Exception):
|
|
||||||
"""Old librouteros version."""
|
|
||||||
|
|
||||||
|
|
||||||
class ApiEntryNotFound(Exception):
|
class ApiEntryNotFound(Exception):
|
||||||
"""Old librouteros version."""
|
"""Api entry not found."""
|
||||||
|
|
|
@ -5,7 +5,7 @@ import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import importlib
|
import importlib
|
||||||
from .exceptions import OldLibrouteros, ApiEntryNotFound
|
from .exceptions import ApiEntryNotFound
|
||||||
|
|
||||||
MODULE_PATH = os.path.join(os.path.dirname(__file__), "librouteros", "__init__.py")
|
MODULE_PATH = os.path.join(os.path.dirname(__file__), "librouteros", "__init__.py")
|
||||||
MODULE_NAME = "librouteros"
|
MODULE_NAME = "librouteros"
|
||||||
|
@ -38,24 +38,10 @@ class MikrotikAPI:
|
||||||
self._connected = False
|
self._connected = False
|
||||||
self.error = ""
|
self.error = ""
|
||||||
|
|
||||||
self.check_library()
|
|
||||||
|
|
||||||
# Default ports
|
# Default ports
|
||||||
if not self._port:
|
if not self._port:
|
||||||
self._port = 8729 if self._use_ssl else 8728
|
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
|
# connect
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue