Issues with String Comparisons

piston

#1

1) Give a description of the problem

I’ve got a simple action that turns off a light switch if another switch’s “LastEvent” string is not equal to Tap ▲▲. The logs seem to show that even though the string looks to match, it evaluates the comparison as true (as in, WebCoRE thinks that the two strings indeed do not match).

2) What is the expected behaviour?
WebCoRE evaluates the two strings as matching.

3) What is happening/not happening?
WebCoRE is evaluating the two strings as not matching.

4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full

9/14/2021, 8:37:17 PM +74ms
+5ms ╔Received event [Hubitat].time = 1631669837016 with a delay of 58ms, canQueue: true, calledMyself: false
+13ms ║RunTime initialize > 12 LockT > 1ms > rtDT > 1ms > pistonT > 0ms (first state access 10 6 6)
+15ms ║Runtime (5873 bytes) successfully initialized in 1ms (v0.3.113.20210825_HE)
+19ms ║╔Execution stage started
+30ms ║║Comparison (string) Tap ▲▲ is_not (string) Tap ▲▲ = true (1ms)
+31ms ║║Condition #4 evaluated true (5ms)
+34ms ║║Condition group #3 evaluated true (state did not change) (8ms)
+35ms ║║Cancelling statement #7's schedules...
+68ms ║║Executed physical command [Master Closet Lights].off() (19ms)
+69ms ║║Executed [Master Closet Lights].off (31ms)
+77ms ║╚Execution stage complete. (57ms)
+84ms ╚Event processed successfully (82ms)
9/14/2021, 8:37:11 PM +943ms
+4ms ╔Received event [Master Closet Lights].switch = on with a delay of 51ms, canQueue: true, calledMyself: false
+42ms ║RunTime initialize > 41 LockT > 4ms > rtDT > 27ms > pistonT > 26ms (first state access 10 9 32)
+45ms ║Runtime (5821 bytes) successfully initialized in 27ms (v0.3.113.20210825_HE)
+46ms ║╔Execution stage started
+54ms ║║Comparison (enum) on changes_to (string) on = true (1ms)
+56ms ║║Cancelling condition #2's schedules...
+57ms ║║Condition #2 evaluated true (8ms)
+59ms ║║Cancelling condition #1's schedules...
+61ms ║║Condition group #1 evaluated true (state changed) (11ms)
+63ms ║║Cancelling statement #5's schedules...
+70ms ║║Executed virtual command wait (1ms)
+73ms ║║Requesting a wake up for Tue, Sep 14 2021 @ 8:37:17 PM CDT (in 5000ms)
+89ms ║╚Execution stage complete. (44ms)
+110ms ║Setting up scheduled job for Tue, Sep 14 2021 @ 8:37:17 PM CDT (in 5009ms)
+112ms ╚Event processed successfully (110ms)

The issue here is this line:

+30ms ║║Comparison (string) Tap ▲▲ is_not (string) Tap ▲▲ = true (1ms)

Based on what I’m reading, it sure looks like this should evaluate to false, but is instead evaluating to true. Am I missing something here? Thanks!


#2

There is probably some special character or formatting that is not obvious. I suggest you store the lastEvent value into another variable and log it to see if you can tell the difference. You could also try an expression using contains to do the comparison also to alleviate problematic extraneous characters.


#3

Was able to figure this out - WebCoRE trims leading/trailing spaces :slight_smile:

This:

Outputs to this:
image

Notice that in my log code, I put || then zero spaces, then variable. Same on tail end. In the log itself, you can see the leading space there. This shows when using expressions, but doesn’t show elsewhere in the log (such as in my original post). As such, it looked like it was the same string, but only cause WebCoRE was trimming.

All sorted now. Thanks for shoving me in the right direction @guxdude