Turn on or off.

        :param state: True (on) or False (off).
514476
def on(self, state):
        
        self._on = state
        cmd = self.command_set.off()
        if state:
            cmd = self.command_set.on()
        self.send(cmd)
950133
def set_start_state(self, state):
        
        if state is None:
            self.start_state_id = None
        elif isinstance(state, State):
            self.start_state_id = state.state_id
        else:
            self.start_state_id = state
86668
def toggle_state(self, state, active=TOGGLE, scope=None):
        
        self.conversation(scope).toggle_state(state, active)
571507
def switch_on(self, *args):
        
        if self.on_check(*args):
            return self._switch.switch(True)
        else:
            return False
454375
def _on_light_state(self, header, payload, rest, addr):
        
        with self.lock:
            label = payload['label'].strip('\x00')
            self.bulbs[header.mac] = bulb = Bulb(label, header.mac)
            if len(self.bulbs) >= self.num_bulbs:
                self.bulbs_found_event.set()

            self.light_state[header.mac] = payload
            if len(self.light_state) >= self.num_bulbs:
                self.light_state_event.set()

        self.callbacks.put(EVENT_LIGHT_STATE, bulb,
                           raw=payload,
                           hue=(payload['hue'] / float(0xffff) * 360) % 360.0,
                           saturation=payload['sat'] / float(0xffff),
                           brightness=payload['bright'] / float(0xffff),
                           kelvin=payload['kelvin'],
                           is_on=bool(payload['power']))
735477
def set_state(self, state):
        
        values = {"desired_state": {"powered": state}}
        response = self.api_interface.set_device_state(self, values)
        self._update_state_from_response(response)
669115
def switch_toggle(self, device):
        """"""
        state = self.get_state(device)
        if(state == '1'):
            return self.switch_off(device)

        elif(state == '0'):
            return self.switch_on(device)
        else:
            return state
252264
public function toggleState() {
		if ( $this->isSet() ) {
			$this->write( $this->getLow() );
		} else {
			$this->write( $this->getHigh() );
		}
	}
303780
def set_state(self, state, speed=None):
        
        speed = speed or self.current_fan_speed()
        if state:
            desired_state = {"powered": state, "mode": speed}
        else:
            desired_state = {"powered": state}

        response = self.api_interface.set_device_state(self, {
            "desired_state": desired_state
        })

        self._update_state_from_response(response)
1211061
def set_state(self, state, speed=None):
        
        desired_state = {"powered": state}
        if state:
            brightness = self._to_brightness.get(speed or self.current_fan_speed(), 0.33)
            desired_state.update({'brightness': brightness})

        response = self.api_interface.set_device_state(self, {
            "desired_state": desired_state
        })

        self._update_state_from_response(response)
59533
def switch_off(self):
        """"""
        success = self.set_status(CONST.STATUS_OFF_INT)

        if success:
            self._json_state['status'] = CONST.STATUS_CLOSED

        return success
1366602
def switch_on(self):
        """"""
        success = self.set_status(CONST.STATUS_ON_INT)

        if success:
            self._json_state['status'] = CONST.STATUS_ON

        return success
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)
864993
public void setState(String state)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "setState", state);

    this.state = state;

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "setState");
  }
1271450
def status_light(self):
        
        result = self.deviceProperties.GetLEDState()
        LEDState = result["CurrentLEDState"]  # pylint: disable=invalid-name
        return True if LEDState == "On" else False
1174768
def set_heartbeat(self, state):
        

        if state in ["on", "off", "open"]:
            self.heartbeat = state
            self.server.request("screen_set %s heartbeat %s" % (self.ref, self.heartbeat))
938579
def switch_on(self):
        """"""
        success = self.set_status(CONST.STATUS_OPEN_INT)

        if success:
            self._json_state['status'] = CONST.STATUS_OPEN

        return success