[SOLVED] Adding switch case to rule

Hey there,

I’m trying to add a switch case to my rule. But it does not trigger.
First i intialize a variabel called “Schritt” it gets the Value “1”. So if my Roomlight turns from OFF to ON the rule should be triggered. When “Schritt” equals 1 then also another light (blackboardlight) turns to ON. Independently of the second light there is also a projector that switches to ON.

So the proplem is that everything works except of the switch case function. That means the Trigger is regocnized and the Projecter is turned to ON. But nothing happens with the blackboardlight.

I guess i didn’t initialized “Schritt” correct. Well can anyone help me?

Here is my rule:

val int Schritt = 1

rule "Ablaufsteuerung"
when
    Item MeinZuhause_Erdgeschoss_Buero_Licht_RaumlichtAnAus changed from OFF to ON
then
    switch Schritt
    {
        case 1:
        sendCommand(MeinZuhause_Erdgeschoss_Buero_Licht_TafellichtAnAus,OFF)
    }
        sendCommand(MeinZuhause_Erdgeschoss_Buero_Schalter_BeamerAnAus, ON)
        

end

Fixed it, there was a logical mistake of mine, syntax and everything is correct, I just changed

    switch Schritt
    {
        case 1:
        sendCommand(MeinZuhause_Erdgeschoss_Buero_Licht_TafellichtAnAus,OFF)
    }

to

    switch Schritt
    {
        case 1:
        sendCommand(MeinZuhause_Erdgeschoss_Buero_Licht_TafellichtAnAus,ON)
    }

So I just changed the sending command from OFF to ON…

Note that because you made Schritt with a val, it will always be 1. If you are going to change it later, use a var

1 Like

Nice hint, I’m going to use “Schritte” later. if I want it to be an integer can i do:

var int Schritte
or
int Schritte
?

It’s just var (variable, can change) instead of val (value, never changes)

1 Like

Thank your very much, i guess this will save me a lot of frustration.