Stochastic Nonsmooth Analysis For Energy Harvesting