Global Variable - Varies


#1

1) Give a description of the problem
Guys and Girls, been searching on the google and trying to find an example to my issue but no luck. As I am still a noob in webcore and coding!

Purpose - Using Global variable “@_Presence_Counter” to indicate status of presence. Then subsequently other pistons can reference to the Global variable to determine which SMS notification to send in order to trigger different action for the heating system via IFTTT (as seperate piston).

  • When Gary (owner) arrives “+ 1” to global variable and When Gary leaves “- 1” from Variable.
  • When Jenny (Guest) arrives “+ 2” to global variable and When Jenny leaves “- 2” from Variable.

I have 1 more guest and 1 more owner to add but not yet finished.

2) What is the expected behavior?
Expecting the variable to be moving up and down pending on the presence status changes.

3) What is happening/not happening?
Unsure, hence want to check with your all how can I check the current value held in the Global Variable. As in the summary where all variable (Global and Local). Local ones shows values however the Global one is “Not set”.

**4) Post a Green Snapshot of the piston!

5) Attach any logs (From ST IDE and by turning logging level to Full)


#2

For debugging, push the variable value to notifications.


#3

When you open any piston, you can see global variables to the right of the screen.


#4

Cheers, I have added the push line for each if. Hopefully in the next few days will see some PUSH notification with values!


#5

Here is a screen shot, I belive this is the same as what you are referring to? As you see it only gives “not set” as value.

One question, when a trigger/ condition is met, you want to “+1” to the global value. Am I correct in thinking in the field I should enter the following: -

@_Presence_Counter +1” … or the input should be different in order to add 1 to the counter?

Thanks.


#6

I’m on my phone and having trouble posting a green snapshot. Take a look at my post in this thread… It should accomplish what you’re trying to do.


#7

Since you are using presence as your trigger/condition, I recommend using a different switch while you are building/debugging your piston. Log into the IDE and create simulated switches. These will appear in the app on your phone as devices that you can manually toggle on/off and you can build pistons around them as well. I.e. SimulatedSwitch1 represents Gary, “on” means home and “off” means away. SimulatedSwitch2 represents Jenny… and so on. Once the piston works as you expect, change them back to presence sensors. Otherwise, you’re waiting around for people to naturally come and go (or asking them to leave and hoping they return!).


#8

Thanks for above advice. Now I am searching how to create the simulated switch on IDE. As this will give me much more options for my venture later on. At the moment as you said I literally had to create the scenario… Including my wife to go home before i walk near home so the presence sensor can be detected at different time which is not so convenient!