Set the state of the device.
176227
async def _set_state(self, state: int) -> bool:
        """"""
        try:
            set_state_resp = await self.api._request(
                'put',
                DEVICE_SET_ENDPOINT,
                json={
                    'attributeName': 'desireddoorstate',
                    'myQDeviceId': self.device_id,
                    'AttributeValue': state,
                })
        except RequestError as err:
            _LOGGER.error('%s: Setting state failed (and halting): %s',
                          self.name, err)
            return False

        if set_state_resp is None:
            return False

        if int(set_state_resp.get('ReturnCode', 1)) != 0:
            _LOGGER.error(
                '%s: Error setting the device state: %s', self.name,
                set_state_resp.get('ErrorMessage', 'Unknown Error'))
            return False

        return True
1058712
def _set_state(self, state):
        
        if state != self._association_state:
            self.__log_debug('- %s -> %s', self._association_state, state)
            self._association_state = state

        if state == self.State.ESTABLISHED:
            self.__state = 'connected'
            for channel in list(self._data_channels.values()):
                if channel.negotiated and channel.readyState != 'open':
                    channel._setReadyState('open')
            asyncio.ensure_future(self._data_channel_flush())
        elif state == self.State.CLOSED:
            self._t1_cancel()
            self._t2_cancel()
            self._t3_cancel()
            self.__state = 'closed'

            # close data channels
            for stream_id in list(self._data_channels.keys()):
                self._data_channel_closed(stream_id)

            # no more events will be emitted, so remove all event listeners
            # to facilitate garbage collection.
            self.remove_all_listeners()
809519
def state(self, state):
        """"""
        with self._lock:
            self._value = self._states.index(state)
205608
public function set_state() {
		if ( ! empty( $this->struct['state'] ) ) {
			$this->classes[] = 'notice-' . $this->struct['state'];
		} else {
			$this->classes[] = 'notice-warning';
		}
	}
1276231
def set_state(self, hdr):
        """"""

        self.conf_f = hdr.get('CSUCONFF', 'UNKNOWN')
        # Read CSUPOS and set position in model
        # The bars
        for idx in self.bars:
            key = "CSUP{}".format(idx)
            # UNIT is mm

            # set CSUPOS for BAR
            # Using the model, this sets the X,Y coordinate
            self.bars[idx].csupos = hdr[key]

        self._update_slits(hdr)
31346
def set_smartplug_state(self, device_label, state):
        
        response = None
        try:
            response = requests.post(
                urls.smartplug(self._giid),
                headers={
                    'Content-Type': 'application/json',
                    'Cookie': 'vid={}'.format(self._vid)},
                data=json.dumps([{
                    "deviceLabel": device_label,
                    "state": state}]))
        except requests.exceptions.RequestException as ex:
            raise RequestError(ex)
        _validate_response(response)
199405
void onStart(Device device) {
	  KernelDeviceProfile currentDeviceProfile = deviceProfiles.get(device);
      if (currentDeviceProfile == null) {    	 
         currentDeviceProfile = new KernelDeviceProfile(this, kernelClass, device);
         KernelDeviceProfile existingProfile = deviceProfiles.putIfAbsent(device, currentDeviceProfile);
         if (existingProfile != null) {
        	 currentDeviceProfile = existingProfile;
         }
      }
      
      currentDeviceProfile.onEvent(ProfilingEvent.START);
      currentDevice.set(device);
   }
839165
def update(self, retry=2) -> None:
        """"""
        try:
            _LOGGER.debug("Updating device state.")
            key = ON_KEY if not self._flip_on_off else OFF_KEY
            self.state = self._device.readCharacteristic(HANDLE) == key
        except (bluepy.btle.BTLEException, AttributeError):
            if retry < 1 or not self._connect():
                self.available = False
                _LOGGER.error("Failed to update device state.", exc_info=True)
                return None
            return self.update(retry-1)
        self.available = True
        return None
47451
def _lock(self):
        """"""
        if not self.locked:
            self.device.cu.lock()
            self.locked = True
1230961
def set_alarm_state(self, state):
        
        values = {"desired_state": {"alarm_enabled": state}}
        response = self.api_interface.set_device_state(self, values)
        self._update_state_from_response(response)
1247998
def set_state(self, state):
        
        desired_state = {"desired_state": {"powered": state}}
        response = self.api_interface.set_device_state(self, desired_state)
        self._update_state_from_response(response)
405800
private void setState(State state) {
    if (this.state != state) {
      this.state = state;
      LOGGER.debug("State changed: {}", state);
      changeListeners.forEach(l -> l.accept(state));
    }
  }
1134916
def set_status(self, status):
        
        if status is not self.status:
            logger.debug("Setting %s state to %s.", self.stack.name,
                         status.name)
            self.status = status
            self.last_updated = time.time()
            if self.stack.logging:
                log_step(self)
675436
def set_state(self, state):
        
        self.index_x.set(state[REG_X])
        self.index_y.set(state[REG_Y])

        self.user_stack_pointer.set(state[REG_U])
        self.system_stack_pointer.set(state[REG_S])

        self.program_counter.set(state[REG_PC])

        self.accu_a.set(state[REG_A])
        self.accu_b.set(state[REG_B])

        self.direct_page.set(state[REG_DP])
        self.set_cc(state[REG_CC])

        self.cycles = state["cycles"]
        self.memory.load(address=0x0000, data=state["RAM"])
879916
def set_state(seed_value=None, step=None):
    """"""
    global RANDOM_SEED  # pylint: disable=global-statement
    if seed_value is not None:
        RANDOM_SEED = seed_value
    if step is not None:
        RANDOM_SEED += step
562222
def SetStatus(self, status, message="", backtrace=None):
    """"""
    self.status.status = status
    self.status.error_message = utils.SmartUnicode(message)
    if backtrace:
      self.status.backtrace = utils.SmartUnicode(backtrace)
305244
def change_state(self, state):
        """"""
        if state is not self.state:
            if self.debug:
                self.print_debug(b'state => ' + STATE_NAMES[state].encode())
            if self.state is STATE_NOT_STARTED:
                self.read_in_state_not_started = b''
            self.state = state