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();
// raise notification if clock is off (setting clock is not supported by ruffy)
Date now = new Date();
int minutesOfDayNow = now.getHours() * 60 + now.getMinutes();
if ((Math.abs(preCheckResult.state.pumpTimeMinutesOfDay - minutesOfDayNow) > 3)) {
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, "Check pump clock", Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
if (preCheckResult.state.pumpTimeMinutesOfDay != 0) {
Date now = new Date();
int minutesOfDayNow = now.getHours() * 60 + now.getMinutes();
if ((Math.abs(preCheckResult.state.pumpTimeMinutesOfDay - minutesOfDayNow) > 3)) {
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);
}
}
return null;