Update values from response of URL_DEVICES, callback if changed.
359972
def update_devices(self, devices):
        """"""
        for qspacket in devices:
            try:
                qsid = qspacket[QS_ID]
            except KeyError:
                _LOGGER.debug("Device without ID: %s", qspacket)
                continue

            if qsid not in self:
                self[qsid] = QSDev(data=qspacket)

            dev = self[qsid]
            dev.data = qspacket
            # Decode value from QSUSB
            newqs = _legacy_status(qspacket[QS_VALUE])
            if dev.is_dimmer:
                # Adjust dimmer exponentially to get a smoother effect
                newqs = min(round(math.pow(newqs, self.dim_adj)), 100)
            newin = round(newqs * _MAX / 100)
            if abs(dev.value - newin) > 1:  # Significant change
                _LOGGER.debug("%s qs=%s  -->  %s", qsid, newqs, newin)
                dev.value = newin
                self._cb_value_changed(self, qsid, newin)
1274397
def update_device_list(self, sessions):
        
        if sessions is None:
            _LOGGER.error('Error updating Emby devices.')
            return

        new_devices = []
        active_devices = []
        dev_update = False
        for device in sessions:
            dev_name = '{}.{}'.format(device['DeviceId'], device['Client'])

            try:
                _LOGGER.debug('Session msg on %s of type: %s, themeflag: %s',
                              dev_name, device['NowPlayingItem']['Type'],
                              device['NowPlayingItem']['IsThemeMedia'])
            except KeyError:
                pass

            active_devices.append(dev_name)
            if dev_name not in self._devices and \
                    device['DeviceId'] != str(self._api_id):
                _LOGGER.debug('New Emby DeviceID: %s. Adding to device list.',
                              dev_name)
                new = EmbyDevice(device, self)
                self._devices[dev_name] = new
                new_devices.append(new)
            elif device['DeviceId'] != str(self._api_id):
                # Before we send in new data check for changes to state
                # to decide if we need to fire the update callback
                if not self._devices[dev_name].is_active:
                    # Device wasn't active on the last update
                    # We need to fire a device callback to let subs now
                    dev_update = True

                do_update = self.update_check(
                    self._devices[dev_name], device)
                self._devices[dev_name].update_data(device)
                self._devices[dev_name].set_active(True)
                if dev_update:
                    self._do_new_devices_callback(0)
                    dev_update = False
                if do_update:
                    self._do_update_callback(dev_name)

        # Need to check for new inactive devices and flag
        for dev_id in self._devices:
            if dev_id not in active_devices:
                # Device no longer active
                if self._devices[dev_id].is_active:
                    self._devices[dev_id].set_active(False)
                    self._do_update_callback(dev_id)
                    self._do_stale_devices_callback(dev_id)

        # Call device callback if new devices were found.
        if new_devices:
            self._do_new_devices_callback(0)
325756
def updateDeviceState(self, device):
        
        # this is only threadsafe because the targetstate is effectively immutable, if it becomes mutable in future then
        # funkiness may result
        self._reactor.offer(REACH_TARGET_STATE, [self._targetStateProvider.state, device, self._httpclient])
25271
def add_device_callback(self, devices, callback):
        """"""
        if not devices:
            return False

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

        for device in devices:
            # Device may be a device_id
            device_id = device

            # If they gave us an actual device, get that devices ID
            if isinstance(device, AbodeDevice):
                device_id = device.device_id

            # Validate the device is valid
            if not self._abode.get_device(device_id):
                raise AbodeException((ERROR.EVENT_DEVICE_INVALID))

            _LOGGER.debug(
                "Subscribing to updated for device_id: %s", device_id)

            self._device_callbacks[device_id].append((callback))

        return True
435980
def update_state(self):
        
        response = self.api_interface.get_device_state(self, id_override=self.parent_id(),
                                                       type_override=self.parent_object_type())
        self._update_state_from_response(response)
286499
def update(self):
        """"""
        if "tag_groups" not in self._device_dict:
            return
        for group in self.tag_groups:
            group.update()
        for i in range(len(self._device_dict["tag_groups"])):
            tag_group_dict = self._device_dict["tag_groups"][i]
            for group in self.tag_groups:
                if group.name == tag_group_dict["common.ALLTYPES_NAME"]:
                    self._device_dict["tag_groups"][i] = group.as_dict()
1353296
def update_urls(self, request, resource_name=None, ids=None):
        
        http_host = request.META.get('HTTP_HOST', None)

        if http_host is None:
            http_host = request.META['SERVER_NAME']
            if request.META['SERVER_PORT'] not in ('80', '443'):
                http_host = "{}:{}".format(
                    http_host, request.META['SERVER_PORT'])

        self.base_url = "{}://{}".format(
            request.META['wsgi.url_scheme'],
            http_host
        )
        self.api_url = "{}{}".format(self.base_url, request.path)
        self.api_url = self.api_url.rstrip("/")

        if ids is not None:
            self.api_url = self.api_url.rsplit("/", 1)[0]

        if resource_name is not None:
            self.api_url = self.api_url.rsplit("/", 1)[0]
433860
def update(self, key, value=None, dir=False, ttl=None, refresh=False,
               prev_value=None, prev_index=None, timeout=None):
        """"""
        return self.adapter.set(key, value, dir=dir, ttl=ttl, refresh=refresh,
                                prev_value=prev_value, prev_index=prev_index,
                                prev_exist=True, timeout=timeout)
1206570
def refresh_attributes(self, name):
        """"""
        url = DEVICES_ENDPOINT
        response = self.query(url)

        if not response or not isinstance(response, dict):
            return None

        for device in response.get('data'):
            if device.get('deviceName') == name:
                return device
        return None
967583
def update(cls, id, params):
        """"""
        cls.echo('Updating your vlan.')
        result = cls.call('hosting.vlan.update', cls.usable_id(id), params)
        return result
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))
736986
def get_devices(self, refresh=False):
        """"""
        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)

            _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 = SkybellDevice(device_json, self)
                    self._devices[device.device_id] = device

        return list(self._devices.values())
928544
def update(self, url, data):
        
        url = self.get_full_url(url)
        self.log.debug("update url : " + url)
        # Building request
        post_data = json.dumps(data).encode("UTF-8")
        request = urllib2.Request(url, post_data)
        request.add_header('Content-Type', 'application/json; charset=UTF-8')
        request.add_header('Accept', 'application/json')
        request.get_method = lambda: 'PUT'
        # Do request
        ret = self.do_request(request)
        self.log.debug("""put url : %(url)s : request time : %(time)s""",
                       {"url": url,
                        "time": self.last_req_time})
        return ret
763504
def update_attrs(self):
        
        for key, value in self._response_json.items():
            if key != 'results' and type(value) not in (list, dict):
                setattr(self, key, value)
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)
250547
def update_ret(self, space_no, field_types, key_tuple, op_list):
        
        d = self.replyQueue.get()
        packet = RequestUpdate(self.charset, self.errors, d._ipro_request_id,
                               space_no, Request.TNT_FLAG_RETURN, key_tuple, op_list)
        self.transport.write(bytes(packet))
        return d.addCallback(self.handle_reply, self.charset, self.errors, field_types)
171066
def update(self):
        """"""
        response = self.jss.session.post(self.url, data=self.auth)
        response_xml = ElementTree.fromstring(response.text.encode("utf_8"))

        # Remove previous data, if any, and then add in response's XML.
        self.clear()
        for child in response_xml.getchildren():
            self.append(child)