Rules sometimes executing with long delay

Thanks for your replies and the links!
It’s quite difficult to assess if some changes made a difference since the problem occurs quite at random.
I increased the threaspool size.

Would this also be a good idea?
And what about the part with VSC and the language server? At the moment i have VSC open in the background most of the time…

Your post is brilliant! Is there any way to monitor the Rule Execution Threads? Or the threads/… of openHAB in general?

No Thread::sleep, No executeCommandLine, no while loops but a few sendHttpPutRequests to trigger light scenes from the Hue Bridge and the http binding to get the status of my Hue Motion Sensor and Hue Dimmer Switch

// Hue Motion Senssor - temperature sensor
Number hueMotionSensorTemperature
"Temperatur Hue Motion Sensor [%.1f °C]"
<temperature>
(HueMotionSensorVZ, Temperatures)
{ http="<[hueMotionSensorTemperature:60000:JS(getHueTemperature.js)]" }

DateTime hueMotionSensorTemperatureLastChange
"Letzte Änderung [%1$tH:%1$tM:%1$tS]"
<time>
(HueMotionSensorVZ)
{ http="<[hueMotionSensorTemperature:60000:JS(getHueLastChange.js)]" }

// Hue Motion Sensor - motion sensor
Switch hueMotionSensorPresence
"Bewegung Vorzimmer JA/NEIN [%s]"
<motion>
(HueMotionSensorVZ, Motions)
{ http="<[hueMotionSensorPresence:5000:JS(getHuePresence.js)]" }

DateTime hueMotionSensorPresentLastChange
"Letzte Änderung [%1$tH:%1$tM:%1$tS]"
<time>
(HueMotionSensorVZ)
{ http="<[hueMotionSensorPresence:5000:JS(getHueLastChange.js)]" }

// Hue Motion Sensor - ambient light sensor
Number hueMotionSensorIlluminance
"Helligkeit Vorzimmer [%.1f Lux]"
<light>
(HueMotionSensorVZ, Luxs)
{ http="<[hueMotionSensorIlluminance:15000:JS(getHueIlluminance.js)]" }

DateTime hueMotionSensorIlluminanceLastChange
"Letzte Änderung [%1$tH:%1$tM:%1$tS]"
<time>
(HueMotionSensorVZ)
{ http="<[hueMotionSensorIlluminance:15000:JS(getHueLastChange.js)]" }
when

Item XiaomiWandschalter2_CLICK received update

then

val String bridgeURL = "http://192.168.2.69/api/XXXXXX/"
val String scene_group = "1"

if (XiaomiWandschalter2_CLICK.state.toString == "left") {
    if (AstroDayStatus.state == ON) {
        val String scene_id = "IziAxVom2Egc58Z" //Stehlampe Hell
        sendHttpPutRequest(bridgeURL + "groups/" + scene_group + "/action", "application/json", '{"scene": "' + scene_id + '"}')
    }
    
    else if  (AstroDayStatus.state == OFF && now.getHourOfDay < 22 && now.getHourOfDay > 5) {
        val String scene_id = "yrgqdXYVGKLzZTK"
        sendHttpPutRequest(bridgeURL + "groups/" + scene_group + "/action", "application/json", '{"scene": "' + scene_id + '"}')
    }

    else {
        val String scene_id = "WFNZIyjZcXbPHgv"
        sendHttpPutRequest(bridgeURL + "groups/" + scene_group + "/action", "application/json", '{"scene": "' + scene_id + '"}')
    }
}

else if (XiaomiWandschalter2_CLICK.state.toString == "right") {
    if (AstroDayStatus.state == ON) {
        val String scene_id = "LvQ8i4NvCv4bWIk"
        sendHttpPutRequest(bridgeURL + "groups/" + scene_group + "/action", "application/json", '{"scene": "' + scene_id + '"}')
    }

    else {
        val String scene_id = "VzOR65SMPwN5Lhm"
        sendHttpPutRequest(bridgeURL + "groups/" + scene_group + "/action", "application/json", '{"scene": "' + scene_id + '"}')
    }
}

else if (XiaomiWandschalter2_CLICK.state.toString == "both") {
    HueWZStehlampe1Dimmer.sendCommand(0)
    HueWZStehlampe2Dimmer.sendCommand(0)
    HueWZStehlampe3Dimmer.sendCommand(0)
    HueWZStehlampe4Dimmer.sendCommand(0)
    HueWZIrisBlackDimmer.sendCommand(0)
    HueWZIrisWhiteDimmer.sendCommand(0)
    HueSchreibtischLightstripDimmer.sendCommand(0)
    HueEZDeckeDimmer.sendCommand(0)
    OsramKuecheDeckeDimmer.sendCommand(0)
    gKuecheHerdLinksDimmer.sendCommand(0)
    gKuecheHerdRechtsDimmer.sendCommand(0)
    HueKuecheLightstripDimmer.sendCommand(0) 
    XiaomiWandschalter1_CLICK.send (OFF)

}

end

I just read this topic with a similar problem: Sometimes rules don't get executed?
I’m persisting all Sensor Data and a bunch more at the moment at every update to an external MySQL Database… maybe i should tone it down a bit and only store the relevant data for my graphs?


UPDATE: it seems like the higher thread pool size improved things but just now i again had a delay of 17 sec.