Contents of a variable -Solution


#1

1) Give a description of the problem
What would be the best / easiest way to pass the contents of a variable to another piston that is not in the same location nor on the same network?

2) What is the expected behaviour?
The content of the variable is a string. Want to pass that string from one piston to another, but the two pistons are not on the same location, and not on the same network.

3) What is happening/not happening?
Have not done Webcore for about a year and forgot most of it. Looking for suggestions from someone not as rusty as I am.

**4) Post a Green Snapshot of the piston!
N/A

5) Attach logs after turning logging level to Full
N/A

.


#2

Make a web request with arguments task, pass the variable as your arguments.

In the receiving piston, the $args.variablename will hold that value you passed.


#3

Alternatively, you can tack the string on to the end of the External URL.

For example, one piston can send a HTTP GET request to the other piston:
https://api.smartthings.com/api/token/123abc/smartapps/installations/456def/execute/:789ghi:?string=The quick brown fox jumps over the lazy dog

The receiving piston can capture the contents of:
$args.string
to capture the entire sentence.


#4

Sorry, but I am just not understanding this.
If Piston #1 generates the text:

and Piston #2 is to retrieve the text:

What do I out in the Task:


#5

It works in reverse…

The piston that generates the text, should be the piston that makes a web request to the “receiving” piston. (essentially “pushing” the string to the 2nd piston)


#6

Still don’t get it:




#7

Here is a sample of the method I described earlier:

Here is the “Send” piston:

pic

The URL points to the other piston, in this format:
https://api.smartthings.com/api/token/123abc/smartapps/installations/456def/execute/:789ghi:?msg={msg}


Here is the “Receive” piston:

pic


Pro Tip:

If you import the “Receive” piston first, you can copy the External URL to the clipboard… which will help you when importing the “Send” piston.

You will likely have to add
?msg={msg}
to the end of that URL.

Once they are both imported, and you have tweaked the URL, just press Test in the “Send” piston, to see results in the other piston.


Side Note:

There are certain symbols that can tamper with the URL, so I would be careful what you add to that string.


#8

Great Success!

So, by changing the Send Variables to msg:

I was able to send msg from a Piston on Smartthings
to a Piston on Hubitat.

Thank you so much!