Set the switch state, also update local state.
543405
def set_switch_state(self, state):
        """"""
        self.set_service_value(
            self.switch_service,
            'Target',
            'newTargetValue',
            state)
        self.set_cache_value('Status', state)
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
835088
def setEnabled(self, state):
        
        super(XToolButton, self).setEnabled(state)
        
        self.updateUi()
990552
public void updateState() {
        if (Thread.currentThread() == this.homeThread) {
            IState state = null;
            // Check the state queue to see if we need to carry out a transition:
            synchronized (this.stateQueue) {
                if (this.stateQueue.size() > 0) {
                    state = this.stateQueue.remove(0);
                }
            }
            if (state != null) {
                setState(state);   // Transition to the next state.
            }
        }
    }
613558
def set_(self, state):
    """"""
    if not self.can_be_(state):
        state = self._meta['translator'].translate(state)
        raise TransitionError(
            "Cannot transit from '{actual_value}' to '{value}'."
            .format(actual_value=self.actual_state.value, value=state.value)
        )

    self.force_set(state)
744444
private void setState(final RunnableProcessState newState) {
    if (!this.state.isLegal(newState)) {
      throw new IllegalStateException("Transition from " + this.state + " to " + newState + " is illegal");
    }
    this.state = newState;
  }
403298
def set_state(self, new_state):
        
        # Make sure it's a valid state
        if new_state not in self.STATES:
            raise ValueError('Invalid state value: %r' % new_state)

        # Set the state
        LOGGER.debug('State changing from %s to %s', self.STATES[self.state],
                     self.STATES[new_state])
        self.state = new_state
        self.state_start = time.time()
333498
public int setState(boolean state, boolean bDisplayOption, int iMoveMode)
    {       // Must be overidden
        if (this.getNextConverter() != null)
            return this.getNextConverter().setState(state, bDisplayOption, iMoveMode);
        else
            return super.setState(state, bDisplayOption, iMoveMode);
    }
227385
def add_reserved_switch_binding(switch_ip, state):
    """"""

    # overload port_id to contain switch state
    add_nexusport_binding(
        state,
        const.NO_VLAN_OR_VNI_ID,
        const.NO_VLAN_OR_VNI_ID,
        switch_ip,
        const.RESERVED_NEXUS_SWITCH_DEVICE_ID_R1)
720809
async def async_set_switch_state(
            self, switch_number: SwitchNumber, state: bool) -> None:
        

        await self._protocol.async_execute(
            SetSwitchCommand(
                switch_number,
                SwitchState.On if state else SwitchState.Off))
274605
def update_state(self):
        
        response = self.api_interface.local_get_state(self, type_override="binary_switche")
        return self._update_state_from_response(response)
437207
private void setState(State newState) {
        m_logger.debug("Entering state: {}", newState.toString());
        synchronized (m_stateChangeLock) {
            m_state = newState;
            m_stateChangeLock.notifyAll();
        }
    }
468330
def update_state(self):
        """"""
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.settimeout(self._timeout)
        try:
            if sock.connect_ex((self._ip, self._port['state'])) == 0:
                self.state = True
            else:
                self.state = False
            sock.close()
        except socket.error:
            raise
230530
public int setState(boolean state, boolean bDisplayOption, int moveMode)
    {
        double value = 0;
        if (state)
            value = 1;
        return this.setValue(value, bDisplayOption, moveMode);  // Move value to this field
    }
306177
private void updateState(final TaskStatus.State state) {
    statusUpdater.setState(state);
    // Commit and push a new status
    try {
      statusUpdater.update();
    } catch (InterruptedException e) {
      // TODO: propagate interrupt instead?
      Thread.currentThread().interrupt();
    }
  }
112014
def update_reserved_switch_binding(switch_ip, state):
    """"""

    # overload port_id to contain switch state
    update_reserved_binding(
        const.NO_VLAN_OR_VNI_ID,
        switch_ip,
        const.RESERVED_NEXUS_SWITCH_DEVICE_ID_R1,
        state)
343063
void changeState(State state) {

        m_state = state;
        switch (state) {
            case validationRunning:
                m_cancelButton.setEnabled(false);
                m_okButton.setEnabled(false);
                clearValidationError();
                break;
            case validationFailed:
                m_okButton.setEnabled(false);
                m_cancelButton.setEnabled(true);
                break;
            case validationUnknown:
            default:
                m_cancelButton.setEnabled(true);
                m_okButton.setEnabled(true);
                clearValidationError();
                break;

        }
    }