The problem with Thread::sleep is that it “locks” that thread and the system only have 5 in total.
250ms should be enough time to update an item value on the event bus.
Thread::sleep should be avoided if more that 500ms
Group you items updates together, wait 250ms and do you logInfo together
Try this:
I put the whole rule in a timer after 5 seconds, that replaces the first Thread:sleep(5000)
Then I group the postupdates (First batch together) wait 250ms and do the logInfos
The you have the if statements. Again only do the item update and then at the end of the rule post the logInfos together after waiting 250ms.
Your rule should now take 20ms to run. Time to create the timer
When timer executes, it should take not more than 1s in total to run. instead of your previous systax that was monoplolising a thread for at least 29 seconds
rule "Set Default Values"
when
System started
then
createTimer(now.plusSeconds(5), [ | //Thread::sleep(5000) // let persistence finish restoring a few seconds
logInfo("FILE", "***** SET_DEFAULTS starting: Setting System Defaults at openHAB2 startup or recycle *****")
// Standard Luftdruckwert für Ginsheim
STDPres.postUpdate(1013.25)
// Standard Kalibrierwert für Devolo Sensor setzen
WzTempCalibWert.postUpdate(0.6)
WzHumiCalibWert.postUpdate(-7.0)
// Standard Temperatur für das Wohnzimmer setzen
comfGruppeEGtemp.postUpdate(22.9)
Thread::sleep(250) // let persistence finish restoring a few seconds
logInfo("FILE", "***** Standard Luftdruckwert STDPres wird gesetzt auf Default: " + STDPres.state)
logInfo("FILE", "***** WzTempCalibWert wird gesetzt auf Default: " + WzTempCalibWert.state)
logInfo("FILE", "***** WzHumiCalibWert wird gesetzt auf Default: " + WzHumiCalibWert.state)
logInfo("FILE", "***** comfGruppeEGtemp wird gesetzt auf Default: " + comfGruppeEGtemp.state)
// Setting default for Wasserdruck Notification
if (EmailStatusDruck.state != NULL) logInfo("FILE", "***** EmailStatusDruck ist gesetzt mit dem Wert: " + EmailStatusDruck.state)
if (EmailStatusDruck.state == NULL) {
EmailStatusDruck.postUpdate("off")
logInfo("FILE", "***** EmailStatusDruck hatte noch keinen Wert und wird gesetzt auf: " + EmailStatusDruck.state)
}
// Setting default for MamaIstKalt
MamaIstKalt.postUpdate(0)
// Setting default for PartyPauseModus
PartyPauseModus.postUpdate(0)
// Setting default for ManualOverWrite
ManualOverWrite.postUpdate(0)
// Setting Min und Max Werte für Heizungsdruck Chart
minBudHeizDruck.postUpdate(0)
maxBudHeizDruck.postUpdate(2.5)
// Online Status von Sensor und Thermostaten abfragen und in Variablen setzen
var wz_status = getThingStatusInfo("zwave:device:73a3cf04:node2").getStatus()
ZwaveWzStat.postUpdate(wz_status.toString())
var gh_status = getThingStatusInfo("zwave:device:73a3cf04:node3").getStatus()
ZwaveGhStat.postUpdate(gh_status.toString())
var statavm1 = getThingStatusInfo("avmfritz:FRITZ_DECT_300:fritzbox:SOME_FB_AIN").getStatus()
DevFD3CdgEZstat.postUpdate(statavm1.toString())
var statavm2 = getThingStatusInfo("avmfritz:Comet_DECT:fritzbox:SOME_FB_AIN").getStatus()
DevCD3CogBZstat.postUpdate(statavm2.toString())
var statavm3 = getThingStatusInfo("avmfritz:FRITZ_DECT_300:fritzbox:SOME_FB_AIN").getStatus()
DevFD3CegKstat.postUpdate(statavm3.toString())
var statavm4 = getThingStatusInfo("avmfritz:FRITZ_DECT_300:fritzbox:SOME_FB_AIN").getStatus()
DevFD3CegWZFstat.postUpdate(statavm4.toString())
var statavm5 = getThingStatusInfo("avmfritz:FRITZ_DECT_300:fritzbox:SOME_FB_AIN").getStatus()
DevFD3CegWZTstat.postUpdate(statavm5.toString())
// Kontrolle ob Devolo Sensor (Wohnzimmer) online ist
if (wz_status.toString() == 'OFFLINE') {
logInfo("FILE", "***** SET_DEFAULTS: The zWave Thing << Devolo Sensor >> is " + wz_status)
val message = "SET_DEFAULTS Rule: Devolo Sensor (Wohnzimmer) is >> " + wz_status + " <<. Please consider rebooting the Docker container !!!"
sendMail("bla@yahoo.kx", "SET_DEFAULTS: Devolo Sensor (WZ) is " + wz_status + " !!!", message)
}
if (wz_status.toString() == 'ONLINE') {
logInfo("FILE", "***** SET_DEFAULTS: zWave Thing << Devolo Sensor (Wohnzimmer) >> is " + wz_status)
val message = "SET_DEFAULTS Rule: Devolo Sensor (Wohnzimmer) is >> " + wz_status + " <<. Nothing to do !!!"
sendMail("bla@yahoo.kx", "SET_DEFAULTS: Devolo Sensor (WZ) is " + wz_status + " !!!", message)
}
// Kontrolle ob Fibaro Sensor (Gartenhaus) online ist
if (gh_status.toString() == 'OFFLINE') {
logInfo("FILE", "***** SET_DEFAULTS: The zWave Thing << Fibaro Sensor (Gartenhaus) >> is " + gh_status)
val message = "SET_DEFAULTS Rule: Fibaro Sensor (Gartenhaus) is >> " + gh_status + " <<. Please consider rebooting the Docker container !!!"
sendMail("bla@yahoo.kx", "SET_DEFAULTS: Fibaro Sensor (GH) is " + gh_status + " !", message)
}
if (gh_status.toString() == 'ONLINE') {
logInfo("FILE", "***** SET_DEFAULTS: zWave Thing << Fibaro Sensor (Gartenhaus) >> is " + gh_status)
val message = "SET_DEFAULTS Rule: Fibaro Sensor (Gartenhaus) is >> " + gh_status + " <<. Nothing to do !!!"
sendMail("bla@yahoo.kx", "SET_DEFAULTS: Fibaro Sensor (GH) is " + gh_status + " !", message)
}
// Korrigieren der Außentemperatur
corrBudAussen.postUpdate((istBudAussen.state as DecimalType) - 1.3)
logInfo("FILE", "***** istBudAussen wird korrigiert auf: " + corrBudAussen.state)
// repeat 'if' for other items
Thread::sleep(250) // let persistence finish restoring a few seconds
logInfo("FILE", "***** MamaIstKalt wird gesetzt auf Default: " + MamaIstKalt.state)
logInfo("FILE", "***** PartyPauseModus wird gesetzt auf Default: " + PartyPauseModus.state)
logInfo("FILE", "***** ManualOverWrite wird gesetzt auf Default: " + ManualOverWrite.state)
logInfo("FILE", "***** minBudHeizDruck wird gesetzt auf Default: " + minBudHeizDruck.state)
logInfo("FILE", "***** maxBudHeizDruck wird gesetzt auf Default: " + maxBudHeizDruck.state)
logInfo("FILE", "***** SET_DEFAULTS finished: Setting System Defaults at openHAB2 startup or recycle *****")
])
end