Struggling with Comparison (integer) 1 is (integer) 1 = false


#1

1) Give a description of the problem
I’m working on the simplest of pistons and I just don’t understand the DEBUG logging. I have a WD100+ in-wall switch and a Lutron Dimmer Plug that seem perfectly healthy in ST overall. In WebCoRE, I just can’t seem to make it work.

2) What is the expected behaviour?
Double tapping up (which triggers a Button 1 Push) should turn the lamp On. Double tapping down (which triggers Button 2 Push) should turn it off.

3) What is happening/not happening?
Regardless of tapping up or down, neither device index makes it though the switch statement, but I can’t for the life of me understand why. Both the value and the type of the comparison are identical.

4) Post a Green Snapshot of the piston!

5) Attach logs after turning logging level to Full

4/28/2020, 4:57:59 PM +181ms
+1ms   ╔Received event [Bedroom Light].button = pushed with a delay of 76ms
+79ms  ║RunTime Analysis CS > 16ms > PS > 33ms > PE > 30ms > CE
+81ms  ║Runtime (38578 bytes) successfully initialized in 33ms (v0.3.110.20191009) (80ms)
+82ms  ║╔Execution stage started
+89ms  ║║Comparison (enum) pushed gets (string) pushed = true (1ms)
+91ms  ║║Cancelling condition #2's schedules...
+92ms  ║║Condition #2 evaluated true (5ms)
+92ms  ║║Cancelling condition #1's schedules...
+93ms  ║║Condition group #1 evaluated true (state changed) (7ms)
+95ms  ║║Evaluating switch with values [[i:3:null:0, v:[t:integer, v:1, vt:string]]]
+98ms  ║║Comparison (integer) 1 is (integer) 1 = false (1ms)
+101ms ║║Comparison (integer) 1 is (integer) 2 = false (2ms)
+103ms ║╚Execution stage complete. (21ms)
+104ms ╚Event processed successfully (104ms)

4/28/2020, 4:58:03 PM +255ms
+1ms.  ╔Received event [Bedroom Light].button = pushed with a delay of 83ms
+81ms  ║RunTime Analysis CS > 17ms > PS > 34ms > PE > 30ms > CE
+84ms  ║Runtime (38573 bytes) successfully initialized in 34ms (v0.3.110.20191009) (81ms) 
+85ms  ║╔Execution stage started
+94ms  ║║Comparison (enum) pushed gets (string) pushed = true (3ms)
+95ms  ║║Condition #2 evaluated true (6ms)
+96ms  ║║Condition group #1 evaluated true (state did not change) (8ms)
+98ms  ║║Evaluating switch with values [[i:3:null:0, v:[t:integer, v:2, vt:string]]]
+101ms ║║Comparison (integer) 2 is (integer) 1 = false (1ms)
+104ms ║║Comparison (integer) 2 is (integer) 2 = false (1ms)
+106ms ║╚Execution stage complete. (22ms)
+107ms ╚Event processed successfully (107ms)

Thanks for any help you can provide!


#3

Why not simply two blocks?

IF button #1 gets pushed
    Then Turn on Dimmer 1
END IF

IF button #2 gets pushed
    Then Turn off Dimmer 1
END IF

#4

You can take a peek at a Wiki page that covers a bit about the logging process.


As far as Debug/Info etc, they are just there to give you alternative colors, to make troubleshooting easier.

Here is a little picture showing off all five colors:


#5

Right, thanks WCmore. I should be clear that it’s not the DEBUG logging itself that’s not clear, it’s very specficly the idea that

Comparison (integer) 1 is (integer) 1 = false

I’m trying to wrap my head around advanced concepts, but clearly I’m missing something.


#6

100%, I bet that would work. But I’m trying to distill the issue into the simplest thing I can using a switch that’s not behaving as expected. Any idea why the switch comparison isn’t working?


#7

Check out this example. It is probably something to do with using the IF statement but I don’t really get that either.


#8

Yes @Terminal, I think you’re on to something, but I’m still a little stuck. One of the things in WebCoRE I struggle with is knowing the syntax I need as displayed, but not knowing how to get that via the wizard. I just wish I could type it all out.

Thanks for pointing out what I was missing!


#9

Welp, it wasn’t the if statements, I’ve remade it to match other examples more closely and I still can’t get the comparison to match :frowning:

4/29/2020, 10:04:10 AM +833ms
+1ms   ╔Received event [Bedroom Light].button = pushed with a delay of 88ms
+87ms  ║RunTime Analysis CS > 20ms > PS > 35ms > PE > 32ms > CE
+90ms  ║Runtime (38362 bytes) successfully initialized in 35ms (v0.3.110.20191009) (87ms)
+91ms  ║╔Execution stage started
+96ms  ║║Evaluating switch with values [[i:3:null:0, v:[t:integer, v:2, vt:string]]]
+99ms  ║║Comparison (integer) 2 is (integer) 1 = false (1ms)
+102ms ║║Comparison (integer) 2 is (integer) 2 = false (1ms)
+104ms ║╚Execution stage complete. (14ms)
+105ms ╚Event processed successfully (105ms)

#10

Maybe set another integer variable equal to $currenteventdeviceindex integer and then see if that compares correctly? That is weird, must be something in the DTH, or somersetting I don’t understand about a switch statement or system variable. My initial thought was that it is a type mismatch as I had never used the system variable $currenteventdeviceindex before. I opened up a test piston and it says it is an integer. From looking at your logs it looks like the system variable is changing between 1 and 2, so why it does not compare?? I am at a loss.

Maybe just go with @WCmore 's example. He is the expert maybe he will chime in with what is going on there.


#11

my guess is the sub-index is biting you. It may be a webcore bug in how devices with subindexes are handled.


#12

My initial reaction is that there has to be a string/integer thing going on in there somewhere. The webCoRE logging isn’t always clear in that respect.

Button numbers are something of a de facto undocumented fudge to cater for the limitations of the button capability in the classic environment. The convention seems to be to send them as a number in the event data.

I just took a quick look at a WD100 device handler (I don’t know if there is more than one) and it is sending the index as a string rather than a number. I wonder if that is confusing the issue. I am not sure how to resolve it if it is as it doesn’t seem like the sort of thing that would break anything.


#13

That was my initial thought as well.

@mobilemike Perhaps try a forced conversion integer($CurrentEventDeviceIndex)?


#14

I think you will find it is the subindex.


#15

Before processing “controversial” data, I like storing it in to a specific variable type.
(in this case, integers)

For the rest of the piston, I’ll simply make comparisons to the newly set variable.


#16

I tried both casting to a string and an integer and the results were the same both times. 49 and 50 deterministically. It might not make sense, but I can work with it and that’s all that matters in the end.

5/3/2020, 8:54:33 PM +19ms
+1ms ╔Received event [Bedroom Light].button = pushed with a delay of 94ms
+90ms ║RunTime Analysis CS > 20ms > PS > 33ms > PE > 37ms > CE
+92ms ║Runtime (38696 bytes) successfully initialized in 33ms (v0.3.110.20191009) (90ms)
+93ms ║╔Execution stage started
+100ms ║║Evaluating switch with values [[i:3:null:0, v:[t:integer, v:50, d:1, vt:string]]]
+102ms ║║Comparison (integer) 50 is (integer) 49 = false (1ms)
+105ms ║║Comparison (integer) 50 is (integer) 50 = true (1ms)
+107ms ║║Cancelling statement #8's schedules...
+200ms ║║Executed physical command [Bedroom Lamp (Mike)].off() (90ms)
+201ms ║║Executed [Bedroom Lamp (Mike)].off (91ms)
+203ms ║╚Execution stage complete. (110ms)
+204ms ╚Event processed successfully (204ms)

Thanks so much to everyone that helped out, but I do have one last question. Where can I read more about subindices? I saw it brought up as a possible explanation, but I don’t know what pointed folks there as a possible cause.


#17

Honestly, I cannot recall ever reading a dedicated article on the Wiki…


The best forum post I have found is here
(The topic is slightly different, but the advice still applies)


#18

Did you ever figure out why it uses these index values? I’m seeing the same with my Zooz switches.


#19

Not why, but I know what to do about it now. No matter if I cast them to integers or strings, they come out deterministically as unexpected values (in my case, 49 and 50) so, now I just know that and can make a constant declaration for clearer code.

Try casting the values you’re getting back from the Zooz and logging it, then match on those.

If I was really ambitious, I’d try messing around with the custom device handler for my switches, but since they do appear as buttons 1, 2, etc. to regular SmartApps in the classic UI, like Smart Lighting, I’ve just left it.


#20

It would be good to know how many devices actually use/require sub-indexes, vs. are random values.

webCoRE currently considers them important. If they are not webCoRE should just ignore them when it does comparisons.