Cust App won't initialize with expression " 'String' in list"


#1

Hello!

In one of my customized apps, the app won't initialize and I found that it is directly correlated to the code below

 def illum = sensor.currentValue("illuminance")
        def FindUnit = sensor.currentState("illuminance")

        def i = 0
        def s = dimmers.size()
        def dimmersLevelState = []
        def dimmersSwitchState = []

        for(s!=0;i<s;i++)
        {
            def lvState = dimmers[i].currentValue("level") as String
            def swState = dimmers[i].currentValue("switch") as String
            dimmersLevelState << lvState
            dimmersSwitchState << swState
        }

        boolean atLeastOneIsOn = on in dimmersSwitchState // ??? why does it refuse to initialize when I type "on" here??? 

As stated in the comment, if I type :

boolean atLeastOneIsOn = "on" in dimmersSwitchState

it won't initialize... I don't get it, because nowhere have I declared a variable called "on" so how can groovy take it as an object of some sort and not require a string, while lists, if I'm correct, are lists of strings...?

NB: I don't get any error message, the page is simply stuck with the little blue spinning circle until I refresh the page. It WILL init if and only if I take the "" out of the expression, just as if on was a required object in this expression.

Thanks in advance


#4

So, apparently, if I name a method eval() or evaluate(), this platform hates it. I have no idea why. Something in the body script?

If I call

 runIn(60, evaluate) 

, here is what I get:

java.lang.IllegalArgumentException: Name cannot be null. "

And if I call

 runIn(60, eval) 

the whole thing crashes as described above... except it also worked for the past couple days before this was an issue... AND I remember changing "evaluate" into "eval" a week ago because I had the illegal argument exception thrown, so this specific issue is systematic but for what regards "eval" having worked for days and suddenly blocking everything (if called during update/initialization), that, I can't figure out where it comes from.

The very same app had worked for literally years without any issue on another platform, so I wonder what I'm not getting here (and it's not 4 am yet!)