Passing argument, can you send more than one variable?

variables

#1

Is there a way to pass more than one variable from one piston to another. I could accomplish by using a global variable, but don’t want to add one that is only being consumed by one piston and be constrained by having the piston to complete all execution before updating.


#2

If you’re calling the piston via its external url, you can do:

external_piston_url/?var_name1=var_value1&var_name2=var_value2

On the receiving piston, you can extract those values using:

$args.var_name1 and $args.var_name2

Curious what kind of data is in the variable that you’re passing to the other piston?


#3

In my shop, I have a minsplit HVAC system using a sensibo pod to control it. For some strange reason it only accepts temperatures of (85,83,80,78,76,74,71,69,67,65,62) I have a piston that looks at the outside temp, the inside temp, thermostat setting, and I have it keep the shop just a little cooler than the outside but keeps the humidity out(mostly). I have it call a 2nd pistion that when lowering or raising the thermostat, it change to one of the allowed values and then sets the new cooling point.
Currently the 1st piston sends the variable (temp) to 2nd piston, which tells the pod the new cooling point, with winter coming, I want to send an additional variable of heat or cool, and then have the 2nd piston use the appropriate set cooling point or set heating point. If I could send the temp to sensibo and have it remain on auto, I would be fine but alas no set auto point is not an option.


#4

Are you using the ‘Execute piston’ task to send the variable?


#5

Yes, I am using execute piston with argument in this case the variable temperature is the argument.


#6

Instead of doing that, use the ‘Make a web request’ task, for the URL, use the second piston’s External URL.

That way you can pass multiple variables like in my example above.

image


#7

Thanks, I will try that now.


#8

Worked like a charm, Thanks. I may eventually figure this webcore out, or at least more of it. The more I learn the more I can learn!


#9

You can pass multiple variables with ‘Execute Piston’ as well. Just add a check mark next to each variable in the argument dropdown.


#10

bthrock, Thanks. That is much easier and should have been obvious to me!


#11

Do I have to load the passed values into a variable in order to use the value?

image


Function behavior with passed arguments
#12

Looks like it’s coming in as a string as 102 is just Pass1 and Pass2 concatinated?


#13


#14


#15

What do you get if you wrap $args.Pass1 and 2 in integer()?


#16

The same…


image


#17

The same with ()


#18


#19

Variable issue… Receive4
7/1/2020, 5:58:45 PM +802ms
+108ms ║Pass1 is : 10
+116ms ║Pass2 is : 2
+133ms ║Receive1 is : 102
+149ms ║Receive2 is : 8


#20

integer($args.Pass1) + integer($args.Pass2) worked! Thank you very much.