Only raise notification to check pump time when the latter could be read.

This commit is contained in:
Johannes Mockenhaupt 2017-11-22 00:44:56 +01:00
parent b4d2d9f71d
commit 8b81925ccb
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -690,12 +690,14 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
if (mismatch) checkPumpHistory(); if (mismatch) checkPumpHistory();
// raise notification if clock is off (setting clock is not supported by ruffy) // raise notification if clock is off (setting clock is not supported by ruffy)
Date now = new Date(); if (preCheckResult.state.pumpTimeMinutesOfDay != 0) {
int minutesOfDayNow = now.getHours() * 60 + now.getMinutes(); Date now = new Date();
if ((Math.abs(preCheckResult.state.pumpTimeMinutesOfDay - minutesOfDayNow) > 3)) { int minutesOfDayNow = now.getHours() * 60 + now.getMinutes();
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, "Check pump clock", Notification.NORMAL); if ((Math.abs(preCheckResult.state.pumpTimeMinutesOfDay - minutesOfDayNow) > 3)) {
MainApp.bus().post(new EventNewNotification(notification)); Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, "Check pump clock", Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
// runCommand("Updating pump clock", 2, ruffyScripter::setDateAndTime); // runCommand("Updating pump clock", 2, ruffyScripter::setDateAndTime);
}
} }
return null; return null;