Trying to get a pistons Local Variables to Reflect in Global Variables [Presence Issues]


#1

1) Give a description of the problem
I cannot seem to get my Global Variables to mirror that data of a local variable in a piston correctly

2) What is the expected behaviour?
Specifically, im testing with 2 presence devices, both WebCoRE presence types. Looking to get a global variable count of devices present and not present.
If X and Y are PRESENT then the global count will be 2
If X and Y are NOT PRESENT then the global count will be 0

3) What is happening/not happening?
The LOCAL VARIABLE count can display 0, but the GLOBAL count never goes less than 1. The last presence to leave will still be displayed and counted, even though it is not present.

4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full
6/19/2019, 2:49:30 PM +125ms
+2ms ╔Received event [Leila’s iPhone [WebCoRE]].presence = not present with a delay of 69ms
+105ms â•‘RunTime Analysis CS > 24ms > PS > 45ms > PE > 35ms > CE
+107ms â•‘Runtime (39617 bytes) successfully initialized in 45ms (v0.3.10c.20190522) (103ms)
+110ms â•‘â•”Execution stage started
+126ms â•‘â•‘Comparison (enum) not present is (string) present = false (2ms)
+129ms â•‘â•‘Comparison (enum) not present is (string) present = false (2ms)
+137ms ║║Cancelling condition #5’s schedules…
+138ms â•‘â•‘Condition #5 evaluated false (22ms)
+140ms ║║Cancelling condition #1’s schedules…
+141ms â•‘â•‘Condition group #1 evaluated false (state changed) (24ms)
+143ms ║╚Execution stage complete. (35ms)
+145ms ╚Event processed successfully (145ms)
6/19/2019, 2:48:49 PM +4ms
+1ms ╔Received event [Phil’s iPhone [WebCoRE]].presence = not present with a delay of 55ms
+82ms â•‘RunTime Analysis CS > 15ms > PS > 35ms > PE > 32ms > CE
+85ms â•‘Runtime (39635 bytes) successfully initialized in 35ms (v0.3.10c.20190522) (83ms)
+86ms â•‘â•”Execution stage started
+101ms â•‘â•‘Comparison (enum) present is (string) present = true (2ms)
+104ms â•‘â•‘Comparison (enum) not present is (string) present = false (2ms)
+110ms â•‘â•‘Condition #5 evaluated true (18ms)
+111ms â•‘â•‘Condition group #1 evaluated true (state did not change) (20ms)
+114ms ║║Cancelling statement #6’s schedules…
+119ms â•‘â•‘Executed virtual command setVariable (1ms)
+124ms â•‘â•‘Executed virtual command setVariable (1ms)
+131ms â•‘â•‘Executed virtual command setVariable (1ms)
+134ms ║╚Execution stage complete. (48ms)
+135ms ╚Event processed successfully (135ms)
6/19/2019, 2:48:38 PM +200ms
+1ms â•”Received event [Home].test = 1560970118199 with a delay of 1ms
+121ms â•‘RunTime Analysis CS > 27ms > PS > 49ms > PE > 44ms > CE
+125ms â•‘Runtime (39614 bytes) successfully initialized in 49ms (v0.3.10c.20190522) (122ms)
+126ms â•‘â•”Execution stage started
+149ms â•‘â•‘Comparison (enum) present is (string) present = true (2ms)
+153ms â•‘â•‘Comparison (enum) present is (string) present = true (2ms)
+163ms â•‘â•‘Condition #5 evaluated true (30ms)
+165ms â•‘â•‘Condition group #1 evaluated true (state did not change) (32ms)
+168ms ║║Cancelling statement #6’s schedules…
+179ms â•‘â•‘Executed virtual command setVariable (2ms)
+186ms â•‘â•‘Executed virtual command setVariable (2ms)
+197ms â•‘â•‘Executed virtual command setVariable (2ms)
+200ms ║╚Execution stage complete. (74ms)
+203ms ╚Event processed successfully (202ms)


#2

I’m not 100%sure but i believe local variables register as piston runs, global variables wait until piston is done (or otherway around) this might be causing the issue.

Just to test it, I’d use local variables in a seperate piston and globals in a seperate piston.
Meaning:
IF
Any of the presense sensors present
Save matching devices to LOCAL variables
And check the status

other piston
IF
Any of the presense sensors present
Save matching devices to GLOBAL variables

Just to see if they are giving the correct numbers. If so, the issue might be what I mentioned above.


#3

This is because your trigger is:
IF any of Sensor 1 or Sensor 2's presence is present

This means if both sensors are away, the piston will cancel out, and not run the commands.


Perhaps you want the first line to be:
IF any of Sensor 1 or Sensor 2's presence CHANGES


#4

Ohh…that makes sense, I will try making those adjustments


#5

It seems it was the fact the piston wasnt running since logically no presence was present. The CHANGES, logic wasnt quite working for me, but here is what I came up with that seems to be working now. Thanks for the help!


#6

Using “CHANGES” means the piston runs whenever anyone leaves or arrives.
I think this is the preferred method, although using the Test button will do nothing.


#7

Hey Phill
just out of curiosity, why are you saving them to a local variable and than global variable??
Why not directly to global??


#8

The save matching devices to variable option Under the IF command didn’t seem to allow me to save to Global type, only a local


#9

I just assumed I’d have issues sorting the devices into the right variables, present or not present, if I had an ambiguous command. Maybe I was just having tunnel vision.


#10

I see… Haven’t tried that one before… I guess it doesn’t give you the global list… You are right…
Thank you for the info…


#11

Well, for what it’s worth:

  • “is present” (a condition) is vague…
    (true for awhile, false for awhile)
  • “changes” (a trigger) is precise…
    (true for a brief moment, false 99.9% of the time)

#12

I guess for my use case I was concerned with being able to sort the devices into present and not present categories and have a running count of both, and if a device “changes” i lose the ability to choose what to do depending on if it changed to away, or present. At least with how I had it structured, I will see if i can write it in a way to leverage the “changes” trigger since that might be more precise


#13

In that case, perhaps you want the trigger:
“IF Sensor's presence changes to present”


#14

Jeez, like i said, I get “Tunnel Vision” sometimes. Thank you! I will change to that trigger and see if anything behaves differently from the condition i was using