2019-04-03 15:40:03 +00:00
|
|
|
"""Support for Mikrotik routers as device tracker."""
|
2017-04-30 03:39:11 +00:00
|
|
|
import logging
|
|
|
|
|
Add mikrotik SSL support (#17898)
* Update mikrotik.py
* Update mikrotik.py
* Added basic api_ssl support
Added preliminary support to use api_ssl instead of api. It don't check the validity of the certificate need it.
At Home Assistant side add ssl = true to your sensor configuration, and don't forget to change the port too (to 8729 by default):
device_tracker:
- platform: mikrotik
host: 192.168.88.1
port: 8729
ssl: true
username: homeassistant
password: TopSecret
At MikroTik side you have to add or generate a certificate, and configure api_ssl to use it. Here is an example:
/certificate add common-name="Self signed demo certificate for API" days-valid=3650 name="Self signed demo certificate for API" key-usage=digital-signature,key-encipherment,tls-server,key-cert-sign,crl-sign
/certificate sign "Self signed demo certificate for API"
/ip service set api-ssl certificate="Self signed demo certificate for API"
/ip service enable api-ssl
/ip service disable api
/user group add name=homeassistant policy=read,api,!local,!telnet,!ssh,!ftp,!reboot,!write,!policy,!test,!winbox,!password,!web,!sniff,!sensitive,!romon,!dude,!tikapp
/user add group=homeassistant name=homeassistant
/user set password="TopSecret" homeassistant
* Fixed import missind ssl lib
* SSL support code cleanup, use ssl-api port by default if ssl enabled
* Restored accidentalli deleted method parameter
* Fixed Python 3.5.3 compilation errors
Fixed Python 3.5.3 compilation errors reported by Travis CI
* Removed duplicated MTK_DEFAULT_API_PORT
2018-11-19 15:54:09 +00:00
|
|
|
import ssl
|
|
|
|
|
2017-04-30 03:39:11 +00:00
|
|
|
import voluptuous as vol
|
|
|
|
|
|
|
|
import homeassistant.helpers.config_validation as cv
|
|
|
|
from homeassistant.components.device_tracker import (
|
|
|
|
DOMAIN, PLATFORM_SCHEMA, DeviceScanner)
|
2017-07-24 14:45:02 +00:00
|
|
|
from homeassistant.const import (
|
Add mikrotik SSL support (#17898)
* Update mikrotik.py
* Update mikrotik.py
* Added basic api_ssl support
Added preliminary support to use api_ssl instead of api. It don't check the validity of the certificate need it.
At Home Assistant side add ssl = true to your sensor configuration, and don't forget to change the port too (to 8729 by default):
device_tracker:
- platform: mikrotik
host: 192.168.88.1
port: 8729
ssl: true
username: homeassistant
password: TopSecret
At MikroTik side you have to add or generate a certificate, and configure api_ssl to use it. Here is an example:
/certificate add common-name="Self signed demo certificate for API" days-valid=3650 name="Self signed demo certificate for API" key-usage=digital-signature,key-encipherment,tls-server,key-cert-sign,crl-sign
/certificate sign "Self signed demo certificate for API"
/ip service set api-ssl certificate="Self signed demo certificate for API"
/ip service enable api-ssl
/ip service disable api
/user group add name=homeassistant policy=read,api,!local,!telnet,!ssh,!ftp,!reboot,!write,!policy,!test,!winbox,!password,!web,!sniff,!sensitive,!romon,!dude,!tikapp
/user add group=homeassistant name=homeassistant
/user set password="TopSecret" homeassistant
* Fixed import missind ssl lib
* SSL support code cleanup, use ssl-api port by default if ssl enabled
* Restored accidentalli deleted method parameter
* Fixed Python 3.5.3 compilation errors
Fixed Python 3.5.3 compilation errors reported by Travis CI
* Removed duplicated MTK_DEFAULT_API_PORT
2018-11-19 15:54:09 +00:00
|
|
|
CONF_HOST, CONF_PASSWORD, CONF_USERNAME, CONF_PORT, CONF_SSL, CONF_METHOD)
|
2017-04-30 03:39:11 +00:00
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
2018-11-03 22:48:08 +00:00
|
|
|
MTK_DEFAULT_API_PORT = '8728'
|
Add mikrotik SSL support (#17898)
* Update mikrotik.py
* Update mikrotik.py
* Added basic api_ssl support
Added preliminary support to use api_ssl instead of api. It don't check the validity of the certificate need it.
At Home Assistant side add ssl = true to your sensor configuration, and don't forget to change the port too (to 8729 by default):
device_tracker:
- platform: mikrotik
host: 192.168.88.1
port: 8729
ssl: true
username: homeassistant
password: TopSecret
At MikroTik side you have to add or generate a certificate, and configure api_ssl to use it. Here is an example:
/certificate add common-name="Self signed demo certificate for API" days-valid=3650 name="Self signed demo certificate for API" key-usage=digital-signature,key-encipherment,tls-server,key-cert-sign,crl-sign
/certificate sign "Self signed demo certificate for API"
/ip service set api-ssl certificate="Self signed demo certificate for API"
/ip service enable api-ssl
/ip service disable api
/user group add name=homeassistant policy=read,api,!local,!telnet,!ssh,!ftp,!reboot,!write,!policy,!test,!winbox,!password,!web,!sniff,!sensitive,!romon,!dude,!tikapp
/user add group=homeassistant name=homeassistant
/user set password="TopSecret" homeassistant
* Fixed import missind ssl lib
* SSL support code cleanup, use ssl-api port by default if ssl enabled
* Restored accidentalli deleted method parameter
* Fixed Python 3.5.3 compilation errors
Fixed Python 3.5.3 compilation errors reported by Travis CI
* Removed duplicated MTK_DEFAULT_API_PORT
2018-11-19 15:54:09 +00:00
|
|
|
MTK_DEFAULT_API_SSL_PORT = '8729'
|
2018-11-03 22:48:08 +00:00
|
|
|
|
2019-04-04 09:15:20 +00:00
|
|
|
CONF_ENCODING = 'encoding'
|
|
|
|
DEFAULT_ENCODING = 'utf-8'
|
|
|
|
|
2017-04-30 03:39:11 +00:00
|
|
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
|
|
|
vol.Required(CONF_HOST): cv.string,
|
|
|
|
vol.Required(CONF_USERNAME): cv.string,
|
|
|
|
vol.Required(CONF_PASSWORD): cv.string,
|
2018-11-03 22:48:08 +00:00
|
|
|
vol.Optional(CONF_METHOD): cv.string,
|
Add mikrotik SSL support (#17898)
* Update mikrotik.py
* Update mikrotik.py
* Added basic api_ssl support
Added preliminary support to use api_ssl instead of api. It don't check the validity of the certificate need it.
At Home Assistant side add ssl = true to your sensor configuration, and don't forget to change the port too (to 8729 by default):
device_tracker:
- platform: mikrotik
host: 192.168.88.1
port: 8729
ssl: true
username: homeassistant
password: TopSecret
At MikroTik side you have to add or generate a certificate, and configure api_ssl to use it. Here is an example:
/certificate add common-name="Self signed demo certificate for API" days-valid=3650 name="Self signed demo certificate for API" key-usage=digital-signature,key-encipherment,tls-server,key-cert-sign,crl-sign
/certificate sign "Self signed demo certificate for API"
/ip service set api-ssl certificate="Self signed demo certificate for API"
/ip service enable api-ssl
/ip service disable api
/user group add name=homeassistant policy=read,api,!local,!telnet,!ssh,!ftp,!reboot,!write,!policy,!test,!winbox,!password,!web,!sniff,!sensitive,!romon,!dude,!tikapp
/user add group=homeassistant name=homeassistant
/user set password="TopSecret" homeassistant
* Fixed import missind ssl lib
* SSL support code cleanup, use ssl-api port by default if ssl enabled
* Restored accidentalli deleted method parameter
* Fixed Python 3.5.3 compilation errors
Fixed Python 3.5.3 compilation errors reported by Travis CI
* Removed duplicated MTK_DEFAULT_API_PORT
2018-11-19 15:54:09 +00:00
|
|
|
vol.Optional(CONF_PORT): cv.port,
|
2019-04-04 09:15:20 +00:00
|
|
|
vol.Optional(CONF_SSL, default=False): cv.boolean,
|
|
|
|
vol.Optional(CONF_ENCODING, default=DEFAULT_ENCODING): cv.string,
|
2017-04-30 03:39:11 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
def get_scanner(hass, config):
|
|
|
|
"""Validate the configuration and return MTikScanner."""
|
|
|
|
scanner = MikrotikScanner(config[DOMAIN])
|
|
|
|
return scanner if scanner.success_init else None
|
|
|
|
|
|
|
|
|
|
|
|
class MikrotikScanner(DeviceScanner):
|
|
|
|
"""This class queries a Mikrotik router."""
|
|
|
|
|
|
|
|
def __init__(self, config):
|
|
|
|
"""Initialize the scanner."""
|
|
|
|
self.last_results = {}
|
|
|
|
|
|
|
|
self.host = config[CONF_HOST]
|
Add mikrotik SSL support (#17898)
* Update mikrotik.py
* Update mikrotik.py
* Added basic api_ssl support
Added preliminary support to use api_ssl instead of api. It don't check the validity of the certificate need it.
At Home Assistant side add ssl = true to your sensor configuration, and don't forget to change the port too (to 8729 by default):
device_tracker:
- platform: mikrotik
host: 192.168.88.1
port: 8729
ssl: true
username: homeassistant
password: TopSecret
At MikroTik side you have to add or generate a certificate, and configure api_ssl to use it. Here is an example:
/certificate add common-name="Self signed demo certificate for API" days-valid=3650 name="Self signed demo certificate for API" key-usage=digital-signature,key-encipherment,tls-server,key-cert-sign,crl-sign
/certificate sign "Self signed demo certificate for API"
/ip service set api-ssl certificate="Self signed demo certificate for API"
/ip service enable api-ssl
/ip service disable api
/user group add name=homeassistant policy=read,api,!local,!telnet,!ssh,!ftp,!reboot,!write,!policy,!test,!winbox,!password,!web,!sniff,!sensitive,!romon,!dude,!tikapp
/user add group=homeassistant name=homeassistant
/user set password="TopSecret" homeassistant
* Fixed import missind ssl lib
* SSL support code cleanup, use ssl-api port by default if ssl enabled
* Restored accidentalli deleted method parameter
* Fixed Python 3.5.3 compilation errors
Fixed Python 3.5.3 compilation errors reported by Travis CI
* Removed duplicated MTK_DEFAULT_API_PORT
2018-11-19 15:54:09 +00:00
|
|
|
self.ssl = config[CONF_SSL]
|
|
|
|
try:
|
|
|
|
self.port = config[CONF_PORT]
|
|
|
|
except KeyError:
|
|
|
|
if self.ssl:
|
|
|
|
self.port = MTK_DEFAULT_API_SSL_PORT
|
|
|
|
else:
|
|
|
|
self.port = MTK_DEFAULT_API_PORT
|
2017-04-30 03:39:11 +00:00
|
|
|
self.username = config[CONF_USERNAME]
|
|
|
|
self.password = config[CONF_PASSWORD]
|
2018-11-14 17:05:29 +00:00
|
|
|
self.method = config.get(CONF_METHOD)
|
2019-04-18 20:46:49 +00:00
|
|
|
self.encoding = config[CONF_ENCODING]
|
2017-04-30 03:39:11 +00:00
|
|
|
|
|
|
|
self.connected = False
|
|
|
|
self.success_init = False
|
|
|
|
self.client = None
|
2017-05-22 00:18:55 +00:00
|
|
|
self.wireless_exist = None
|
2017-04-30 03:39:11 +00:00
|
|
|
self.success_init = self.connect_to_device()
|
|
|
|
|
|
|
|
if self.success_init:
|
2018-11-03 22:48:08 +00:00
|
|
|
_LOGGER.info("Start polling Mikrotik (%s) router...", self.host)
|
2017-04-30 03:39:11 +00:00
|
|
|
self._update_info()
|
|
|
|
else:
|
2018-11-03 22:48:08 +00:00
|
|
|
_LOGGER.error("Connection to Mikrotik (%s) failed", self.host)
|
2017-04-30 03:39:11 +00:00
|
|
|
|
|
|
|
def connect_to_device(self):
|
|
|
|
"""Connect to Mikrotik method."""
|
|
|
|
import librouteros
|
|
|
|
try:
|
Add mikrotik SSL support (#17898)
* Update mikrotik.py
* Update mikrotik.py
* Added basic api_ssl support
Added preliminary support to use api_ssl instead of api. It don't check the validity of the certificate need it.
At Home Assistant side add ssl = true to your sensor configuration, and don't forget to change the port too (to 8729 by default):
device_tracker:
- platform: mikrotik
host: 192.168.88.1
port: 8729
ssl: true
username: homeassistant
password: TopSecret
At MikroTik side you have to add or generate a certificate, and configure api_ssl to use it. Here is an example:
/certificate add common-name="Self signed demo certificate for API" days-valid=3650 name="Self signed demo certificate for API" key-usage=digital-signature,key-encipherment,tls-server,key-cert-sign,crl-sign
/certificate sign "Self signed demo certificate for API"
/ip service set api-ssl certificate="Self signed demo certificate for API"
/ip service enable api-ssl
/ip service disable api
/user group add name=homeassistant policy=read,api,!local,!telnet,!ssh,!ftp,!reboot,!write,!policy,!test,!winbox,!password,!web,!sniff,!sensitive,!romon,!dude,!tikapp
/user add group=homeassistant name=homeassistant
/user set password="TopSecret" homeassistant
* Fixed import missind ssl lib
* SSL support code cleanup, use ssl-api port by default if ssl enabled
* Restored accidentalli deleted method parameter
* Fixed Python 3.5.3 compilation errors
Fixed Python 3.5.3 compilation errors reported by Travis CI
* Removed duplicated MTK_DEFAULT_API_PORT
2018-11-19 15:54:09 +00:00
|
|
|
kwargs = {
|
|
|
|
'port': self.port,
|
2019-04-04 09:15:20 +00:00
|
|
|
'encoding': self.encoding
|
Add mikrotik SSL support (#17898)
* Update mikrotik.py
* Update mikrotik.py
* Added basic api_ssl support
Added preliminary support to use api_ssl instead of api. It don't check the validity of the certificate need it.
At Home Assistant side add ssl = true to your sensor configuration, and don't forget to change the port too (to 8729 by default):
device_tracker:
- platform: mikrotik
host: 192.168.88.1
port: 8729
ssl: true
username: homeassistant
password: TopSecret
At MikroTik side you have to add or generate a certificate, and configure api_ssl to use it. Here is an example:
/certificate add common-name="Self signed demo certificate for API" days-valid=3650 name="Self signed demo certificate for API" key-usage=digital-signature,key-encipherment,tls-server,key-cert-sign,crl-sign
/certificate sign "Self signed demo certificate for API"
/ip service set api-ssl certificate="Self signed demo certificate for API"
/ip service enable api-ssl
/ip service disable api
/user group add name=homeassistant policy=read,api,!local,!telnet,!ssh,!ftp,!reboot,!write,!policy,!test,!winbox,!password,!web,!sniff,!sensitive,!romon,!dude,!tikapp
/user add group=homeassistant name=homeassistant
/user set password="TopSecret" homeassistant
* Fixed import missind ssl lib
* SSL support code cleanup, use ssl-api port by default if ssl enabled
* Restored accidentalli deleted method parameter
* Fixed Python 3.5.3 compilation errors
Fixed Python 3.5.3 compilation errors reported by Travis CI
* Removed duplicated MTK_DEFAULT_API_PORT
2018-11-19 15:54:09 +00:00
|
|
|
}
|
|
|
|
if self.ssl:
|
|
|
|
ssl_context = ssl.create_default_context()
|
|
|
|
ssl_context.check_hostname = False
|
|
|
|
ssl_context.verify_mode = ssl.CERT_NONE
|
|
|
|
kwargs['ssl_wrapper'] = ssl_context.wrap_socket
|
2017-04-30 03:39:11 +00:00
|
|
|
self.client = librouteros.connect(
|
Add mikrotik SSL support (#17898)
* Update mikrotik.py
* Update mikrotik.py
* Added basic api_ssl support
Added preliminary support to use api_ssl instead of api. It don't check the validity of the certificate need it.
At Home Assistant side add ssl = true to your sensor configuration, and don't forget to change the port too (to 8729 by default):
device_tracker:
- platform: mikrotik
host: 192.168.88.1
port: 8729
ssl: true
username: homeassistant
password: TopSecret
At MikroTik side you have to add or generate a certificate, and configure api_ssl to use it. Here is an example:
/certificate add common-name="Self signed demo certificate for API" days-valid=3650 name="Self signed demo certificate for API" key-usage=digital-signature,key-encipherment,tls-server,key-cert-sign,crl-sign
/certificate sign "Self signed demo certificate for API"
/ip service set api-ssl certificate="Self signed demo certificate for API"
/ip service enable api-ssl
/ip service disable api
/user group add name=homeassistant policy=read,api,!local,!telnet,!ssh,!ftp,!reboot,!write,!policy,!test,!winbox,!password,!web,!sniff,!sensitive,!romon,!dude,!tikapp
/user add group=homeassistant name=homeassistant
/user set password="TopSecret" homeassistant
* Fixed import missind ssl lib
* SSL support code cleanup, use ssl-api port by default if ssl enabled
* Restored accidentalli deleted method parameter
* Fixed Python 3.5.3 compilation errors
Fixed Python 3.5.3 compilation errors reported by Travis CI
* Removed duplicated MTK_DEFAULT_API_PORT
2018-11-19 15:54:09 +00:00
|
|
|
self.host,
|
|
|
|
self.username,
|
|
|
|
self.password,
|
|
|
|
**kwargs
|
|
|
|
)
|
2017-04-30 03:39:11 +00:00
|
|
|
|
2017-10-30 07:41:37 +00:00
|
|
|
try:
|
|
|
|
routerboard_info = self.client(
|
|
|
|
cmd='/system/routerboard/getall')
|
|
|
|
except (librouteros.exceptions.TrapError,
|
|
|
|
librouteros.exceptions.MultiTrapError,
|
|
|
|
librouteros.exceptions.ConnectionError):
|
|
|
|
routerboard_info = None
|
|
|
|
raise
|
2017-04-30 03:39:11 +00:00
|
|
|
|
|
|
|
if routerboard_info:
|
2018-11-03 22:48:08 +00:00
|
|
|
_LOGGER.info(
|
|
|
|
"Connected to Mikrotik %s with IP %s",
|
|
|
|
routerboard_info[0].get('model', 'Router'), self.host)
|
2017-10-30 07:41:37 +00:00
|
|
|
|
2017-04-30 03:39:11 +00:00
|
|
|
self.connected = True
|
2017-10-30 07:41:37 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
self.capsman_exist = self.client(
|
2018-11-03 22:48:08 +00:00
|
|
|
cmd='/caps-man/interface/getall')
|
2017-10-30 07:41:37 +00:00
|
|
|
except (librouteros.exceptions.TrapError,
|
|
|
|
librouteros.exceptions.MultiTrapError,
|
|
|
|
librouteros.exceptions.ConnectionError):
|
|
|
|
self.capsman_exist = False
|
|
|
|
|
2017-10-13 08:54:58 +00:00
|
|
|
if not self.capsman_exist:
|
|
|
|
_LOGGER.info(
|
2018-11-03 22:48:08 +00:00
|
|
|
"Mikrotik %s: Not a CAPSman controller. Trying "
|
|
|
|
"local interfaces", self.host)
|
2017-10-30 07:41:37 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
self.wireless_exist = self.client(
|
2018-11-03 22:48:08 +00:00
|
|
|
cmd='/interface/wireless/getall')
|
2017-10-30 07:41:37 +00:00
|
|
|
except (librouteros.exceptions.TrapError,
|
|
|
|
librouteros.exceptions.MultiTrapError,
|
|
|
|
librouteros.exceptions.ConnectionError):
|
|
|
|
self.wireless_exist = False
|
|
|
|
|
2018-11-25 11:21:26 +00:00
|
|
|
if not self.wireless_exist and not self.capsman_exist \
|
|
|
|
or self.method == 'ip':
|
2018-11-03 22:48:08 +00:00
|
|
|
_LOGGER.info(
|
|
|
|
"Mikrotik %s: Wireless adapters not found. Try to "
|
|
|
|
"use DHCP lease table as presence tracker source. "
|
|
|
|
"Please decrease lease time as much as possible",
|
|
|
|
self.host)
|
|
|
|
if self.method:
|
2017-05-22 00:18:55 +00:00
|
|
|
_LOGGER.info(
|
2018-11-03 22:48:08 +00:00
|
|
|
"Mikrotik %s: Manually selected polling method %s",
|
|
|
|
self.host, self.method)
|
2017-04-30 03:39:11 +00:00
|
|
|
|
|
|
|
except (librouteros.exceptions.TrapError,
|
2017-10-30 07:41:37 +00:00
|
|
|
librouteros.exceptions.MultiTrapError,
|
2017-04-30 03:39:11 +00:00
|
|
|
librouteros.exceptions.ConnectionError) as api_error:
|
2017-05-02 16:18:47 +00:00
|
|
|
_LOGGER.error("Connection error: %s", api_error)
|
2017-04-30 03:39:11 +00:00
|
|
|
return self.connected
|
|
|
|
|
|
|
|
def scan_devices(self):
|
|
|
|
"""Scan for new devices and return a list with found device MACs."""
|
2018-11-27 12:26:52 +00:00
|
|
|
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()
|
2017-04-30 03:39:11 +00:00
|
|
|
return [device for device in self.last_results]
|
|
|
|
|
2018-02-11 17:20:28 +00:00
|
|
|
def get_device_name(self, device):
|
2017-04-30 03:39:11 +00:00
|
|
|
"""Return the name of the given device or None if we don't know."""
|
2018-02-11 17:20:28 +00:00
|
|
|
return self.last_results.get(device)
|
2017-04-30 03:39:11 +00:00
|
|
|
|
|
|
|
def _update_info(self):
|
|
|
|
"""Retrieve latest information from the Mikrotik box."""
|
2018-11-03 22:48:08 +00:00
|
|
|
if self.method:
|
|
|
|
devices_tracker = self.method
|
2017-07-24 14:45:02 +00:00
|
|
|
else:
|
2018-11-03 22:48:08 +00:00
|
|
|
if self.capsman_exist:
|
|
|
|
devices_tracker = 'capsman'
|
|
|
|
elif self.wireless_exist:
|
|
|
|
devices_tracker = 'wireless'
|
|
|
|
else:
|
|
|
|
devices_tracker = 'ip'
|
2017-07-24 14:45:02 +00:00
|
|
|
|
2019-02-03 21:06:39 +00:00
|
|
|
_LOGGER.debug(
|
2017-07-24 14:45:02 +00:00
|
|
|
"Loading %s devices from Mikrotik (%s) ...",
|
2018-11-03 22:48:08 +00:00
|
|
|
devices_tracker, self.host)
|
2017-07-24 14:45:02 +00:00
|
|
|
|
|
|
|
device_names = self.client(cmd='/ip/dhcp-server/lease/getall')
|
2017-10-13 08:54:58 +00:00
|
|
|
if devices_tracker == 'capsman':
|
|
|
|
devices = self.client(
|
2018-11-03 22:48:08 +00:00
|
|
|
cmd='/caps-man/registration-table/getall')
|
2017-10-13 08:54:58 +00:00
|
|
|
elif devices_tracker == 'wireless':
|
2017-07-24 14:45:02 +00:00
|
|
|
devices = self.client(
|
2018-11-03 22:48:08 +00:00
|
|
|
cmd='/interface/wireless/registration-table/getall')
|
2017-07-24 14:45:02 +00:00
|
|
|
else:
|
|
|
|
devices = device_names
|
2017-04-30 03:39:11 +00:00
|
|
|
|
2017-07-24 14:45:02 +00:00
|
|
|
if device_names is None and devices is None:
|
|
|
|
return False
|
|
|
|
|
|
|
|
mac_names = {device.get('mac-address'): device.get('host-name')
|
2018-11-03 22:48:08 +00:00
|
|
|
for device in device_names if device.get('mac-address')}
|
2017-07-24 14:45:02 +00:00
|
|
|
|
2018-11-03 22:48:08 +00:00
|
|
|
if devices_tracker in ('wireless', 'capsman'):
|
2017-07-24 14:45:02 +00:00
|
|
|
self.last_results = {
|
|
|
|
device.get('mac-address'):
|
|
|
|
mac_names.get(device.get('mac-address'))
|
2018-11-03 22:48:08 +00:00
|
|
|
for device in devices}
|
2017-07-24 14:45:02 +00:00
|
|
|
else:
|
|
|
|
self.last_results = {
|
|
|
|
device.get('mac-address'):
|
|
|
|
mac_names.get(device.get('mac-address'))
|
2018-11-03 22:48:08 +00:00
|
|
|
for device in device_names if device.get('active-address')}
|
2017-07-24 14:45:02 +00:00
|
|
|
|
|
|
|
return True
|