Ephemeris cache

I test ephemeris and it works very well except that if I compare a date to today it works well, on the other hand if I leave a rules running every day it does not update the date comparison values, there have a cache to empty?

I’m on OH3.4 M4

This ecmascript-2021 rune every 6 minutes , when i reload rule is perfect , but i fi leave runing the day after le value still the same… why ?
thanks for your help


const Ephemeris = Java.type('org.openhab.core.model.script.actions.Ephemeris');
// est t'on le weekend ?
let weekend = actions.Ephemeris.isWeekend();
// quelle est l'ephemeris du jour ? si rien return rien de special
let today = actions.Ephemeris.getBankHolidayName("/openhab/conf/services/Holidays_be_custom_.xml");
// combien de jour restant avant les anniversaire
let Days_RestTo_Birth_PH = actions.Ephemeris.getDaysUntil('Anniverssaire_PH', "/openhab/conf/services/Holidays_be_custom_.xml");


let prochainEvenement = actions.Ephemeris.getNextBankHoliday(1,"/openhab/conf/services/Holidays_be_custom_.xml");


let EphemerisDemain = actions.Ephemeris.isBankHoliday(1,"/openhab/conf/services/Holidays_be_custom_.xml");

//toute les 6 minutes
rules.when().cron("0 0/6 * 1/1 * ? *").then(e => {
  
  
    
    console.info(`Est t'on le weekend ? ${weekend} `);

    if(today == null){
        console.info(`Aujourd'hui rien de spécial... `);
      }
    else{
      console.info(`Aujourd'hui c'est ${today} `);
    }
  
    console.info(`Demain vaux ${EphemerisDemain} `);

    console.info(`Il reste ${Days_RestTo_Birth_PH} jours avant l'anniversaire de Pol-henri `);
    items.getItem("DaysRestToBirth_Ph").sendCommand(Days_RestTo_Birth_PH);

    console.info(`Prochain evenement ${prochainEvenement}`);

    // classe les objet dans l'ordre numerique  
    let sortable = [];
    for (var member in Days_RestTo_Birth_To_Order) {
        sortable.push([member, Days_RestTo_Birth_To_Order[member]]);
    }

    sortable.sort(function(a, b) {
        return a[1] - b[1];
    });

    for(var ordered in sortable){
      console.info(` ${parseInt(ordered) + 1} Anniversaire de ${sortable[ordered][0] } ${(sortable[ordered][1] == 0 ? 'c\'est Aujourd\'hui!' : 'dans ' + sortable[ordered][1] + ' jours')} `);
    }
  
  
  
}).build("Ephemeris infos every 6 minutes", "donne les ephemeride toute les 6 minute");

No.

All the code that executes before rules executes only when the file is first loaded and then never again. So weekend, today, and all the rest of the variables will only be set when the file is loaded.

If you want to refresh them when a rule runs, you need to call the Ephemeris actions inside the rule.

Thanks again ! u are so … amazing thanks ! :grinning:
i test that :smiley: