Only Execute Piston with URL call


#1

1) Give a description of the problem
I have a beacon in my car. When my phone detects the beacon (meaning i am in the car), my phone triggers a webhook to a URL; namely, the URL for executing a specific piston. I want this piston to only execute when triggered to do so by the URL call. I understand i can change it to where the piston does not subscribe to certain parameter updates, but am not sure how that works exactly or if that will solve the problem given my specific piston. Another, less elegant solution would be to have the URL trigger another piston that sets a variable, and then add the variable to this piston as a condition for its execution. But I’m not sure what the best type of “variable” to use would be - what type of variable could i use to be a sort of “momentary button” as in smartthings.

2) What is the expected behavior?
For the piston to execute only when triggered to do so by the URL call.

3) What is happening/not happening?
The piston has conditions in it. When those conditions are met, the piston executes even if not triggered to do so by the URL call.

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

5) Attach any logs (From ST IDE and by turning logging level to Full)
4/11/2019, 12:35:15 PM +36ms
+1ms â•”Received event [Home].test = 1555000515035 with a delay of 0ms
+303ms â•‘RunTime Analysis CS > 29ms > PS > 248ms > PE > 26ms > CE
+306ms â•‘Runtime (41927 bytes) successfully initialized in 248ms (v0.3.10a.20190223) (303ms)
+307ms â•‘â•”Execution stage started
+323ms ║║Comparison (integer) 12 is_inside_of_range (integer) 17 … (integer) 19 = false (3ms)
+326ms â•‘â•‘Condition #6 evaluated false (11ms)
+328ms â•‘â•‘Condition group #5 evaluated false (state did not change) (13ms)
+332ms ║║Cancelling statement #18’s schedules…
+341ms â•‘â•‘Skipped execution of physical command [null].off([]) because it would make no change to the device. (3ms)
+342ms â•‘â•‘Executed [Justin Combined Presence].off (6ms)
+347ms â•‘â•šExecution stage complete. (40ms)
+350ms â•šEvent processed successfully (349ms)


#2

I would use your URL to trigger another separate piston that turns on a virtual switch, without a condition (without an IF) i.e. THEN turn on virtual switch.
Then in your original pistons’ list of conditions include that virtual switch turning on.
Edit, Alternatively, instead of a virtual switch, you could use a Boolean global variable turning to true say.


#4

Sorry edited my post.
Try with a global variable, simple piston, THEN set global variable to true…


#5

Thanks. I will go the Boolean global variable route and I guess just reset it back to false after a short delay.


#6

Ooops here comes @WCmore I think we’re in trouble!


#7

If you want to keep it in one piston with no global variable or SimSwitch, you can add a few characters to the end of the long URL.

In the example below, I added “?PcApp=eventghost” to the end of the url, and then the main IF in the piston looks like this:

temp

With this block in place, nothing else can trigger this piston.


Once the piston is saved, you want to see this up top:


Execute piston externally (via webhook) with arguments?
#8

Ah, that’s the secret trick i was looking for. I think that probably represents the true solution here, although Alwas’ answer deserves a solution tick mark too if that was allowed…


#9

So, i don’t see that message at the top even though the outer IF statement is as you suggested. Seems like it would still work as intended though?


#10

As long as you have no triggers outside the “IF $args” block, you should be ok.
(I’m not sure why it’s not alerting you)


#11

By the way, I just imported your “f2wu” piston (without making any changes), and I do see the message up top after I save it.


After adding the new IF block, the message still remains:

(Import code: 6n9f)


#12

I wonder if that’s because in that version the subscription to the 3rd and 4th conditions in the inner IF statement are set to never. I don’t know what that does exactly, so i had turned those back to Auto.


#13

Essentially, it treats that line as a condition (instead of a trigger)

Normally, only triggers will activate a piston, but when you have no triggers, then all conditions become triggers. (seen as lightning bolts in the left margin)

If you go back to: “Subscription Method: Never Subscribe” for those two conditions, you can keep them as conditions, and prevent them from activating the piston.