TriggerRecurringTime extends Trigger { @Override public boolean shouldRun() { if (validTo != 0 && DateUtil.now() > validTo) return false; Calendar c = Calendar.getInstance(); int scheduledDayOfWeek = c.get(Calendar.DAY_OF_WEEK); Calendar scheduledCal = DateUtil.gregorianCalendar(); scheduledCal.set(Calendar.HOUR_OF_DAY, hour); scheduledCal.set(Calendar.MINUTE, minute); scheduledCal.set(Calendar.SECOND, 0); long scheduled = scheduledCal.getTimeInMillis(); if (isSet(Objects.requireNonNull(DayOfWeek.fromCalendarInt(scheduledDayOfWeek)))) { if (DateUtil.now() >= scheduled && DateUtil.now() - scheduled < T.mins(5).msecs()) { if (lastRun < scheduled) { if (L.isEnabled(L.AUTOMATION)) log.debug("Ready for execution: " + friendlyDescription()); return true; } } } return false; } TriggerRecurringTime(); private  TriggerRecurringTime(TriggerRecurringTime triggerTime); void setAll(boolean value); TriggerRecurringTime set(DayOfWeek day, boolean value); @Override boolean shouldRun(); @Override String toJSON(); @Override int friendlyName(); @Override String friendlyDescription(); @Override Optional<Integer> icon(); @Override Trigger duplicate(); @Override void generateDialog(LinearLayout root, FragmentManager fragmentManager);  }
@Test public void shouldRunTest() { TriggerRecurringTime t = new TriggerRecurringTime().hour(1).minute(34).validTo(1); t.setAll(true); Assert.assertFalse(t.shouldRun()); t = new TriggerRecurringTime().hour(1).minute(34).lastRun(now - 1); t.setAll(true); Assert.assertFalse(t.shouldRun()); }