mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-10 01:14:33 +02:00
pylint consistency
This commit is contained in:
parent
8769c322a3
commit
a6e6f4c697
3 changed files with 28 additions and 16 deletions
|
@ -63,7 +63,12 @@ class MikrotikControllerConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
errors["base"] = "name_exists"
|
errors["base"] = "name_exists"
|
||||||
|
|
||||||
# Test connection
|
# 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"])
|
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():
|
if not api.connect():
|
||||||
errors[CONF_HOST] = api.error
|
errors[CONF_HOST] = api.error
|
||||||
|
|
||||||
|
@ -74,7 +79,14 @@ class MikrotikControllerConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
data=user_input
|
data=user_input
|
||||||
)
|
)
|
||||||
|
|
||||||
return self._show_config_form(host=user_input["host"], username=user_input["username"], password=user_input["password"], port=user_input["port"], name=user_input["name"], use_ssl=user_input["ssl"], errors=errors)
|
return self._show_config_form(host=user_input["host"],
|
||||||
|
username=user_input["username"],
|
||||||
|
password=user_input["password"],
|
||||||
|
port=user_input["port"],
|
||||||
|
name=user_input["name"],
|
||||||
|
use_ssl=user_input["ssl"],
|
||||||
|
errors=errors
|
||||||
|
)
|
||||||
|
|
||||||
return self._show_config_form(errors=errors)
|
return self._show_config_form(errors=errors)
|
||||||
|
|
||||||
|
|
|
@ -141,13 +141,13 @@ class MikrotikControllerPortDeviceTracker(ScannerEntity):
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
"""Return the icon."""
|
"""Return the icon."""
|
||||||
if not self.mikrotik_controller.data['interface'][self._uid]['enabled']:
|
icon = 'mdi:lan-disconnect'
|
||||||
return 'mdi:lan-disconnect'
|
|
||||||
|
|
||||||
if self.mikrotik_controller.data['interface'][self._uid]['running']:
|
if self.mikrotik_controller.data['interface'][self._uid]['running']:
|
||||||
return 'mdi:lan-connect'
|
icon = 'mdi:lan-connect'
|
||||||
else:
|
else:
|
||||||
return 'mdi:lan-pending'
|
icon = 'mdi:lan-pending'
|
||||||
|
|
||||||
|
return icon
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self):
|
||||||
|
|
|
@ -56,11 +56,11 @@ class MikrotikAPI:
|
||||||
try:
|
try:
|
||||||
self._connection = librouteros.connect(self._host, self._username, self._password, **kwargs)
|
self._connection = librouteros.connect(self._host, self._username, self._password, **kwargs)
|
||||||
except (
|
except (
|
||||||
librouteros.exceptions.TrapError,
|
librouteros.exceptions.TrapError,
|
||||||
librouteros.exceptions.MultiTrapError,
|
librouteros.exceptions.MultiTrapError,
|
||||||
librouteros.exceptions.ConnectionClosed,
|
librouteros.exceptions.ConnectionClosed,
|
||||||
librouteros.exceptions.ProtocolError,
|
librouteros.exceptions.ProtocolError,
|
||||||
librouteros.exceptions.FatalError
|
librouteros.exceptions.FatalError
|
||||||
) as api_error:
|
) as api_error:
|
||||||
_LOGGER.error("Mikrotik %s: %s", self._host, api_error)
|
_LOGGER.error("Mikrotik %s: %s", self._host, api_error)
|
||||||
self.error_to_strings("%s" % api_error)
|
self.error_to_strings("%s" % api_error)
|
||||||
|
@ -107,10 +107,10 @@ class MikrotikAPI:
|
||||||
self._connection = None
|
self._connection = None
|
||||||
return None
|
return None
|
||||||
except (
|
except (
|
||||||
librouteros.exceptions.TrapError,
|
librouteros.exceptions.TrapError,
|
||||||
librouteros.exceptions.MultiTrapError,
|
librouteros.exceptions.MultiTrapError,
|
||||||
librouteros.exceptions.ProtocolError,
|
librouteros.exceptions.ProtocolError,
|
||||||
librouteros.exceptions.FatalError
|
librouteros.exceptions.FatalError
|
||||||
) as api_error:
|
) as api_error:
|
||||||
_LOGGER.error("Mikrotik %s connection error %s", self._host, api_error)
|
_LOGGER.error("Mikrotik %s connection error %s", self._host, api_error)
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue