Tasker variable into Webcore?


#1

I’ve not yet played with variables in webcore. The first thing I’d like to do with them is to import a variable from Tasker. So I don’t have a piston yet…

The idea is that, for example, if Tasker shows a non-smartthings device XXXXXX as ‘closed’, I want to bring that variable’s state into webcore so ST can reference it for other pistons.

First: is it possible?
Second: if possible, how would I begin to write it?

EDIT: I think I just figured it out. please disregard the “show me how” request, and I’ll see what I can do.


#2

First stage: in IDE, I have the following relevant detail.
Device = Garage. (This is a simulated contact I created.)
From that device Events List, any of the following are sufficient to define that the event should trigger a piston:

description: Sharptools sent close (open) command to Garage
eventSource: APP_COMMAND
linkText: SharpTools

And the data I want to set into a variable for later use:
value: close (open)

Sooo… how do I capture at least one of the first three components, plus the last, in a way that I can store and utilize in another piston?


#3

Just trying to understand what you’re doing with Tasker/Sharptools/WC. Why not just setup a piston that watches the status of the virtual contact Garage then set your variable accordingly? I’m possibly missing something :slight_smile:


#4

Good question.

The issue I’m trying to rectify is that the simulated contact Garage will change from open to closed, or closed to open, if I accidentally touch it in the Dashboard.

I want, should I accidentally touch that icon, for the piston to refer back to the actual state of the garage and set the icon accordingly . Which is itself unavailable in Smartthings, unless I somehow manage the above.


#5

I think I have more questions than answers lol. If ST doesn’t know the status of the device, I’m assuming Tasker does?

If Tasker knows the status, I believe it is capable of making a web/http call to a piston that will set your variable?


#6

I have Tasker making such calls to my Bravia HDTV and to my Denon AVR. So certainly it can make the calls… but again, as a rank beginner at webcore I’ve not yet figured out the details. And you are correct, Tasker does indeed know the status of the device.

I could easily enough include the http put/get or whatever as a task in the process of telling ST whether the door is open or closed. It could in fact replace the current Sharptools pull from AutoNotification, and accomplish both tasks (set the simulated ‘garage’ sensor, and set the variable) at once.

That is, if I knew how to do it. lol


#7

This is an example of a piston called externally and the URL to call can be found under Quick Facts.
In the example, the Push task I have, you can edit that to set your variable that other pistons can use… it has to be a global variable (prefixed with @) so it’s accessible outside of your piston.

2017-09-07_114200


#8

Thanks, it works well. A simple http get in Tasker, and it’s done.

Only issue is that each such variable set in webcore needs its own piston. So a closed/open variable needs two separate pistons.
I’ve read that it’s possible that too many running pistons could be a problem. No way I’m anywhere close to that, but who knows about the future…


#9

Would it be at all possible to share a screenshot of the Tasker task you used for this? I’m in the process of trying to move a bunch of stuff that I used to use Tasker for to Webcore instead, so this is exactly what I’m looking for, but I’m brand new to Webcore and never used either HTTP Post or Get in Tasker, so it’s all a bit of a mess right now!


#10

There’s a Tasker plugin called RESTask that can be used to send json body to the webcore piston. It is possible to just have one piston receiving the Tasker data you’re sending by putting multiple IFs in the piston or using switch/case.

I will check if I can put together an example later as this is new to me also. The log below is just sending one piece of data from Tasker/RESTask,

9/9/2017, 1:02:24 PM +502ms
+162ms	║Data: open
+181ms	║Data: [param1:execute, param2::25d7a0723e0113d604d14047xxxxx:, status:open, remoteAddr:174.17.xxx.xxx]

#11

That’s cool, but you don’t even need to get that complex to do many http tasks in Tasker. http get works just fine.

The Tasker profile says, condition:

  • when a notification comes from Chamberlain
    Then

  • if the notification regex ~ closed,
    Then set the virtual garage contact sensor to closed in Sharptools
    And
    Via http get, Set the ‘$garagestatus’ variable in webcore to 'closed"

If the notification regex NOT~ closed,
Then set the virtual garage contact to open in Sharptools
And
Via http get, set the ‘$garagestatus’ variable in webcore to ‘open’

My Tasker is on a different machine than this iPad, sorry I can’t post the images.
The http get commands start with the domain name as the address, and all the remainder of the statement as the data.


#12

The only reason I suggested that is so you don’t need one piston per http call.


#13

Ahhh, got it… how then to write a piston that can do it?
Looking forward to your example.


#14

I just did a lot of work between tasker and webcore, replacing autonotification with web GETs. Can you elaborate on what you mean by you would need a piston per variable? I don’t fully understand what you are trying to accomplish (sorry I know you’ve described it, I am having a hard time visualizing). Off the top of my head it seems you could have one piston, pass it a command, set the appropriate variable based on the command, but again I don’t fully understand.


#15

Ok, ground-up description.

I’m not using a contact sensor on the garage door, and I don’t have the ST myQ smartapp running.
I am working entirely from the Chamberlain app.

I also have two pistons in webcore. One sets the virtual garage sensor to ‘closed’, the other sets the virtual garage sensor to ‘open’.

The Chamberlain app is loaded on an android tablet. That tablet is running Tasker and AutoNotification.
When the garage opens, the Chamberlain app sends a notification. Likewise when it closes.

I am having AutoNotification intercept those notifications, look for the correct text (open or closed) in %antext, and if that text exists send an http get to the corresponding webcore piston.
This fires the appropriate piston and therefore, my virtual sensor accurately reports whether the garage is open or closed.

As I read up on it, I see that indeed I could do that with one piston. That I could have the existence of closed/open in %antext insert a variable into my http statement, and that webcore can then detect that variable and run the appropriate command in the piston based on it.

I just don’t know how to do it yet. And of course the fact that it is working as-is has made me a bit lazy in mucking around with variables to try to narrow it down to one piston lol


#16

Ok, sounds like you have it, if the below is already known to you I apologize.

Your Piston called from the HTTP GET will be passed data in the form ?argument=value,[argument=value,…] where argument is a variable you define in the Piston and value is what you set it to. Lets say for your example the variable you define is called status, status will be passed the value “open” or “closed” via the GET. In the Piston body you set the virtual switch based on the value. Then obtain the URL from webcore from the Piston page under Quick Facts.

From Tasker perform the HTTP GET on the URL with ?status=value appended, where “value” parsed from %antext in your case.

  1. Variable Set, name %status To %antext (assume you are actually parsing/splitting)
  2. Variable Set, name %pistonURL To whatever you find in webcore for your Piston
  3. HTTP Get, Server:Port %pistonURL?status=%status

Note: I store the webcore URL minus the Piston name in a settings file on my Android that I read whenever I need to initialize the Android app. This will avoid reacquiring it in the future should your Android app lose its global vars, and I use to call other pistons.

Hope this helps.


#17

Hmmm. Seems simple enough.
I don’t even have to parse %antext; the action in Tasker can send whatever variable you designate based on the condition. I’ll try it out later.

Presumably, a series of variables can be sent in one GET??


#18

I’ve not done it with webcore but yes you should be able to send multiple variables=values separated by commas in your GET.


#19

I’m trying to figure out the same thing if anyone can help! I have a test piston and a test task in Tasker set up. The Tasker task fires HTTP Get with the URL for the piston followed by ?Testvariable=testvalue. I think I’m confused on what my piston needs to look like, though. How do I point it to know what to do with the incoming information?


#20

use $args.Testvariable in the piston to access the passed in parameter.