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
2 changed files with 10 additions and 4 deletions
|
@ -16,7 +16,7 @@ from homeassistant.components.device_tracker import (
|
|||
from homeassistant.const import (
|
||||
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__)
|
||||
|
||||
|
@ -144,12 +144,18 @@ class MikrotikScanner(DeviceScanner):
|
|||
librouteros.exceptions.MultiTrapError,
|
||||
librouteros.exceptions.ConnectionError) as api_error:
|
||||
_LOGGER.error("Connection error: %s", api_error)
|
||||
|
||||
return self.connected
|
||||
|
||||
def scan_devices(self):
|
||||
"""Scan for new devices and return a list with found device MACs."""
|
||||
self._update_info()
|
||||
import librouteros
|
||||
try:
|
||||
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]
|
||||
|
||||
def get_device_name(self, device):
|
||||
|
|
|
@ -570,7 +570,7 @@ libpurecoollink==0.4.2
|
|||
libpyfoscam==1.0
|
||||
|
||||
# homeassistant.components.device_tracker.mikrotik
|
||||
librouteros==2.1.1
|
||||
librouteros==2.2.0
|
||||
|
||||
# homeassistant.components.media_player.soundtouch
|
||||
libsoundtouch==0.7.2
|
||||
|
|
Loading…
Add table
Reference in a new issue