Query hub and refresh all details of a device,
        but NOT status, includes grouplist not present in
        refresh_all_devices
486694
def refresh_details(self):
        ''''''
        try:
            return self.api_iface._api_get("/api/v2/devices/" + str(self.device_id))
        except APIError as e:
            print("API error: ")
            for key,value in e.data.iteritems:
                print(str(key) + ": " + str(value))
607599
def remove_from_group(self, devices):
        """"""
        ids = {d.id for d in self.devices_in_group()}
        ids.difference_update(self._device_ids(devices))
        self._set_group(ids)
1018267
def refresh(self):
        
        table   = self.tableType()
        search  = nativestring(self._pywidget.text())
        if search == self._lastSearch:
            return
        
        self._lastSearch = search
        if not search:
            return
        
        if search in self._cache:
            records = self._cache[search]
        else:
            records = table.select(where = self.baseQuery(),
                                   order = self.order())
            records = list(records.search(search, limit=self.limit()))
            self._cache[search] = records
        
        self._records = records
        self.model().setStringList(map(str, self._records))
        self.complete()
905538
def get_hosting_devices_qry(self, context, hosting_device_ids,
                                load_agent=True):
        """"""
        query = context.session.query(hd_models.HostingDevice)
        if load_agent:
            query = query.options(joinedload('cfg_agent'))
        if len(hosting_device_ids) > 1:
            query = query.filter(hd_models.HostingDevice.id.in_(
                hosting_device_ids))
        else:
            query = query.filter(hd_models.HostingDevice.id ==
                                 hosting_device_ids[0])
        return query
1196112
def get_devices(self, refresh=False, generic_type=None):
        """"""
        if refresh or self._devices is None:
            if self._devices is None:
                self._devices = {}

            _LOGGER.info("Updating all devices...")
            response = self.send_request("get", CONST.DEVICES_URL)
            response_object = json.loads(response.text)

            if (response_object and
                    not isinstance(response_object, (tuple, list))):
                response_object = [response_object]

            _LOGGER.debug("Get Devices Response: %s", response.text)

            for device_json in response_object:
                # Attempt to reuse an existing device
                device = self._devices.get(device_json['id'])

                # No existing device, create a new one
                if device:
                    device.update(device_json)
                else:
                    device = new_device(device_json, self)

                    if not device:
                        _LOGGER.debug(
                            "Skipping unknown device: %s",
                            device_json)

                        continue

                    self._devices[device.device_id] = device

            # We will be treating the Abode panel itself as an armable device.
            panel_response = self.send_request("get", CONST.PANEL_URL)
            panel_json = json.loads(panel_response.text)

            self._panel.update(panel_json)

            _LOGGER.debug("Get Mode Panel Response: %s", response.text)

            alarm_device = self._devices.get(CONST.ALARM_DEVICE_ID + '1')

            if alarm_device:
                alarm_device.update(panel_json)
            else:
                alarm_device = ALARM.create_alarm(panel_json, self)
                self._devices[alarm_device.device_id] = alarm_device

        if generic_type:
            devices = []
            for device in self._devices.values():
                if (device.generic_type is not None and
                        device.generic_type in generic_type):
                    devices.append(device)
            return devices

        return list(self._devices.values())
906987
def _treat_devices_added(self):
        """"""
        try:
            devices_details_list = self._plugin_rpc.get_devices_details_list(
                self._context, self._added_ports, self._agent_id)
        except Exception as exc:
            LOG.debug("Unable to get ports details for "
                      "devices %(devices)s: %(exc)s",
                      {'devices': self._added_ports, 'exc': exc})
            return

        for device_details in devices_details_list:
            device = device_details['device']
            LOG.info("Adding port %s", device)
            if 'port_id' in device_details:
                LOG.info("Port %(device)s updated. "
                         "Details: %(device_details)s",
                         {'device': device, 'device_details': device_details})
                eventlet.spawn_n(self.process_added_port, device_details)
            else:
                LOG.debug("Missing port_id from device details: "
                          "%(device)s. Details: %(device_details)s",
                          {'device': device, 'device_details': device_details})

            LOG.debug("Remove the port from added ports set, so it "
                      "doesn't get reprocessed.")
            self._added_ports.discard(device)
20525
def report_non_responding_hosting_devices(self, context, host,
                                              hosting_device_ids):
        
        # let the generic status update callback function handle this callback
        self.update_hosting_device_status(context, host,
                                          {const.HD_DEAD: hosting_device_ids})
932231
def _add_device_to_device_group(self, device):
        '''
        '''

        device_name = get_device_info(device).name
        dg = pollster(self._get_device_group)(device)
        dg.devices_s.devices.create(name=device_name, partition=self.partition)
        pollster(self._check_device_exists_in_device_group)(device_name)
19440
def kpl_status(self, address, group):
        """"""
        addr = Address(address)
        device = self.plm.devices[addr.id]
        device.states[group].async_refresh_state()
749806
def get_all_connected_devices(self):
        
        self.bbox_auth.set_access(BboxConstant.AUTHENTICATION_LEVEL_PUBLIC, BboxConstant.AUTHENTICATION_LEVEL_PRIVATE)
        self.bbox_url.set_api_name(BboxConstant.API_HOSTS, None)
        api = BboxApiCall(self.bbox_url, BboxConstant.HTTP_METHOD_GET, None,
                          self.bbox_auth)
        resp = api.execute_api_request()
        return resp.json()[0]["hosts"]["list"]
249487
def devices(self):
        ''''''
        out = self.run_cmd('devices') #subprocess.check_output([self.adb_path(), 'devices']).decode("utf-8")
        if 'adb server is out of date' in out:
            out = self.run_cmd('devices')
        match = "List of devices attached"
        index = out.find(match)
        if index < 0:
            raise EnvironmentError("adb is not working.")
        return dict(re.findall(r'([^\s]+)\t(\w+)', out))
460382
def get_devices(self):
        
        url = self.base_url + '/net/home_auto_query.lua'
        response = self.session.get(url, params={
            'sid': self.sid,
            'command': 'AllOutletStates',
            'xhr': 0,
        }, timeout=15)
        response.raise_for_status()
        data = response.json()
        count = int(data["Outlet_count"])
        devices = []
        for i in range(1, count + 1):
            device = Device(
                int(data["DeviceID_{0}".format(i)]),
                int(data["DeviceConnectState_{0}".format(i)]),
                int(data["DeviceSwitchState_{0}".format(i)])
            )
            devices.append(device)
        return devices
368987
def devices
      url = "me/player/devices"
      response = RSpotify.resolve_auth_request(@id, url)

      return response if RSpotify.raw_response
      response['devices'].map { |i| Device.new i }
    end
33642
def _get_device_names_in_group(self):
        '''
        '''

        device_names = []
        dg = pollster(self._get_device_group)(self.devices[0])
        members = dg.devices_s.get_collection()
        for member in members:
            member_name = member.name.replace('/%s/' % self.partition, '')
            device_names.append(member_name)
        return device_names
1209008
def update_from_devices(self):
        """"""
        # _LOGGER.warning("update from devices")
        try:
            rest = requests.get(URL_DEVICES.format(self._url))
            if rest.status_code != 200:
                _LOGGER.error("Devices returned %s", rest.status_code)
                return False
            self.devices.update_devices(rest.json())
            return True
        except requests.exceptions.ConnectionError as conn_err:
            _LOGGER.error("Could not connect: %s", conn_err)
        except Exception as err:  # pylint: disable=broad-except
            _LOGGER.error(err)
1223939
def resolve_updates(orig_list, updated_list):
        """"""

        if updated_list is not None and updated_list:
            if orig_list is None:
                orig_list = updated_list
            else:
                # Add new devices not in list but found in the update
                for new_device in updated_list:
                    was_found = False

                    for device in orig_list:
                        if new_device.cid == device.cid:
                            was_found = True
                            break

                    if not was_found:
                        orig_list.append(new_device)

                # Remove old devices in the list not found in the update
                for device in orig_list:
                    should_remove = True

                    for new_device in updated_list:
                        if device.cid == new_device.cid:
                            should_remove = False
                            break

                    if should_remove:
                        orig_list.remove(device)

            # Call update on each device in the list
            [device.update() for device in orig_list]

        return orig_list
387805
def get_devices(self):
        """"""
        utils.pending_message('Fetching device list...')

        get_devices_task = self.client.devices(
            account=self.account
        )

        # We wait for device list info as this sample relies on it next.
        get_devices_task.wait_for_result(timeout=self.timeout)

        get_devices_result = json.loads(get_devices_task.result)
        self.devices = get_devices_result['devices']

        utils.info_message('Get devices successful')