Execute piston on second hub and pass arguments


#1

1) Give a description of the problem
I’m trying to get around Alexa’s inability to handle multiple ST hubs/locations. So in Location 1 (L1) I have created virtual switches that mirror the Location 2 (L2) switches I wish to control. So if L2 has switches S1, S2, S3, then in L1 I define virtual switches Mirror-S1, Mirror-S2, Mirror-S3. When any of the mirror switches changes, I am trying to execute a piston at L2, passing as arguments the information about which L1 switch changed and its current status. This way, I can execute a single piston at L2 and let it decide what to do based on the arguments it receives.

Except that when I execute the piston from L1, it never actually runs on L2.

2) What is the expected behaviour?
Change of switch Mirror-Sn at L1 causes piston to run on L2; L2 piston uses arguments passed to determine what to do.

3) What is happening/not happening?
Piston on L2 never gets fired.

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

5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)
L1 log:

L2 log:


#2

I should add that the two locations are in different cities, and thus on different LANs, but using the same SmartThings account.


#3

You probably need to pass:

$currentEventDevice = device name
$currentEventAttribute = switch (optional)
$currentEventValue = on/off

#4

It may not help you here, but there is a way to run a piston on one SmartThings hub from another. What you do is do a Make a Web Request to the “External URL” of the piston you want to execute (Shown under Quick Facts on the overview of the piston). You can pass arguments as you do that.


#5

I’ve tried using the External URL, and I can in fact get the second piston to fire using the URL. I’m getting tripped up on passing parameters. Does the first piston use PUT, POST, or something else? FORM, JSON, or something else? It’s unclear to me how the second piston retrieves the data that was passed. I’m usually pretty good at hacking around until I find what works, but this has me stymied because I haven’t located any good examples. Can someone post an example that shows both ends of the process, or point me to something that’s already been posted?


#6

Try something like this…

Receiving piston…

To extract the details…
image


Passing device variable to a called piston causes device reference to be lost
#7

Thanks, I’ll give it a try later today. :+1:


#8

I wrote an example program on passing parameters between pistons. Perhaps that would help. It’s over here:


#9

Thanks, everyone - @eibyer’s code did the trick.