Help with another simple rule (SOLVED)

What do you mean?
Do you have problems with triggers?

&& means AND, it’s used when you want to check multiple conditions in one if-statement instead of nesting multiple ifs.

1 Like

The part that at the bottom that says if these are all off switch motion_home to off and if any are on set it too on

I will update some of my rules and use that it makes it simple with less brackets

Actually we can make that even a bit better:

rule "Motion Detection"
when
    Time cron "0 0/2 * 1/1 * ? *" //Every 2 mins
then
    if ((gHueMotions.state == OFF) && ((gTotalBrightness.state as Number) == 0)) {
        House_Motion.sendCommand(OFF)
    } else {
        House_Motion.sendCommand(ON)
    }
end

What was wrong with my version of the rule apart from it being long

There was 1 } too many at the end

1 Like

The problem is the else-part, which will only be triggered if every if-statement except the last evaluates to true.

Haha there is alot of them it’s the only way I knew how too do what I wanted I have used the same rule slightly different before works perfect just couldent get it running for this use case

So as soon as it found a light on or motion on it ends the rule and never gets far enough too change the switch to ON

@Sharpy

Have a look at:

It checks you syntax for you and much more!! Brilliant tool

Correct. If you put all conditions in one if-statement with && between them all must be true for the code to run, if only one of them is false the else-code is run instead.

I use vscode to edit my files it has made it alot easier to create these files but I have been getting an error so its not working properly Im not sure what’s wrong and I just havent got around too finding the problem it says there is a server error check openhab log

Thanks for that it’s better to learn what you were doing wrong than letting others just post code for me

1 Like

Weirdly I just loaded vs code too check what it said and its not reporting this now its been reporting this error for weeks

Haven’t used vscode for a few weeks now, but I’ve gotten those errors from time to time, a restart usually helps, but it always come back eventually…

1 Like

Ahh so it’s not just me slightly good too hear

@rlkoshak

That’s a very good question
Do you know the actual answer to this?

No, there shouldn’t be a limit. Or to be more precise, the lining will be so large (hundreds to thousands if the lining is low) as to never be a practical concern.

I’m pretty sure a HashMap is used for the in memory storage of group membership which in Java has a max of 2^30 elements.

Thanks