Contains() and currentMotion reporting true regardless of result

Since upgrading to 2.3.2.125 I noticed several of my custom apps were not performing as expected.

All checks on either currentMotion or contains(String) we’re giving a true result regardless of the actual state.

I have custom code which has worked flawlessly for years now which started failing.

Here is an example of what used to work but then stopped after upgrading

def colorState = “green”
If (![“green”,”yellow”].contains(colorState)) {
performAction2()
return
} else performAction1()

The result should always be performAction1()” but It started failing.

But if I add a log line of code after the check then the result would work as expected. ?

def colorState = “green”
If (![“green”,”yellow”].contains(colorState)) {
log.info “green was NOT present)
performAction2()
return
} else performAction1()

I'm unable to replicate this in 2.3.2.127

def test() {
    def colorState = "green"
    if (!["green","yellow"].contains(colorState)) {
        action2()
        return
    } else action1()
}
def action1(){log.debug "action1"}
def action2(){log.debug "action2"}

works as expected, BTW the return statement is not required...

I appreciate you trying.
The return statement is required in my code because there’s lots more after this check in the actual function. That was just an example of what mine does.

I also cannot replicate it in new code either.
It seems to be a problem with existing code after the upgrade. ? It’s almost as if the code is not compiling correctly unless I edit it all first by including a new line of code.

After the new line has been added, things start working as expected again even if I then remove the new line of logging code.

It’s a strange one I admit.

I don’t know if it’s of any relevance to my problem but i forgot to point out that the original object being checked is actually from an atomicState.

I was also seeing the exact same problem when checking the motion state of a sensor.

if (onlyIfThisSensorIsActive && !onlyIfThisSensorIsActive.currentMotion.contains("active")) return

The sensor would be active yet it was still resulting in the return happening.

Do you mean you're putting a DeviceWrapper (device reference) in atomicState? If so, I think they recently made changes that didn't make storing these in state totally choke, but IHMO it's better to just store something like the device ID in state and then retrieve a reference to it when needed, e.g., by finding that device (by ID) from the input name/field that it originally came from. I'm not sure if that affects the outcome of your original findings or not--but it's a more common practice either way.

No it was just a string value.