Hi,
I have a rule, that runs at 00:05 everyday which updates some counters (days to left in the year, days until christmas, days until the next holiday is up etc).
Weirdly this shows the correct answer (in the LOG) when I run the rule (manually) a second time.
My Rule:
strNextBankHolidayID.sendCommand(Ephemeris.getNextBankHoliday())
var String HOLIDAY_LIST = "/etc/openhab/services/Holidays_de.xml"
/* NEXT HOLIDAY */
if (Ephemeris.isBankHoliday() == true)
{
strUpcomingBankHoliday.sendCommand("Today is "+Ephemeris.getHolidayDescription(getNextBankHoliday,HOLIDAY_LIST).toString)
logInfo("holidays.rules",strUpcomingBankHoliday.state.toString.toUpperCase)
}
else
{
strUpcomingBankHoliday.sendCommand(Ephemeris.getDaysUntil(getNextBankHoliday,HOLIDAY_LIST).toString+" Day(s) until "+Ephemeris.getHolidayDescription(getNextBankHoliday,HOLIDAY_LIST).toString)
logInfo("holidays.rules",strUpcomingBankHoliday.state.toString.toUpperCase)
}
/* CHRISTMAS */
if (Ephemeris.getDaysUntil("FIRST_CHRISTMAS_DAY") != 0)
{
//postUpdate
strDaysUntilChristmas.sendCommand(Ephemeris.getDaysUntil("FIRST_CHRISTMAS_DAY").toString +" Day(s) until Christmas")
logInfo("holidays.rules",strDaysUntilChristmas.state.toString.toUpperCase)
}
else
{
//postUpdate
strDaysUntilChristmas.sendCommand("Today is "+Ephemeris.getHolidayDescription("FIRST_CHRISTMAS_DAY").toString)
logInfo("holidays.rules",strDaysUntilChristmas.state.toString.toUpperCase)
}
/* NEW YEAR */
if (Ephemeris.getDaysUntil("NEW_YEAR") != 0 && Ephemeris.getDaysUntil("NEW_YEARS_EVE") == 0)
{
//postUpdate(
strDaysOfYearLeft.sendCommand((Ephemeris.getDaysUntil("NEW_YEARS_EVE",HOLIDAY_LIST)).toString +" Day(s) left in "+ now.getYear().toString)
logInfo("holiday.rules",strDaysOfYearLeft.state.toString.toUpperCase)
}
else
{
//postUpdate(strDaysOfYearLeft,("First Day Of "+ now.getYear().toString))
//postUpdate
strDaysOfYearLeft.sendCommand((Ephemeris.getDaysUntil("NEW_YEARS_EVE",HOLIDAY_LIST)).toString +" Day(s) left in "+ now.getYear().toString)
logInfo("holidays.rules",strDaysOfYearLeft.state.toString.toUpperCase)
}
When triggered at 00:05, it results in:
2024-05-09 00:05:00.947 [INFO ] [hab.core.model.script.holidays.rules] - 1 DAY(S) UNTIL ASCENSION DAY
2024-05-09 00:05:00.949 [INFO ] [hab.core.model.script.holidays.rules] - 231 DAY(S) UNTIL CHRISTMAS
2024-05-09 00:05:00.950 [INFO ] [hab.core.model.script.holidays.rules] - 237 DAY(S) LEFT IN 2024
When I run the rule manually it shows the correct results:
2024-05-09 08:07:18.656 [INFO ] [hab.core.model.script.holidays.rules] - TODAY IS ASCENSION DAY
2024-05-09 08:07:18.658 [INFO ] [hab.core.model.script.holidays.rules] - 230 DAY(S) UNTIL CHRISTMAS
2024-05-09 08:07:18.659 [INFO ] [hab.core.model.script.holidays.rules] - 236 DAY(S) LEFT IN 2024
Any idea why this is ?
Thanks