mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-14 03:14:30 +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
|
@ -21,6 +21,7 @@ from .const import (
|
|||
DEFAULT_SCAN_INTERVAL,
|
||||
)
|
||||
|
||||
from .exceptions import OldLibrouteros
|
||||
from .mikrotikapi import MikrotikAPI
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -64,14 +65,18 @@ class MikrotikControllerConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
errors["base"] = "name_exists"
|
||||
|
||||
# Test connection
|
||||
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
|
||||
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
|
||||
|
||||
# Save instance
|
||||
if not errors:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue