Action to Run a piston return value

variables

#1

In the image below is the section with ‘variable’ representative of the return values from the piston?

I want to basically use a piston for input and return values. I send some values to it and it can output a different value.


Feature Request: Piston $return variable
#2

There’s no image, can you try posting it again or editing your first post? What you’re trying to do is almost certainly possible, it’s just difficult to answer without more information.

If you don’t have your variable values predefined, their updates values will be stored following a piston execution, if that’s what you’re trying to figure out.


#3

Oops! Now i updated my post.

That explanation is what i don’t follow. the second paragraph. Do you happen to have an example?


#4

Ah, now I think I understand what you’re trying to figure out. To set a variable to any value, choose “add action”, you can choose a device or leave it as location, and then scroll down until you see Set Variable:


#5

Hey @michicago I don’t think i explained myself well enough.

What i am asking about is how the execute piston action works.

The way i think it works in my head is sort of like python functions work where you have a function defined as F(x,y) = mx + y where x and y are the arguments in this piston exampel that you are passing into that piston you are calling while the output of the function in this example can be considered the variable in this piston screenshot.

Did i explain it better?


#6

So you’re just trying to share variables between pistons? That can be done by putting an @ at the beginning of your variable name.

You can also set a variable Value to an Expression (using the blue drop-down box), where you can use logic and/or math functions to derive a value.


#7

No i’m trying to send specific values to a child piston and have that child piston return a value

For example if i have a child piston that is called Set Thermostat that takes care of setting the fan to auto and thermostat to auto and set upstairs to a number while the downstairs thermostat to a different.

Instead of writing these steps multiple times i could write a chile routine that doesn’t have any triggers and that does these settings.

Then i can have a, for instance, Home Mode piston that calls the Set Thermostat piston and send 4 values to it (cooling point temp and heat point temp) for Upstairs and the same 2 values for the downstairs.

This way i save myself those series of steps

Sort of like this. If you create a subroutine for simplicity sake that took care of taking 2 inputs and output a single output and the routine took care of adding the two inputs and spitting out an output then in your main piece of code people usually save steps by calling functions or subroutines and input those 2 inputs and wait for the output. This is the same concept here. I see that you can pass arguments to a piston which takes care of the inputs but i don’t see how to wait for the output and how to save that output back into another variable


#8

For exampel this is what i am doing. I’m creating a Home Trigger piston that takes care of the changes to my house, but the way i am organizing my pistons are to have a XXX Trigger piston where XXX equals each mode i have. Then i will have a XXX Action Piston where XXX is the same as each mode. From here though i basically do repetitive tasks by how i set up my thermostat which i don’t want to keep writing each little detail. I want to only change those values that change often so i created a Set Thermostat piston that takes 4 values when called by another piston. Those 4 values are High temp for upstaris and low temp for upstairs (since my thermostat can support a cooling point and a heating point at the same time) and i do the same for the downstairs thermostate.

Now i just have to set 4 variables with my desired temperature and i pass those arguments to the Set Thermostat piston and then that piston will do everything. The only difference is that as i change temperatures later i don’t have to keep putting things like “set fan to auto” etc. all the time i just change those values that change often.


#9

What you’re doing seems right to me, with the exception of the “with arguments” part. You don’t need to send the values with the start command as long as your “Set Thermostat” piston has something along the lines of

Set thermostat1 Hightemp to @HighTemp_Upstairs
Set thermostat1 Lowtemp to @LowTemp_Upstairs
Set thermostat2 Hightemp to @HighTemp_Downstairs
Set thermostat2 Lowtemp to @HighTemp_Downstairs