Delay when setting items in OpenHAB

This is because the sendCommand doesn’t change the state of the item straight away, it needs to be processed through the event bus and persistence first. As a result, when you are retreiving the item state, it hasn’t changed yet. One way to deal with that is to wait a little bit for the event bus to catch up.

Notice the use of the code fences:

rule “Dim lights”
when
    Time cron “0 45 19 ? * *”
then
    I_ART_Flurlampe_vorne.sendCommand(15)
    I_ART_Flurlampe_hinten.sendCommand(15)
    if (I_ART_Anwesenheit.state == ON) {
        Tread::sleep(100) // 100ms
        I_FL_Deckenlampe_vorn_Dimmer.sendCommand(I_ART_Flurlampe_vorne.state)
        I_FL_Deckenlampe_hinten_Dimmer.sendCommand(I_ART_Flurlampe_hinten.state)
    }
end