I’m not sure whether this is ia bug, or I’ve misunderstood how this should work? Below is a short test piston to demonstrate the issue.
When The switch is turned on, the piston executes as expected from top to bottom. The http is called and the piston suspends awaiting the response. It then wakes up when the call returns, but when it gets to the switch turned on condition, it evaluates as false as it thinks the switch has not changed.
This is a short excerpt from a larger piston to demonstrate the issue, I’m aware there are other ways to write this (put http call inside the if statement)
23/01/2023, 21:49:23 +518ms
+3ms ╔Received event [Home].wc_async_reply = httpRequest with a delay of 1ms, canQueue: true, calledMyself: false
+8ms ║RunTime initialize > 7 LockT > 0ms > r9T > 1ms > pistonT > 0ms (first state access 3 m:6 3 4)
+10ms ║Runtime (6840 bytes) initialized in 1ms (v0.3.114.20230113_HE)
+26ms ║╔Execution stage started
+32ms ║║Calculating (string)http status= + (string)401 >> (string)http status=401
+34ms ║║http status=401
+36ms ║║Executed virtual command log (1ms)
+39ms ║║Comparison (enum) on changes_to (string) on = false (1ms)
+40ms ║║Condition #5 evaluated false (2ms)
+41ms ║║Condition group #4 evaluated false (condition did not change) (3ms)
+43ms ║╚Execution stage complete. (17ms)
+44ms ╚Event processed successfully (42ms)
23/01/2023, 21:49:23 +346ms
+2ms ╔Received event [Fault NAS-316].switch = on with a delay of 27ms, canQueue: true, calledMyself: false
+27ms ║RunTime initialize > 27 LockT > 0ms > r9T > 22ms > pistonT > 20ms (first state access 2 m:5 2 25)
+29ms ║Runtime (6760 bytes) initialized in 22ms (v0.3.114.20230113_HE)
+30ms ║╔Execution stage started
+38ms ║║Sending asynchttpGet web request to: 192.168.0.51
+40ms ║║Executed virtual command httpRequest (2ms)
+42ms ║║Requesting wake up at Mon, Jan 23 2023 @ 9:49:47 PM GMT (in 23999ms) for 1 (st:2)
+45ms ║╚Execution stage complete. (14ms)
+109ms ║Setting up scheduled job for Mon, Jan 23 2023 @ 9:49:47 PM GMT (in 23991ms)
+110ms ╚Event processed successfully (109ms)