Update Device Status
Update Device Status
@param deviceId Device ID. (required)
@param body Body (optional)
@return ApiResponse&lt;DeviceStatus&gt;
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
510453
public ApiResponse<DeviceStatus> putDeviceStatusWithHttpInfo(String deviceId, DeviceStatusPut body) throws ApiException {
        com.squareup.okhttp.Call call = putDeviceStatusValidateBeforeCall(deviceId, body, null, null);
        Type localVarReturnType = new TypeToken<DeviceStatus>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }
431952
def update(self, params):
        
        dev_info = self.json_state.get('deviceInfo')
        dev_info.update({k: params[k] for k in params if dev_info.get(k)})
9747
public String updateStatus(final DeviceState state) throws DevFailed {
        xlogger.entry();
        if (getStatusMethod != null) {
            try {
                status = (String) getStatusMethod.invoke(businessObject);
            } catch (final IllegalArgumentException e) {
                throw DevFailedUtils.newDevFailed(e);
            } catch (final IllegalAccessException e) {
                throw DevFailedUtils.newDevFailed(e);
            } catch (final InvocationTargetException e) {
                if (e.getCause() instanceof DevFailed) {
                    throw (DevFailed) e.getCause();
                } else {
                    throw DevFailedUtils.newDevFailed("INVOCATION_ERROR", ExceptionUtils.getStackTrace(e.getCause())
                            + " InvocationTargetException");
                }
            }
        } else {
            if (status.isEmpty()) {
                status = "The device is in " + state + " state.";
            }
        }
        StringBuilder statusAlarm = new StringBuilder();
        for (final String string : attributeAlarm.values()) {
            statusAlarm = statusAlarm.append(string);
        }

        return status + statusAlarm;
    }
571181
void setDeviceId(int nDeviceId) {
        synchronized (LOCK) {
            // Move this instance inside the HashMaps
            INSTANCES.get(connection()).remove(getDeviceId());
            INSTANCES.get(connection()).put(nDeviceId, this);

            this.deviceId = nDeviceId;
        }
    }
669992
public T update() throws IOException, PlivoRestException {
    validate();
    Response<T> response = obtainCall().execute();

    handleResponse(response);

    return response.body();
  }
893488
public void updateClientId(String clientId) {
        if (configForVM != null) {
            configForVM.withClientId(clientId);
        } else {
            configForAppService.withClientId(clientId);
        }
    }
1326619
public static DeviceUpdateResult deviceUpdate(String accessToken,
                                                  DeviceUpdate deviceUpdate) {
        return deviceUpdate(accessToken, JsonUtil.toJSONString(deviceUpdate));
    }
849129
public void setDeviceId(String deviceId) throws CouldNotPersistException {
        this.deviceId = deviceId;
        if (deviceId != null && path != null) {
            persistDeviceId();
        }
    }
82198
public void updateOccupantStatus (BodyObject body, final byte status)
    {
        // no need to NOOP
        if (body.status != status) {
            // update the status in their body object
            body.setStatus(status);
            body.getLocal(BodyLocal.class).statusTime = System.currentTimeMillis();
        }

        updateOccupantInfo(body, new OccupantInfo.Updater<OccupantInfo>() {
            public boolean update (OccupantInfo info) {
                if (info.status == status) {
                    return false;
                }
                info.status = status;
                return true;
            }
        });
    }
950338
public Observable<Void> downloadUpdatesAsync(String deviceName, String resourceGroupName) {
        return downloadUpdatesWithServiceResponseAsync(deviceName, resourceGroupName).map(new Func1<ServiceResponse<Void>, Void>() {
            @Override
            public Void call(ServiceResponse<Void> response) {
                return response.body();
            }
        });
    }
783679
public static device_profile update(nitro_service client, device_profile resource) throws Exception
	{
		resource.validate("modify");
		return ((device_profile[]) resource.update_resource(client))[0];
	}
1011303
def update(id, body)
      wf_savedsearch_id?(id)
      raise ArgumentError unless body.is_a?(Hash)
      api.put(id, body)
    end
340630
def DeviceGet(self, device_id):
        
        if self.__SenseApiCall__('/devices/{0}'.format(device_id), 'GET'):
            return True
        else:
            self.__error__ = "api call unsuccessful"
            return False
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)
456583
private <T> Observable<PollingState<T>> updateStateFromAzureAsyncOperationHeaderOnPostOrDeleteAsync(final PollingState<T> pollingState) {
        return pollAsync(pollingState.azureAsyncOperationHeaderLink(), pollingState.loggingContext())
                .flatMap(new Func1<Response<ResponseBody>, Observable<PollingState<T>>>() {
                    @Override
                    public Observable<PollingState<T>> call(Response<ResponseBody> response) {
                        final AzureAsyncOperation asyncOperation;
                        try {
                            asyncOperation = AzureAsyncOperation.fromResponse(restClient().serializerAdapter(), response);
                        } catch (CloudException exception) {
                            return Observable.error(exception);
                        }
                        pollingState.withStatus(asyncOperation.status());
                        pollingState.withErrorBody(asyncOperation.getError());
                        pollingState.withResponse(response);
                        try {
                            T resource = restClient().serializerAdapter().deserialize(asyncOperation.rawString(), pollingState.resourceType());
                            pollingState.withResource(resource);
                        } catch (IOException e) {
                            // Ignore and let resource be null
                        }
                        return Observable.just(pollingState);
                    }
                });
    }
289082
def _update(self, uri, body, **kwargs):
        
        self.run_hooks("modify_body_for_update", body, **kwargs)
        resp, resp_body = self.api.method_put(uri, body=body)
        return resp_body
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)