Search the list of connected devices by ID.

        device_id param is the integer ID of the device
427473
def get_device_by_id(self, device_id):
        

        # Find the device for the vera device name we are interested in
        found_device = None
        for device in self.get_devices():
            if device.device_id == device_id:
              found_device = device
              # found the first (and should be only) one so we will finish
              break

        if found_device is None:
            logger.debug('Did not find device with {}'.format(device_id))

        return found_device
10127
def findConnectedDevices(self):
        
        tmpTimeout = self._serial.timeout
        self._serial.timeout = 0.01

        for dev in range(128):
            device = self._getDeviceID(dev)

            if device is not None and int(device) not in self._deviceConfig:
                config = self._deviceConfig.setdefault(int(device), {})
                self._deviceCallback(device, config)
                self._log and self._log.info(
                    "Found device '%s' with configuration: %s", device, config)

        self._serial.timeout = tmpTimeout
942956
def scan():
    '''
    
    '''
    ret = []
    devices = bluetooth.discover_devices(lookup_names=True)
    for device in devices:
        ret.append({device[0]: device[1]})
    return ret
1227123
def get_device_by_name(self, device_name):
        

        # Find the device for the vera device name we are interested in
        found_device = None
        for device in self.get_devices():
            if device.name == device_name:
              found_device = device
              # found the first (and should be only) one so we will finish
              break

        if found_device is None:
            logger.debug('Did not find device with {}'.format(device_name))

        return found_device
1281734
def list_devices(self, shop_id=None, page_index=1, page_size=20):
        
        data = optionaldict(
            shop_id=shop_id,
            pageindex=page_index,
            pagesize=page_size
        )
        res = self._post(
            'device/list',
            data=data,
            result_processor=lambda x: x['data']
        )
        return res
730974
def lookup_camera_by_id(self, device_id):
        """"""
        camera = list(filter(
            lambda cam: cam.device_id == device_id, self.cameras))[0]
        if camera:
            return camera
        return None
269679
def find_device(self):
        """"""
        for bdaddr, name in self.scan():
            if name == "Wireless Controller":
                self.logger.info("Found device {0}", bdaddr)
                return BluetoothDS4Device.connect(bdaddr)
703085
def _get_devices_by_failover_status(self, status):
        '''
        '''

        devices_with_status = []
        for device in self.devices:
            if (self._check_device_failover_status(device, status)):
                devices_with_status.append(device)
        return devices_with_status
415170
def _device_lookup(self, device_name):
        '''  '''
        device_found = {}
        response = requests.get(self._api_url + 'devices',
                                auth=(self._api_key, ''))
        if response.ok:
            for device in response.json()['devices']:
                if device_name == device['extras']['model']:
                    #TODO Check device['extras']['nickname'] as well
                    device_found = device
        return device_found
959060
def devices(self):
        """"""
        log_msg = True
        while True:
            if log_msg:
                self.logger.info("Scanning for devices")

            try:
                device = self.find_device()
                if device:
                    yield device
                    log_msg = True
                else:
                    log_msg = False
            except BackendError as err:
                self.logger.error("Error while scanning for devices: {0}",
                                  err)
                return
            except DeviceError as err:
                self.logger.error("Unable to connect to detected device: {0}",
                                  err)
760158
def is_device_connected(self, ip):
        
        all_devices = self.get_all_connected_devices()
        for device in all_devices:
            if ip == device['ipaddress']:
                return device['active'] == 1
        return False
263526
def get_connected_devices
      get_adb_command_output('devices')
      .drop(1)
      .map { |line| line.split[0] }
      .reject { |d| d.nil? || d.empty? }
    end
1044024
def find_device(vidpid):
    """"""
    for port in list_ports.comports():
        if re.search(vidpid, port[2], flags=re.IGNORECASE):
            return port[0]

    raise exceptions.RoasterLookupError
505359
def list_devices(names=None, continue_from=None, **kwargs):
    """"""

    if not names:
        names = [device for device, _type in settings.GOLDEN_DEVICES if _type == 'OpenThread']

    if continue_from:
        continue_from = names.index(continue_from)
    else:
        continue_from = 0

    for port in names[continue_from:]:
        try:
            with OpenThreadController(port) as otc:
                print('%s: %s' % (port, otc.version))
        except:
            logger.exception('failed to get version of %s' % port)
1280211
def device_at_index(self, index):
        
        if index >= len(self.__xid_cons):
            raise ValueError("Invalid device index")

        return self.__xid_cons[index]
127122
def get_connectware_id(self, use_cached=True):
        """"""
        device_json = self.get_device_json(use_cached)
        return device_json.get("devConnectwareId")
113995
def _find_devices():
    
    ret = []

    logger.info('Looking for devices....')

    if pyusb1:
        for d in usb.core.find(idVendor=USB_VID, idProduct=USB_PID, find_all=1,
                               backend=pyusb_backend):
            ret.append(d)
    else:
        busses = usb.busses()
        for bus in busses:
            for device in bus.devices:
                if device.idVendor == USB_VID:
                    if device.idProduct == USB_PID:
                        ret += [device, ]

    return ret