Passing an argument to a piston


#1

1) Give a description of the problem
I’d like to avoid having multiple similar pistons if possible, and use a http request from blue iris to call a piston, which will do slightly different things depending on what the http call line says.

2) What is the expected behaviour?

Easier to describe with pics, to be honest.

Here are two pistons…

image

All they do is either set a (virtual) motion sensor (hubitat) to either ACTIVE or INACTIVE, i.e.

image

or

image

These pistons currently are called by BlueIris when a camera becomes triggered or returns to inactive.

i.e.

I’m sure there’s a way to combine the two pistons by adding something to the above, and adjust the piston to look for an argument of some type to kind of do

IF (arg1)
then
set active

IF (arg2)
then
set inactive

TIA

3) What is happening/not happening?
(PUT YOUR INFO HERE)

4) Post a Green Snapshot of the pistonimage
(UPLOAD YOUR IMAGE HERE)

5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

You have the right idea. If you add ?status=active or ?status=inactive to the end of the BlueIris call then on the piston side, you can just evaluate if $args.status == inactive/inactive


#3

OK, so I have achieved part of this. The double “?” stumped me a little.

Here’s the BI screen (for active):

192.168.1.11/apps/api/7/execute/:xxxxx:?access_token=xxxx&target=active

Passing to this piston:

Now, what I don’t understand is how to add a 2nd argument to the BI line to hopefully mean that I can use a single piston for multiple cam/motion_sensors.

What really boils my brain with this (to start with) is that if I remove all references to the physical device, and replace with a device variable (similar to most of my webcore pistons), then I can’t get this to function. No error messages.
Ignore. See next post. Oops
i.e.
original, working:

image

device variable, not working:

image

Any ideas?


#4

Apparently, I’m lying.

So this piston works. Still need to figure out how to pass a 2nd argument over to allow single piston for multiple cams/sensors.:


#5

Looks like you got it working :slight_smile:


#6

You can pass as many arguments as you like by separating with ‘&’.

for example:

URL?status=active&actuator=light 1&level=50