Item status in OH3 to trigger rule

Just trying to use an OH2 rule in OH3, but it doesnt work.
I assume it´s the status of the door, but don´t know how to fix.

The shutter called “Jalousie_EG_Wohnzimmer3” should close only if the door (Wozi_Tuer_3_Status) is not open.
So this worked fine within OH2, but not in OH3.

PS: the “telegram”-part works as expected

rule "Lux check and close shutter 3"

when
     Item Terrassen_Helligkeit changed
then
    if(!(Terrassen_Helligkeit.state instanceof Number))
        return;
    val nLux = (Terrassen_Helligkeit.state as Number).floatValue

    if(nLux < 30 && !Notify) {
        val telegramAction = getActions("telegram","telegram:telegramBot:XXXXXXXXX")
		telegramAction.sendTelegram("Es wird dunkler, Rollo3 runter: " + String::format("%.0f Lux",nLux))
		Notify = true
			
    } if (Wozi_Tuer_3_Status != OPEN) {
		Jalousie_EG_Wohnzimmer3.sendCommand(DOWN)
	}
end

I think you need

Wozi_Tuer_3_Status.state == CLOSED

I would use == CLOSED, so you don’t close it when the state is unknown

Add some temporary diagnostics to find out why.
Sometimes it’s because you have made an Item type differently now.

rule "Lux check and close shutter 3"

when
     Item Terrassen_Helligkeit changed
then
    logInfo("diag", "Rule triggered")
    //next we'll test a value - what is that?
    logInfo("diag", "TH state " + Terrassen_Helligkeit.state.toString)
    if(!(Terrassen_Helligkeit.state instanceof Number))
        return;

    val nLux = (Terrassen_Helligkeit.state as Number).floatValue
    // looks important - what's that?
    logInfo("diag", "nlux " + nLux.toString)

    // what's this Notify variable?
    logInfo("diag", "notify " + Notify.toString)

    if(nLux < 30 && !Notify) {
// and so on

This is the output

2021-03-07 14:10:00.277 [INFO ] [org.openhab.core.model.script.diag  ] - Rule triggered
2021-03-07 14:10:00.278 [INFO ] [org.openhab.core.model.script.diag  ] - TH state 2198
2021-03-07 14:10:00.278 [INFO ] [org.openhab.core.model.script.diag  ] - nlux 2198.0
2021-03-07 14:10:00.279 [INFO ] [org.openhab.core.model.script.diag  ] - notify true

I´m really poor in programming, so I don´t really understand why there is a difference between states in OH2 and OH3.

Wozi_Tuer_3_Status is a “contact item” as before, so the shutter should only close if the status of the contact “!=OPEN” or “==CLOSED”

with current rule the shutter closes with “nlux >30” although it shouldnt

The logInfo I suggested were suggestions, so that you could follow where your rule goes and what values it is looking at, so that you could work out what else you needed to know and perhaps add your own logInfo to find out.

I expect you’d want to know the state of that contact at the time the rule runs, for example?

You are aware that the way you’ve structured your rule, the lux makes no difference to the shutter down part, only to the messaging?

if (xx) { do stuff }
if (yy) { do other stuff }

is not the same as

if (xx) {
    do stuff 
    if (yy) { do other stuff }
}

I don’t know what states you had in OH2, are they different?

There are no differences in this case. Ever since the beginning of openHAB, you would check to see if a Contact Item is open by comparing that Item’s state, not the Item itself, as the Item itself has a whole bunch of other stuff like the Item’s name and tags and such.

So Eric’s suggestion has always been how one needs to check the state of an Item.

Thank you very much for your help!

It wasn´t the state of the item but wrong placed brackets: “{}”

modified the rule and now it seems to work again.