Trouble with Shutter rules since OH 2.3

Since you ask…

First, let’s combine into one Rule so we can get rid of those Thread::sleeps. They aren’t needed (unless there is something I don’t know) and only tie up the run time threads.

Then it can be a little easier to split up the if statements a bit. It can be hard to keep and reason long complicated if statements in your head at the same time. The complicated part here is that there is overlap when the various shutters should be activated so I’m going to use a List to keep all the shutters that should be activated.

import java.util.List

rule "Sonnenschutz aktivieren"
when
    Item VT_VAL_Sun_Elevation received update or
    Item VT_VAL_Sun_Azimuth changed
then
    if(VT_SWI_Sonnenschutz.state != ON) return; // exit if this isn't ON

    // get the list of shutters that need to be activated based on the sun position
    val List<SwitchItem> activate = newArrayList
    if(VT_VAL_Sun_Elevation.state >= 30) activate.add(VT_SWI_Sonnenschutz_Dach)
    if(VT_VAL_Sun_Azimuth.state <= 150) activate.add(VT_SWI_Sonnenschutz_Osten)
    if(VT_VAL_Sun_Azimuth.state > 150 && VT_VAL_Sun_Azimuth.state < 280) activate.add(VT_SWI_Sonnenschutz_Sueden)
    if(VT_VAL_Sun_Azimuth.state > 225) activate.add(VT_SWI_Sonnenschutz_Westen)

    // send the command if necessary
    activate.filter[ s | s.state != ON].forEach[ s |
        s.sendCommand(ON)
        logInfo("Rollershutter", "Sonnenschutz für die " + s.name.split("_").get(3) + " wurde aktiviert " +VT_VAL_Current_Clouds.state +" " +VT_VAL_Sun_Azimuth)
    ]
end

You might want to do something like Design Pattern: Human Readable Names in Messages to convert the Item name to the proper String for your log if that is important.

If the sleeps were there to keep from overloading your devices with too many commands at once, add a Thread::sleep(100) to the for loop.

It’s fewer lines of code, and perhaps a little easier to work through the cases to figure out what rollershutters are to be activated under what circumstances. And there is no duplicated code. But it requires a List and loop so I don’t know if it is a fare trade.