Is it possible to get the contents of a variable OUT of webcore?


#1

I’m looking to see if I can access the current value of a variable from outside of webcore.

Specifically, I’d like to create an Apple “shortcut” that will present a “time picker”, pass that value back to webcore, set a variable to that “time value”, then have the shortcut validate that the variable is actually changed.

Right now I’ve got it doing everything it’s supposed to except for the validation. All that I have is the “ok” response after the piston is triggered manually, but that doesn’t confirm the actual value of the variable.

How can I access the value of a variable externally?


Android alarm into webcore?
#2

To keep it simple: have Webcore do a PUSH notification and make that notification contain the variable.
That will at least validate that you have the variable you want.


#3

That is true, but I don’t want to hassle my wife with the push notification… Actually, I don’t want to hassle my wife with all of my OTHER push notifications, so I have them disabled on her ST app.

I have tried to use the SMS option, but I’m in Canada and I have to pay for every non-Canadian SMS I receive, and the SMS comes from an American number… bummer.


#4

Do you need to validate that the variable is changed everytime you change it? Or are you just testing to make sure the variable actually changed and the logic is working?


#5

I want to make sure the variable changed every time I change it. I’ve had some (rare) flakiness with variables. The extra check would really help with peace-of-mind.


#6

How about having it send an email with the updated value of the var?


#7

Ideally, it’d be accessible in some way that my “shortcut” could validate. Email seems clunky. I was considering IFTTT via webhooks to activate PushOver or something, but again, a lot of moving parts.


#8

yeah, I don’t use IFTTT/pushOver at all, so I’m not really sure on that one. Not sure of your technical level, but if you run a raspberry pi or a similar home linux server, you can POST data to that and have the shortcut possibly validate there (think apache/python solution or something)


#9

I had considered the theory of pushing the variable “somewhere” and grabbing it from the shortcut, but I don’t have a server to post it to.


#10

I’m assuming this is the iOS apple shortcuts builder your using… What exactly are you trying to accomplish? There may be multiple ways to do whatever that is.


#11

When you run the shortcut, a “time picker” window opens up. You select the time, that gets parsed down and added as an argument to the URL that will manually trigger my “coffeebot” piston (which will set the smart plug connected to my dumb coffee maker to run at the prescribed time).
The argument that gets passed from shortcuts to the coffeebot piston gets set as the variable @coffeebottime, and also sets @coffebotarmed to “true”. Then, IF @coffeebotarmed IS TRUE then TURN ON the SMART PLUG at “@coffeebottime”, WAIT 15 minutes, then TURN OFF, and reset @coffeebotarmed to “false”

It works really well, and right now my shortcut will check the URL for successful run of the piston and error out if it doesn’t run. The trouble is that (on rare occasions) I’ve had a piston run and NOT actually set the variable like it’s supposed to.

This is going to be used MANY mornings by my then-uncaffeinated wife, and I want to avoid any problems!


#12

Maybe http://ptsv2.com ?
Allows you to post data and retrieve results.

So maybe the piston can post the “time” variable to this, then the iOS shortcut can call a URL to verify?
I’m playing around with it now to see how it works, never used the service before, but looks like it may work for what you need.


#13

okay, so this works:


Pay no attention to the variables at the top other than “postTest”.
The anonymized url is “http://ptsv2.com/t/allrak/post

Now when I visit “http://ptsv2.com/t/allrak”, I see a list of the most recent “posts” and if I click on the latest and show the value, it actually shows the contents of the “postTest” variable.


#14

That actually looks really handy, but I can’t figure out what URL to point the shortcut to since it changes each time the POST request is sent from webcore.


#15

it shouldn’t change if you create a toilet, you just need to define the “toilet”. Only inconvenience is it’ll take an extra click to see the latest value and verify. For example, i made multiple post requests using my test piston, if I visit the following page (go ahead and click it):

http://ptsv2.com/t/allrak

It should provide a list of post requests where you can click the latest and verify the variable data.
Although I’m not sure how long the site owner keeps them active.
There may be other sites that do the same thing on a more permanent basis

edit: you can also program a GET request in the piston to flush all the post history at the end of each day or something to that effect, just to keep it cleaner.


#16

Right, I get that, but if I do a “get” of that URL, will I get only the most recent entry, or will I need to do a “get” of “http://ptsv2.com/t/allrak/d/50001” in order to get the most recent entry?


#17

ah, I see where you’re going with that… I was thinking at the end of my apple shortcut to just have the shortcut open a browser with that URL right on your iphone, and from there, just click the latest link to verify the variable data… I don’t think there’s a way to program a GET request to grab the latest post.


#18

So close!!


#19

yeah it is close, but it’s just an extra click inside a safari browser to verify. To me it wouldn’t be an issue as I probably wouldn’t change my coffee brewing time everyday. Like I mentioned before, you could do a custom program if you have a RP3 laying around, or there may be other websites like ptsv2 that have a little more functionality. I’ll poke around a little more.

Just for fun, I emailed the site author to find out if there’s a query string to just grab the latest POST request rather than seeing the whole list. I’ll let ya know if I get a response.


#20

And apparently ios shortcuts can parse json data. So if there’s a way to pull the “latest” post request and return it in json format, you can parse exactly what the “time” variable is, which would be the solution.