Blocky: Calculating the average of light intensity last minutes

moved from OH2.5 to OH3 and do not get it.

Have several rollershutters which have to shut to x% if it is sunny. To prevent opening and shutting by each cloud, I would like to build an average of light intensity for the last minutes.
The values are stored in rrd4j and in OH2 rules it was very easy by using
helligkeit_avg = (Wetterstation_ILLUMINATION.averageSince(now.minusMinutes(10)) as Number).intValue
in a rule.
But how to do it in OH3 with blockly?
Sorry, I do not get it.
Thanks for any idea.
Best regards

Use the same rule from OH2

The blocky implementation in OH3 is currently quite limited. Better things to come one day.

try to do it now like:

  1. Generate rrdj4.persist file within persistence folder with following entries:
    Strategies {
  •    everyMinute : "0 * * * * ?"*
  •    default = everyChange*

Items {

  • WetterstationGarten_Illumination : strategy = everyChange, everyMinute, restoreOnStartup*


  1. I’m building EMCA Script like:
    var logger = Java.type(‘org.slf4j.LoggerFactory’).getLogger(‘org.openhab.rule.’ + ctx.ruleUID);
    var ZonedDateTime = Java.type(‘java.time.ZonedDateTime’);
    var PersistenceExtensions = Java.type(‘org.openhab.core.persistence.extensions.PersistenceExtensions’);

    var v_schwellwert_verschattung_lux_avg_max = 6000.0;
    var v_aktuelle_helligkeit = itemRegistry.getItem(“WetterstationGarten_Illumination”).getState();

    var v_helligkeit_avg = PersistenceExtensions.averageSince(
    itemRegistry.getItem(“WetterstationGarten_Illumination”),;'Helligkeit = ’ + v_aktuelle_helligkeit + " - AVG: " + v_helligkeit_avg);

Output from the log is:
[rg.openhab.rule.VerschattungUndSturm] - Helligkeit = 6077.00 - AVG: undefined
Any idea why it is undefined?
Thank you very much in advance!

In the meantime this has been added to blockly. See here

I will add the documentation for these blocks to the Blockly Reference very soon.

cc: @andi1306