JRuby OpenHAB Rules System

Thank you for your suggestion, I did implement it today and it works a charm I would most probably not have been able to come up with that on my own. Quite simple rules for something that works more or less like the design pattern for long and short press

rule 'long/short press button rule button up' do
  changed button_up, to: ON

  run { logger.info("button UP changed event")}
  
  run do
    if button_up.on? and lamp_cluster.off?
      logger.info("turning light on")
      lamp_cluster << 30
    end

    java_import java.time.ZonedDateTime
    timer = after(2.second) do

      if button_up.on?
        logger.info("button still ON, sending increase command, rescheduling")
        lamp_cluster.brighten(10)

        timer.reschedule(ZonedDateTime.now.plus(Java::JavaTime::Duration.ofSeconds(2)))
       end
     end
  end
end

rule 'long/short press rule button down' do
  changed button_down, to: ON
  
  run { logger.info("button DOWN changed event")}
  
  dimming = false
  
  run do
    java_import java.time.ZonedDateTime
    timer = after(2.second) do
      if button_down.on?
       logger.info("button still ON, sending decrease command, rescheduling")
       lamp_cluster.dim(10)
       dimming = true
       timer.reschedule(ZonedDateTime.now.plus(Java::JavaTime::Duration.ofSeconds(2)))
      else
        if dimming == false
          logger.info("button OFF, sending off command")
          lamp_cluster.off
          dimming = false
        end
      dimming = false
      end
    end
  end
end

all of this achieved without casting or converting a single type very slick indeed. With the wrappers around the timer objects it would be even more slick.
But if one could have a trigger function that works for repeated time intervals, as well as time intervals that are shorter than a certain period of time, that could compress this rule very much indeed. Like I suggested, but something along the lines of changed ... for: less than 1.second

next is to try implementing a state machine with a state machine gem. I have done some preliminary testing to show that the gem file is installed, loaded, I have initialised the class and it all works, now I just have to rework (and understand) the example to work in my situation. Will report back in due time.