mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-10 09:24:31 +02:00
display invalid lib version in UI during setup #2
This commit is contained in:
parent
6467673dce
commit
619871a719
4 changed files with 20 additions and 15 deletions
|
@ -17,9 +17,9 @@
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"name_exists": "Name already exists.",
|
"name_exists": "Name already exists.",
|
||||||
|
"librouteros_invalid": "Invalid librouteros library version installed.",
|
||||||
"cannot_connect": "Cannot connect to Mikrotik.",
|
"cannot_connect": "Cannot connect to Mikrotik.",
|
||||||
"wrong_login": "Invalid user name or password.",
|
"wrong_login": "Invalid user name or password."
|
||||||
"routeros_api_missing": "Python module routeros_api not installed."
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
},
|
},
|
||||||
"device_tracker": {
|
"device_tracker": {
|
||||||
"data": {
|
"data": {
|
||||||
"scan_interval": "Scan interval",
|
"scan_interval": "Scan interval (requires HA restart)",
|
||||||
"track_arp": "Show client MAC and IP on interfaces"
|
"track_arp": "Show client MAC and IP on interfaces"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ 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__)
|
||||||
|
@ -64,12 +65,16 @@ class MikrotikControllerConfigFlow(config_entries.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"]
|
||||||
)
|
)
|
||||||
|
except OldLibrouteros:
|
||||||
|
errors["base"] = "librouteros_invalid"
|
||||||
|
else:
|
||||||
if not api.connect():
|
if not api.connect():
|
||||||
errors[CONF_HOST] = api.error
|
errors[CONF_HOST] = api.error
|
||||||
|
|
||||||
|
|
|
@ -39,11 +39,11 @@ class MikrotikAPI:
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
def check_library(self):
|
def check_library(self):
|
||||||
if not hasattr(librouteros.exceptions, 'ConnectionClosed'):
|
if not hasattr(librouteros.exceptions, 'ConnectionClosed'):
|
||||||
error = "Old librouteros installed, check for possible conflicts with other integrations."
|
error = "Invalid librouteros library version installed, possible conflict with other software."
|
||||||
raise OldLibrouteros(error)
|
raise OldLibrouteros(error)
|
||||||
|
|
||||||
if not hasattr(librouteros.exceptions, 'ProtocolError'):
|
if not hasattr(librouteros.exceptions, 'ProtocolError'):
|
||||||
error = "Old librouteros installed, check for possible conflicts with other integrations."
|
error = "Invalid librouteros library version installed, possible conflict with other software."
|
||||||
raise OldLibrouteros(error)
|
raise OldLibrouteros(error)
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"name_exists": "Name already exists.",
|
"name_exists": "Name already exists.",
|
||||||
|
"librouteros_invalid": "Invalid librouteros library version installed.",
|
||||||
"cannot_connect": "Cannot connect to Mikrotik.",
|
"cannot_connect": "Cannot connect to Mikrotik.",
|
||||||
"wrong_login": "Invalid user name or password.",
|
"wrong_login": "Invalid user name or password."
|
||||||
"routeros_api_missing": "Python module routeros_api not installed."
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue