Setting up variables


#1

1) Give a description of the problem
Can’t figure out how to set variable

2) What is the expected behavior?
I’d like to make sure that the piston runs only once per day (at most, some days maybe it won’t run at all). My thought (unless there’s a better way you’d suggest) is to check if the variable = 0 and run the piston if so. Then last action in the piston will change the variable to 1 (so it won’t run again). At 11:59pm, I would have a piston run which will reset the variable back to 0 so that the piston will be able to run in the morning.

3) What is happening/not happening?
Since variables are not set up correctly, nothing triggers.

**4) Post a Green Snapshot of the piston![image|45x37]
I’m new member of the community so I cannot yet upload pics, but the piston is linked here and I have no clue at all how to create the midnight variable reset piston.

Thanks for any help! Frustrating getting started.


#2

Try something like this.

Obviously you don’t have to worry about the span of time in my piston, but the variable info. will give you some ideas.


#3

Thanks @Eric182 - can you help me understand what your variables are doing?
First, ‘$day’ has a dollar sign and ‘lastday’ doesn’t so I assume that means they are different types of variables?
Line 17, You defined ‘lastday’ but not ‘$day’… Why, under what circumstances do you (and do you not) need to define?
Line 32 sets ‘lastday’ to equal ‘$day’… Doesn’t that make it so this piston will NEVER run (line 28)?
Is there another piston doing something to change these variables?


#4

$day is a system variable that cannot be changed by a user.

In the screenshot, you can view the system variables. This page can be found at the bottom of a piston when you are editing a piston.

Any variable with a $ before it is a system variable.

Variable $day, for instance, is 31. Tomorrow it will be 1 (November 1st)

YOY cn also just import my piston using the import code in the screenshot “rf3tk”


#5

Wow… This took me a while to understand the logic, but it’s brilliant! You also just taught me a bunch of things I struggled with… Thanks so much!


#6

I do not see $currentEventDate in the list of system variables. Where can I find info on $currentEventDate and similar system variables?


#7

That’s not a system variable. You’d use it in a “If
$Device is true” statement, such as “if a device is on/off/true/false/offline” etc statement. Click on the Gear icon to set this up…