Pass variable from SmartApp to WebCoRE?


#1

Is there a way to pass a variable from a weather smart app to WebCoRE? I want to flash my lights red during a tornado warning, and by default for as long as the tornado warning lasts. So I need to pass a variable for the duration of the warning to WebCoRE. Or use a different SmartApp besides WebCoRE to flash the lights…


(Micheal ) #2

The smartapp has to be specially written to take advantage of WebCoRE. There is no ‘standard’ between SmartApps to communication, and in fact each SmartThings designed the smartapp structure to sit in its own ‘sandbox’ to prevent ‘cross contamination’. However, developers have figured out how to use the SendLocationEvent to pass information (like Ask Alexa to WebCoRE)

If it is simple on/off information, you could use a virtual switch to accomplish this. Outside of that, you may have to create your own SmartApp to send info to WebCoRE.


(JIm) #3

You could also create a simulated device of some sort that takes a value. Then use the smartapp to write a value to that device and read it in WebCore.


(ocpd+adhd+alz+md+hfa+fms+lol=me :)) #4

Expanding on this…

If there is a known list of potential variables, you could create a separate virtual (simulated) switch to represent each one.

The SmartApp could then communicate the ‘variables’ to webCoRE via these switches (turning them ON and OFF).

I would probably create two separate pistons for this; one to translate the ‘variables’ from the SmartApp over to the set of switches, and the other to ‘read’ and translate those switches to do something in webCoRE.

The ‘variable reading’ piston in webCoRE would just need to be programmed to know what each of these switches means.

FYI: In case you’re not familiar with how to do this, it’s fairly easy once you get into it.
If you need any assistance with how to go about this, I’m sure you can find that assistance either here or over on the webCoRE forum.

Of course…

If such a device exists, that could be a shortcut to the whole thing.
The only problem is whether the SmartApp in question has the capability to ‘write’ a variable to said device. If not, I bet the virtual switches ON/OFF thing would be easier to implement (i.e. no coding needed); especially if a modified version of the SmartApp is not an option, due to wanting to keep up with the latest version of it from the app’s programmer, etc.


(JIm) #5

Create a simulated temperature sensor. You can then write a value to that in a smartapp. And thus WebCore can read it.


(Robin) #6

Are you aware that webCoRE has built in integration with weather underground?

And more specifically for your use case, weather alerts for your local weather station:

https://wiki.webcore.co/Weather#Type

You could write a simple piston as follows:


(Robin) #7

But I should add that it’s probably not a good idea to rely on a cloud based service like ST during a Tornado Warning!!

image


#8

Nice, thanks! Yeah, more using it just as an extra layer of precaution.


#9

I’m still learning pistons. Will that while loop only execute until the next instance of the piston runs (every other minute)? If not, I would have multiple instances of the piston running in parallel during an alert, which could cause conflicting flash commands.


(Robin) #10

Pistons only run in parallel if you tell them to in the piston settings (which in my example I didn’t).

Every two minutes the piston will just reset and you might see a longer red duration or a quick flash of white instead of the full 3 seconds of white.

Could be overcome with the use of a variable and some more IF’s but I didn’t see much point.

The only reason I had to put the ‘every other minute’ part in is because you can’t subscribe directly to the weather, and therefore it needs another trigger to tell the piston to go and check the weather periodically.

The ‘while’ will keep running until the condition changes to false, but as we can’t subscribe to weather, it will keep flashing until the next piston run (so up to two minutes after the end of the warning).


(ocpd+adhd+alz+md+hfa+fms+lol=me :)) #11

Nice!

So, as it is, by default as you have created it, does this go by whatever area the ST hub is set to?


(Robin) #12

Correct… webCoRE pulls weather underground data based on the hub location (as defined in the ST mobile app settings page)