mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-10 01:14:33 +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": {
|
||||
"name_exists": "Name already exists.",
|
||||
"librouteros_invalid": "Invalid librouteros library version installed.",
|
||||
"cannot_connect": "Cannot connect to Mikrotik.",
|
||||
"wrong_login": "Invalid user name or password.",
|
||||
"routeros_api_missing": "Python module routeros_api not installed."
|
||||
"wrong_login": "Invalid user name or password."
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
|
@ -29,7 +29,7 @@
|
|||
},
|
||||
"device_tracker": {
|
||||
"data": {
|
||||
"scan_interval": "Scan interval",
|
||||
"scan_interval": "Scan interval (requires HA restart)",
|
||||
"track_arp": "Show client MAC and IP on interfaces"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ from .const import (
|
|||
DEFAULT_SCAN_INTERVAL,
|
||||
)
|
||||
|
||||
from .exceptions import OldLibrouteros
|
||||
from .mikrotikapi import MikrotikAPI
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -64,12 +65,16 @@ class MikrotikControllerConfigFlow(config_entries.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
|
||||
|
||||
|
|
|
@ -39,11 +39,11 @@ class MikrotikAPI:
|
|||
# ---------------------------
|
||||
def check_library(self):
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
# ---------------------------
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
},
|
||||
"error": {
|
||||
"name_exists": "Name already exists.",
|
||||
"librouteros_invalid": "Invalid librouteros library version installed.",
|
||||
"cannot_connect": "Cannot connect to Mikrotik.",
|
||||
"wrong_login": "Invalid user name or password.",
|
||||
"routeros_api_missing": "Python module routeros_api not installed."
|
||||
"wrong_login": "Invalid user name or password."
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue