Global Variables aren't updating

variables

#1

1) Give a description of the problem
I’m creating a new piston to auto-close my garage door after it has been open for too long. In this Piston I’m just trying to set the Close Time into a Global Variable and it isn’t updating the Variable.

2) What is the expected behavior?
Global Variable would update

3) What is happening/not happening?
It’s not updating

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
11/13/2018, 4:38:23 PM +734ms
+1ms ╔Received event [Garage Door - Kristen].door = open with a delay of 134ms
+541ms ║RunTime Analysis CS > 255ms > PS > 268ms > PE > 18ms > CE
+543ms ║Runtime (47046 bytes) successfully initialized in 268ms (v0.3.108.20180906) (541ms)
+545ms ║╔Execution stage started
+574ms ║║Comparison (enum) open changes_to (string) open = true (1ms)
+577ms ║║Cancelling condition #117’s schedules…
+578ms ║║Condition #117 evaluated true (27ms)
+579ms ║║Cancelling condition #116’s schedules…
+580ms ║║Condition group #116 evaluated true (state changed) (30ms)
+583ms ║║Cancelling statement #118’s schedules…
+594ms ║║Executed virtual command setVariable (1ms)
+615ms ║║Calculating (string) Garage Door - Kristen + (string) Opened: Setting to auto-close in >> (string) Garage Door - Kristen Opened: Setting to auto-close in
+620ms ║║Calculating (string) Garage Door - Kristen Opened: Setting to auto-close in + (string) 20 >> (string) Garage Door - Kristen Opened: Setting to auto-close in 20
+624ms ║║Calculating (string) Garage Door - Kristen Opened: Setting to auto-close in 20 + (string) minutes. Will auto-close at >> (string) Garage Door - Kristen Opened: Setting to auto-close in 20 minutes. Will auto-close at
+628ms ║║Calculating (string) Garage Door - Kristen Opened: Setting to auto-close in 20 minutes. Will auto-close at + (string) 4:58:24 PM >> (string) Garage Door - Kristen Opened: Setting to auto-close in 20 minutes. Will auto-close at 4:58:24 PM
+632ms ║║Calculating (string) Garage Door - Kristen Opened: Setting to auto-close in 20 minutes. Will auto-close at 4:58:24 PM + (string) . >> (string) Garage Door - Kristen Opened: Setting to auto-close in 20 minutes. Will auto-close at 4:58:24 PM.
+636ms ║║Garage Door - Kristen Opened: Setting to auto-close in 20 minutes. Will auto-close at 4:58:24 PM.
+639ms ║║Executed virtual command log (3ms)
+642ms ║╚Execution stage complete. (98ms)
+644ms ╚Event processed successfully (644ms)


#2

Strange

4:38:23 PM = Piston ran
4:38:24 PM = Global was set

Your last line referred to the global at 4:58:24
This is exactly 20 minutes in the future, as requested.

So the code ran correctly, and the new global was stored & read back correctly…
(as confirmed in your log)

Perhaps your web browser simply did not update the right column fast enough for you.
(Ctrl-F5 will force a hard refresh in your web browser)


#3

I agree that the log seems to indicate that the Global Variable correctly updated, however, if I hard refresh my browser or access the webcore dashboard via Incognito mode the variable still shows incorrectly.

Additionally, I created a simple test piston to show the global variable in the log. It is also showing the wrong time as well.

I’m very confused.


#4

That is peculiar…
I am tied up for the next day or two, but here is some food for thought…

Whenever I set a global, I always do the math & formatting locally first. (using local variables)
Then, towards the end of the piston, I use this command:
Set variable @globalVar = localVar

I find this helpful because it lets me easily see what is being written at each stage in the piston, plus it guarantees that the global matches because there is no math or conversion done in that step.


#5

I still haven’t found a way to fix this. I’ve now removed the scripts ability to actually close the door and am just running it with notices for testing. It still doesn’t appear to be working right. I also modified it per @WCmore to have both a local and global variable for the time.

To give a bigger picture in case it helps, there are 3 total pistons. One that fires when a garage door is open and set the initial close time. One that detects any motion in the driveway and extends the close time to 20 min from the last motion.

Logs from the Door Opening Piston:

12/4/2018, 3:06:40 PM +675ms
+2ms ╔Received event [Garage Door - Kristen].door = closed with a delay of 162ms
+694ms ║RunTime Analysis CS > 460ms > PS > 198ms > PE > 36ms > CE
+697ms ║Runtime (50611 bytes) successfully initialized in 198ms (v0.3.108.20180906) (695ms)
+698ms ║╔Execution stage started
+730ms ║║Comparison (enum) closed changes_to (string) open = false (2ms)
+734ms ║║Cancelling condition #117's schedules...
+736ms ║║Condition #117 evaluated false (32ms)
+738ms ║║Cancelling condition #116's schedules...
+739ms ║║Condition group #116 evaluated false (state changed) (34ms)
+741ms ║╚Execution stage complete. (43ms)
+743ms ╚Event processed successfully (743ms)

12/4/2018, 3:06:03 PM +152ms
+1ms ╔Received event [Garage Door - Kristen].door = open with a delay of 186ms
+584ms ║RunTime Analysis CS > 389ms > PS > 153ms > PE > 43ms > CE
+587ms ║Runtime (50529 bytes) successfully initialized in 153ms (v0.3.108.20180906) (585ms)
+588ms ║╔Execution stage started
+608ms ║║Comparison (enum) open changes_to (string) open = true (1ms)
+610ms ║║Cancelling condition #117's schedules...
+611ms ║║Condition #117 evaluated true (17ms)
+612ms ║║Cancelling condition #116's schedules...
+613ms ║║Condition group #116 evaluated true (state changed) (19ms)
+616ms ║║Cancelling statement #118's schedules...
+629ms ║║Executed virtual command setVariable (3ms)
+634ms ║║Executed virtual command setVariable (1ms)
+639ms ║║Executed virtual command setVariable (2ms)
+665ms ║║Calculating (string) [TEST] + (string) Garage Door - Kristen >> (string) [TEST] Garage Door - Kristen
+670ms ║║Calculating (string) [TEST] Garage Door - Kristen + (string) Opened: Setting to auto-close in >> (string) [TEST] Garage Door - Kristen Opened: Setting to auto-close in
+675ms ║║Calculating (string) [TEST] Garage Door - Kristen Opened: Setting to auto-close in + (string) 20 >> (string) [TEST] Garage Door - Kristen Opened: Setting to auto-close in 20
+680ms ║║Calculating (string) [TEST] Garage Door - Kristen Opened: Setting to auto-close in 20 + (string) minutes. Will auto-close at >> (string) [TEST] Garage Door - Kristen Opened: Setting to auto-close in 20 minutes. Will auto-close at
+685ms ║║Calculating (string) [TEST] Garage Door - Kristen Opened: Setting to auto-close in 20 minutes. Will auto-close at + (string) 3:26:03 PM >> (string) [TEST] Garage Door - Kristen Opened: Setting to auto-close in 20 minutes. Will auto-close at 3:26:03 PM
+689ms ║║Calculating (string) [TEST] Garage Door - Kristen Opened: Setting to auto-close in 20 minutes. Will auto-close at 3:26:03 PM + (string) [Global] or >> (string) [TEST] Garage Door - Kristen Opened: Setting to auto-close in 20 minutes. Will auto-close at 3:26:03 PM [Global] or
+692ms ║║Calculating (string) [TEST] Garage Door - Kristen Opened: Setting to auto-close in 20 minutes. Will auto-close at 3:26:03 PM [Global] or + (string) 3:26:03 PM >> (string) [TEST] Garage Door - Kristen Opened: Setting to auto-close in 20 minutes. Will auto-close at 3:26:03 PM [Global] or 3:26:03 PM
+696ms ║║Calculating (string) [TEST] Garage Door - Kristen Opened: Setting to auto-close in 20 minutes. Will auto-close at 3:26:03 PM [Global] or 3:26:03 PM + (string) [Local]. >> (string) [TEST] Garage Door - Kristen Opened: Setting to auto-close in 20 minutes. Will auto-close at 3:26:03 PM [Global] or 3:26:03 PM [Local].
+701ms ║║Executed virtual command setVariable (3ms)
+708ms ║║[TEST] Garage Door - Kristen Opened: Setting to auto-close in 20 minutes. Will auto-close at 3:26:03 PM [Global] or 3:26:03 PM [Local].
+711ms ║║Executed virtual command log (4ms)
+719ms ║║Comparison (string) :929b9fcb8417e6014fc2928537bbdbef: is (string) :70c55985e71580c97f3e1b3d6b70ccb6: = false (2ms)
+721ms ║║Condition #16 evaluated false (7ms)
+722ms ║║Condition group #11 evaluated false (state did not change) (8ms)
+725ms ║║Cancelling statement #12's schedules...
+742ms ║║Executed virtual command sendPushNotification (12ms)
+746ms ║╚Execution stage complete. (158ms)
+747ms ╚Event processed successfully (747ms)