mirror of
https://github.com/home-assistant/core.git
synced 2025-07-12 15:57:06 +00:00
Update librouteros and re-connect to api if connection is lost (#18421)
* Reconnect when connection is lost * Fix tabs * add librouteros.exceptions * add logger * fix line too long * added import librouteros * Update librouteros version * Update mikrotik.py * Update mikrotik.py * Fix trailing whitespace * Update mikrotik.py * Update mikrotik.py
This commit is contained in:
parent
1cbe080df9
commit
c1ed2f17ac
@ -16,7 +16,7 @@ from homeassistant.components.device_tracker import (
|
|||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST, CONF_PASSWORD, CONF_USERNAME, CONF_PORT, CONF_SSL, CONF_METHOD)
|
CONF_HOST, CONF_PASSWORD, CONF_USERNAME, CONF_PORT, CONF_SSL, CONF_METHOD)
|
||||||
|
|
||||||
REQUIREMENTS = ['librouteros==2.1.1']
|
REQUIREMENTS = ['librouteros==2.2.0']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -144,12 +144,18 @@ class MikrotikScanner(DeviceScanner):
|
|||||||
librouteros.exceptions.MultiTrapError,
|
librouteros.exceptions.MultiTrapError,
|
||||||
librouteros.exceptions.ConnectionError) as api_error:
|
librouteros.exceptions.ConnectionError) as api_error:
|
||||||
_LOGGER.error("Connection error: %s", api_error)
|
_LOGGER.error("Connection error: %s", api_error)
|
||||||
|
|
||||||
return self.connected
|
return self.connected
|
||||||
|
|
||||||
def scan_devices(self):
|
def scan_devices(self):
|
||||||
"""Scan for new devices and return a list with found device MACs."""
|
"""Scan for new devices and return a list with found device MACs."""
|
||||||
|
import librouteros
|
||||||
|
try:
|
||||||
self._update_info()
|
self._update_info()
|
||||||
|
except (librouteros.exceptions.TrapError,
|
||||||
|
librouteros.exceptions.MultiTrapError,
|
||||||
|
librouteros.exceptions.ConnectionError) as api_error:
|
||||||
|
_LOGGER.error("Connection error: %s", api_error)
|
||||||
|
self.connect_to_device()
|
||||||
return [device for device in self.last_results]
|
return [device for device in self.last_results]
|
||||||
|
|
||||||
def get_device_name(self, device):
|
def get_device_name(self, device):
|
||||||
|
@ -570,7 +570,7 @@ libpurecoollink==0.4.2
|
|||||||
libpyfoscam==1.0
|
libpyfoscam==1.0
|
||||||
|
|
||||||
# homeassistant.components.device_tracker.mikrotik
|
# homeassistant.components.device_tracker.mikrotik
|
||||||
librouteros==2.1.1
|
librouteros==2.2.0
|
||||||
|
|
||||||
# homeassistant.components.media_player.soundtouch
|
# homeassistant.components.media_player.soundtouch
|
||||||
libsoundtouch==0.7.2
|
libsoundtouch==0.7.2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user