Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update librouteros and re-connect to api if connection is lost #18421

Merged
merged 12 commits into from
Nov 27, 2018
12 changes: 9 additions & 3 deletions homeassistant/components/device_tracker/mikrotik.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from homeassistant.const import (
CONF_HOST, CONF_PASSWORD, CONF_USERNAME, CONF_PORT)

REQUIREMENTS = ['librouteros==2.1.1']
REQUIREMENTS = ['librouteros==2.2.0']

MTK_DEFAULT_API_PORT = '8728'

Expand Down Expand Up @@ -129,12 +129,18 @@ def connect_to_device(self):
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,
slackr31337 marked this conversation as resolved.
Show resolved Hide resolved
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):
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,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
Expand Down