Mathematical Functions Not Working As Expected


#1

I am trying to use a mathematical function to add 10 to an integer variable. I have tried everything I can think of and it continues to concatenate as if one of them was a string. I have even gone so far as to store the amount to add in an integer variable so that it knows that’s an integer as well. I don’t understand why it is treating one of these as a string. They are clearly numerical.


#2

What happens if change your set variable line to:

Set variable {brightness} = decimal($response)?

If you get decimal values and don’t want them, you could try

Set variable {brightness} = round($response,0)

or

Set variable {brightness} = round(decimal($response),0) if the above returns an error. I’ve never tried to ‘round’ text.


#3

There has to be something wrong with WebCore because the piston is ecuting 3 times and screwing everything up. It sets it correct and then sends another request to the server.
All of this is from pressing the button once.
4/23/2018, 10:28:48 AM +317ms
+0ms ╔Received event [Home].time = 1524493729970 with a delay of -1654ms
+1244ms ║RunTime Analysis CS > 31ms > PS > 72ms > PE > 1141ms > CE
+1248ms ║Runtime (53286 bytes) successfully initialized in 72ms (v0.3.104.20180323) (1247ms)
+1250ms ║╔Execution stage started
+1251ms ║╚Execution stage complete. (2ms)
+1253ms ╚Event processed successfully (1253ms)
4/23/2018, 10:28:30 AM +215ms
+1ms ╔Received event [Home].wc_async_reply = httpRequest with a delay of 0ms
+237ms ║RunTime Analysis CS > 31ms > PS > 70ms > PE > 135ms > CE
+240ms ║Runtime (53288 bytes) successfully initialized in 70ms (v0.3.104.20180323) (239ms)
+241ms ║╔Execution stage started
+297ms ║╚Execution stage complete. (55ms)
+298ms ╚Event processed successfully (298ms)
4/23/2018, 10:28:29 AM +602ms
+1ms ╔Received event [Home].wc_async_reply = httpRequest with a delay of 1ms
+262ms ║RunTime Analysis CS > 51ms > PS > 71ms > PE > 136ms > CE
+265ms ║Runtime (53288 bytes) successfully initialized in 71ms (v0.3.104.20180323) (264ms)
+266ms ║╔Execution stage started
+334ms ║║Calculating (decimal) 0.0 + (decimal) 10.0 >> (decimal) 10.0
+341ms ║║Executed virtual command setVariable (5ms)
+350ms ║║Calculating (string) http://192.168.1. + (string) 45 >> (string) http://192.168.1.45
+354ms ║║Calculating (string) http://192.168.1.45 + (string) /set_brightness?c= >> (string) http://192.168.1.45/set_brightness?c=
+357ms ║║Calculating (string) http://192.168.1.45/set_brightness?c= + (string) 10 >> (string) http://192.168.1.45/set_brightness?c=10
+363ms ║║Sending internal web request to: 192.168.1.45/set_brightness?c=10
+366ms ║║Executed virtual command httpRequest (4ms)
+367ms ║║Requesting a wake up for Mon, Apr 23 2018 @ 10:28:49 AM EDT (in 20.0s)
+372ms ║╚Execution stage complete. (106ms)
+375ms ║Setting up scheduled job for Mon, Apr 23 2018 @ 10:28:49 AM EDT (in 19.994s)
+387ms ╚Event processed successfully (386ms)
4/23/2018, 10:28:29 AM +18ms
+0ms ╔Received event [Home].wc_async_reply = httpRequest with a delay of 0ms
+226ms ║RunTime Analysis CS > 31ms > PS > 67ms > PE > 128ms > CE
+229ms ║Runtime (53288 bytes) successfully initialized in 67ms (v0.3.104.20180323) (228ms)
+230ms ║╔Execution stage started
+294ms ║║Calculating (decimal) 18.0 + (decimal) 10.0 >> (decimal) 28.0
+300ms ║║Executed virtual command setVariable (3ms)
+310ms ║║Calculating (string) http://192.168.1. + (string) 45 >> (string) http://192.168.1.45
+313ms ║║Calculating (string) http://192.168.1.45 + (string) /set_brightness?c= >> (string) http://192.168.1.45/set_brightness?c=
+316ms ║║Calculating (string) http://192.168.1.45/set_brightness?c= + (string) 28 >> (string) http://192.168.1.45/set_brightness?c=28
+327ms ║║Sending internal web request to: 192.168.1.45/set_brightness?c=28
+329ms ║║Executed virtual command httpRequest (7ms)
+331ms ║║Requesting a wake up for Mon, Apr 23 2018 @ 10:28:49 AM EDT (in 20.0s)
+336ms ║╚Execution stage complete. (105ms)
+337ms ║Setting up scheduled job for Mon, Apr 23 2018 @ 10:28:49 AM EDT (in 19.995s)
+349ms ╚Event processed successfully (349ms)
4/23/2018, 10:28:28 AM +396ms
+1ms ╔Received event [LED Controller].button = pushed with a delay of 143ms
+229ms ║RunTime Analysis CS > 30ms > PS > 53ms > PE > 147ms > CE
+233ms ║Runtime (53287 bytes) successfully initialized in 53ms (v0.3.104.20180323) (232ms)
+234ms ║╔Execution stage started
+244ms ║║Comparison (string) :10ce40f8d22974532815992ec1f4d574: is_not (string) :ee9bdca69a7b039efb14d0cc92a5eae8: = true (2ms)
+245ms ║║Condition #1 evaluated true (6ms)
+246ms ║║Condition group #null evaluated true (state did not change) (8ms)
+253ms ║║Comparison (enum) pushed gets (string) pushed = false (1ms)
+255ms ║║Condition #5 evaluated false (5ms)
+256ms ║║Condition group #2 evaluated false (state did not change) (7ms)
+263ms ║║Comparison (enum) pushed gets (string) pushed = false (1ms)
+264ms ║║Condition #9 evaluated false (5ms)
+265ms ║║Condition group #6 evaluated false (state did not change) (7ms)
+272ms ║║Comparison (enum) pushed gets (string) pushed = false (1ms)
+274ms ║║Condition #13 evaluated false (5ms)
+275ms ║║Condition group #10 evaluated false (state did not change) (6ms)
+282ms ║║Comparison (enum) pushed gets (string) pushed = false (0ms)
+283ms ║║Condition #17 evaluated false (5ms)
+284ms ║║Condition group #14 evaluated false (state did not change) (7ms)
+291ms ║║Comparison (enum) pushed gets (string) pushed = false (1ms)
+293ms ║║Condition #21 evaluated false (5ms)
+294ms ║║Condition group #18 evaluated false (state did not change) (6ms)
+301ms ║║Comparison (enum) pushed gets (string) pushed = false (1ms)
+302ms ║║Condition #25 evaluated false (5ms)
+303ms ║║Condition group #22 evaluated false (state did not change) (7ms)
+310ms ║║Comparison (enum) pushed gets (string) pushed = false (1ms)
+312ms ║║Condition #29 evaluated false (5ms)
+313ms ║║Condition group #26 evaluated false (state did not change) (6ms)
+319ms ║║Comparison (enum) pushed gets (string) pushed = false (1ms)
+321ms ║║Condition #33 evaluated false (5ms)
+322ms ║║Condition group #30 evaluated false (state did not change) (7ms)
+329ms ║║Comparison (enum) pushed gets (string) pushed = false (1ms)
+330ms ║║Condition #41 evaluated false (5ms)
+331ms ║║Condition group #38 evaluated false (state did not change) (6ms)
+338ms ║║Comparison (enum) pushed gets (string) pushed = true (1ms)
+340ms ║║Condition #50 evaluated true (5ms)
+341ms ║║Condition group #45 evaluated true (state did not change) (7ms)
+343ms ║║Cancelling statement #46’s schedules…
+352ms ║║Calculating (string) http://192.168.1. + (string) 45 >> (string) http://192.168.1.45
+355ms ║║Calculating (string) http://192.168.1.45 + (string) /get_brightness >> (string) http://192.168.1.45/get_brightness
+362ms ║║Sending internal web request to: 192.168.1.45/get_brightness
+364ms ║║Executed virtual command httpRequest (3ms)
+366ms ║║Requesting a wake up for Mon, Apr 23 2018 @ 10:28:48 AM EDT (in 20.0s)
+371ms ║╚Execution stage complete. (138ms)
+372ms ║Setting up scheduled job for Mon, Apr 23 2018 @ 10:28:48 AM EDT (in 19.994s)
+381ms ╚Event processed successfully (381ms)


#4

To me it looks like WebCore thinks it is getting two replies to the one GET, which is not the case.


#5

Is it possible that wc is receiving more than one $response?


#6

I don’t believe so. This might be tied to the issue I saw this morning with IFTTT. It detected 3 triggers for one IFTTT event as well.
When I try the same call in Postman, I only get one response.