[SOLVED] Help with the rule

Hello,
I have a trouble defining a when statement in rule for the switch item light. I have a button named tipka and when the button is pressed:

  • If the light is on when the button is pressed the light must be turned off.

  • and if the light is off when the button is pressed the light must be turned on.

Here is the rule:

        rule "light"
        when
                item tipka changed from OPEN to CLOSED
        then
                if (luc.state != ON) {
                        luc.sendCommand(ON)
                        logInfo("ON")}
                if (luc.state == ON) {
                        luc.sendCommand(OFF)
                        logInfo("OFF")}
        end

and here is the error in the log:
'home.rules' has errors, therefore ignoring it: [27,2]: no viable alternative at input 'item'

Rules syntax is picky, and case sensitive. The error message does point you to the problem, but doesn’t spell out the solution. Item not item here.

1 Like

This fixed my problem and the rules is working, but in the log there is a new error.

Rule 'light': An error occurred during the script execution: index=1, size=1

logInfo() requires two parameters, both strings

1 Like