code: 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)
docs: :param state: bool
          :param speed: a string one of ["lowest", "low",
              "medium", "high", "auto"] defaults to last speed
          :return: nothing