We consider an energy harvesting device whose state at a given time is determined by its energy level and an "importance" value, associated to the transmission of a data packet to the receiver at that particular time. We consider policies that, at each time, elect whether to transmit the data packet or not, based on the current energy level and data importance, so as to maximize the long-term average transmitted data importance. Under the assumption of i.i.d. Bernoulli energy arrivals, we show that the sensor should report only data with an importance value above a given threshold, which is a strictly decreasing function of the energy level, and we derive upper and lower bounds on the thresholds for any energy level. Leveraging on these findings, we construct a suboptimal policy that performs very close to the optimal one, at a fraction of the complexity. Finally, we demonstrate that a threshold policy, which on the average transmits with probability equal to the average energy arrival rate is asymptotically optimal as the energy storage capacity grows large.