* @return the historic item with the minimum state value since the given point in time
*/
static public HistoricItem minimumSince(final Item item, AbstractInstant timestamp, String serviceName) {
Iterable<HistoricItem> result = getAllStatesSince(item, timestamp, serviceName);
Iterator<HistoricItem> it = result.iterator();
HistoricItem minimumHistoricItem = null;
DecimalType minimum = (DecimalType) item.getStateAs(DecimalType.class);
while(it.hasNext()) {
HistoricItem historicItem = it.next();
State state = historicItem.getState();
if (state instanceof DecimalType) {
DecimalType value = (DecimalType) state;
if(minimum==null || value.compareTo(minimum)<0) {
minimum = value;
minimumHistoricItem = historicItem;
}
}
}
if(minimumHistoricItem==null && minimum!=null) {
// the minimal state is the current one, so construct a historic item on the fly
final DecimalType state = minimum;
return new HistoricItem() {
public Date getTimestamp() {
return Calendar.getInstance().getTime();
}