'Connect to Mikrotik method.'

def connect_to_device(self):

    import librouteros
    try:
        self.client = librouteros.connect(self.host, self.username, self.password, port=int(self.port))
        routerboard_info = self.client(cmd='/system/routerboard/getall')
        if routerboard_info:
            _LOGGER.info('Connected    to    Mikrotik    %s    with    IP    %s', routerboard_info[0].get('model', 'Router'), self.host)
            self.connected = True
            self.wireless_exist = self.client(cmd='/interface/wireless/getall')
            if (not self.wireless_exist):
                _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)
    except (librouteros.exceptions.TrapError, librouteros.exceptions.ConnectionError) as api_error:
        _LOGGER.error('Connection    error:    %s', api_error)
    return self.connected
