Switch to enable/disable 1 rule

Hi guys,

i would like to enable/disable a rule with a simple switch.

item files

Switch astrorule01

rule file

rule "test"
    when
        Item astrorule01 received command
    then
        switch (receivedCommand) {
            case ON: ENABLE RULE BELOW
            case OFF: DISABLE RULE BELOW
        }
end

rule "the rule that gets disabled"
    when
        Item light1 received command
    then
        switch (receivedCommand) {
            case ON: (light1, ON)
            case OFF: (light1, OFF)
        }
end

Add an if statement to check the state astrorule01 before executing the rest of the rule.

1 Like

Thank you