Passing variables through pistons


#30

nope nothing changed…



#31

before you try the following … not sure why in the set variable there is square brackets enclosing the set variable statement.

first:
please remove those square brackets only and try. if that still does not work … then try the second one below:

second:
change that set variable line to the following and try please:

set variable Switch = mid(string($args.CurrentSwitch), 1, length(string($args.CurrentSwitch)) - 2)


#32

heres a working example of passing in a device from one piston to another piston at runtime:


#33

You are the man!! The simple example worked, I will now try to add a second device and see if it still works. I did not add the ‘[’ to the variable, this must be a weird webcore thing. Thank you again for your help, I had literally spent days trying to figure it out.


#34

if you insist :slight_smile:

adding in a second device will not work i suspect given the string passed is wonky … it will need to be parsed properly to work


#35

and you are correct again:-) It did not work, more work to do. Is this a webcore bug we have discovered? I am signing off for tonight had enough webcore fun for a day. Thanks again.


Multiple web requests
#36

we discovered more than one bug. :slight_smile:


#37

Why don’t we just goo over to Features and Suggestions and ask for a way to pass device names from piston to piston via arguments or Global variables or some other method.

I would think that’s an easy ask.


#38

Will do, though @bangali found a workaround that solves this issue for now.


#39

@bangali I don’t want to take up your entire evening on this again, but in the thread where I first found you, you mentioned that
" also fyi piston parallelism when turned on creates a 2nd instance of the piston to handle incoming events. while there will be 2 instances of the piston all variables in the define block are shared and each piston does not get its own instance of variables."

Is there a way to instead of using a With ‘switch name’ to turn the device on/off to use a With ‘location’ and then access the attributes of the device directly (via the $args variable) so you could execute commands at the device level?


#41

no worries. you didnt take up my entire evening … it was only a few minutes between what i was working on yesterday evening. :slight_smile:

no. you are executing them at the device level … the with statement specifies the device to execute commands on.


#42

Any insight if this feature was implemented? I find myself trying to pass a device name from piston to piston and struggling


#43

I’m also trying to pass multiple devices to a other piston, it doesn’t recognize the passed values as devices. Any idea?


#44

I use global variables. In this case, the global variable @WhichEcho carries the device names of the Echos that I want to hear from.

In my speaking piston, the variable EchoSpeaks takes the names of the devices in @WhichEcho


#45

Thanks! Yea i thought globals would work but is a shame we can’t just pass them through directly. Single device does work though.


#46

The globals in my pistons pass multiple devices (at least for the Echos). The only drawback for globals is that those variables aren’t written until the piston is done, so if you call a second piston in the middle of the first, it won’t work.


#47

Is this issue with passing devices as arguments still pending?


#48

I am not sure, I eventually gave up and found a different way to solve my problem.


#49

I think using the wait parameter on the execute piston would have resolved this issue properly.

Basically there are two different methods of executing the piston, and the ‘no wait’ puts the variable thru a conversion process.

I have not tried this, but it is what I see reading the code


#50

It’s relatively easy to pass a device from one piston to another. I do this by passing device names as strings.

It gets a little bit more complicated when you need to pass a few devices. However, this is doable too.

These are pistons which pass and receive one device.